private static PileOfCards CreateRuins(CardGameSubset gameSubset, int ruinsCount, Random random) { int ruinCountPerPile = 10; var allRuinsCards = new ListOfCards(gameSubset); allRuinsCards.AddNCardsToTop(Cards.AbandonedMine, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.RuinedMarket, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.RuinedLibrary, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.RuinedVillage, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.Survivors, ruinCountPerPile); allRuinsCards.Shuffle(random); var result = new PileOfCards(gameSubset, Cards.Ruins); for (int i = 0; i < ruinsCount; ++i) { Card card = allRuinsCards.DrawCardFromTop(); if (card == null) { throw new Exception("Not enough ruins available."); } result.AddCardToTop(card); } result.EraseKnownCountKnowledge(); return(result); }
public Card PlayerGainCardFromSupply(Card cardType, PlayerState playerState, DeckPlacement defaultLocation = DeckPlacement.Discard, GainReason gainReason = GainReason.Gain) { PileOfCards pile = this.GetPile(cardType); if (pile == null) { return(null); } if (GetPile(this.supplyPiles, cardType) != null) { this.hasPileEverBeenGained[pile] = true; } Card card = pile.DrawCardFromTop(); if (card == null) { return(null); } playerState.GainCard(this, card, DeckPlacement.Supply, defaultLocation, gainReason); return(card); }
public bool CanGainCardFromSupply(Card cardType) { PileOfCards pile = this.GetPile(cardType); if (pile == null) { return(false); } return(pile.TopCard() == cardType); }
public bool CanGainCardFromSupply(Card cardType) { PileOfCards pile = this.GetPile(cardType); if (pile == null) { return(false); } return(IsCardEqualOrOfType(pile.TopCard(), cardType)); }
private int GetIndexForPile(PileOfCards pile) { for (int index = 0; index < this.supplyPiles.Length; ++index) { if (object.ReferenceEquals(pile, this.supplyPiles[index])) { return(index); } } throw new Exception("Pile not a part of supply"); }
public T this[PileOfCards pileOfCards] { get { return(this.array[this.GetIndexForPile(pileOfCards)]); } set { this.array[this.GetIndexForPile(pileOfCards)] = value; } }
private static PileOfCards GetPile(PileOfCards[] piles, Card cardType) { for (int i = 0; i < piles.Length; ++i) { PileOfCards cardPile = piles[i]; if (cardPile.IsType(cardType)) { return(cardPile); } } return(null); }
private PileOfCards GetPile(Card cardType) { for (int i = 0; i < this.supplyPiles.Length; ++i) { PileOfCards cardPile = this.supplyPiles[i]; if (cardPile.IsType(cardType)) { return(cardPile); } } return(null); }
public Card PlayerGainCardFromSupply(Card cardType, PlayerState playerState, DeckPlacement defaultLocation = DeckPlacement.Discard, GainReason gainReason = GainReason.Gain) { bool canGainCardFromSupply = CanGainCardFromSupply(cardType); PileOfCards pile = this.GetPile(cardType); if (pile == null) { System.Diagnostics.Debug.Assert(!canGainCardFromSupply); return(null); } if (GetPile(this.supplyPiles, cardType) != null) { this.hasPileEverBeenGained[pile] = true; } if (pile.TopCard() != cardType) { System.Diagnostics.Debug.Assert(!canGainCardFromSupply); return(null); } Card card = pile.DrawCardFromTop(); if (card == null) { System.Diagnostics.Debug.Assert(!canGainCardFromSupply); return(null); } System.Diagnostics.Debug.Assert(canGainCardFromSupply); playerState.GainCard(this, card, DeckPlacement.Supply, defaultLocation, gainReason); return(card); }
private static PileOfCards CreateTournamentPrizes(CardGameSubset gameSubset) { Card[] prizes = { Cards.BagOfGold, Cards.Diadem, Cards.Followers, Cards.Princess, Cards.TrustySteed }; if (gameSubset.isInitializing) { gameSubset.AddCard(Cards.Prize); foreach (Card prize in prizes) { gameSubset.AddCard(prize); } return(null); } else { var result = new PileOfCards(gameSubset, Cards.Prize); foreach (Card prize in prizes) { result.AddCardToTop(prize); } return(result); } }
private static PileOfCards CreateRuins(CardGameSubset gameSubset, int ruinsCount, Random random) { if (gameSubset.isInitializing) { gameSubset.AddCard(Cards.Ruins); gameSubset.AddCard(Cards.AbandonedMine); gameSubset.AddCard(Cards.RuinedMarket); gameSubset.AddCard(Cards.RuinedLibrary); gameSubset.AddCard(Cards.RuinedVillage); gameSubset.AddCard(Cards.Survivors); return null; } else { int ruinCountPerPile = 10; var allRuinsCards = new ListOfCards(gameSubset); allRuinsCards.AddNCardsToTop(Cards.AbandonedMine, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.RuinedMarket, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.RuinedLibrary, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.RuinedVillage, ruinCountPerPile); allRuinsCards.AddNCardsToTop(Cards.Survivors, ruinCountPerPile); allRuinsCards.Shuffle(random); var result = new PileOfCards(gameSubset, Cards.Ruins); for (int i = 0; i < ruinsCount; ++i) { Card card = allRuinsCards.DrawCardFromTop(); if (card == null) { throw new Exception("Not enough ruins available."); } result.AddCardToTop(card); } result.EraseKnownCountKnowledge(); return result; } }
internal bool HasCardEverBeenGainedFromPile(PileOfCards pile) { return(this.hasPileEverBeenGained[pile]); }
internal void AddEmbargoTokenToPile(PileOfCards pile) { this.pileEmbargoTokenCount[pile] += 1; }
private static PileOfCards GetPile(PileOfCards[] piles, Card cardType) { for (int i = 0; i < piles.Length; ++i) { PileOfCards cardPile = piles[i]; if (cardPile.IsType(cardType)) { return cardPile; } } return null; }
internal bool HasCardEverBeenGainedFromPile(PileOfCards pile) { return this.hasPileEverBeenGained[pile]; }