aboutsummaryrefslogtreecommitdiff
path: root/src/PKBank.cs
diff options
context:
space:
mode:
authorame <[email protected]>2024-07-06 00:35:24 -0500
committerame <[email protected]>2024-07-06 00:35:24 -0500
commitcc3768e1509c22fa52ec7bf895390407a0ce0435 (patch)
tree70489029d0ae183aff3de32dbeb87118635a6a34 /src/PKBank.cs
Diffstat (limited to 'src/PKBank.cs')
-rw-r--r--src/PKBank.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/PKBank.cs b/src/PKBank.cs
new file mode 100644
index 0000000..4b31a58
--- /dev/null
+++ b/src/PKBank.cs
@@ -0,0 +1,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();
+} \ No newline at end of file