Commit 55f137fd authored by handsomekiwi's avatar handsomekiwi Committed by mercury233

add Card.Sequence (#83)

parent 2616468a
......@@ -12,6 +12,7 @@ namespace WindBot.Game
public string Name { get; private set; }
public int Position { get; set; }
public int Sequence { get; set; }
public CardLocation Location { get; set; }
public int Alias { get; private set; }
public int Level { get; private set; }
......@@ -44,14 +45,15 @@ namespace WindBot.Game
public int[] ActionIndex { get; set; }
public IDictionary<int, int> ActionActivateIndex { get; private set; }
public ClientCard(int id, CardLocation loc)
: this(id, loc, 0)
public ClientCard(int id, CardLocation loc, int sequence)
: this(id, loc, -1 , 0)
{
}
public ClientCard(int id, CardLocation loc, int position)
public ClientCard(int id, CardLocation loc, int sequence, int position)
{
SetId(id);
Sequence = sequence;
Position = position;
Overlays = new List<int>();
ActionIndex = new int[16];
......@@ -189,7 +191,7 @@ namespace WindBot.Game
public bool IsExtraCard()
{
return (HasType(CardType.Fusion) || HasType(CardType.Synchro) || HasType(CardType.Xyz));
return HasType(CardType.Fusion) || HasType(CardType.Synchro) || HasType(CardType.Xyz) || HasType(CardType.Link);
}
public bool IsFaceup()
......
......@@ -31,9 +31,9 @@ namespace WindBot.Game
ExtraDeck = new List<ClientCard>();
for (int i = 0; i < deck; ++i)
Deck.Add(new ClientCard(0, CardLocation.Deck));
Deck.Add(new ClientCard(0, CardLocation.Deck, -1));
for (int i = 0; i < extra; ++i)
ExtraDeck.Add(new ClientCard(0, CardLocation.Extra));
ExtraDeck.Add(new ClientCard(0, CardLocation.Extra, -1));
}
public int GetMonstersExtraZoneCount()
......
......@@ -38,12 +38,12 @@ namespace WindBot.Game
LastSummonedCards = new List<ClientCard>();
}
public ClientCard GetCard(int player, CardLocation loc, int index)
public ClientCard GetCard(int player, CardLocation loc, int seq)
{
return GetCard(player, (int)loc, index, 0);
return GetCard(player, (int)loc, seq, 0);
}
public ClientCard GetCard(int player, int loc, int index, int subindex)
public ClientCard GetCard(int player, int loc, int seq, int subSeq)
{
if (player < 0 || player > 1)
return null;
......@@ -79,51 +79,52 @@ namespace WindBot.Game
if (cards == null)
return null;
if (index >= cards.Count)
if (seq >= cards.Count)
return null;
if (isXyz)
{
ClientCard card = cards[index];
if (card == null || subindex >= card.Overlays.Count)
ClientCard card = cards[seq];
if (card == null || subSeq >= card.Overlays.Count)
return null;
return null; // TODO card.Overlays[subindex]
return null; // TODO card.Overlays[subSeq]
}
return cards[index];
return cards[seq];
}
public void AddCard(CardLocation loc, int cardId, int player, int zone, int pos)
public void AddCard(CardLocation loc, int cardId, int player, int seq, int pos)
{
switch (loc)
{
case CardLocation.Hand:
Fields[player].Hand.Add(new ClientCard(cardId, loc, pos));
Fields[player].Hand.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.Grave:
Fields[player].Graveyard.Add(new ClientCard(cardId, loc, pos));
Fields[player].Graveyard.Add(new ClientCard(cardId, loc,-1, pos));
break;
case CardLocation.Removed:
Fields[player].Banished.Add(new ClientCard(cardId, loc, pos));
Fields[player].Banished.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.MonsterZone:
Fields[player].MonsterZone[zone] = new ClientCard(cardId, loc, pos);
Fields[player].MonsterZone[seq] = new ClientCard(cardId, loc, seq, pos);
break;
case CardLocation.SpellZone:
Fields[player].SpellZone[zone] = new ClientCard(cardId, loc, pos);
Fields[player].SpellZone[seq] = new ClientCard(cardId, loc, seq, pos);
break;
case CardLocation.Deck:
Fields[player].Deck.Add(new ClientCard(cardId, loc, pos));
Fields[player].Deck.Add(new ClientCard(cardId, loc, -1, pos));
break;
case CardLocation.Extra:
Fields[player].ExtraDeck.Add(new ClientCard(cardId, loc, pos));
Fields[player].ExtraDeck.Add(new ClientCard(cardId, loc, -1, pos));
break;
}
}
public void AddCard(CardLocation loc, ClientCard card, int player, int zone, int pos, int id)
public void AddCard(CardLocation loc, ClientCard card, int player, int seq, int pos, int id)
{
card.Location = loc;
card.Sequence = seq;
card.Position = pos;
card.SetId(id);
switch (loc)
......@@ -138,10 +139,10 @@ namespace WindBot.Game
Fields[player].Banished.Add(card);
break;
case CardLocation.MonsterZone:
Fields[player].MonsterZone[zone] = card;
Fields[player].MonsterZone[seq] = card;
break;
case CardLocation.SpellZone:
Fields[player].SpellZone[zone] = card;
Fields[player].SpellZone[seq] = card;
break;
case CardLocation.Deck:
Fields[player].Deck.Add(card);
......@@ -152,7 +153,7 @@ namespace WindBot.Game
}
}
public void RemoveCard(CardLocation loc, ClientCard card, int player, int zone)
public void RemoveCard(CardLocation loc, ClientCard card, int player, int seq)
{
switch (loc)
{
......@@ -166,10 +167,10 @@ namespace WindBot.Game
Fields[player].Banished.Remove(card);
break;
case CardLocation.MonsterZone:
Fields[player].MonsterZone[zone] = null;
Fields[player].MonsterZone[seq] = null;
break;
case CardLocation.SpellZone:
Fields[player].SpellZone[zone] = null;
Fields[player].SpellZone[seq] = null;
break;
case CardLocation.Deck:
Fields[player].Deck.Remove(card);
......
......@@ -365,7 +365,7 @@ namespace WindBot.Game
for (int i = 0; i < count; ++i)
{
_duel.Fields[player].Deck.RemoveAt(_duel.Fields[player].Deck.Count - 1);
_duel.Fields[player].Hand.Add(new ClientCard(0, CardLocation.Hand));
_duel.Fields[player].Hand.Add(new ClientCard(0, CardLocation.Hand, -1));
}
_ai.OnDraw(player);
}
......@@ -436,19 +436,19 @@ namespace WindBot.Game
_duel.Fields[player].Deck.Clear();
for (int i = 0; i < mcount; ++i)
{
_duel.Fields[player].Deck.Add(new ClientCard(0, CardLocation.Deck));
_duel.Fields[player].Deck.Add(new ClientCard(0, CardLocation.Deck, -1));
}
_duel.Fields[player].ExtraDeck.Clear();
for (int i = 0; i < ecount; ++i)
{
int code = packet.ReadInt32() & 0x7fffffff;
_duel.Fields[player].ExtraDeck.Add(new ClientCard(code, CardLocation.Extra));
_duel.Fields[player].ExtraDeck.Add(new ClientCard(code, CardLocation.Extra, -1));
}
_duel.Fields[player].Hand.Clear();
for (int i = 0; i < hcount; ++i)
{
int code = packet.ReadInt32();
_duel.Fields[player].Hand.Add(new ClientCard(code, CardLocation.Hand));
_duel.Fields[player].Hand.Add(new ClientCard(code, CardLocation.Hand,-1));
}
}
......@@ -662,7 +662,7 @@ namespace WindBot.Game
int seq = packet.ReadByte();
ClientCard card;
if (((int)loc & (int)CardLocation.Overlay) != 0)
card = new ClientCard(id, CardLocation.Overlay);
card = new ClientCard(id, CardLocation.Overlay, -1);
else
card = _duel.GetCard(controler, loc, seq);
if (card == null) continue;
......@@ -850,7 +850,7 @@ namespace WindBot.Game
packet.ReadByte(); // pos
ClientCard card;
if (((int)loc & (int)CardLocation.Overlay) != 0)
card = new ClientCard(id, CardLocation.Overlay);
card = new ClientCard(id, CardLocation.Overlay, -1);
else
card = _duel.GetCard(player, loc, seq);
if (card == null) continue;
......@@ -909,7 +909,7 @@ namespace WindBot.Game
packet.ReadByte(); // pos
ClientCard card;
if (((int)loc & (int)CardLocation.Overlay) != 0)
card = new ClientCard(id, CardLocation.Overlay);
card = new ClientCard(id, CardLocation.Overlay, -1);
else
card = _duel.GetCard(player, loc, seq);
if (card == null) continue;
......
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