Namespace BattleSystem ''' ''' Represents a Pokémon in battle. ''' Public Class PokemonProfile ''' ''' Creates a new instance of the Pokémon Profile. ''' ''' The Position on the battle field. ''' The reference to the Pokémon in the party. Public Sub New(ByVal Target As PokemonTarget, ByVal Pokemon As Pokemon) Me._fieldPosition = Target Me._pokemon = Pokemon End Sub Private _pokemon As Pokemon = Nothing Private _fieldPosition As PokemonTarget = PokemonTarget.OwnCenter ''' ''' The Pokémon reference class instance that is associated with this profile. ''' Public ReadOnly Property Pokémon As Pokemon Get Return Me._pokemon End Get End Property ''' ''' The position of this Pokémon on the field. ''' Public ReadOnly Property FieldPosition As PokemonTarget Get Return Me._fieldPosition End Get End Property 'Stuff that needs to be in FieldEffects cause its an effect for one side of the field or the entire field: 'HealingWish: Heal next Pokémon switched in on the side. 'Spikes, Toxic Spikes, Stealth Rocks, Mist, Guard Spec: Full side, not single Pokémon 'Turn Count: Turn count for the entire battle, not just the Pokémon. 'Reflect, Tailwind, HealBlock, Safeguard, and LightScreen: Affects whole team. 'Wish: Need to store the target. 'RemoteMoves (RemoteDamage,RemoteTurns,RemoteTarget,RemoteMoveID): per Target (Foresight) 'TrickRoom, Gravity, MudSport, WaterSport, RoundCount, Weather, WeatherRounds, AmuletCoinUsed 'PayDay: All uses add up. #Region "ProfileElements" ''' ''' The amount of damage this Pokémon took in the last attack. ''' Public LastDamageTaken As Integer = 0 ''' ''' The counter that indicates how many turns this Pokémon has been in battle. ''' Public TurnsInBattle As Integer = 0 ''' ''' If this Pokémon directly damaged an opponent last turn. ''' Public DealtDamageThisTurn As Boolean = False ''' ''' List of used moves (IDs) ''' Public UsedMoves As New List(Of Integer) ''' ''' An item this Pokémon possibly lost in battle. ''' Public LostItem As Item = Nothing ''' ''' If this Pokémon Mega Evolved in this battle. ''' Public MegaEvolved As Boolean = False ''' ''' The last move this Pokémon used. ''' Public LastMove As Attack = Nothing ''' ''' The turn number this Pokémon last used a move. ''' Public LastTurnMoved As Integer = 0 ''' ''' Trigger, if the Pokémon wants to switch out but another one used Pursuit on it. ''' Public Pursuit As Boolean = False ''' ''' The turns until the Pokémon wakes up. ''' Public SleepTurns As Integer = 0 ''' ''' Round counter for toxic. ''' Public ToxicRound As Integer = 0 ''' ''' Rounds until Yawn affects the Pokémon. ''' Public Yawn As Integer = 0 ''' ''' Turns until confusion runs out. ''' Public ConfusionTurns As Integer = 0 ''' ''' The Truant ability counter. When this is 1, the Pokémon won't move this round. ''' Public TruantRound As Integer = 0 ' ''' ''' Turns True if Imprison was used on this Pokémon. ''' Public Imprisoned As Boolean = False ''' ''' Taunt move counter, if true, Pokémon cannot use status moves. ''' Public Taunted As Integer = 0 ''' ''' If the Pokémon is affected by Embargo. ''' Public Embargo As Integer = 0 ''' ''' Rounds until Encore wears off. ''' Public Encore As Integer = 0 ''' ''' The move reference that the encored Pokémon has to use. ''' Public EncoreMove As Attack = Nothing ''' ''' Rounds until Torment wears off. ''' Public Torment As Integer = 0 ''' ''' The move that the Pokémon is forced to use. ''' Public TormentMoveID As Integer = -1 ''' ''' The move chosen for Choice Items. ''' Public ChoiceMove As Attack = Nothing ''' ''' Turns true when the Pokémon is affected by Gastro Acid. ''' Public GastroAcid As Integer = 0 ''' ''' The counter for the rage move. ''' Public Rage As Integer = 0 ''' ''' Checks if Defense Curl was used. ''' Public DefenseCurl As Integer = 0 ''' ''' Charge move counter. ''' Public Charge As Integer = 0 ''' ''' Indicates if minimize got used. ''' Public Minimize As Integer = 0 ''' ''' Counter for Bide ''' Public Bide As Integer = 0 ''' ''' Stores all the damage that the Pokémon will deal with Bide. ''' Public BideDamage As Integer = 0 ''' ''' Doubles effect probability for four turns. ''' Public WaterPledge As Integer = 0 ''' ''' The counter for the Uproar move. ''' Public Uproar As Integer = 0 ''' ''' The Outrage move counter. ''' Public Outrage As Integer = 0 ''' ''' The Thrash move counter. ''' Public Thrash As Integer = 0 ''' ''' The Petal Dance move counter. ''' Public PetalDance As Integer = 0 ''' ''' Rollout move counter ''' Public Rollout As Integer = 0 ''' ''' Iceball move counter ''' Public IceBall As Integer = 0 ''' ''' Recharge counter for moves like Hyperbeam. ''' Public Recharge As Integer = 0 ''' ''' Razor Wind move counter. ''' Public RazorWind As Integer = 0 ''' ''' Skull bash Move counter. ''' Public SkullBash As Integer = 0 ''' ''' Sky Attack move counter. ''' Public SkyAttack As Integer = 0 ''' ''' Solar beam move counter. ''' Public SolarBeam As Integer = 0 ''' ''' Solar blade move counter. ''' Public SolarBlade As Integer = 0 ''' ''' Ice Burn move counter. ''' Public IceBurn As Integer = 0 ''' ''' Freeze Shock move counter. ''' Public FreezeShock As Integer = 0 ''' ''' Fly move counter. ''' Public Fly As Integer = 0 ''' ''' Dig move counter. ''' Public Dig As Integer = 0 ''' ''' Bounce move counter. ''' Public Bounce As Integer = 0 ''' ''' Dive move counter. ''' Public Dive As Integer = 0 ''' ''' Shadow Force move counter. ''' Public ShadowForce As Integer = 0 ''' ''' Phantom Force move counter. ''' Public PhantomForce As Integer = 0 ''' ''' Sky Drop move counter. ''' Public SkyDrop As Integer = 0 ''' ''' Geomancy move counter. ''' Public Geomancy As Integer = 0 ''' ''' Turns this Pokémon is trapped in Wrap. ''' Public Wrap As Integer = 0 ''' ''' Turns this Pokémon is trapped in Whirlpool. ''' Public Whirlpool As Integer = 0 ''' ''' Turns this Pokémon is trapped in Bind. ''' Public Bind As Integer = 0 ''' ''' Turns this Pokémon is trapped in Clamp. ''' Public Clamp As Integer = 0 ''' ''' Turns this Pokémon is trapped in FireSpin. ''' Public FireSpin As Integer = 0 ''' ''' Turns this Pokémon is trapped in MagmaStorm. ''' Public MagmaStorm As Integer = 0 ''' ''' Turns this Pokémon is trapped in SandTomb. ''' Public SandTomb As Integer = 0 ''' ''' Focus Energy move counter. ''' Public FocusEnergy As Integer = 0 ''' ''' Lucky Chant move counter. ''' Public LuckyChant As Integer = 0 ''' ''' Counter for the Lock On and Mind Reader move. ''' Public LockedOn As Integer = 0 ''' ''' Counter for the Fury Cutter move. ''' Public FuryCutter As Integer = 0 ''' ''' Counter for the Echoed Voice move. ''' Public EchoedVoice As Integer = 0 ''' ''' Counter for the Stockpile move. ''' Public StockPile As Integer = 0 ''' ''' Magic Coat move counter. ''' Public MagicCoat As Integer = 0 ''' ''' Roost counter, set to flying type. ''' Public Roost As Integer = 0 ''' ''' Destiny Bond move counter. ''' Public DestinyBond As Integer = 0 ''' ''' Endure move counter. ''' Public Endure As Integer = 0 ''' ''' Protect move counter ''' Public Protect As Integer = 0 ''' ''' Detect move counter ''' Public Detect As Integer = 0 ''' ''' Indicates how much HP the substitute has left. ''' Public Substitute As Integer = 0 ''' ''' Counts the consecutive uses of Protect like moves. ''' Public ProtectMoveCounter As Integer = 0 ''' ''' King's Shield move counter. ''' Public KingsShield As Integer = 0 ''' ''' Ingrain move counter. ''' Public Ingrain As Integer = 0 ''' ''' Counter for the Magnet Rise move. ''' Public MagnetRise As Integer = 0 ''' ''' Counter for the Aqua Ring move. ''' Public AquaRing As Integer = 0 ''' ''' If the Pokémon is affected by Nightmare. ''' Public Nightmare As Integer = 0 ''' ''' If the Pokémon is affected by Curse. ''' Public Cursed As Integer = 0 ''' ''' Turns until Perish Song faints Pokémon. ''' Public PerishSong As Integer = 0 ''' ''' Counter for moves like Spider Web. ''' Public Trapped As Integer = 0 ''' ''' Counter for the Foresight move. ''' Public Foresight As Integer = 0 ''' ''' Counter for the Odor Sleught move. ''' Public OdorSleught As Integer = 0 ''' ''' Counter for the Miracle Eye move. ''' Public MiracleEye As Integer = 0 ''' ''' Halves this Pokémon's speed for four turns. ''' Public GrassPledge As Integer = 0 ''' ''' Deals damage of 1/8 HP at the end of turn for four turns. ''' Public FirePledge As Integer = 0 ''' ''' If Leech Seed got used on this Pokémon ''' Public LeechSeed As Integer = 0 ''' ''' The target the leech seed HP gets sent to. ''' Public LeechSeedTarget As PokemonTarget = Nothing ''' ''' Counter for the Metronome item. ''' Public MetronomeItemCount As Integer = 0 ''' ''' Raises critical Hit ratio, Lansat Berry trigger ''' Public LansatBerry As Integer = 0 ''' ''' Raises attack speed when Custap berry got eaten. ''' Public CustapBerry As Integer = 0 #End Region ''' ''' Resets the fields to their default values when a new Pokémon gets switched in. ''' ''' If the Pokémon got switched in using Baton Pass. Public Sub ResetFields(ByVal BatonPassed As Boolean) Me.SleepTurns = 0 Me.TruantRound = 0 Me.Taunted = 0 Me.Rage = 0 Me.Uproar = 0 Me.Endure = 0 Me.Protect = 0 Me.Detect = 0 Me.KingsShield = 0 Me.ProtectMoveCounter = 0 Me.ToxicRound = 0 Me.Nightmare = 0 Me.Outrage = 0 Me.Thrash = 0 Me.PetalDance = 0 Me.Encore = 0 Me.EncoreMove = Nothing Me.Yawn = 0 Me.ConfusionTurns = 0 Me.Torment = 0 Me.TormentMoveID = 0 Me.ChoiceMove = Nothing Me.Recharge = 0 Me.Rollout = 0 Me.IceBall = 0 Me.DefenseCurl = 0 Me.Charge = 0 Me.SolarBeam = 0 Me.SolarBlade = 0 Me.LansatBerry = 0 Me.CustapBerry = 0 Me.Trapped = 0 Me.FuryCutter = 0 Me.EchoedVoice = 0 Me.TurnsInBattle = 0 Me.StockPile = 0 Me.DestinyBond = 0 Me.GastroAcid = 0 Me.Foresight = 0 Me.OdorSleught = 0 Me.MiracleEye = 0 Me.Fly = 0 Me.Dig = 0 Me.Bounce = 0 Me.Dive = 0 Me.ShadowForce = 0 Me.PhantomForce = 0 Me.SkyDrop = 0 Me.Geomancy = 0 Me.SkyAttack = 0 Me.RazorWind = 0 Me.SkullBash = 0 Me.Wrap = 0 Me.Whirlpool = 0 Me.Bind = 0 Me.Clamp = 0 Me.FireSpin = 0 Me.MagmaStorm = 0 Me.SandTomb = 0 Me.Bide = 0 Me.BideDamage = 0 Me.Roost = 0 'If Baton Pass is not used to switch, also reset these variables: If BatonPassed = False Then Me.FocusEnergy = 0 Me.Ingrain = 0 Me.Substitute = 0 Me.MagnetRise = 0 Me.AquaRing = 0 Me.Cursed = 0 Me.Embargo = 0 Me.PerishSong = 0 Me.LeechSeed = 0 Me.LeechSeedTarget = Nothing End If End Sub End Class ''' ''' Represents a position on the battle field by targeting the Pokémon. ''' Public Class PokemonTarget ''' ''' The positions on the battle field a Pokémon can get targeted on. ''' Public Enum Targets OwnLeft OwnCenter OwnRight OppLeft OppCenter OppRight End Enum Private _target As Targets = Targets.OwnCenter ''' ''' Creates a new instance of a Pokémon Target. ''' ''' The Target type of this Pokémon Target. Public Sub New(ByVal t As Targets) Me._target = t End Sub ''' ''' Creates a new instance of a Pokémon Target. ''' ''' The Target type of this Pokémon Target. Public Sub New(ByVal s As String) Select Case s.ToLower() Case "ownleft" Me._target = Targets.OwnLeft Case "ownright" Me._target = Targets.OwnRight Case "owncenter" Me._target = Targets.OwnCenter Case "oppleft" Me._target = Targets.OppLeft Case "oppright" Me._target = Targets.OppRight Case "oppcenter" Me._target = Targets.OppCenter End Select End Sub ''' ''' The target of this PokémonTarget. ''' Public ReadOnly Property Target() As Targets Get Return Me._target End Get End Property Public Shared Operator =(ByVal FirstTarget As PokemonTarget, ByVal SecondTarget As PokemonTarget) As Boolean Return FirstTarget._target = SecondTarget._target End Operator Public Shared Operator <>(ByVal FirstTarget As PokemonTarget, ByVal SecondTarget As PokemonTarget) As Boolean Return FirstTarget._target <> SecondTarget._target End Operator ''' ''' Creates a target set to Own Left. ''' Public Shared ReadOnly Property OwnLeft() As PokemonTarget Get Return New PokemonTarget(Targets.OwnLeft) End Get End Property ''' ''' Creates a target set to Own Center. ''' Public Shared ReadOnly Property OwnCenter() As PokemonTarget Get Return New PokemonTarget(Targets.OwnCenter) End Get End Property ''' ''' Creates a target set to Own Right. ''' Public Shared ReadOnly Property OwnRight() As PokemonTarget Get Return New PokemonTarget(Targets.OwnRight) End Get End Property ''' ''' Creates a target set to Opp Left. ''' Public Shared ReadOnly Property OppLeft() As PokemonTarget Get Return New PokemonTarget(Targets.OppLeft) End Get End Property ''' ''' Creates a target set to Opp Center. ''' Public Shared ReadOnly Property OppCenter() As PokemonTarget Get Return New PokemonTarget(Targets.OppCenter) End Get End Property ''' ''' Creates a target set to Opp Right. ''' Public Shared ReadOnly Property OppRight() As PokemonTarget Get Return New PokemonTarget(Targets.OppRight) End Get End Property ''' ''' Reverses the sides of the target (Own => Opp; Opp => Own) ''' Public Sub Reverse() Select Case Me._target Case Targets.OwnLeft Me._target = Targets.OppLeft Case Targets.OwnCenter Me._target = Targets.OppCenter Case Targets.OwnRight Me._target = Targets.OppRight Case Targets.OppLeft Me._target = Targets.OwnLeft Case Targets.OppCenter Me._target = Targets.OwnCenter Case Targets.OppRight Me._target = Targets.OwnRight End Select End Sub ''' ''' Returns a string that represents the target. ''' Public Overrides Function ToString() As String Return Me._target.ToString() End Function ''' ''' This converts the Attack Target in an AttackV2 into a useable Pokemon Target on the field. ''' ''' The Attack Target that should get converted. ''' A list of PokemonTargets that can be accessed with the Attack Target. ''' The list includes targets for which no Pokémon exist, so call the GetValidPokemonTargets function afterwards. Public Function ConvertAttackTarget(ByVal AttackTarget As Attack.Targets) As List(Of PokemonTarget) If AttackTarget = Attack.Targets.All Then Return {OwnLeft, OwnCenter, OwnRight, OppLeft, OppCenter, OppRight}.ToList() End If If AttackTarget = Attack.Targets.Self Then Return {Me}.ToList() End If Select Case Me._target Case Targets.OwnLeft Select Case AttackTarget Case Attack.Targets.OneAdjacentTarget, Attack.Targets.AllAdjacentTargets Return {OwnCenter, OppLeft, OppCenter}.ToList() Case Attack.Targets.OneAdjacentFoe, Attack.Targets.AllAdjacentFoes Return {OppLeft, OppCenter}.ToList() Case Attack.Targets.OneAdjacentAlly, Attack.Targets.AllAdjacentAllies Return {OwnCenter}.ToList() Case Attack.Targets.OneTarget, Attack.Targets.AllTargets Return {OwnCenter, OwnRight, OppLeft, OppCenter, OppRight}.ToList() Case Attack.Targets.OneFoe, Attack.Targets.AllFoes Return {OppLeft, OppCenter, OppRight}.ToList() Case Attack.Targets.OneAlly, Attack.Targets.AllAllies Return {OwnCenter, OwnRight}.ToList() Case Attack.Targets.AllOwn Return {OwnCenter, OwnRight, OwnLeft}.ToList() End Select Case Targets.OwnCenter Select Case AttackTarget Case Attack.Targets.OneAdjacentTarget, Attack.Targets.OneTarget, Attack.Targets.AllAdjacentTargets, Attack.Targets.AllTargets Return {OwnLeft, OwnRight, OppLeft, OppCenter, OppRight}.ToList() Case Attack.Targets.OneAdjacentFoe, Attack.Targets.OneFoe, Attack.Targets.AllAdjacentFoes, Attack.Targets.AllFoes Return {OppLeft, OppCenter, OppRight}.ToList() Case Attack.Targets.OneAdjacentAlly, Attack.Targets.OneAlly, Attack.Targets.AllAdjacentAllies, Attack.Targets.AllAllies Return {OwnLeft, OwnRight}.ToList() Case Attack.Targets.AllOwn Return {OwnCenter, OwnRight, OwnLeft}.ToList() End Select Case Targets.OwnRight Select Case AttackTarget Case Attack.Targets.OneAdjacentTarget, Attack.Targets.AllAdjacentTargets Return {OwnCenter, OppCenter, OppRight}.ToList() Case Attack.Targets.OneAdjacentFoe, Attack.Targets.AllAdjacentFoes Return {OppCenter, OppRight}.ToList() Case Attack.Targets.OneAdjacentAlly, Attack.Targets.AllAdjacentAllies Return {OwnCenter}.ToList() Case Attack.Targets.OneTarget, Attack.Targets.AllTargets Return {OwnLeft, OwnCenter, OppLeft, OppCenter, OppRight}.ToList() Case Attack.Targets.OneFoe, Attack.Targets.AllFoes Return {OppLeft, OppCenter, OppRight}.ToList() Case Attack.Targets.OneAlly, Attack.Targets.AllAllies Return {OwnLeft, OwnCenter}.ToList() Case Attack.Targets.AllOwn Return {OwnCenter, OwnRight, OwnLeft}.ToList() End Select Case Targets.OppLeft Select Case AttackTarget Case Attack.Targets.OneAdjacentTarget, Attack.Targets.AllAdjacentTargets Return {OwnLeft, OwnCenter, OppCenter}.ToList() Case Attack.Targets.OneAdjacentFoe, Attack.Targets.AllAdjacentFoes Return {OwnLeft, OwnCenter}.ToList() Case Attack.Targets.OneAdjacentAlly, Attack.Targets.AllAdjacentAllies Return {OppCenter}.ToList() Case Attack.Targets.OneTarget, Attack.Targets.AllTargets Return {OwnLeft, OwnCenter, OwnRight, OppCenter, OppRight}.ToList() Case Attack.Targets.OneFoe, Attack.Targets.AllFoes Return {OwnLeft, OwnCenter, OwnRight}.ToList() Case Attack.Targets.OneAlly, Attack.Targets.AllAllies Return {OppCenter, OppRight}.ToList() Case Attack.Targets.AllOwn Return {OppCenter, OppRight, OppLeft}.ToList() End Select Case Targets.OppCenter Select Case AttackTarget Case Attack.Targets.OneAdjacentTarget, Attack.Targets.OneTarget, Attack.Targets.AllAdjacentTargets, Attack.Targets.AllTargets Return {OwnLeft, OwnCenter, OwnRight, OppLeft, OppRight}.ToList() Case Attack.Targets.OneAdjacentFoe, Attack.Targets.OneFoe, Attack.Targets.AllAdjacentFoes, Attack.Targets.AllFoes Return {OwnLeft, OwnCenter, OwnRight}.ToList() Case Attack.Targets.OneAdjacentAlly, Attack.Targets.OneAlly, Attack.Targets.AllAdjacentAllies, Attack.Targets.AllAllies Return {OppLeft, OppRight}.ToList() Case Attack.Targets.AllOwn Return {OppCenter, OppRight, OppLeft}.ToList() End Select Case Targets.OppRight Select Case AttackTarget Case Attack.Targets.OneAdjacentTarget, Attack.Targets.AllAdjacentTargets Return {OwnCenter, OwnRight, OppCenter}.ToList() Case Attack.Targets.OneAdjacentFoe, Attack.Targets.AllAdjacentFoes Return {OwnCenter, OwnRight}.ToList() Case Attack.Targets.OneAdjacentAlly, Attack.Targets.AllAdjacentAllies Return {OppCenter}.ToList() Case Attack.Targets.OneTarget, Attack.Targets.AllTargets Return {OwnLeft, OwnCenter, OwnRight, OppRight, OppCenter}.ToList() Case Attack.Targets.OneFoe, Attack.Targets.AllFoes Return {OwnLeft, OwnCenter, OwnRight}.ToList() Case Attack.Targets.OneAlly, Attack.Targets.AllAllies Return {OppLeft, OppCenter}.ToList() Case Attack.Targets.AllOwn Return {OppCenter, OppRight, OppLeft}.ToList() End Select End Select Return New List(Of PokemonTarget) End Function ''' ''' Converts a list of Pokémon targets to a list of valid Pokémon targets that have a Pokémon profile assigned to them on the battle field. ''' ''' The reference to the BattleScreen. ''' The list of Pokémon targets. Public Shared Function GetValidPokemonTargets(ByVal BattleScreen As BattleScreen, ByVal l As List(Of PokemonTarget)) As List(Of PokemonTarget) Dim returnList As New List(Of PokemonTarget) For Each Target As PokemonTarget In l If Not BattleScreen.GetProfile(Target) Is Nothing Then returnList.Add(Target) End If Next Return returnList End Function ''' ''' If the Pokémon target is on the own side of the field. ''' Public ReadOnly Property IsOwn() As Boolean Get Select Case Me._target Case Targets.OwnCenter, Targets.OwnLeft, Targets.OwnRight Return True Case Targets.OppCenter, Targets.OppLeft, Targets.OppRight Return False End Select 'Wont ever happen. Return True End Get End Property End Class End Namespace