aboutsummaryrefslogtreecommitdiff
path: root/src/PKBank.cs
blob: 4b31a5879bfc94f4b02e0af4948d8fc06affd4d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using PKHeX.Core;

public class PKBank : PKSlot {
    public const int BOX_SIZE = 40;
    public PKM?[] Box;

    public PKBank(){
        this.Box = new PKM?[BOX_SIZE];
    }

    override public void SetBox(PKM pk, int box_index, int index){
        if(index >= BOX_SIZE) throw new Exception("index larger than BOX_SIZE("+BOX_SIZE+")");

        int target = box_index * BOX_SIZE + index;

        if(target >= this.Box.Length){
            int next_box = BOX_SIZE * (int)Math.Ceiling((double)target / BOX_SIZE);
            if(next_box == target) next_box += BOX_SIZE;
            Array.Resize<PKM?>(ref this.Box, next_box);
            
        }

        this.Box[target] = pk.Species == 0 ? null : pk;
    }

    override public PKM GetBox(int box_index, int index){
        int target = box_index * BOX_SIZE + index;

        if(target >= this.Box.Length) return BlankPKM;

        return this.Box[target] ?? BlankPKM;
    }

    public void _print(){
        for(int i = 0; i != this.Box.Length; i++){
            if(i%BOX_SIZE == 0){
                Console.WriteLine("\n---- box "+i/BOX_SIZE);
            } 

            Console.Write((this.Box[i] ?? BlankPKM).Species.ToString() + ":");
            Console.Write((Species)(this.Box[i] ?? BlankPKM).Species);
            if((this.Box[i] ?? BlankPKM).IsShiny) Console.Write("*");
            Console.Write(" ");

        }
    }

    public override void SetParty(PKM pkm, int index) => throw new NotImplementedException();
    public override PKM GetParty(int index) => throw new NotImplementedException();
}