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

add Card.Sequence (#83)

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