Adds more unit tests
This commit is contained in:
parent
c2ff18a48c
commit
e54c7bd02b
|
@ -3,11 +3,52 @@ namespace Gen7{
|
||||||
class Acupressure : PkmnScript {
|
class Acupressure : PkmnScript {
|
||||||
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override {
|
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override {
|
||||||
if (attack.User is target){
|
if (attack.User is target){
|
||||||
// TODO: Fail.
|
attack.GetHitData(target, hit).Fail();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto randStat = Statistic(target.Battle.Random.Get(0, 6));
|
auto randStat = Statistic(target.Battle.Random.Get(1, 6));
|
||||||
target.ChangeStatBoost(randStat, 2);
|
target.ChangeStatBoost(randStat, 2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TESTS
|
||||||
|
|
||||||
|
void TestWithRandomSeed(uint seed, Statistic stat){
|
||||||
|
auto battle = CreateSimpleBattle(seed, "charizard", "venusaur", 100);
|
||||||
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
||||||
|
auto mon2 = battle.GetBattleSide(1).GetPokemon(0);
|
||||||
|
|
||||||
|
auto script = cast<Gen7::Acupressure>(CreateMoveScript("Acupressure"));
|
||||||
|
auto executingMove = CreateExecutingMove("Acupressure", mon1, mon2);
|
||||||
|
script.OnSecondaryEffect(executingMove, mon2, 0x0);
|
||||||
|
RequireEquals(2, mon2.GetStatBoost(stat));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test name="Acupressure: Random stat increases by two"]
|
||||||
|
void Acupressure_RandomStatIncreasesBy2(){
|
||||||
|
TestWithRandomSeed(684, Statistic::SpecialDefense);
|
||||||
|
TestWithRandomSeed(1037038, Statistic::SpecialDefense);
|
||||||
|
TestWithRandomSeed(3572948, Statistic::Attack);
|
||||||
|
TestWithRandomSeed(4087125, Statistic::SpecialDefense);
|
||||||
|
TestWithRandomSeed(4199056, Statistic::Speed);
|
||||||
|
TestWithRandomSeed(7291450, Statistic::Attack);
|
||||||
|
TestWithRandomSeed(8639137, Statistic::SpecialAttack);
|
||||||
|
TestWithRandomSeed(8918584, Statistic::Attack);
|
||||||
|
TestWithRandomSeed(9564376, Statistic::Defense);
|
||||||
|
TestWithRandomSeed(9859436, Statistic::SpecialDefense);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test name="Acupressure: Fails When Targets Self"]
|
||||||
|
void Acupressure_FailsOnSelfTarget(){
|
||||||
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
||||||
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
||||||
|
|
||||||
|
auto script = cast<Gen7::Acupressure>(CreateMoveScript("Acupressure"));
|
||||||
|
auto executingMove = CreateExecutingMove("Acupressure", mon1, mon1);
|
||||||
|
script.OnSecondaryEffect(executingMove, mon1, 0x0);
|
||||||
|
Require(executingMove.GetHitData(mon1, 0x0).HasFailed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace Gen7 {
|
||||||
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override {
|
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit) override {
|
||||||
bool result = target.Battle.TurnQueue.MovePokemonChoiceNext(target);
|
bool result = target.Battle.TurnQueue.MovePokemonChoiceNext(target);
|
||||||
if (!result){
|
if (!result){
|
||||||
// TODO: Failed
|
attack.GetHitData(target, hit).Fail();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,3 +16,28 @@ namespace Gen7 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TESTS
|
||||||
|
void TestChangeAllStats(int8 amount){
|
||||||
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
||||||
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
||||||
|
|
||||||
|
auto script = cast<Gen7::ChangeAllTargetStats>(CreateMoveScript("ChangeAllTargetStats"));
|
||||||
|
auto executingMove = CreateExecutingMove("Tackle", mon1, mon1);
|
||||||
|
script._amount = amount;
|
||||||
|
script.OnSecondaryEffect(executingMove, mon1, 0x0);
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::Attack));
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::Defense));
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::SpecialAttack));
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::SpecialDefense));
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::Speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test name="ChangeAllTargetStats: Does as the name suggests"]
|
||||||
|
void ChangeAllTargetStats_Test(){
|
||||||
|
for (int8 i = -6; i <= 6; i++){
|
||||||
|
TestChangeAllStats(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -12,3 +12,24 @@ namespace Gen7 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TESTS
|
||||||
|
void TestChangeAttackStat(int8 amount){
|
||||||
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
||||||
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
||||||
|
|
||||||
|
auto script = cast<Gen7::ChangeTargetAttack>(CreateMoveScript("ChangeTargetAtt"));
|
||||||
|
auto executingMove = CreateExecutingMove("Tackle", mon1, mon1);
|
||||||
|
script._amount = amount;
|
||||||
|
script.OnSecondaryEffect(executingMove, mon1, 0x0);
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::Attack));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test name="ChangeTargetAttack: Does as the name suggests"]
|
||||||
|
void ChangeTargetAttack_Test(){
|
||||||
|
for (int8 i = -6; i <= 6; i++){
|
||||||
|
TestChangeAttackStat(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -12,3 +12,24 @@ namespace Gen7 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TESTS
|
||||||
|
void TestChangeDefenseStat(int8 amount){
|
||||||
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
||||||
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
||||||
|
|
||||||
|
auto script = cast<Gen7::ChangeTargetDefense>(CreateMoveScript("ChangeTargetDef"));
|
||||||
|
auto executingMove = CreateExecutingMove("Tackle", mon1, mon1);
|
||||||
|
script._amount = amount;
|
||||||
|
script.OnSecondaryEffect(executingMove, mon1, 0x0);
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::Defense));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test name="ChangeTargetDefense: Does as the name suggests"]
|
||||||
|
void ChangeTargetDefense_Test(){
|
||||||
|
for (int8 i = -6; i <= 6; i++){
|
||||||
|
TestChangeDefenseStat(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -12,3 +12,24 @@ namespace Gen7 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TESTS
|
||||||
|
void TestChangeDefense(int8 amount){
|
||||||
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
||||||
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
||||||
|
|
||||||
|
auto script = cast<Gen7::ChangeTargetSpecialDefense>(CreateMoveScript("ChangeTargetSpDef"));
|
||||||
|
auto executingMove = CreateExecutingMove("Tackle", mon1, mon1);
|
||||||
|
script._amount = amount;
|
||||||
|
script.OnSecondaryEffect(executingMove, mon1, 0x0);
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::SpecialDefense));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test name="ChangeTargetSpecialDefense: Does as the name suggests"]
|
||||||
|
void ChangeTargetSpecialDefense_Test(){
|
||||||
|
for (int8 i = -6; i <= 6; i++){
|
||||||
|
TestChangeDefense(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -12,3 +12,24 @@ namespace Gen7 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TESTS
|
||||||
|
void TestChangeTargetSpeed(int8 amount){
|
||||||
|
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
|
||||||
|
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
|
||||||
|
|
||||||
|
auto script = cast<Gen7::ChangeTargetSpeed>(CreateMoveScript("ChangeTargetSpeed"));
|
||||||
|
auto executingMove = CreateExecutingMove("Tackle", mon1, mon1);
|
||||||
|
script._amount = amount;
|
||||||
|
script.OnSecondaryEffect(executingMove, mon1, 0x0);
|
||||||
|
RequireEquals(amount, mon1.GetStatBoost(Statistic::Speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test name="ChangeTargetSpeed: Does as the name suggests"]
|
||||||
|
void ChangeTargetSpeed_Test(){
|
||||||
|
for (int8 i = -6; i <= 6; i++){
|
||||||
|
TestChangeTargetSpeed(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue