diff options
author | tom-overton <tom.overton@outlook.com> | 2021-12-23 15:53:31 -0800 |
---|---|---|
committer | tom-overton <tom.overton@outlook.com> | 2021-12-23 15:53:31 -0800 |
commit | c61f14531c03912db05b5b39dff9bb7d13bf91be (patch) | |
tree | fee0934882efe2a5c3628960ce9cf811be43c419 /src | |
parent | 32a404a2c09fc6eb1746e3a1b0b68fe55359b984 (diff) |
Gen 1: Make Added Stats on Evolution preserve BST
Diffstat (limited to 'src')
-rw-r--r-- | src/com/dabomstew/pkrandom/pokemon/Gen1Pokemon.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/dabomstew/pkrandom/pokemon/Gen1Pokemon.java b/src/com/dabomstew/pkrandom/pokemon/Gen1Pokemon.java index 67b7255..bd320c6 100644 --- a/src/com/dabomstew/pkrandom/pokemon/Gen1Pokemon.java +++ b/src/com/dabomstew/pkrandom/pokemon/Gen1Pokemon.java @@ -100,6 +100,32 @@ public class Gen1Pokemon extends Pokemon { } @Override + public void assignNewStatsForEvolution(Pokemon evolvesFrom, Random random) { + double ourBST = bst(); + double theirBST = evolvesFrom.bst(); + + double bstDiff = ourBST - theirBST; + + // Make weightings + double hpW = random.nextDouble(), atkW = random.nextDouble(), defW = random.nextDouble(); + double specW = random.nextDouble(), speW = random.nextDouble(); + + double totW = hpW + atkW + defW + specW + speW; + + double hpDiff = Math.round((hpW / totW) * bstDiff); + double atkDiff = Math.round((atkW / totW) * bstDiff); + double defDiff = Math.round((defW / totW) * bstDiff); + double specDiff = Math.round((specW / totW) * bstDiff); + double speDiff = Math.round((speW / totW) * bstDiff); + + hp = (int) Math.min(255, Math.max(1, evolvesFrom.hp + hpDiff)); + attack = (int) Math.min(255, Math.max(1, evolvesFrom.attack + atkDiff)); + defense = (int) Math.min(255, Math.max(1, evolvesFrom.defense + defDiff)); + speed = (int) Math.min(255, Math.max(1, evolvesFrom.speed + speDiff)); + special = (int) Math.min(255, Math.max(1, evolvesFrom.special + specDiff)); + } + + @Override protected int bst() { return hp + attack + defense + special + speed; } |