public void Init(List <CardWrapper> cards, List <CardWrapper> handShouldBe = null, bool removeDuplicates = true) { for (int i = (int)Zones.PLAY; i < (int)Zones.COUNT; ++i) { PlayerZonedCards[i] = new List <CardWrapper>(); OpponentZonedCards[i] = new List <CardWrapper>(); } cards.Sort((x, y) => { return(x.ZonePos - y.ZonePos); }); foreach (CardWrapper card in cards) { if (card.Zone == "PLAY") { this.AddCardToZone(Zones.PLAY, card, removeDuplicates); } else if (card.Zone == "HAND") { this.AddCardToZone(Zones.HAND, card, removeDuplicates); } else if (card.Zone == "GRAVEYARD") { this.AddCardToZone(Zones.GRAVEYARD, card, removeDuplicates); } else if (card.Zone == "SETASIDE") { this.AddCardToZone(Zones.SETASIDE, card, removeDuplicates); } else if (card.Zone == "DECK") { this.AddCardToZone(Zones.DECK, card, removeDuplicates); } else if (card.Zone == "REMOVEDFROMGAME") { this.AddCardToZone(Zones.REMOVEDFROMGAME, card, removeDuplicates); } else { //throw new Exception("A NEW ZONE"); } } this.PlayerHand = new UniqueCardList(Zones.HAND, this.PlayerZonedCards); foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.HAND]) { this.PlayerHand.AddCardToList(card); } foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.HAND]) { if (this.PlayerHand.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos) == null) { this.PlayerHand.AddCardToList(card); } } this.PlayerHand.CardsInList.Sort((x, y) => x.ZonePos - y.ZonePos); this.PlayerPlay = new UniqueCardList(Zones.PLAY, this.PlayerZonedCards); foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.PLAY]) { this.PlayerPlay.AddCardToList(card); } foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.PLAY]) { if (this.PlayerPlay.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos) == null) { this.PlayerPlay.AddCardToList(card); } } this.PlayerPlay.CardsInList.Sort((x, y) => x.ZonePos - y.ZonePos); this.OpponentPlay = new UniqueCardList(Zones.PLAY, this.OpponentZonedCards); foreach (CardWrapper card in this.OpponentZonedCards[(int)Zones.PLAY]) { this.OpponentPlay.AddCardToList(card); } foreach (CardWrapper card in this.OpponentZonedCards[(int)Zones.PLAY]) { if (this.OpponentPlay.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos) == null) { this.OpponentPlay.AddCardToList(card); } } this.OpponentPlay.CardsInList.Sort((x, y) => x.ZonePos - y.ZonePos); }
public void Init(List<CardWrapper> cards, List<CardWrapper> handShouldBe = null, bool removeDuplicates = true) { for (int i = (int)Zones.PLAY; i < (int)Zones.COUNT; ++i) { PlayerZonedCards[i] = new List<CardWrapper>(); OpponentZonedCards[i] = new List<CardWrapper>(); } cards.Sort((x, y) => { return x.ZonePos - y.ZonePos; }); foreach (CardWrapper card in cards) { if (card.Zone == "PLAY") { this.AddCardToZone(Zones.PLAY, card, removeDuplicates); } else if (card.Zone == "HAND") { this.AddCardToZone(Zones.HAND, card, removeDuplicates); } else if (card.Zone == "GRAVEYARD") { this.AddCardToZone(Zones.GRAVEYARD, card, removeDuplicates); } else if (card.Zone == "SETASIDE") { this.AddCardToZone(Zones.SETASIDE, card, removeDuplicates); } else if (card.Zone == "DECK") { this.AddCardToZone(Zones.DECK, card, removeDuplicates); } else if(card.Zone == "REMOVEDFROMGAME") { this.AddCardToZone(Zones.REMOVEDFROMGAME, card, removeDuplicates); } else { //throw new Exception("A NEW ZONE"); } } this.PlayerHand = new UniqueCardList(Zones.HAND, this.PlayerZonedCards); foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.HAND]) { this.PlayerHand.AddCardToList(card); } foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.HAND]) { if(this.PlayerHand.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos) == null) { this.PlayerHand.AddCardToList(card); } } this.PlayerHand.CardsInList.Sort((x, y) => x.ZonePos - y.ZonePos); this.PlayerPlay = new UniqueCardList(Zones.PLAY, this.PlayerZonedCards); foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.PLAY]) { this.PlayerPlay.AddCardToList(card); } foreach (CardWrapper card in this.PlayerZonedCards[(int)Zones.PLAY]) { if (this.PlayerPlay.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos) == null) { this.PlayerPlay.AddCardToList(card); } } this.PlayerPlay.CardsInList.Sort((x, y) => x.ZonePos - y.ZonePos); this.OpponentPlay = new UniqueCardList(Zones.PLAY, this.OpponentZonedCards); foreach (CardWrapper card in this.OpponentZonedCards[(int)Zones.PLAY]) { this.OpponentPlay.AddCardToList(card); } foreach (CardWrapper card in this.OpponentZonedCards[(int)Zones.PLAY]) { if (this.OpponentPlay.CardsInList.FirstOrDefault(c => c.ZonePos == card.ZonePos) == null) { this.OpponentPlay.AddCardToList(card); } } this.OpponentPlay.CardsInList.Sort((x, y) => x.ZonePos - y.ZonePos); }