Gen7Data/Scripts/Moves/2_5HitMove.as

56 lines
1.5 KiB
ActionScript

namespace Gen7 {
[Move effect=2_5HitMove]
class MultiHitMove : PkmnScript{
void ModifyNumberOfHits(MoveTurnChoice@ choice, uint8 &inout numberHits) override {
auto randValue = choice.User.Battle.Random.Get(6);
switch (randValue){
case 0:
case 1:
numberHits = 2;
break;
case 2:
case 3:
numberHits = 3;
break;
case 4:
numberHits = 4;
break;
case 5:
numberHits = 5;
break;
default:
throw("Invalid randValue");
}
}
}
}
#if TESTS
void RunHits(uint seed, uint8 expectedHits){
auto battle = CreateSimpleBattle(seed, "charizard", "venusaur", 100);
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto choice = CreateMoveTurnChoice("tackle", mon1, 1, 0);
auto script = cast<Gen7::MultiHitMove>(CreateMoveScript("2_5HitMove"));
uint8 numberHits = 1;
script.ModifyNumberOfHits(choice, numberHits);
RequireEquals(expectedHits, numberHits);
}
[Test name="2-5 Hit Move"]
void MultiHitMove_HasMultiHits(){
RunHits(684, 3);
RunHits(78216, 4);
RunHits(123640, 3);
RunHits(280282, 2);
RunHits(353353, 3);
RunHits(388667, 2);
RunHits(436269, 2);
RunHits(784419, 5);
RunHits(800144, 2);
RunHits(901811, 5);
RunHits(992841, 4);
}
#endif