Gen7Data/Scripts/Moves/2_5HitMove.as

56 lines
1.7 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 MultiHitMove_TestHits(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(){
MultiHitMove_TestHits(684, 3);
MultiHitMove_TestHits(78216, 4);
MultiHitMove_TestHits(123640, 3);
MultiHitMove_TestHits(280282, 2);
MultiHitMove_TestHits(353353, 3);
MultiHitMove_TestHits(388667, 2);
MultiHitMove_TestHits(436269, 2);
MultiHitMove_TestHits(784419, 5);
MultiHitMove_TestHits(800144, 2);
MultiHitMove_TestHits(901811, 5);
MultiHitMove_TestHits(992841, 4);
}
#endif