100 lines
3.5 KiB
ActionScript
100 lines
3.5 KiB
ActionScript
namespace Gen7 {
|
|
[Move effect=Attract]
|
|
shared class Attract : PkmnScript {
|
|
void OnSecondaryEffect(ExecutingMove@ move, Pokemon@ target, uint8 hit) override {
|
|
auto userGender = move.User.Gender;
|
|
// If the move is used on a Pokémon that is the same gender as the user, it will fail
|
|
if (target.Gender == userGender){
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
// It will also fail if used by or on a gender-unknown Pokémon
|
|
if (userGender == Gender::Genderless || target.Gender == Gender::Genderless){
|
|
move.GetHitData(target, hit).Fail();
|
|
return;
|
|
}
|
|
// If the target is the opposite gender of the Pokémon who launched the move, the target becomes infatuated
|
|
target.AddVolatile("Infatuated");
|
|
};
|
|
}
|
|
}
|
|
|
|
#if TESTS
|
|
[Test name="Attract: Adds Infatuated for different genders"]
|
|
void Attract_DifferentGenders(){
|
|
auto mon1 = CreatePokemonBuilder("charizard", 100)
|
|
.WithGender(Gender::Male)
|
|
.Build();
|
|
auto mon2 = CreatePokemonBuilder("venusaur", 100)
|
|
.WithGender(Gender::Female)
|
|
.Build();
|
|
|
|
auto p1 = CreateParty({mon1});
|
|
auto p2 = CreateParty({mon2});
|
|
|
|
auto script = cast<Gen7::Attract>(CreateMoveScript("Attract"));
|
|
auto executingMove = CreateExecutingMove("Attract", mon1, mon2);
|
|
script.OnSecondaryEffect(executingMove, mon2, 0x0);
|
|
Require(!executingMove.GetHitData(mon2, 0).HasFailed);
|
|
Require(mon2.HasVolatile("Infatuated"));
|
|
}
|
|
|
|
[Test name="Attract: Doesnt work on genderless target"]
|
|
void Attract_GenderlessTarget(){
|
|
auto mon1 = CreatePokemonBuilder("charizard", 100)
|
|
.WithGender(Gender::Male)
|
|
.Build();
|
|
auto mon2 = CreatePokemonBuilder("venusaur", 100)
|
|
.WithGender(Gender::Genderless)
|
|
.Build();
|
|
|
|
auto p1 = CreateParty({mon1});
|
|
auto p2 = CreateParty({mon2});
|
|
|
|
auto script = cast<Gen7::Attract>(CreateMoveScript("Attract"));
|
|
auto executingMove = CreateExecutingMove("Attract", mon1, mon2);
|
|
script.OnSecondaryEffect(executingMove, mon2, 0x0);
|
|
Require(executingMove.GetHitData(mon2, 0).HasFailed);
|
|
Require(!mon2.HasVolatile("Infatuated"));
|
|
}
|
|
|
|
[Test name="Attract: Doesnt work on genderless user"]
|
|
void Attract_GenderlessUser(){
|
|
auto mon1 = CreatePokemonBuilder("charizard", 100)
|
|
.WithGender(Gender::Genderless)
|
|
.Build();
|
|
auto mon2 = CreatePokemonBuilder("venusaur", 100)
|
|
.WithGender(Gender::Male)
|
|
.Build();
|
|
|
|
auto p1 = CreateParty({mon1});
|
|
auto p2 = CreateParty({mon2});
|
|
|
|
auto script = cast<Gen7::Attract>(CreateMoveScript("Attract"));
|
|
auto executingMove = CreateExecutingMove("Attract", mon1, mon2);
|
|
script.OnSecondaryEffect(executingMove, mon2, 0x0);
|
|
Require(executingMove.GetHitData(mon2, 0).HasFailed);
|
|
Require(!mon2.HasVolatile("Infatuated"));
|
|
}
|
|
|
|
[Test name="Attract: Doesnt work for same gender"]
|
|
void Attract_SameGender(){
|
|
auto mon1 = CreatePokemonBuilder("charizard", 100)
|
|
.WithGender(Gender::Male)
|
|
.Build();
|
|
auto mon2 = CreatePokemonBuilder("venusaur", 100)
|
|
.WithGender(Gender::Male)
|
|
.Build();
|
|
|
|
auto p1 = CreateParty({mon1});
|
|
auto p2 = CreateParty({mon2});
|
|
|
|
auto script = cast<Gen7::Attract>(CreateMoveScript("Attract"));
|
|
auto executingMove = CreateExecutingMove("Attract", mon1, mon2);
|
|
script.OnSecondaryEffect(executingMove, mon2, 0x0);
|
|
Require(executingMove.GetHitData(mon2, 0).HasFailed);
|
|
Require(!mon2.HasVolatile("Infatuated"));
|
|
}
|
|
|
|
|
|
#endif |