Update tester, implements attract
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-10-24 16:34:58 +02:00
parent c8a43107d9
commit 12f0e46372
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
7 changed files with 3081 additions and 649 deletions

3590
Moves.json

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,7 @@ type Pokemon {
uint GetBoostedStat(Statistic stat) const; uint GetBoostedStat(Statistic stat) const;
uint GetBaseStat(Statistic stat) const; uint GetBaseStat(Statistic stat) const;
int8 GetStatBoost(Statistic stat) const; int8 GetStatBoost(Statistic stat) const;
bool HasVolatile(const constString &in name);
ref@ AddVolatile(const constString &in name); ref@ AddVolatile(const constString &in name);
void RemoveVolatile(const constString &in name) const; void RemoveVolatile(const constString &in name) const;
void ClearStatus() const; void ClearStatus() const;

View File

@ -2,6 +2,7 @@ func bool Require(bool expression);
func bool RequireEquals(int expected, int actual); func bool RequireEquals(int expected, int actual);
func bool RequireEquals(const string &in expected, const string &in actual); func bool RequireEquals(const string &in expected, const string &in actual);
func Party@ CreateParty(const array<Pokemon@>&in species);
func Party@ CreateSimpleParty(const array<constString>&in species, uint8 level); func Party@ CreateSimpleParty(const array<constString>&in species, uint8 level);
func Battle@ CreateSimpleBattle(uint seed, const constString&in species1, const constString&in species2, uint8 level); func Battle@ CreateSimpleBattle(uint seed, const constString&in species1, const constString&in species2, uint8 level);
func Battle@ CreateSimpleBattle(uint seed, Party@ p1, Party@ p2); func Battle@ CreateSimpleBattle(uint seed, Party@ p1, Party@ p2);
@ -15,3 +16,21 @@ type Pokemon {
bool PassTurn(); bool PassTurn();
bool LearnMove(const constString&in move); bool LearnMove(const constString&in move);
} }
type PokemonBuilder {
PokemonBuilder@ WithForme(const constString&in forme);
PokemonBuilder@ WithGender(Gender gender);
PokemonBuilder@ IsShiny(bool value);
PokemonBuilder@ WithHeldItem(const constString&in item);
PokemonBuilder@ LearnMove(const constString&in move, MoveLearnMethod method);
PokemonBuilder@ WithIndividualValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed);
PokemonBuilder@ WithEffortValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed);
PokemonBuilder@ WithNature(const constString&in nature);
PokemonBuilder@ WithNickname(const string&in name);
Pokemon@ Build(uint seed = 0);
}
func PokemonBuilder@ CreatePokemonBuilder(const constString&in species, uint8 level);

100
Scripts/Moves/Attract.as Normal file
View File

@ -0,0 +1,100 @@
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

View File

@ -1,6 +1,6 @@
namespace Pokemon{ namespace Gen7 {
[Pokemon effect=Flinch] [Pokemon effect=Flinch]
class Flinch : PkmnScript{ class FlinchEffect : PkmnScript{
void PreventAttack(ExecutingMove@ attack, bool& result) override { void PreventAttack(ExecutingMove@ attack, bool& result) override {
result = true; result = true;
attack.User.RemoveVolatile("flinch"); attack.User.RemoveVolatile("flinch");

View File

@ -0,0 +1,10 @@
namespace Gen7 {
[Pokemon effect=Infatuated]
class Infatuated : PkmnScript{
void PreventAttack(ExecutingMove@ attack, bool& result) override {
if (attack.User.Battle.Random.Get(2) == 0){
result = true;
}
}
}
}

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
TESTERVERSION=0.0.7 TESTERVERSION=0.0.8
# Get the release information from the api for the specified version # Get the release information from the api for the specified version
curl -X GET "https://git.p-epsilon.com/api/v1/repos/Deukhoofd/PokemonScriptTester/releases/tags/$TESTERVERSION" -H "accept: application/json" | curl -X GET "https://git.p-epsilon.com/api/v1/repos/Deukhoofd/PokemonScriptTester/releases/tags/$TESTERVERSION" -H "accept: application/json" |