Adds Assurance effect

This commit is contained in:
Deukhoofd 2021-10-23 18:29:18 +02:00
parent a31698cac0
commit e85460fd22
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
8 changed files with 81 additions and 1 deletions

View File

@ -406,7 +406,10 @@
"priority": 0,
"target": "Any",
"category": "physical",
"flags": ["contact", "protect", "mirror"]
"flags": ["contact", "protect", "mirror"],
"effect": {
"name": "Assurance"
}
},
{
"name": "astonish",

View File

@ -0,0 +1,7 @@
type AttackUseHistory {
const HistoryElement@ Previous { get const; };
HistoryElementKind Kind { get const; };
uint TurnNumber { get const; };
const HistoryElement@ opImplCast() const;
const ExecutingMove@ Move { get const; };
}

View File

@ -6,6 +6,7 @@ type Battle {
ChoiceQueue@ TurnQueue { get const; };
narray<BattleSide>@ Sides { get const; };
narray<BattleParty>@ Parties { get const; };
BattleHistory@ History { get const; };
bool CanUse(BaseTurnChoice@ choice);
ref@ AddVolatile(const constString &in name);
void RemoveVolatile(const constString &in name) const;

View File

@ -0,0 +1,5 @@
type BattleHistory {
const HistoryElement@ TopElement { get const; };
const AttackUseHistory@ GetLastUsedAttack() const;
const DamageHistory@ GetLastDamageOnTarget(Pokemon@ target) const;
}

View File

@ -0,0 +1,9 @@
type DamageHistory {
const HistoryElement@ Previous { get const; };
HistoryElementKind Kind { get const; };
uint TurnNumber { get const; };
const HistoryElement@ opImplCast() const;
Pokemon@ Target { get const; };
uint Amount { get const; };
DamageSource Source { get const; };
}

View File

@ -0,0 +1,4 @@
type HistoryElement {
const DamageHistory@ opCast() const;
const AttackUseHistory@ opCast() const;
}

View File

@ -0,0 +1,4 @@
enum HistoryElementKind {
AttackUse = 0,
Damage = 1,
}

View File

@ -0,0 +1,47 @@
namespace Gen7{
[Move effect=Assurance]
class Assurance : PkmnScript {
void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint &inout damage) override {
auto damageEvent = target.Battle.History.GetLastDamageOnTarget(target);
if (damageEvent is null){
return;
}
if (damageEvent.TurnNumber == target.Battle.CurrentTurn){
damage *= 2;
}
};
}
}
#if TESTS
[Test name="Assurance: damage without damage on the same turn"]
void Assurance_DamageWithoutEvent(){
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto mon2 = battle.GetBattleSide(1).GetPokemon(0);
auto script = cast<Gen7::Assurance>(CreateMoveScript("Assurance"));
Require(script !is null);
uint damage = 100;
auto executingMove = CreateExecutingMove("Assurance", mon1, mon2);
script.OverrideDamage(executingMove, mon2, 0x0, damage);
RequireEquals(100, damage);
}
[Test name="Assurance: damage with damage on the same turn"]
void Assurance_DamageWithEvent(){
auto battle = CreateSimpleBattle(684, "charizard", "venusaur", 100);
auto mon1 = battle.GetBattleSide(0).GetPokemon(0);
auto mon2 = battle.GetBattleSide(1).GetPokemon(0);
mon2.Damage(10, DamageSource::AttackDamage);
auto script = cast<Gen7::Assurance>(CreateMoveScript("Assurance"));
Require(script !is null);
uint damage = 100;
auto executingMove = CreateExecutingMove("Assurance", mon1, mon2);
script.OverrideDamage(executingMove, mon2, 0x0, damage);
RequireEquals(200, damage);
}
#endif