Commit 1d6da58b authored by mercury233's avatar mercury233

add SummoningCards, LastSummonedCards, IsSpecialSummoned

parent 702b0932
......@@ -887,8 +887,7 @@ namespace WindBot.Game.AI
List<ClientCard> monsters = Bot.GetMonsters();
foreach (ClientCard monster in monsters)
{
// The bot don't know if the card is special summoned, so let we assume all monsters are special summoned
if (!monster.Equals(Card) && monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack)
if (!monster.Equals(Card) && monster.IsSpecialSummoned && monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack)
selfCount++;
}
......@@ -896,7 +895,7 @@ namespace WindBot.Game.AI
monsters = Enemy.GetMonsters();
foreach (ClientCard monster in monsters)
{
if (monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack)
if (monster.IsSpecialSummoned && monster.HasType(CardType.Effect) && monster.Attack <= Card.Attack)
oppoCount++;
}
......
......@@ -39,6 +39,7 @@ namespace WindBot.Game
public bool ShouldDirectAttack { get; set; }
public bool Attacked { get; set; }
public bool IsLastAttacker { get; set; }
public bool IsSpecialSummoned { get; set; }
public int[] ActionIndex { get; set; }
public IDictionary<int, int> ActionActivateIndex { get; private set; }
......
......@@ -21,6 +21,8 @@ namespace WindBot.Game
public IList<ClientCard> ChainTargets { get; set; }
public IList<ClientCard> ChainTargetOnly { get; set; }
public int LastSummonPlayer { get; set; }
public IList<ClientCard> SummoningCards { get; set; }
public IList<ClientCard> LastSummonedCards { get; set; }
public Duel()
{
......@@ -32,6 +34,8 @@ namespace WindBot.Game
ChainTargets = new List<ClientCard>();
ChainTargetOnly = new List<ClientCard>();
LastSummonPlayer = -1;
SummoningCards = new List<ClientCard>();
LastSummonedCards = new List<ClientCard>();
}
public ClientCard GetCard(int player, CardLocation loc, int index)
......
......@@ -430,7 +430,6 @@ namespace WindBot.Game
if (ShouldExecute(exec, card, ExecutorType.SpSummon))
{
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.SpSummon, card.ActionIndex);
}
}
......@@ -439,7 +438,6 @@ namespace WindBot.Game
if (ShouldExecute(exec, card, ExecutorType.Summon))
{
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex);
}
if (ShouldExecute(exec, card, ExecutorType.SummonOrSet))
......@@ -451,7 +449,6 @@ namespace WindBot.Game
return new MainPhaseAction(MainPhaseAction.MainAction.SetMonster, card.ActionIndex);
}
_dialogs.SendSummon(card.Name);
Duel.LastSummonPlayer = 0;
return new MainPhaseAction(MainPhaseAction.MainAction.Summon, card.ActionIndex);
}
}
......
......@@ -129,8 +129,12 @@ namespace WindBot.Game
_messages.Add(GameMessage.AnnounceCardFilter, OnAnnounceCard);
_messages.Add(GameMessage.RockPaperScissors, OnRockPaperScissors);
_messages.Add(GameMessage.SpSummoning, OnSpSummon);
_messages.Add(GameMessage.SpSummoned, OnSpSummon);
_messages.Add(GameMessage.Summoning, OnSummoning);
_messages.Add(GameMessage.Summoned, OnSummoned);
_messages.Add(GameMessage.SpSummoning, OnSpSummoning);
_messages.Add(GameMessage.SpSummoned, OnSpSummoned);
_messages.Add(GameMessage.FlipSummoning, OnSummoning);
_messages.Add(GameMessage.FlipSummoned, OnSummoned);
}
private void OnJoinGame(BinaryReader packet)
......@@ -478,6 +482,8 @@ namespace WindBot.Game
if (_debug)
Logger.WriteLine("(Go to " + (_duel.Phase.ToString()) + ")");
_duel.LastSummonPlayer = -1;
_duel.SummoningCards.Clear();
_duel.LastSummonedCards.Clear();
_duel.Fields[0].BattlingMonster = null;
_duel.Fields[1].BattlingMonster = null;
_ai.OnNewPhase();
......@@ -557,6 +563,8 @@ namespace WindBot.Game
else
{
_duel.AddCard((CardLocation)currentLocation, card, currentControler, currentSequence, currentPosition, cardId);
if (card != null && previousLocation != currentLocation)
card.IsSpecialSummoned = false;
if (_debug && card != null)
Logger.WriteLine("(" + previousControler.ToString() + " 's " + (card.Name ?? "UnKnowCard")
+ " from " +
......@@ -1400,9 +1408,50 @@ namespace WindBot.Game
Connection.Send(CtosMessage.Response, result);
}
private void OnSpSummon(BinaryReader packet)
private void OnSummoning(BinaryReader packet)
{
_duel.LastSummonedCards.Clear();
int code = packet.ReadInt32();
int currentControler = GetLocalPlayer(packet.ReadByte());
int currentLocation = packet.ReadByte();
int currentSequence = packet.ReadSByte();
int currentPosition = packet.ReadSByte();
ClientCard card = _duel.GetCard(currentControler, (CardLocation)currentLocation, currentSequence);
_duel.SummoningCards.Add(card);
_duel.LastSummonPlayer = currentControler;
}
private void OnSummoned(BinaryReader packet)
{
foreach (ClientCard card in _duel.SummoningCards)
{
_duel.LastSummonedCards.Add(card);
}
_duel.SummoningCards.Clear();
}
private void OnSpSummoning(BinaryReader packet)
{
_duel.LastSummonedCards.Clear();
_ai.CleanSelectMaterials();
int code = packet.ReadInt32();
int currentControler = GetLocalPlayer(packet.ReadByte());
int currentLocation = packet.ReadByte();
int currentSequence = packet.ReadSByte();
int currentPosition = packet.ReadSByte();
ClientCard card = _duel.GetCard(currentControler, (CardLocation)currentLocation, currentSequence);
_duel.SummoningCards.Add(card);
_duel.LastSummonPlayer = currentControler;
}
private void OnSpSummoned(BinaryReader packet)
{
foreach (ClientCard card in _duel.SummoningCards)
{
card.IsSpecialSummoned = true;
_duel.LastSummonedCards.Add(card);
}
_duel.SummoningCards.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