Implements core interfaces for better language server compiles.

This commit is contained in:
Deukhoofd 2020-09-19 17:44:06 +02:00
parent 5650fd004c
commit d3262e924d
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
38 changed files with 292 additions and 70 deletions

View File

@ -0,0 +1,5 @@
shared interface BaseTurnChoice {
TurnChoiceKind Kind { get const; }
Pokemon@ User { get const; }
MoveTurnChoice@ opCast();
}

View File

@ -0,0 +1,12 @@
shared interface Battle {
const BattleLibrary@ Library { get const; }
bool CanUse(BaseTurnChoice@ choice);
bool CanFlee { get const; }
BattleRandom@ Random { get const; }
ChoiceQueue@ TurnQueue { get const; }
void AddVolatile(const constString &in name) const;
void RemoveVolatile(const constString &in name) const;
void SetWeather(const constString &in name) const;
void ClearWeather(const constString &in name) const;
const constString& GetWeatherName() const;
}

View File

@ -0,0 +1,7 @@
shared enum BattleItemCategory {
None = 0,
Healing = 1,
StatusHealing = 2,
CaptureDevice = 3,
Misc = 4,
}

View File

@ -0,0 +1,8 @@
shared interface BattleLibrary {
const LibrarySettings@ Settings { get const; }
const StaticLibrary@ StaticLibrary { get const; }
const SpeciesLibrary@ SpeciesLibrary { get const; }
const MoveLibrary@ MoveLibrary { get const; }
const ItemLibrary@ ItemLibrary { get const; }
const DamageLibrary@ DamageLibrary { get const; }
}

View File

@ -0,0 +1,6 @@
shared interface BattleRandom {
bool EffectChance(float chance, ExecutingMove@ move, Pokemon@ target);
int Get();
int Get(int max);
int Get(int min, int max);
}

View File

@ -0,0 +1,4 @@
shared interface ChoiceQueue {
bool MovePokemonChoiceNext(Pokemon@ target);
const BaseTurnChoice@ Peek() const;
}

View File

@ -0,0 +1,3 @@
shared interface DamageLibrary {
int GetDamage() const;
}

View File

@ -0,0 +1,4 @@
shared enum DamageSource {
AttackDamage = 0,
Struggle = 1,
}

View File

@ -0,0 +1,7 @@
shared interface EffectParameter {
EffectParameterType GetType() const;
bool AsBool() const;
int64 AsInt() const;
float AsFloat() const;
const constString& AsString() const;
}

View File

@ -0,0 +1,7 @@
shared enum EffectParameterType {
None = 0,
Bool = 1,
Int = 2,
Float = 3,
String = 4,
}

View File

@ -0,0 +1,6 @@
shared interface ExecutingMove {
HitData@ GetHitData(Pokemon@ target, uint8 hit) const;
bool IsPokemonTarget(Pokemon@ pkmn) const;
Pokemon@ User { get const; }
LearnedMove@ Move { get const; }
}

View File

@ -0,0 +1,10 @@
shared interface Forme {
const constString& Name { get const; }
float Weight { get const; }
float Height { get const; }
uint BaseExperience { get const; }
int TypeCount { get const; }
uint8 GetType(int index) const;
uint GetStatistic(Statistic stat) const;
const constString& GetAbility(bool hidden, uint8 index) const;
}

View File

@ -0,0 +1,5 @@
shared enum Gender {
Male = 0,
Female = 1,
Genderless = 2,
}

View File

@ -0,0 +1,4 @@
shared interface GrowthRate {
uint8 CalculateLevel(uint experience) const;
uint CalculateExperience(uint8 level) const;
}

View File

@ -0,0 +1,4 @@
shared interface GrowthRateLibrary {
uint8 CalculateLevel(const constString &in growthRate, uint experience) const;
uint CalculateExperience(const constString &in growthRate, uint8 experience) const;
}

View File

@ -0,0 +1,7 @@
shared interface HitData {
bool IsCritical { get const; }
uint8 BasePower { get const; }
float Effectiveness { get const; }
uint Damage { get const; }
uint8 Type { get const; }
}

View File

@ -0,0 +1,7 @@
shared interface Item {
const constString& Name { get const; }
ItemCategory Category { get const; }
BattleItemCategory BattleCategory { get const; }
int Price { get const; }
bool HasFlag(const constString &in flag) const;
}

View File

@ -0,0 +1,10 @@
shared enum ItemCategory {
Misc = 0,
Pokeball = 1,
Medicine = 2,
Berry = 3,
TM = 4,
VariantChanger = 5,
KeyItem = 6,
Mail = 7,
}

View File

@ -0,0 +1,3 @@
shared interface ItemLibrary {
const Item@ Get(const constString &in name) const;
}

View File

@ -0,0 +1,6 @@
shared interface LearnedMove {
const MoveData@ MoveData { get const; }
uint8 MaxUses { get const; }
uint8 RemainingUses { get const; }
Gender LearnMethod { get const; }
}

View File

@ -0,0 +1,5 @@
shared interface LibrarySettings {
uint8 MaximalLevel { get const; }
uint8 MaximalMoves { get const; }
uint16 ShinyRate { get const; }
}

View File

@ -0,0 +1,5 @@
shared enum MoveCategory {
Physical = 0,
Special = 1,
Status = 2,
}

View File

@ -0,0 +1,11 @@
shared interface MoveData {
const constString& Name { get const; }
uint8 Type { get const; }
MoveCategory Category { get const; }
uint8 BasePower { get const; }
uint8 Accuracy { get const; }
uint8 BaseUsages { get const; }
MoveTarget Target { get const; }
int8 Priority { get const; }
bool HasFlag(const constString &in flag) const;
}

View File

@ -0,0 +1,4 @@
shared enum MoveLearnMethod {
Unknown = 0,
Level = 1,
}

View File

@ -0,0 +1,3 @@
shared interface MoveLibrary {
const MoveData@ Get(const constString &in name) const;
}

View File

@ -0,0 +1,14 @@
shared enum MoveTarget {
Adjacent = 0,
AdjacentAlly = 1,
AdjacentAllySelf = 2,
AdjacentOpponent = 3,
All = 4,
AllAdjacent = 5,
AllAdjacentOpponent = 6,
AllAlly = 7,
AllOpponent = 8,
Any = 9,
RandomOpponent = 10,
Self = 11,
}

View File

@ -0,0 +1,7 @@
shared interface MoveTurnChoice {
TurnChoiceKind Kind { get const; }
Pokemon@ User { get const; }
LearnedMove@ Move { get const; }
int8 Priority { get const; }
BaseTurnChoice@ opImplCast();
}

View File

@ -1,32 +1,34 @@
shared abstract class PkmnScript {
// CreatureLib methods
void OnInitialize(const array<EffectParameter@> &in parameters){};
void Stack(){};
void OnRemove(){};
void PreventAttack(ExecutingMove@ attack, bool& result){};
void FailAttack(ExecutingMove@ attack, bool& result){};
void StopBeforeAttack(ExecutingMove@ attack, bool& result){};
void OnBeforeAttack(ExecutingMove@ attack){};
void FailIncomingAttack(ExecutingMove@ attack, Pokemon@ target, bool& result){};
void IsInvulnerable(ExecutingMove@ attack, Pokemon@ target, bool& result){};
void OnAttackMiss(ExecutingMove@ attack, Pokemon@ target){};
void ChangeAttackType(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& outType){};
void OnStatusMove(ExecutingMove@ attack, Pokemon@ target, uint8 hit){};
void PreventSecondaryEffects(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& outResult){};
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit){};
void OnAfterHits(ExecutingMove@ attack, Pokemon@ target){};
void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
void OverrideBasePower(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& chance){};
void ChangeDamageStatsUser(ExecutingMove@ attack, Pokemon@ target, uint8 hit, Pokemon@& user){};
void BypassDefensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass){};
void BypassOffensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass){};
void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage){};
// PkmnLib methods
void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){};
}
void OnInitialize(const EffectParameter@[] &in){};
void Stack(){};
void OnRemove(){};
void OnBeforeTurn(BaseTurnChoice@){};
void ChangeAttack(MoveTurnChoice@, constString &inout){};
void PreventAttack(ExecutingMove@, bool &inout){};
void FailAttack(ExecutingMove@, bool &inout){};
void StopBeforeAttack(ExecutingMove@, bool &inout){};
void OnBeforeAttack(ExecutingMove@){};
void FailIncomingAttack(ExecutingMove@, Pokemon@, bool &inout){};
void IsInvulnerable(ExecutingMove@, Pokemon@, bool &inout){};
void OnAttackMiss(ExecutingMove@, Pokemon@){};
void ChangeAttackType(ExecutingMove@, Pokemon@, uint8, uint8 &inout){};
void ChangeEffectiveness(ExecutingMove@, Pokemon@, uint8, float &inout){};
void PreventSecondaryEffects(ExecutingMove@, Pokemon@, uint8, bool &inout){};
void OnSecondaryEffect(ExecutingMove@, Pokemon@, uint8){};
void OnAfterHits(ExecutingMove@, Pokemon@){};
void PreventSelfSwitch(SwitchTurnChoice@, bool &inout){};
void ModifyEffectChance(ExecutingMove@, Pokemon@, float &inout){};
void ModifyIncomingEffectChance(ExecutingMove@, Pokemon@, float &inout){};
void OverrideBasePower(ExecutingMove@, Pokemon@, uint8, uint8 &inout){};
void ChangeDamageStatsUser(ExecutingMove@, Pokemon@, uint8, Pokemon@ &inout){};
void BypassDefensiveStat(ExecutingMove@, Pokemon@, uint8, bool &inout){};
void BypassOffensiveStat(ExecutingMove@, Pokemon@, uint8, bool &inout){};
void ModifyStatModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void ModifyDamageModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void OverrideDamage(ExecutingMove@, Pokemon@, uint8, uint &inout){};
void ModifyCriticalStage(ExecutingMove@, Pokemon@, uint8, uint8 &inout){};
void OverrideCriticalModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void OverrideSTABModifier(ExecutingMove@, Pokemon@, uint8, float &inout){};
void ModifyExperienceGain(Pokemon@, Pokemon@, uint &inout){};
void DoesShareExperience(Pokemon@, Pokemon@, bool &inout){};
}

View File

@ -1,38 +1,33 @@
interface Pokemon{
const Species@ Species { get const; }
const Forme@ Forme { get const; }
const Species@ DisplaySpecies { get const; }
const Forme@ DisplayForme { get const; }
uint8 Level { get const; }
uint32 Experience { get const; }
Gender Gender { get const; }
uint8 Coloring { get const; }
bool Shiny { get const; }
const Item@ HeldItem { get const; }
uint32 CurrentHealth{ get const; }
const string& Nickname { get const; }
const string& ActiveAbility { get const; }
bool IsFainted { get const; }
bool HasType(uint8) const;
uint32 MaxHealth{ get const; };
const Species@ DisplaySpecies { get const; }
uint8[]@ GetTypes() const;
LearnedMove@[]@ GetMoves() const
void ChangeStatBoost(Statistic stat, int8 amount);
uint32 GetFlatStat(Statistic stat) const;
uint32 GetBoostedStat(Statistic stat) const;
uint32 GetBaseStat(Statistic stat) const;
int8 GetStatBoost(Statistic stat) const;
bool HasHeldItem(const string &in name) const;
void Damage(uint32 amount, DamageSource source);
void Heal(uint32 amount);
void OverrideActiveAbility(const string &in ability);
void SetHeldItem(const string &in name);
void SetHeldItem(const Item@ name);
Battle Battle{ get const; }
}
shared interface Pokemon {
const Species@ Species { get const; }
const Forme@ Forme { get const; }
uint8 Level { get const; }
uint Experience { get const; }
Gender Gender { get const; }
uint8 Coloring { get const; }
bool Shiny { get const; }
const Item@ HeldItem { get const; }
bool HasHeldItem(const constString &in name) const;
void SetHeldItem(const string &in name);
void SetHeldItem(const Item@ item);
uint CurrentHealth { get const; }
const string& Nickname { get const; }
const constString& ActiveAbility { get const; }
bool IsFainted { get const; }
bool HasType(uint8 type) const;
uint MaxHealth { get const; }
void Damage(uint type, DamageSource source);
void Heal(uint type);
void OverrideActiveAbility(const string &in ability);
LearnedMove@[]@ GetMoves() const;
void ChangeStatBoost(Statistic stat, int8 amount);
const Species@ DisplaySpecies { get const; }
const Species@ DisplayForme { get const; }
uint GetFlatStat(Statistic stat) const;
uint GetBoostedStat(Statistic stat) const;
uint GetBaseStat(Statistic stat) const;
int8 GetStatBoost(Statistic stat) const;
void AddVolatile(const constString &in name) const;
void RemoveVolatile(const constString &in name) const;
const Battle@ Battle { get const; }
}

View File

@ -0,0 +1,9 @@
shared interface Species {
const constString& Name { get const; }
uint16 Id { get const; }
float GenderRate { get const; }
uint8 CaptureRate { get const; }
Gender GetRandomGender() const;
const Forme@ GetForme(string key) const;
const Forme@ DefaultForme { get const; }
}

View File

@ -0,0 +1,3 @@
shared interface SpeciesLibrary {
const Species@ Get(const constString &in name) const;
}

View File

@ -0,0 +1,8 @@
shared interface StaticLibrary {
const LibrarySettings@ Settings { get const; }
const SpeciesLibrary@ SpeciesLibrary { get const; }
const MoveLibrary@ MoveLibrary { get const; }
const ItemLibrary@ ItemLibrary { get const; }
const GrowthRateLibrary@ GrowthRateLibrary { get const; }
const TypeLibrary@ TypeLibrary { get const; }
}

View File

@ -0,0 +1,8 @@
shared enum Statistic {
HP = 0,
Attack = 1,
Defense = 2,
SpecialAttack = 3,
SpecialDefense = 4,
Speed = 5,
}

View File

@ -0,0 +1,7 @@
shared interface SwitchTurnChoice {
TurnChoiceKind Kind { get const; }
Pokemon@ User { get const; }
Pokemon@ NewPokemon { get const; }
MoveTurnChoice@ opCast();
BaseTurnChoice@ opImplCast();
}

View File

@ -0,0 +1,7 @@
shared enum TurnChoiceKind {
Pass = 0,
Attack = 1,
Item = 2,
Switch = 3,
Flee = 4,
}

View File

@ -0,0 +1,4 @@
shared interface TypeLibrary {
uint8 GetTypeId(const constString &in name) const;
float GetSingleEffectiveness(uint8 attacking, uint8 defensive) const;
}

View File

@ -0,0 +1,5 @@
shared interface constString {
bool opEquals(const constString &in) const;
bool opEquals(const string &in) const;
uint opImplConv();
}

View File

@ -3,7 +3,7 @@ namespace Gen7 {
shared class ChangeTargetDefense : PkmnScript{
int8 _amount;
void OnInitialize(const array<EffectParameter@> &in parameters) override{
void OnInitialize(const EffectParameter@[] &in parameters) override{
_amount = int8(parameters[0].AsInt());
}