public static bool CheckFaint(this PokemonProxy pm) { if (pm.Hp == 0 && pm.OnboardPokemon != pm.NullOnboardPokemon) { ATs.Withdrawn(pm, pm.OnboardPokemon.Ability); pm.Field.SetCondition(Cs.FaintTurn, pm.Controller.TurnNumber); pm.Pokemon.State = PokemonState.Faint; pm.Controller.Withdraw(pm, "Faint", 0, false); foreach (var p in pm.Controller.OnboardPokemons) { if (p.AbilityE(As.Soul_Heart)) { p.ChangeLv7D(p, StatType.SpAtk, 1, false, true); } } foreach (var p in pm.Field.Pokemons) { var d = pm.OnboardPokemon.Ability; if ((p.AbilityE(As.Receiver) || p.AbilityE(As.Power_of_Alchemy)) && d != As.WONDER_GUARD && d != As.FORECAST && d != As.MULTITYPE && d != As.ILLUSION && d != As.ZEN_MODE && d != As.Shields_Down && d != As.Schooling && d != As.Shields_Down && d != As.Battle_Bond && d != As.RKS_System && d != As.Comatose) { p.RaiseAbility(); p.ChangeAbility(d); p.Controller.ReportBuilder.ShowLog("Receiver", pm.Id, pm.OnboardPokemon.Ability); } } return(true); } return(false); }
public bool SendOut(Tile tile, bool debut, string log) { Player p = Controller.GetPlayer(tile); int origin = GameSettings.Mode.GetPokemonIndex(tile.X); int sendout = tile.WillSendOutPokemonIndex; if (CanSendOut(tile) && CanSendOut(p.GetPokemon(sendout))) { var pm = SendOutImplement(tile); p.SwitchPokemon(origin, sendout); pm.ShowLogPm(log); pm.OnboardPokemon.AddTurnCondition(Cs.Switched); ATs.Trace(pm); if (debut) { ATs.AttachUnnerve(Controller); pm.Debut(); if (pm.Hp != 0) { ATs.AttachWeatherObserver(pm); } ATs.WeatherChanged(Controller); } return(true); } return(false); }
public static bool ChangeLv7D(this PokemonProxy pm, PokemonProxy by, bool showFail, bool ability, int a, int d = 0, int sa = 0, int sd = 0, int s = 0, int ac = 0, int e = 0) { a = CanChangeLv7D(pm, by, StatType.Atk, a, false); d = CanChangeLv7D(pm, by, StatType.Def, d, false); sa = CanChangeLv7D(pm, by, StatType.SpAtk, sa, false); sd = CanChangeLv7D(pm, by, StatType.SpDef, sd, false); s = CanChangeLv7D(pm, by, StatType.Speed, s, false); ac = CanChangeLv7D(pm, by, StatType.Accuracy, ac, false); e = CanChangeLv7D(pm, by, StatType.Evasion, e, false); if (a != 0 || d != 0 || sa != 0 || sd != 0 || s != 0 || ac != 0 || e != 0) { if (ability) { ATs.RaiseAbility(pm); } ChangeLv7DImplement(pm, by, StatType.Atk, a, null); ChangeLv7DImplement(pm, by, StatType.SpAtk, sa, null); ChangeLv7DImplement(pm, by, StatType.Def, d, null); ChangeLv7DImplement(pm, by, StatType.SpDef, sd, null); ChangeLv7DImplement(pm, by, StatType.Speed, s, null); ChangeLv7DImplement(pm, by, StatType.Accuracy, ac, null); ChangeLv7DImplement(pm, by, StatType.Evasion, e, null); ITs.WhiteHerb(pm); return(true); } return(false); }
public static void MoveEnding(AtkContext atk) { var aer = atk.Attacker; if (atk.Move.Id == Ms.SPIT_UP || atk.Move.Id == Ms.SWALLOW) { int i = aer.OnboardPokemon.GetCondition <int>(Cs.Stockpile); aer.ChangeLv7D(atk.Attacker, false, false, 0, -i, 0, -i); aer.OnboardPokemon.RemoveCondition(Cs.Stockpile); aer.ShowLogPm("DeStockpile"); } MagicCoat(atk); atk.SetAttackerAction(atk.Move.StiffOneTurn ? PokemonAction.Stiff : PokemonAction.Done); if (atk.Targets != null) { foreach (var d in atk.Targets) { ITs.Attach(d.Defender); ATs.RecoverAfterMoldBreaker(d.Defender); } } ITs.Attach(atk.Attacker); //先树果汁后PP果 var c = aer.Controller; { var o = atk.GetCondition(Cs.MultiTurn); if (o != null) { o.Turn--; if (o.Turn != 0) { atk.SetAttackerAction(PokemonAction.Moving); } else if (o.Bool) { aer.AddState(aer, AttachedState.Confuse, false, 0, "EnConfuse2"); } } } { var o = atk.GetCondition <Tile>(Cs.EjectButton); if (o != null) { c.PauseForSendOutInput(o); return; } } { var tile = aer.Tile; if (atk.Move.Switch && tile != null) { c.Withdraw(aer, "SelfWithdraw", 0, true); c.PauseForSendOutInput(tile); } } }
public static void ConsumeItem(this PokemonProxy pm, bool cheekPouch = true) { pm.OnboardPokemon.SetTurnCondition(Cs.UsedItem, pm.Pokemon.Item); pm.Pokemon.UsedItem = pm.Pokemon.Item; if (ITs.Berry(pm.Pokemon.Item)) { pm.OnboardPokemon.SetCondition(Cs.Belch); pm.Pokemon.UsedBerry = pm.Pokemon.Item; if (CanHpRecover(pm) && ATs.RaiseAbility(pm, As.CHEEK_POUCH)) { HpRecoverByOneNth(pm, 3); } } RemoveItem(pm); }
/// <summary> /// null log to show default log /// </summary> /// <param name="by"></param> /// <param name="stat"></param> /// <param name="change"></param> /// <param name="showFail"></param> /// <param name="log"></param> /// <returns></returns> public static bool ChangeLv7D(this PokemonProxy pm, PokemonProxy by, StatType stat, int change, bool showFail, bool ability = false, string log = null) { change = CanChangeLv7D(pm, by, stat, change, showFail); if (change != 0) { if (ability) { ATs.RaiseAbility(pm); } ChangeLv7DImplement(pm, by, stat, change, log); ITs.WhiteHerb(pm); return(true); } return(false); }
private void EndTurnSendOut() { if (Controller.TurnNumber == 0) { Controller.GameStartSendOut(Board[0]); Controller.GameStartSendOut(Board[1]); RefreshPokemons(); } else { foreach (Tile t in Tiles) { if (t.WillSendOutPokemonIndex != Tile.NOPM_INDEX) { Controller.SendOut(t, false); } } } SortTiles(); ATs.AttachUnnerve(Controller); var debut = new List <PokemonProxy>(); foreach (Tile t in Tiles) { if (t.Pokemon != null && t.Pokemon.Action == PokemonAction.Debuting) { t.Pokemon.Debut(); if (t.Pokemon != null) { debut.Add(t.Pokemon); } } } foreach (var p in debut) { ATs.AttachWeatherObserver(p); } ATs.WeatherChanged(Controller); if (ReportBuilder.TurnNumber != 0) { current -= 2; } }
public bool Withdraw(PokemonProxy pm, string log, int arg1, bool canPursuit) { if (CanWithdraw(pm)) { if (log != null) pm.ShowLogPm(log, arg1); STs.Withdrawing(pm, canPursuit); if (pm.Tile != null) { ReportBuilder.Withdraw(pm); var ability = pm.Ability; pm.Action = PokemonAction.InBall; pm.Tile.Pokemon = null; pm.OnboardPokemon = pm.NullOnboardPokemon; Controller.ActingPokemons.Remove(pm); ATs.Withdrawn(pm, ability); return true; } } return false; }
private void NextTurn() { ATs.SlowStart(Controller); Board.ClearTurnCondition(); foreach (var f in Board.Fields) { f.ClearTurnCondition(); } foreach (var t in Tiles) { if (t.Pokemon != null) { t.Pokemon.OnboardPokemon.ClearTurnCondition(); if (t.Pokemon.AtkContext != null) { t.Pokemon.AtkContext.ClearTurnCondition(); } } t.ClearTurnCondition(); } ReportBuilder.Add(new GameEvents.EndTurn()); }
public void StartExecute(MoveTypeE move, Tile selectTile = null, string log = "UseMove") { Move = move; if (STs.CanExecuteMove(Attacker, Move)) { if (log != null) { Attacker.ShowLogPm(log, Move.Id); } InitAtkContext.Execute(this); MoveE.BuildDefContext(this, selectTile); //蓄力技如果选择的是压力特性的精灵,在第一回合就会扣取2点PP,即使最后攻击到的不是压力特性的精灵。 if (MoveProxy != null) { ATs.Pressure(this, Move.GetRange(Attacker)); } MoveExecute.Execute(this); } else { FailAll(null); } }
public static void CalculatePriority(this PokemonProxy pm) { pm.Priority = 0; pm.ItemSpeedValue = 0; if (pm.Action != PokemonAction.WillSwitch) { var m = pm.SelectedMove.MoveE; pm.Priority = m.Priority; if (m.Move.Category == MoveCategory.Status && pm.AbilityE(As.PRANKSTER) || m.Move.Type == BattleType.Flying && pm.AbilityE(As.GALE_WINGS) && pm.Hp == pm.Pokemon.MaxHp || pm.AbilityE(As.Triage) && m.Heal) { pm.Priority++; } switch (pm.Item) { case Is.LAGGING_TAIL: case Is.FULL_INCENSE: pm.ItemSpeedValue = -1; break; case Is.QUICK_CLAW: if (pm.Controller.RandomHappen(20)) { ShowLogPm(pm, "QuickItem", Is.QUICK_CLAW); pm.ItemSpeedValue = 1; } break; case Is.CUSTAP_BERRY: if (ATs.Gluttony(pm)) { ShowLogPm(pm, "QuickItem", Is.CUSTAP_BERRY); pm.ConsumeItem(); pm.ItemSpeedValue = 1; } break; } } }
public void StartExecute(MoveTypeE move, Tile selectTile = null, string log = "UseMove", bool canChangeZmove = true) { Move = move; if (Attacker.SelectZmove && canChangeZmove && !move.Zmove && move.Move.Category != MoveCategory.Status) { Move = MoveTypeE.Get(GameHelper.CommonZmove(Move.Move)); trans = true; transmove = move; } else { trans = false; } if (STs.CanExecuteMove(Attacker, Move)) { InitAtkContext.Execute(this); MoveE.BuildDefContext(this, selectTile); //蓄力技如果选择的是压力特性的精灵,在第一回合就会扣取2点PP,即使最后攻击到的不是压力特性的精灵。 if (MoveProxy != null) { ATs.Pressure(this, Move.GetRange(Attacker)); } if (log == "FSDD") { Target.Defender.ShowLogPm(log, Move.Id); } else if (log != null) { Attacker.ShowLogPm(log, Move.Id); } MoveExecute.Execute(this, selectTile); } else { FailAll(null); } }
internal void Move() { if (SelectZmove) { Pokemon.Zmove = true; } STs.FocusPunch(Controller); LastMoveTurn = Controller.TurnNumber; STs.WillAct(this); switch (Action) { case PokemonAction.Stiff: PTs.ShowLogPm(this, "Stiff"); Action = PokemonAction.Done; break; case PokemonAction.Moving: if (AtkContext.Move.Id == Ms.SKY_DROP) { CoordY = CoordY.Plate; if (AtkContext.Target.Defender.AliveOnboard) { AtkContext.Target.Defender.CoordY = CoordY.Plate; AtkContext.Target.Defender.OnboardPokemon.RemoveCondition(Cs.SkyDrop); } else { AtkContext.SetTargets(Enumerable.Empty <DefContext>()); } } if (CanExecute()) { if (AtkContext.Move.Id != Ms.BIDE) { PTs.ShowLogPm(this, "UseMove", AtkContext.Move.Id); } AtkContext.ContinueExecute(SelectedTarget); } else { Action = PokemonAction.Done; } break; case PokemonAction.MoveAttached: { var o = OnboardPokemon.GetCondition(Cs.Encore); if (o != null) { foreach (var m in Moves) { if (m.MoveE == o.Move) { SelectedMove = m; } } } } ATs.StanceChange(this); if (SelectZmove && SelectedMove.MoveE.Move.Category == MoveCategory.Status) { switch (GameHelper.ZStatus(SelectedMove.MoveE.Move.Id)) { case 0: break; case 1: this.ChangeLv7D(this, StatType.Atk, 1, false); break; case 2: this.ChangeLv7D(this, StatType.Atk, 2, false); break; case 3: this.ChangeLv7D(this, StatType.Atk, 3, false); break; case 4: this.ChangeLv7D(this, StatType.Def, 1, false); break; case 5: this.ChangeLv7D(this, StatType.SpAtk, 1, false); break; case 6: this.ChangeLv7D(this, StatType.SpAtk, 2, false); break; case 7: this.ChangeLv7D(this, StatType.SpDef, 1, false); break; case 8: this.ChangeLv7D(this, StatType.SpDef, 2, false); break; case 9: this.ChangeLv7D(this, StatType.Speed, 1, false); break; case 10: this.ChangeLv7D(this, StatType.Speed, 2, false); break; case 11: this.ChangeLv7D(this, StatType.Accuracy, 1, false); break; case 12: this.ChangeLv7D(this, StatType.Evasion, 1, false); break; case 13: this.ChangeLv7D(this, false, false, 1, 1, 1, 1, 1, 0, 0); break; case 14: if (OnboardPokemon.AddCondition(Cs.FocusEnergy)) { this.ShowLogPm("En" + Cs.FocusEnergy); } break; case 15: ITs.Reset7D(this); break; case 16: this.HpRecover(Pokemon.MaxHp); break; case 17: if (Pokemon.Owner.PmsAlive > Controller.GameSettings.Mode.OnboardPokemonsPerPlayer()) { Tile.SetTurnCondition(Cs.Zheal); } break; case 18: OnboardPokemon.AddTurnCondition(Cs.FollowMe, SelectedMove.MoveE.Move.Id); this.ShowLogPm(Ls.EnFollowMe); break; default: break; } if (SelectedMove.MoveE.Move.Id == Ms.CURSE) { if (OnboardPokemon.HasType(BattleType.Ghost)) { this.HpRecover(Pokemon.MaxHp); } else { this.ChangeLv7D(this, StatType.Atk, 1, false); } } } if (CanExecute() && SelectedMove.CanExecute()) { _atkContext = null; SelectedMove.Execute(); var o = OnboardPokemon.GetCondition(Cs.LastMove); if (o == null) { o = new Condition(); o.Move = AtkContext.Move; OnboardPokemon.SetCondition(Cs.LastMove, o); } else if (o.Move != AtkContext.Move) { o.Move = AtkContext.Move; o.Int = 0; } if (AtkContext.Fail) { o.Int = 0; } else { o.Int++; } Controller.Board.SetCondition(Cs.LastMove, o); } else { OnboardPokemon.RemoveCondition(Cs.LastMove); Action = PokemonAction.Done; } if (AtkContext != null && AtkContext.Move.Dance && AtkContext.Attacker.LastMoveTurn == Controller.TurnNumber) { foreach (var p in Controller.Board.Pokemons) { if (p != null && p.AbilityE(As.Dancer) && p != AtkContext.Attacker) { p.RaiseAbility(); AtkContext dance = new AtkContext(p); dance.StartExecute(AtkContext.Move, null, "UseMove", false); } } } break; } //switch(Action) }
private static void AddStateImplement(this PokemonProxy pm, PokemonProxy by, AttachedState state, int turn, string log, int arg1) { switch (state) { case AttachedState.BRN: pm.Pokemon.State = PokemonState.BRN; goto POKEMON_STATE; case AttachedState.FRZ: pm.Pokemon.State = PokemonState.FRZ; pm.ShowLogPm(log ?? "EnFRZ", arg1); if (pm.CanChangeForm(492, 0)) { pm.ChangeForm(0, true); } goto DONE; case AttachedState.PAR: pm.Pokemon.State = PokemonState.PAR; goto POKEMON_STATE; case AttachedState.PSN: if (turn == 0) { pm.Pokemon.State = PokemonState.PSN; } else { pm.Pokemon.State = PokemonState.BadlyPSN; pm.OnboardPokemon.SetCondition(Cs.BadlyPSN, pm.Controller.TurnNumber); } goto POKEMON_STATE; case AttachedState.SLP: pm.Pokemon.State = PokemonState.SLP; pm.Pokemon.SLPTurn = turn == 0 ? pm.Controller.GetRandomInt(2, 4) : turn; goto POKEMON_STATE; case AttachedState.Confuse: pm.OnboardPokemon.SetCondition(Cs.Confuse, turn == 0 ? pm.Controller.GetRandomInt(2, 5) : turn); pm.ShowLogPm(log ?? "Confuse"); goto DONE; case AttachedState.Attract: pm.OnboardPokemon.SetCondition(Cs.Attract, by); pm.ShowLogPm(log ?? "EnAttract", arg1); ITs.DestinyKnot(pm, by); goto DONE; case AttachedState.Trap: { var move = by.AtkContext.Move; var c = new Condition(); c.By = by; c.Turn = pm.Controller.TurnNumber + (turn == 0 ? pm.Controller.GetRandomInt(4, 5) : turn) - 1; c.Move = move; c.Bool = by.Item == Is.BINDING_BAND; pm.OnboardPokemon.SetCondition(Cs.Trap, c); pm.ShowLogPm("EnTrap" + move.Id.ToString(), by.Id); } goto DONE; case AttachedState.Nightmare: pm.OnboardPokemon.SetCondition(Cs.Nightmare); pm.ShowLogPm("EnNightmare"); goto DONE; case AttachedState.Torment: pm.OnboardPokemon.SetCondition(Cs.Torment, by); pm.ShowLogPm("EnTorment"); goto DONE; case AttachedState.Disable: { var c = new Condition(); c.Move = pm.LastMove; c.Turn = pm.Controller.TurnNumber + 3; //4 - 1 pm.OnboardPokemon.SetCondition(Cs.Disable, c); pm.ShowLogPm("EnDisable", c.Move.Id); } goto DONE; case AttachedState.Yawn: { var o = new Condition(); o.Turn = pm.Controller.TurnNumber + 1; o.By = by; //睡眠规则 pm.OnboardPokemon.AddCondition(Cs.Yawn, o); } pm.ShowLogPm("EnYawn"); goto DONE; case AttachedState.HealBlock: { var o = new Condition(); o.Turn = pm.Controller.TurnNumber + 5; o.By = by; pm.OnboardPokemon.SetCondition(Cs.HealBlock, o); } pm.ShowLogPm("EnHealBlock"); goto DONE; case AttachedState.SoundBlock: { var o = new Condition(); o.Turn = pm.Controller.TurnNumber + 2; o.By = by; pm.OnboardPokemon.SetCondition(Cs.SoundBlock, o); } pm.ShowLogPm("EnSoundBlock"); goto DONE; case AttachedState.CanAttack: { var o = new Condition(); o.BattleType = by.AtkContext.Move.Id == Ms.MIRACLE_EYE ? BattleType.Dark : BattleType.Ghost; o.By = by; pm.OnboardPokemon.SetCondition(Cs.CanAttack, o); pm.ShowLogPm("CanAttack"); } goto DONE; case AttachedState.LeechSeed: pm.OnboardPokemon.SetCondition(Cs.LeechSeed, by.Tile); pm.ShowLogPm("EnLeechSeed"); goto DONE; case AttachedState.Embargo: pm.OnboardPokemon.SetCondition(Cs.Embargo); pm.ShowLogPm("EnEmbargo"); goto DONE; case AttachedState.PerishSong: pm.OnboardPokemon.SetCondition(Cs.PerishSong, 3); goto DONE; case AttachedState.Ingrain: pm.OnboardPokemon.SetCondition(Cs.Ingrain); pm.ShowLogPm("EnIngrain"); goto DONE; #if DEBUG default: System.Diagnostics.Debugger.Break(); return; #endif } POKEMON_STATE: pm.ShowLogPm(log ?? "En" + state.ToString(), arg1); if (state != AttachedState.FRZ && state != AttachedState.SLP) { ATs.Synchronize(pm, by, state, turn); } DONE: StateAdded.Execute(pm); }
internal void Move() { STs.FocusPunch(Controller); LastMoveTurn = Controller.TurnNumber; STs.WillAct(this); switch (Action) { case PokemonAction.Stiff: PTs.ShowLogPm(this, "Stiff"); Action = PokemonAction.Done; break; case PokemonAction.Moving: if (AtkContext.Move.Id == Ms.SKY_DROP) { CoordY = CoordY.Plate; if (AtkContext.Target.Defender.AliveOnboard) { AtkContext.Target.Defender.CoordY = CoordY.Plate; AtkContext.Target.Defender.OnboardPokemon.RemoveCondition(Cs.SkyDrop); } else { AtkContext.SetTargets(Enumerable.Empty <DefContext>()); } } if (CanExecute()) { if (AtkContext.Move.Id != Ms.BIDE) { PTs.ShowLogPm(this, "UseMove", AtkContext.Move.Id); } AtkContext.ContinueExecute(SelectedTarget); } else { Action = PokemonAction.Done; } break; case PokemonAction.MoveAttached: { var o = OnboardPokemon.GetCondition(Cs.Encore); if (o != null) { foreach (var m in Moves) { if (m.MoveE == o.Move) { SelectedMove = m; } } } } ATs.StanceChange(this); if (CanExecute() && SelectedMove.CanExecute()) { _atkContext = null; SelectedMove.Execute(); var o = OnboardPokemon.GetCondition(Cs.LastMove); if (o == null) { o = new Condition(); o.Move = AtkContext.Move; OnboardPokemon.SetCondition(Cs.LastMove, o); } else if (o.Move != AtkContext.Move) { o.Move = AtkContext.Move; o.Int = 0; } if (AtkContext.Fail) { o.Int = 0; } else { o.Int++; } Controller.Board.SetCondition(Cs.LastMove, o); } else { OnboardPokemon.RemoveCondition(Cs.LastMove); Action = PokemonAction.Done; } break; } //switch(Action) }