Commit dd37ed18 authored by mercury233's avatar mercury233

move LastChainPlayer and CurrentChain to Duel class

parent 113f696e
...@@ -302,7 +302,7 @@ namespace WindBot.Game.AI.Decks ...@@ -302,7 +302,7 @@ namespace WindBot.Game.AI.Decks
private bool RebornEffect() private bool RebornEffect()
{ {
if (Duel.Player == 0 && CurrentChain.Count > 0) if (Duel.Player == 0 && Duel.CurrentChain.Count > 0)
{ {
// Silver's Cry spsummon Dragon Spirit at chain 2 will miss the timing // Silver's Cry spsummon Dragon Spirit at chain 2 will miss the timing
return false; return false;
...@@ -446,7 +446,7 @@ namespace WindBot.Game.AI.Decks ...@@ -446,7 +446,7 @@ namespace WindBot.Game.AI.Decks
{ {
if (ActivateDescription == -1 || ActivateDescription == AI.Utils.GetStringId(CardId.BlueEyesSpiritDragon, 0)) if (ActivateDescription == -1 || ActivateDescription == AI.Utils.GetStringId(CardId.BlueEyesSpiritDragon, 0))
{ {
return LastChainPlayer == 1; return Duel.LastChainPlayer == 1;
} }
else if (Duel.Player == 1 && (Duel.Phase == DuelPhase.BattleStart || Duel.Phase == DuelPhase.End)) else if (Duel.Player == 1 && (Duel.Phase == DuelPhase.BattleStart || Duel.Phase == DuelPhase.End))
{ {
...@@ -468,7 +468,7 @@ namespace WindBot.Game.AI.Decks ...@@ -468,7 +468,7 @@ namespace WindBot.Game.AI.Decks
{ {
if (ActivateDescription == -1 || ActivateDescription == AI.Utils.GetStringId(CardId.HopeHarbingerDragonTitanicGalaxy, 0)) if (ActivateDescription == -1 || ActivateDescription == AI.Utils.GetStringId(CardId.HopeHarbingerDragonTitanicGalaxy, 0))
{ {
return LastChainPlayer == 1; return Duel.LastChainPlayer == 1;
} }
return true; return true;
} }
......
...@@ -399,7 +399,7 @@ namespace WindBot.Game.AI.Decks ...@@ -399,7 +399,7 @@ namespace WindBot.Game.AI.Decks
private bool CrystalWingSynchroDragonEffect() private bool CrystalWingSynchroDragonEffect()
{ {
return LastChainPlayer != 0; return Duel.LastChainPlayer != 0;
} }
private bool DragunityPhalanxSummon() private bool DragunityPhalanxSummon()
......
...@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks ...@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks
private bool HorusTheBlackFlameDragonLv8() private bool HorusTheBlackFlameDragonLv8()
{ {
return LastChainPlayer == 1; return Duel.LastChainPlayer == 1;
} }
private bool DragonsRebirth() private bool DragonsRebirth()
......
...@@ -262,9 +262,9 @@ namespace WindBot.Game.AI.Decks ...@@ -262,9 +262,9 @@ namespace WindBot.Game.AI.Decks
private bool CyberDragonInfinityEffect() private bool CyberDragonInfinityEffect()
{ {
if (CurrentChain.Count > 0) if (Duel.CurrentChain.Count > 0)
{ {
return LastChainPlayer == 1; return Duel.LastChainPlayer == 1;
} }
else else
{ {
......
...@@ -302,7 +302,7 @@ namespace WindBot.Game.AI.Decks ...@@ -302,7 +302,7 @@ namespace WindBot.Game.AI.Decks
private bool ToadallyAwesomeEffect() private bool ToadallyAwesomeEffect()
{ {
if (CurrentChain.Count > 0) if (Duel.CurrentChain.Count > 0)
{ {
// negate effect, select a cost for it // negate effect, select a cost for it
List<ClientCard> monsters = Bot.GetMonsters(); List<ClientCard> monsters = Bot.GetMonsters();
......
...@@ -486,7 +486,7 @@ namespace WindBot.Game.AI.Decks ...@@ -486,7 +486,7 @@ namespace WindBot.Game.AI.Decks
private bool DridentEffect() private bool DridentEffect()
{ {
if (LastChainPlayer == 0) if (Duel.LastChainPlayer == 0)
return false; return false;
ClientCard target = AI.Utils.GetBestEnemyCard(true); ClientCard target = AI.Utils.GetBestEnemyCard(true);
if (target == null) if (target == null)
...@@ -571,7 +571,7 @@ namespace WindBot.Game.AI.Decks ...@@ -571,7 +571,7 @@ namespace WindBot.Game.AI.Decks
private bool ZoodiacComboEffect() private bool ZoodiacComboEffect()
{ {
if (CurrentChain.Count > 0) if (Duel.CurrentChain.Count > 0)
return false; return false;
if (Card.Location != CardLocation.Grave) if (Card.Location != CardLocation.Grave)
{ {
......
...@@ -95,7 +95,7 @@ namespace WindBot.Game.AI ...@@ -95,7 +95,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultMysticalSpaceTyphoon() protected bool DefaultMysticalSpaceTyphoon()
{ {
foreach (ClientCard card in CurrentChain) foreach (ClientCard card in Duel.CurrentChain)
if (card.Id == _CardId.MysticalSpaceTyphoon) if (card.Id == _CardId.MysticalSpaceTyphoon)
return false; return false;
...@@ -128,7 +128,7 @@ namespace WindBot.Game.AI ...@@ -128,7 +128,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultCosmicCyclone() protected bool DefaultCosmicCyclone()
{ {
foreach (ClientCard card in CurrentChain) foreach (ClientCard card in Duel.CurrentChain)
if (card.Id == _CardId.CosmicCyclone) if (card.Id == _CardId.CosmicCyclone)
return false; return false;
return (Bot.LifePoints > 1000) && DefaultMysticalSpaceTyphoon(); return (Bot.LifePoints > 1000) && DefaultMysticalSpaceTyphoon();
...@@ -247,7 +247,7 @@ namespace WindBot.Game.AI ...@@ -247,7 +247,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultSolemnJudgment() protected bool DefaultSolemnJudgment()
{ {
return !AI.Utils.IsChainTargetOnly(Card) && !(Duel.Player == 0 && LastChainPlayer == -1) && DefaultTrap(); return !AI.Utils.IsChainTargetOnly(Card) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && DefaultTrap();
} }
/// <summary> /// <summary>
...@@ -255,7 +255,7 @@ namespace WindBot.Game.AI ...@@ -255,7 +255,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultSolemnWarning() protected bool DefaultSolemnWarning()
{ {
return (Bot.LifePoints > 2000) && !(Duel.Player == 0 && LastChainPlayer == -1) && DefaultTrap(); return (Bot.LifePoints > 2000) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && DefaultTrap();
} }
/// <summary> /// <summary>
...@@ -263,7 +263,7 @@ namespace WindBot.Game.AI ...@@ -263,7 +263,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultSolemnStrike() protected bool DefaultSolemnStrike()
{ {
return (Bot.LifePoints > 1500) && !(Duel.Player == 0 && LastChainPlayer == -1) && DefaultTrap(); return (Bot.LifePoints > 1500) && !(Duel.Player == 0 && Duel.LastChainPlayer == -1) && DefaultTrap();
} }
/// <summary> /// <summary>
...@@ -386,7 +386,7 @@ namespace WindBot.Game.AI ...@@ -386,7 +386,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultTrap() protected bool DefaultTrap()
{ {
return (LastChainPlayer == -1 && Duel.LastSummonPlayer != 0) || LastChainPlayer == 1; return (Duel.LastChainPlayer == -1 && Duel.LastSummonPlayer != 0) || Duel.LastChainPlayer == 1;
} }
/// <summary> /// <summary>
...@@ -436,7 +436,7 @@ namespace WindBot.Game.AI ...@@ -436,7 +436,7 @@ namespace WindBot.Game.AI
if (exec.Type == Type && exec.CardId == Card.Id) if (exec.Type == Type && exec.CardId == Card.Id)
return false; return false;
} }
return LastChainPlayer != 0; return Duel.LastChainPlayer != 0;
} }
/// <summary> /// <summary>
...@@ -510,7 +510,7 @@ namespace WindBot.Game.AI ...@@ -510,7 +510,7 @@ namespace WindBot.Game.AI
} }
} }
ClientCard lastchaincard = GetLastChainCard(); ClientCard lastchaincard = GetLastChainCard();
if (LastChainPlayer == 1 && lastchaincard != null && !lastchaincard.IsDisabled()) if (Duel.LastChainPlayer == 1 && lastchaincard != null && !lastchaincard.IsDisabled())
{ {
if (lastchaincard.HasType(CardType.Ritual)) if (lastchaincard.HasType(CardType.Ritual))
{ {
...@@ -690,7 +690,7 @@ namespace WindBot.Game.AI ...@@ -690,7 +690,7 @@ namespace WindBot.Game.AI
/// </summary> /// </summary>
protected bool DefaultStardustDragonEffect() protected bool DefaultStardustDragonEffect()
{ {
return (Card.Location == CardLocation.Grave) || LastChainPlayer == 1; return (Card.Location == CardLocation.Grave) || Duel.LastChainPlayer == 1;
} }
/// <summary> /// <summary>
......
...@@ -21,9 +21,6 @@ namespace WindBot.Game.AI ...@@ -21,9 +21,6 @@ namespace WindBot.Game.AI
protected ClientCard Card { get; private set; } protected ClientCard Card { get; private set; }
protected int ActivateDescription { get; private set; } protected int ActivateDescription { get; private set; }
protected int LastChainPlayer { get; private set; }
protected IList<ClientCard> CurrentChain { get; private set; }
protected ClientField Bot { get; private set; } protected ClientField Bot { get; private set; }
protected ClientField Enemy { get; private set; } protected ClientField Enemy { get; private set; }
...@@ -33,9 +30,6 @@ namespace WindBot.Game.AI ...@@ -33,9 +30,6 @@ namespace WindBot.Game.AI
AI = ai; AI = ai;
Executors = new List<CardExecutor>(); Executors = new List<CardExecutor>();
LastChainPlayer = -1;
CurrentChain = new List<ClientCard>();
Bot = Duel.Fields[0]; Bot = Duel.Fields[0];
Enemy = Duel.Fields[1]; Enemy = Duel.Fields[1];
} }
...@@ -109,14 +103,12 @@ namespace WindBot.Game.AI ...@@ -109,14 +103,12 @@ namespace WindBot.Game.AI
public virtual void OnChaining(int player, ClientCard card) public virtual void OnChaining(int player, ClientCard card)
{ {
CurrentChain.Add(card);
LastChainPlayer = player;
} }
public virtual void OnChainEnd() public virtual void OnChainEnd()
{ {
LastChainPlayer = -1;
CurrentChain.Clear();
} }
public virtual void OnNewTurn() public virtual void OnNewTurn()
...@@ -184,7 +176,7 @@ namespace WindBot.Game.AI ...@@ -184,7 +176,7 @@ namespace WindBot.Game.AI
public bool ChainContainsCard(int id) public bool ChainContainsCard(int id)
{ {
foreach (ClientCard card in CurrentChain) foreach (ClientCard card in Duel.CurrentChain)
{ {
if (card.Id == id) if (card.Id == id)
return true; return true;
...@@ -195,7 +187,7 @@ namespace WindBot.Game.AI ...@@ -195,7 +187,7 @@ namespace WindBot.Game.AI
public int ChainCountPlayer(int player) public int ChainCountPlayer(int player)
{ {
int count = 0; int count = 0;
foreach (ClientCard card in CurrentChain) foreach (ClientCard card in Duel.CurrentChain)
{ {
if (card.Controller == player) if (card.Controller == player)
count++; count++;
...@@ -205,7 +197,7 @@ namespace WindBot.Game.AI ...@@ -205,7 +197,7 @@ namespace WindBot.Game.AI
public bool HasChainedTrap(int player) public bool HasChainedTrap(int player)
{ {
foreach (ClientCard card in CurrentChain) foreach (ClientCard card in Duel.CurrentChain)
{ {
if (card.Controller == player && card.HasType(CardType.Trap)) if (card.Controller == player && card.HasType(CardType.Trap))
return true; return true;
...@@ -215,8 +207,8 @@ namespace WindBot.Game.AI ...@@ -215,8 +207,8 @@ namespace WindBot.Game.AI
public ClientCard GetLastChainCard() public ClientCard GetLastChainCard()
{ {
if (CurrentChain.Count > 0) if (Duel.CurrentChain.Count > 0)
return CurrentChain[CurrentChain.Count - 1]; return Duel.CurrentChain[Duel.CurrentChain.Count - 1];
return null; return null;
} }
......
...@@ -15,6 +15,9 @@ namespace WindBot.Game ...@@ -15,6 +15,9 @@ namespace WindBot.Game
public DuelPhase Phase { get; set; } public DuelPhase Phase { get; set; }
public MainPhase MainPhase { get; set; } public MainPhase MainPhase { get; set; }
public BattlePhase BattlePhase { get; set; } public BattlePhase BattlePhase { get; set; }
public int LastChainPlayer { get; set; }
public IList<ClientCard> CurrentChain { get; set; }
public IList<ClientCard> ChainTargets { get; set; } public IList<ClientCard> ChainTargets { get; set; }
public int LastSummonPlayer { get; set; } public int LastSummonPlayer { get; set; }
...@@ -23,6 +26,8 @@ namespace WindBot.Game ...@@ -23,6 +26,8 @@ namespace WindBot.Game
Fields = new ClientField[2]; Fields = new ClientField[2];
Fields[0] = new ClientField(); Fields[0] = new ClientField();
Fields[1] = new ClientField(); Fields[1] = new ClientField();
LastChainPlayer = -1;
CurrentChain = new List<ClientCard>();
ChainTargets = new List<ClientCard>(); ChainTargets = new List<ClientCard>();
LastSummonPlayer = -1; LastSummonPlayer = -1;
} }
......
...@@ -90,9 +90,6 @@ namespace WindBot.Game ...@@ -90,9 +90,6 @@ namespace WindBot.Game
m_option = -1; m_option = -1;
m_yesno = -1; m_yesno = -1;
m_position = CardPosition.FaceUpAttack; m_position = CardPosition.FaceUpAttack;
Duel.LastSummonPlayer = -1;
Duel.Fields[0].BattlingMonster = null;
Duel.Fields[1].BattlingMonster = null;
if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw) if (Duel.Player == 0 && Duel.Phase == DuelPhase.Draw)
{ {
_dialogs.SendNewTurn(); _dialogs.SendNewTurn();
...@@ -114,7 +111,6 @@ namespace WindBot.Game ...@@ -114,7 +111,6 @@ namespace WindBot.Game
/// <param name="player">Player who is currently chaining.</param> /// <param name="player">Player who is currently chaining.</param>
public void OnChaining(ClientCard card, int player) public void OnChaining(ClientCard card, int player)
{ {
Duel.LastSummonPlayer = -1;
Executor.OnChaining(player,card); Executor.OnChaining(player,card);
} }
......
...@@ -421,6 +421,9 @@ namespace WindBot.Game ...@@ -421,6 +421,9 @@ namespace WindBot.Game
private void OnNewPhase(BinaryReader packet) private void OnNewPhase(BinaryReader packet)
{ {
_duel.Phase = (DuelPhase)packet.ReadInt16(); _duel.Phase = (DuelPhase)packet.ReadInt16();
_duel.LastSummonPlayer = -1;
_duel.Fields[0].BattlingMonster = null;
_duel.Fields[1].BattlingMonster = null;
_ai.OnNewPhase(); _ai.OnNewPhase();
} }
...@@ -534,11 +537,17 @@ namespace WindBot.Game ...@@ -534,11 +537,17 @@ namespace WindBot.Game
int cc = GetLocalPlayer(packet.ReadByte()); int cc = GetLocalPlayer(packet.ReadByte());
_ai.OnChaining(card, cc); _ai.OnChaining(card, cc);
_duel.ChainTargets.Clear(); _duel.ChainTargets.Clear();
_duel.LastSummonPlayer = -1;
_duel.CurrentChain.Add(card);
_duel.LastChainPlayer = cc;
} }
private void OnChainEnd(BinaryReader packet) private void OnChainEnd(BinaryReader packet)
{ {
_ai.OnChainEnd(); _ai.OnChainEnd();
_duel.LastChainPlayer = -1;
_duel.CurrentChain.Clear();
//_duel.ChainTargets.Clear(); //_duel.ChainTargets.Clear();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment