public override void Play(Player player) { base.Play(player); // Perform attack on every player IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player); enumerator.MoveNext(); // skip active player while (enumerator.MoveNext()) { Player attackee = enumerator.Current; // Skip if the attack is blocked (Moat, Lighthouse, etc.) if (this.IsAttackBlocked[attackee]) { continue; } if (attackee.CanDraw) { Card card = attackee.Draw(DeckLocation.Revealed); Cost trashedCardCost = player._Game.ComputeCost(card); attackee.Trash(attackee.RetrieveCardFrom(DeckLocation.Revealed, card)); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost == trashedCardCost); Choice choice = new Choice(String.Format("Choose a card for {0} to gain", attackee), this, gainableSupplies, attackee, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { attackee.Gain(result.Supply); } } } }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List <SupplyInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount) { if (pPageIndex <= 1) { pPageIndex = 1; } List <SupplyInfo> list = new List <SupplyInfo>(); Query q = Supply.CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression, pOrderBy.ToString()); SupplyCollection collection = new SupplyCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Supply supply in collection) { SupplyInfo supplyInfo = new SupplyInfo(); LoadFromDAL(supplyInfo, supply); list.Add(supplyInfo); } pRecordCount = q.GetRecordCount(); return(list); }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List <SupplyInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(SupplyInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return(CachedEntityCommander.GetCache(cacheKey) as List <SupplyInfo>); } else { List <SupplyInfo> list = new List <SupplyInfo>(); SupplyCollection collection = new SupplyCollection(); Query qry = new Query(Supply.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach (Supply supply in collection) { SupplyInfo supplyInfo = new SupplyInfo(); LoadFromDAL(supplyInfo, supply); list.Add(supplyInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(SupplyInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return(list); } }
public override void Play(Player player) { base.Play(player); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= new Coin(4)); Choice choice = new Choice("Gain a card costing up to <coin>4</coin>", this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { CardBenefit benefit = new CardBenefit(); if (player.Gain(result.Supply)) { if ((result.Supply.Category & Cards.Category.Action) == Cards.Category.Action) { benefit.Actions = 1; } if ((result.Supply.Category & Cards.Category.Treasure) == Cards.Category.Treasure) { benefit.Currency += new Coin(1); } if ((result.Supply.Category & Cards.Category.Victory) == Cards.Category.Victory) { benefit.Cards = 1; } player.ReceiveBenefit(this, benefit); } } }
public Supply FindSupplyPileByCardType(Type cardType, Boolean includeSpecialPiles) { if (this.Supplies.ContainsKey(cardType)) { return(this.Supplies[cardType]); } if (includeSpecialPiles && this.SpecialPiles.ContainsKey(cardType)) { return(this.SpecialPiles[cardType]); } SupplyCollection sc = this.Supplies.FindAll(s => s.TopCard != null && s.TopCard.CardType == cardType); if (sc.Count == 1) { return(sc.ElementAt(0).Value); } if (includeSpecialPiles) { sc = this.SpecialPiles.FindAll(s => s.TopCard != null && s.TopCard.CardType == cardType); if (sc.Count == 1) { return(sc.ElementAt(0).Value); } } return(null); }
protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. this._Game = null; this._SupplyPiles = null; this._SpecialPiles = null; this._TokenPiles = null; this._SupplyKeys = null; this._Trash = null; } // Call the appropriate methods to clean up // unmanaged resources here. // If disposing is false, // only the following code is executed. // Note disposing has been done. disposed = true; } }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List <SupplyInfo> pList, SupplyCollection pCollection) { foreach (Supply supply in pCollection) { SupplyInfo supplyInfo = new SupplyInfo(); LoadFromDAL(supplyInfo, supply); pList.Add(supplyInfo); } }
public override void Play(Player player) { base.Play(player); Choice choice = new Choice("Choose 1. You get the version in parenthesis; everyone else gets the other:", this, new CardCollection() { this }, new List <string>() { "+1 (+3) Cards", "Gain a Silver (Gold)", "You may trash a card from your hand and gain a card costing exactly <coin>1</coin> (<coin>2</coin>) more" }, player); ChoiceResult result = player.MakeChoice(choice); IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player); while (enumerator.MoveNext()) { Player actee = enumerator.Current; if (result.Options.Contains("+1 (+3) Cards")) { // 3 or 1 cards, depending on who it is actee.ReceiveBenefit(this, new CardBenefit() { Cards = (actee == player ? 3 : 1) }); } else if (result.Options.Contains("Gain a Silver (Gold)")) { if (actee == player) { actee.Gain(player._Game.Table.Gold); } else { actee.Gain(player._Game.Table.Silver); } } else { Choice choiceTrash = new Choice("You may choose a card to trash", this, actee.Hand, actee, false, 0, 1); ChoiceResult resultTrash = actee.MakeChoice(choiceTrash); actee.Trash(actee.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards)); if (resultTrash.Cards.Count > 0) { Cost trashedCardCost = actee._Game.ComputeCost(resultTrash.Cards[0]); SupplyCollection gainableSupplies = actee._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost == (trashedCardCost + new Coin(actee == player ? 2 : 1))); Choice choiceGain = new Choice("Gain a card", this, gainableSupplies, actee, false); ChoiceResult resultGain = actee.MakeChoice(choiceGain); if (resultGain.Supply != null) { actee.Gain(resultGain.Supply); } } } } }
public override void Play(Player player) { base.Play(player); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= new Coin(4)); Choice choice = new Choice("Gain a card costing up to <coin>4</coin>", this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); } }
public override void Play(Player player) { base.Play(player); Choice choiceTrash = new Choice("You may choose a Treasure card to trash", this, player.Hand[Cards.Category.Treasure], player, false, 0, 1); ChoiceResult resultTrash = player.MakeChoice(choiceTrash); player.Trash(player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards)); if (resultTrash.Cards.Count > 0) { Cost trashedCardCost = player._Game.ComputeCost(resultTrash.Cards[0]); IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player); enumerator.MoveNext(); while (enumerator.MoveNext()) { Player attackee = enumerator.Current; // Skip if the attack is blocked (Moat, Lighthouse, etc.) if (this.IsAttackBlocked[attackee]) { continue; } if (attackee.Hand.Count < 5) { continue; } // If the player doesn't have any of this card, reveal the player's hand if (attackee.Hand[resultTrash.Cards[0].CardType].Count == 0) { attackee.ReturnHand(attackee.RevealHand()); } // Otherwise, the player automatically discards the card (no real choices to be made here) else { attackee.Discard(DeckLocation.Hand, attackee.Hand[resultTrash.Cards[0].CardType].First()); } } SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll( supply => supply.CanGain() && ((supply.Category & Cards.Category.Treasure) == Cards.Category.Treasure) && supply.CurrentCost <= (trashedCardCost + new Coin(3))); Choice choice = new Choice("Gain a card", this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply, DeckLocation.Deck, DeckPosition.Top); } } }
public Supply FindSupplyPileByCard(Cards.Card card) { if (this.Supplies.ContainsKey(card)) { return(this.Supplies[card]); } SupplyCollection sc = this.Supplies.FindAll(s => s.TopCard != null && s.TopCard.Name == card.Name); if (sc.Count == 1) { return(sc.ElementAt(0).Value); } return(null); }
public override void Play(Player player) { base.Play(player); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll( supply => supply.CanGain() && ((supply.Category & Cards.Category.Action) == Cards.Category.Action) && supply.CurrentCost <= new Coin(5)); Choice choice = new Choice("You may gain an Action card costing up to <coin>5</coin>", this, gainableSupplies, player, true); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); } }
public override void Play(Player player) { base.Play(player); if (player.InPlay.Contains(this.PhysicalCard)) { player.Trash(player.RetrieveCardFrom(DeckLocation.InPlay, this.PhysicalCard)); } SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= new Coin(5)); Choice choice = new Choice("Gain a card costing up to <coin>5</coin>", this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); } }
public override void Overpay(Player player, Currency amount) { for (int i = 0; i < 2; i++) { SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && (supply.Category & Cards.Category.Action) == Cards.Category.Action && supply.CurrentCost == amount); Choice choice = new Choice(String.Format("Gain an Action card costing {0}", amount.ToStringInline()), this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); } } }
public override void Play(Player player) { base.Play(player); SupplyCollection availableSupplies = new SupplyCollection(player._Game.Table.Supplies.Where(kvp => kvp.Value.Randomizer != null && kvp.Value.Randomizer.GroupMembership != Group.None)); CardCollection cards = new CardCollection(); Choice choice = new Choice("Name a card", this, availableSupplies, player, false); foreach (Supply supply in player._Game.Table.Supplies.Values.Union(player._Game.Table.SpecialPiles.Values)) { foreach (Type type in supply.CardTypes) { if (!choice.Supplies.Any(kvp => kvp.Value.CardType == type)) { cards.Add(Card.CreateInstance(type)); } } } cards.Sort(); choice.AddCards(cards); ChoiceResult result = player.MakeChoice(choice); ICard wishedCard = null; if (result.Supply != null) { wishedCard = result.Supply; } else { wishedCard = result.Cards[0]; } player._Game.SendMessage(player, this, wishedCard); if (player.CanDraw) { player.Draw(DeckLocation.Revealed); if (player.Revealed[wishedCard.CardType].Count > 0) { player.AddCardsToHand(DeckLocation.Revealed); } else { player.AddCardsToDeck(player.RetrieveCardsFrom(DeckLocation.Revealed), DeckPosition.Top); } } }
public override void Play(Player player) { base.Play(player); SupplyCollection availableSupplies = new SupplyCollection(player._Game.Table.Supplies.Where(kvp => kvp.Value.Randomizer != null && kvp.Value.Randomizer.GroupMembership != Group.None)); CardCollection cards = new CardCollection(); Choice choice = new Choice("Name a card", this, availableSupplies, player, false); foreach (Supply supply in player._Game.Table.Supplies.Values.Union(player._Game.Table.SpecialPiles.Values)) { foreach (Type type in supply.CardTypes) { if (!choice.Supplies.Any(kvp => kvp.Value.CardType == type)) { cards.Add(Card.CreateInstance(type)); } } } cards.Sort(); choice.AddCards(cards); ChoiceResult result = player.MakeChoice(choice); ICard namedCard = null; if (result.Supply != null) { namedCard = result.Supply; } else { namedCard = result.Cards[0]; } player._Game.SendMessage(player, this, namedCard); CardCollection newCards = player.Draw(3, DeckLocation.Revealed); player.Trash(player.RetrieveCardsFrom(DeckLocation.Revealed, c => c.Name == namedCard.Name)); Choice replaceChoice = new Choice("Choose order of cards to put back on your deck", this, player.Revealed, player, true, player.Revealed.Count, player.Revealed.Count); ChoiceResult replaceResult = player.MakeChoice(replaceChoice); player.RetrieveCardsFrom(DeckLocation.Revealed, replaceResult.Cards); player.AddCardsToDeck(replaceResult.Cards, DeckPosition.Top); }
public override void Play(Player player) { base.Play(player); // Perform attack on every player IEnumerator <Player> enumerator = player._Game.GetPlayersStartingWithEnumerator(player); enumerator.MoveNext(); // skip active player while (enumerator.MoveNext()) { Player attackee = enumerator.Current; // Skip if the attack is blocked (Moat, Lighthouse, etc.) if (this.IsAttackBlocked[attackee]) { continue; } attackee.BeginDrawing(); while (attackee.Revealed[card => player._Game.ComputeCost(card).Coin >= 3].Count < 1 && attackee.CanDraw) { attackee.Draw(DeckLocation.Revealed); } attackee.EndDrawing(); CardCollection cards = attackee.Revealed[c => player._Game.ComputeCost(c).Coin >= 3]; if (cards.Count > 0) { Card card = cards[0]; Cost trashedCardCost = player._Game.ComputeCost(card); attackee.Trash(attackee.RetrieveCardFrom(DeckLocation.Revealed, card)); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= (trashedCardCost.Coin - 2)); Choice choice = new Choice("You may gain a card", this, gainableSupplies, player, true); ChoiceResult result = attackee.MakeChoice(choice); if (result.Supply != null) { attackee.Gain(result.Supply); } } attackee.DiscardRevealed(); } }
public override void Play(Player player) { base.Play(player); Choice choiceTrash = new Choice("Choose a card to trash", this, player.Hand, player); ChoiceResult resultTrash = player.MakeChoice(choiceTrash); player.Trash(player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards)); if (resultTrash.Cards.Count > 0) { Cost trashedCardCost = player._Game.ComputeCost(resultTrash.Cards[0]); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= (trashedCardCost + new Coin(2))); Choice choice = new Choice("Gain a card", this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); } } }
public override void Play(Player player) { base.Play(player); player.AddToken(new CoinToken()); player.AddToken(new CoinToken()); Choice choiceTrash = new Choice("You may choose a card to trash", this, player.Hand, player, false, 0, 1); ChoiceResult resultTrash = player.MakeChoice(choiceTrash); if (resultTrash.Cards.Count > 0) { player.Trash(player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards)); List <String> options = new List <string>(); for (int i = 0; i <= player.TokenPiles[TypeClass.CoinToken].Count; i++) { options.Add(i.ToString()); } Choice choiceOverpay = new Choice("You may pay any number of Coin tokens", this, new CardCollection() { this }, options, player); ChoiceResult resultOverpay = player.MakeChoice(choiceOverpay); int overpayAmount = int.Parse(resultOverpay.Options[0]); player._Game.SendMessage(player, this, overpayAmount); player.RemoveTokens(TypeClass.CoinToken, overpayAmount); Cost trashedCardCost = player._Game.ComputeCost(resultTrash.Cards[0]); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= (trashedCardCost + new Coin(overpayAmount))); Choice choice = new Choice("Gain a card", this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); } } }
public override void Play(Player player) { base.Play(player); List <Type> cardTypes = new List <Type>(); foreach (Card card in player.InPlay) { Type t = card.CardType; if (!cardTypes.Contains(t)) { cardTypes.Add(t); } } foreach (Card card in player.SetAside) { Type t = card.CardType; if (!cardTypes.Contains(t)) { cardTypes.Add(t); } } Currencies.Coin uniqueCardsInPlay = new Currencies.Coin(cardTypes.Count); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost <= uniqueCardsInPlay); Choice choice = new Choice("Gain a card.", this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); if ((result.Supply.Category & Cards.Category.Victory) == Cards.Category.Victory) { player.RetrieveCardFrom(DeckLocation.InPlay, this); player.Trash(this); } } }
public override void Play(Player player) { base.Play(player); Choice choiceTrash = new Choice("Choose a card to trash", this, player.Hand, player); ChoiceResult resultTrash = player.MakeChoice(choiceTrash); player.Trash(player.RetrieveCardsFrom(DeckLocation.Hand, resultTrash.Cards)); if (resultTrash.Cards.Count > 0) { Cost trashedCardCost = player._Game.ComputeCost(resultTrash.Cards[0]); for (int i = 0; i < 2; i++) { SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && supply.CurrentCost < trashedCardCost); Choice choice = new Choice(String.Format("Gain a card costing less than {0}", trashedCardCost.ToString()), this, gainableSupplies, player, false); ChoiceResult result = player.MakeChoice(choice); if (result.Supply != null) { player.Gain(result.Supply); } } } }
/// <summary> /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据 /// </summary> /// <param name="pPageIndex">页数</param> /// <param name="pPageSize">每页列表</param> /// <param name="pOrderBy">排序</param> /// <param name="pSortExpression">排序字段</param> /// <param name="pRecordCount">列表行数</param> /// <returns>数据分页</returns> public static List<SupplyInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount) { if(pPageIndex<=1) pPageIndex=1; List< SupplyInfo> list = new List< SupplyInfo>(); Query q = Supply .CreateQuery(); q.PageIndex = pPageIndex; q.PageSize = pPageSize; q.ORDER_BY(pSortExpression,pOrderBy.ToString()); SupplyCollection collection=new SupplyCollection(); collection.LoadAndCloseReader(q.ExecuteReader()); foreach (Supply supply in collection) { SupplyInfo supplyInfo = new SupplyInfo(); LoadFromDAL(supplyInfo, supply); list.Add(supplyInfo); } pRecordCount=q.GetRecordCount(); return list; }
/// <summary> /// 获得数据列表 /// </summary> /// <returns></returns> public static List<SupplyInfo> GetList() { string cacheKey = GetCacheKey(); //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取 if (CachedEntityCommander.IsTypeRegistered(typeof(SupplyInfo)) && CachedEntityCommander.GetCache(cacheKey) != null) { return CachedEntityCommander.GetCache(cacheKey) as List< SupplyInfo>; } else { List< SupplyInfo> list =new List< SupplyInfo>(); SupplyCollection collection=new SupplyCollection(); Query qry = new Query(Supply.Schema); collection.LoadAndCloseReader(qry.ExecuteReader()); foreach(Supply supply in collection) { SupplyInfo supplyInfo= new SupplyInfo(); LoadFromDAL(supplyInfo,supply); list.Add(supplyInfo); } //生成缓存 if (CachedEntityCommander.IsTypeRegistered(typeof(SupplyInfo))) { CachedEntityCommander.SetCache(cacheKey, list); } return list; } }
public override void Play(Player player) { base.Play(player); SupplyCollection availableSupplies = new SupplyCollection(player._Game.Table.Supplies.Where(kvp => kvp.Value.Randomizer != null && kvp.Value.Randomizer.GroupMembership != Group.None)); CardCollection cards = new CardCollection(); Choice choice = new Choice("Name a card", this, availableSupplies, player, false); foreach (Supply supply in player._Game.Table.Supplies.Values.Union(player._Game.Table.SpecialPiles.Values)) { foreach (Type type in supply.CardTypes) { if (!choice.Supplies.Any(kvp => kvp.Value.CardType == type)) cards.Add(Card.CreateInstance(type)); } } cards.Sort(); choice.AddCards(cards); ChoiceResult result = player.MakeChoice(choice); ICard namedCard = null; if (result.Supply != null) namedCard = result.Supply; else namedCard = result.Cards[0]; player._Game.SendMessage(player, this, namedCard); CardCollection newCards = player.Draw(3, DeckLocation.Revealed); player.Trash(player.RetrieveCardsFrom(DeckLocation.Revealed, c => c.Name == namedCard.Name)); Choice replaceChoice = new Choice("Choose order of cards to put back on your deck", this, player.Revealed, player, true, player.Revealed.Count, player.Revealed.Count); ChoiceResult replaceResult = player.MakeChoice(replaceChoice); player.RetrieveCardsFrom(DeckLocation.Revealed, replaceResult.Cards); player.AddCardsToDeck(replaceResult.Cards, DeckPosition.Top); }
public Choice(String text, Card cardSource, SupplyCollection supplies, Player playerSource, Boolean optional) : this(text, cardSource, new CardCollection() { cardSource }, ChoiceType.Supplies, playerSource, null, false, false, optional ? 0 : 1, 1) { _Supplies = supplies; }
/// <summary> /// 批量装载 /// </summary> internal static void LoadFromDALPatch(List< SupplyInfo> pList, SupplyCollection pCollection) { foreach (Supply supply in pCollection) { SupplyInfo supplyInfo = new SupplyInfo(); LoadFromDAL(supplyInfo, supply ); pList.Add(supplyInfo); } }
public override void Play(Player player) { base.Play(player); SupplyCollection availableSupplies = new SupplyCollection(player._Game.Table.Supplies.Where(kvp => kvp.Value.Randomizer != null && kvp.Value.Randomizer.GroupMembership != Group.None)); CardCollection cards = new CardCollection(); Choice choice = new Choice("Name a card", this, availableSupplies, player, false); foreach (Supply supply in player._Game.Table.Supplies.Values.Union(player._Game.Table.SpecialPiles.Values)) { foreach (Type type in supply.CardTypes) { if (!choice.Supplies.Any(kvp => kvp.Value.CardType == type)) cards.Add(Card.CreateInstance(type)); } } choice.AddCards(cards); ChoiceResult result = player.MakeChoice(choice); ICard namedCard = null; if (result.Supply != null) namedCard = result.Supply; else namedCard = result.Cards[0]; player._Game.SendMessage(player, this, namedCard); Card foundCard = null; player.BeginDrawing(); while (player.CanDraw) { player.Draw(DeckLocation.Revealed); Card lastRevealed = player.Revealed.Last(); if ((lastRevealed.Category & Cards.Category.Victory) == Cards.Category.Victory && namedCard.Name != lastRevealed.Name) { foundCard = lastRevealed; break; } } player.EndDrawing(); if (foundCard != null) foundCard = player.RetrieveCardFrom(DeckLocation.Revealed, foundCard); player.DiscardRevealed(); if (foundCard != null) { player.Trash(foundCard); Cost trashedCardCost = player._Game.ComputeCost(foundCard); SupplyCollection gainableSupplies = player._Game.Table.Supplies.FindAll(supply => supply.CanGain() && (supply.Category & Cards.Category.Victory) == Cards.Category.Victory && supply.CurrentCost <= (trashedCardCost + new Coin(3))); Choice choiceGain = new Choice("Gain a Victory card", this, gainableSupplies, player, false); ChoiceResult resultGain = player.MakeChoice(choiceGain); if (resultGain.Supply != null) player.Gain(resultGain.Supply); } }
public override void Play(Player player) { base.Play(player); SupplyCollection availableSupplies = new SupplyCollection(player._Game.Table.Supplies.Where(kvp => kvp.Value.Randomizer != null && kvp.Value.Randomizer.GroupMembership != Group.None)); CardCollection cards = new CardCollection(); Choice choice = new Choice("Name a card", this, availableSupplies, player, false); foreach (Supply supply in player._Game.Table.Supplies.Values.Union(player._Game.Table.SpecialPiles.Values)) { foreach (Type type in supply.CardTypes) { if (!choice.Supplies.Any(kvp => kvp.Value.CardType == type)) cards.Add(Card.CreateInstance(type)); } } cards.Sort(); choice.AddCards(cards); ChoiceResult result = player.MakeChoice(choice); ICard namedCard = null; if (result.Supply != null) namedCard = result.Supply; else namedCard = result.Cards[0]; player._Game.SendMessage(player, this, namedCard); if (player.CanDraw) { player.Draw(DeckLocation.Revealed); if (player.Revealed[namedCard.CardType].Count > 0) { player.AddCardsToHand(DeckLocation.Revealed); } else { player.AddCardsToDeck(player.RetrieveCardsFrom(DeckLocation.Revealed), DeckPosition.Top); } } }