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
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
return false;
......@@ -446,7 +446,7 @@ namespace WindBot.Game.AI.Decks
{
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))
{
......@@ -468,7 +468,7 @@ namespace WindBot.Game.AI.Decks
{
if (ActivateDescription == -1 || ActivateDescription == AI.Utils.GetStringId(CardId.HopeHarbingerDragonTitanicGalaxy, 0))
{
return LastChainPlayer == 1;
return Duel.LastChainPlayer == 1;
}
return true;
}
......
......@@ -399,7 +399,7 @@ namespace WindBot.Game.AI.Decks
private bool CrystalWingSynchroDragonEffect()
{
return LastChainPlayer != 0;
return Duel.LastChainPlayer != 0;
}
private bool DragunityPhalanxSummon()
......
......@@ -162,7 +162,7 @@ namespace WindBot.Game.AI.Decks
private bool HorusTheBlackFlameDragonLv8()
{
return LastChainPlayer == 1;
return Duel.LastChainPlayer == 1;
}
private bool DragonsRebirth()
......
......@@ -262,9 +262,9 @@ namespace WindBot.Game.AI.Decks
private bool CyberDragonInfinityEffect()
{
if (CurrentChain.Count > 0)
if (Duel.CurrentChain.Count > 0)
{
return LastChainPlayer == 1;
return Duel.LastChainPlayer == 1;
}
else
{
......
......@@ -302,7 +302,7 @@ namespace WindBot.Game.AI.Decks
private bool ToadallyAwesomeEffect()
{
if (CurrentChain.Count > 0)
if (Duel.CurrentChain.Count > 0)
{
// negate effect, select a cost for it
List<ClientCard> monsters = Bot.GetMonsters();
......
......@@ -486,7 +486,7 @@ namespace WindBot.Game.AI.Decks
private bool DridentEffect()
{
if (LastChainPlayer == 0)
if (Duel.LastChainPlayer == 0)
return false;
ClientCard target = AI.Utils.GetBestEnemyCard(true);
if (target == null)
......@@ -571,7 +571,7 @@ namespace WindBot.Game.AI.Decks
private bool ZoodiacComboEffect()
{
if (CurrentChain.Count > 0)
if (Duel.CurrentChain.Count > 0)
return false;
if (Card.Location != CardLocation.Grave)
{
......
......@@ -95,7 +95,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultMysticalSpaceTyphoon()
{
foreach (ClientCard card in CurrentChain)
foreach (ClientCard card in Duel.CurrentChain)
if (card.Id == _CardId.MysticalSpaceTyphoon)
return false;
......@@ -128,7 +128,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultCosmicCyclone()
{
foreach (ClientCard card in CurrentChain)
foreach (ClientCard card in Duel.CurrentChain)
if (card.Id == _CardId.CosmicCyclone)
return false;
return (Bot.LifePoints > 1000) && DefaultMysticalSpaceTyphoon();
......@@ -247,7 +247,7 @@ namespace WindBot.Game.AI
/// </summary>
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>
......@@ -255,7 +255,7 @@ namespace WindBot.Game.AI
/// </summary>
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>
......@@ -263,7 +263,7 @@ namespace WindBot.Game.AI
/// </summary>
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>
......@@ -386,7 +386,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultTrap()
{
return (LastChainPlayer == -1 && Duel.LastSummonPlayer != 0) || LastChainPlayer == 1;
return (Duel.LastChainPlayer == -1 && Duel.LastSummonPlayer != 0) || Duel.LastChainPlayer == 1;
}
/// <summary>
......@@ -436,7 +436,7 @@ namespace WindBot.Game.AI
if (exec.Type == Type && exec.CardId == Card.Id)
return false;
}
return LastChainPlayer != 0;
return Duel.LastChainPlayer != 0;
}
/// <summary>
......@@ -510,7 +510,7 @@ namespace WindBot.Game.AI
}
}
ClientCard lastchaincard = GetLastChainCard();
if (LastChainPlayer == 1 && lastchaincard != null && !lastchaincard.IsDisabled())
if (Duel.LastChainPlayer == 1 && lastchaincard != null && !lastchaincard.IsDisabled())
{
if (lastchaincard.HasType(CardType.Ritual))
{
......@@ -690,7 +690,7 @@ namespace WindBot.Game.AI
/// </summary>
protected bool DefaultStardustDragonEffect()
{
return (Card.Location == CardLocation.Grave) || LastChainPlayer == 1;
return (Card.Location == CardLocation.Grave) || Duel.LastChainPlayer == 1;
}
/// <summary>
......
......@@ -21,9 +21,6 @@ namespace WindBot.Game.AI
protected ClientCard Card { 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 Enemy { get; private set; }
......@@ -33,9 +30,6 @@ namespace WindBot.Game.AI
AI = ai;
Executors = new List<CardExecutor>();
LastChainPlayer = -1;
CurrentChain = new List<ClientCard>();
Bot = Duel.Fields[0];
Enemy = Duel.Fields[1];
}
......@@ -109,14 +103,12 @@ namespace WindBot.Game.AI
public virtual void OnChaining(int player, ClientCard card)
{
CurrentChain.Add(card);
LastChainPlayer = player;
}
public virtual void OnChainEnd()
{
LastChainPlayer = -1;
CurrentChain.Clear();
}
public virtual void OnNewTurn()
......@@ -184,7 +176,7 @@ namespace WindBot.Game.AI
public bool ChainContainsCard(int id)
{
foreach (ClientCard card in CurrentChain)
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Id == id)
return true;
......@@ -195,7 +187,7 @@ namespace WindBot.Game.AI
public int ChainCountPlayer(int player)
{
int count = 0;
foreach (ClientCard card in CurrentChain)
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Controller == player)
count++;
......@@ -205,7 +197,7 @@ namespace WindBot.Game.AI
public bool HasChainedTrap(int player)
{
foreach (ClientCard card in CurrentChain)
foreach (ClientCard card in Duel.CurrentChain)
{
if (card.Controller == player && card.HasType(CardType.Trap))
return true;
......@@ -215,8 +207,8 @@ namespace WindBot.Game.AI
public ClientCard GetLastChainCard()
{
if (CurrentChain.Count > 0)
return CurrentChain[CurrentChain.Count - 1];
if (Duel.CurrentChain.Count > 0)
return Duel.CurrentChain[Duel.CurrentChain.Count - 1];
return null;
}
......
......@@ -15,6 +15,9 @@ namespace WindBot.Game
public DuelPhase Phase { get; set; }
public MainPhase MainPhase { 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 int LastSummonPlayer { get; set; }
......@@ -23,6 +26,8 @@ namespace WindBot.Game
Fields = new ClientField[2];
Fields[0] = new ClientField();
Fields[1] = new ClientField();
LastChainPlayer = -1;
CurrentChain = new List<ClientCard>();
ChainTargets = new List<ClientCard>();
LastSummonPlayer = -1;
}
......
......@@ -90,9 +90,6 @@ namespace WindBot.Game
m_option = -1;
m_yesno = -1;
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)
{
_dialogs.SendNewTurn();
......@@ -114,7 +111,6 @@ namespace WindBot.Game
/// <param name="player">Player who is currently chaining.</param>
public void OnChaining(ClientCard card, int player)
{
Duel.LastSummonPlayer = -1;
Executor.OnChaining(player,card);
}
......
......@@ -421,6 +421,9 @@ namespace WindBot.Game
private void OnNewPhase(BinaryReader packet)
{
_duel.Phase = (DuelPhase)packet.ReadInt16();
_duel.LastSummonPlayer = -1;
_duel.Fields[0].BattlingMonster = null;
_duel.Fields[1].BattlingMonster = null;
_ai.OnNewPhase();
}
......@@ -534,11 +537,17 @@ namespace WindBot.Game
int cc = GetLocalPlayer(packet.ReadByte());
_ai.OnChaining(card, cc);
_duel.ChainTargets.Clear();
_duel.LastSummonPlayer = -1;
_duel.CurrentChain.Add(card);
_duel.LastChainPlayer = cc;
}
private void OnChainEnd(BinaryReader packet)
{
_ai.OnChainEnd();
_duel.LastChainPlayer = -1;
_duel.CurrentChain.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