Commit f81d9f58 authored by mercury233's avatar mercury233

add ClientCard.OwnTargets

parent af5a9bfc
......@@ -40,6 +40,8 @@ namespace WindBot.Game
public List<ClientCard> EquipCards { get; set; }
public ClientCard EquipTarget;
public List<ClientCard> OwnTargets { get; set; }
public List<ClientCard> TargetCards { get; set; }
public bool CanDirectAttack { get; set; }
public bool ShouldDirectAttack { get; set; }
......@@ -62,6 +64,8 @@ namespace WindBot.Game
Position = position;
Overlays = new List<int>();
EquipCards = new List<ClientCard>();
OwnTargets = new List<ClientCard>();
TargetCards = new List<ClientCard>();
ActionIndex = new int[16];
ActionActivateIndex = new Dictionary<int, int>();
Location = loc;
......@@ -154,6 +158,20 @@ namespace WindBot.Game
}
}
public void ClearCardTargets()
{
foreach (ClientCard card in TargetCards)
{
card.OwnTargets.Remove(this);
}
foreach (ClientCard card in OwnTargets)
{
card.TargetCards.Remove(this);
}
OwnTargets.Clear();
TargetCards.Clear();
}
public bool HasLinkMarker(int dir)
{
return (LinkMarker & dir) != 0;
......
......@@ -133,6 +133,8 @@ namespace WindBot.Game
_messages.Add(GameMessage.RockPaperScissors, OnRockPaperScissors);
_messages.Add(GameMessage.Equip, OnEquip);
_messages.Add(GameMessage.Unequip, OnUnEquip);
_messages.Add(GameMessage.CardTarget, OnCardTarget);
_messages.Add(GameMessage.CancelTarget, OnCancelTarget);
_messages.Add(GameMessage.Summoning, OnSummoning);
_messages.Add(GameMessage.Summoned, OnSummoned);
_messages.Add(GameMessage.SpSummoning, OnSpSummoning);
......@@ -517,6 +519,7 @@ namespace WindBot.Game
private void OnMove(BinaryReader packet)
{
// TODO: update equip cards and target cards
int cardId = packet.ReadInt32();
int previousControler = GetLocalPlayer(packet.ReadByte());
int previousLocation = packet.ReadByte();
......@@ -631,12 +634,14 @@ namespace WindBot.Game
int pc = GetLocalPlayer(packet.ReadByte());
int pl = packet.ReadByte();
int ps = packet.ReadSByte();
packet.ReadSByte(); // pp
int pp = packet.ReadSByte();
int cp = packet.ReadSByte();
ClientCard card = _duel.GetCard(pc, (CardLocation)pl, ps);
if (card != null)
{
card.Position = cp;
if ((pp & (int) CardPosition.FaceUp) > 0 && (cp & (int) CardPosition.FaceDown) > 0)
card.ClearCardTargets();
if (_debug)
Logger.WriteLine("(" + (card.Name ?? "UnKnowCard") + " change position to " + (CardPosition)cp + ")");
}
......@@ -1468,6 +1473,40 @@ namespace WindBot.Game
}
}
private void OnCardTarget(BinaryReader packet)
{
int ownerCardControler = GetLocalPlayer(packet.ReadByte());
int ownerCardLocation = packet.ReadByte();
int ownerCardSequence = packet.ReadSByte();
packet.ReadByte();
int targetCardControler = GetLocalPlayer(packet.ReadByte());
int targetCardLocation = packet.ReadByte();
int targetCardSequence = packet.ReadSByte();
packet.ReadByte();
ClientCard ownerCard = _duel.GetCard(ownerCardControler, (CardLocation)ownerCardLocation, ownerCardSequence);
ClientCard targetCard = _duel.GetCard(targetCardControler, (CardLocation)targetCardLocation, targetCardSequence);
if (ownerCard == null || targetCard == null) return;
ownerCard.TargetCards.Add(targetCard);
targetCard.OwnTargets.Add(ownerCard);
}
private void OnCancelTarget(BinaryReader packet)
{
int ownerCardControler = GetLocalPlayer(packet.ReadByte());
int ownerCardLocation = packet.ReadByte();
int ownerCardSequence = packet.ReadSByte();
packet.ReadByte();
int targetCardControler = GetLocalPlayer(packet.ReadByte());
int targetCardLocation = packet.ReadByte();
int targetCardSequence = packet.ReadSByte();
packet.ReadByte();
ClientCard ownerCard = _duel.GetCard(ownerCardControler, (CardLocation)ownerCardLocation, ownerCardSequence);
ClientCard targetCard = _duel.GetCard(targetCardControler, (CardLocation)targetCardLocation, targetCardSequence);
if (ownerCard == null || targetCard == null) return;
ownerCard.TargetCards.Remove(targetCard);
targetCard.OwnTargets.Remove(ownerCard);
}
private void OnSummoning(BinaryReader packet)
{
_duel.LastSummonedCards.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