本文整理汇总了C#中IGame.HasAvailable方法的典型用法代码示例。如果您正苦于以下问题:C# IGame.HasAvailable方法的具体用法?C# IGame.HasAvailable怎么用?C# IGame.HasAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGame
的用法示例。
在下文中一共展示了IGame.HasAvailable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuyPhase
public void BuyPhase(IGame game, ITurn turn, IPlayer player)
{
foreach (ICard card in player.Hand)
{
if ((card.Type & CardType.Treasure) == CardType.Treasure)
turn.PlayTreasure(card);
}
while (turn.Buys > 0)
{
if (turn.Treasure >= 8 && game.HasAvailable(Game.Base.Cards.Province))
turn.BuyCard(Game.Base.Cards.Province);
else if (turn.Treasure >= 6 && game.HasAvailable(Game.Base.Cards.Gold))
turn.BuyCard(Game.Base.Cards.Gold);
else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Silver))
turn.BuyCard(Game.Base.Cards.Silver);
else
break;
}
}
示例2: ActionPhase
public void ActionPhase(IGame game, ITurn turn, IPlayer player)
{
ICard card;
while (turn.Actions > 0)
{
card = Utils.GetCard<Village>(player.Hand);
if (card != null)
{
turn.PlayAction(card, null);
continue;
}
card = Utils.GetCard<Market>(player.Hand);
if (card != null)
{
turn.PlayAction(card, null);
continue;
}
card = Utils.GetCard<Cellar>(player.Hand);
if (card != null)
{
IList<ICard> discards = new List<ICard>();
foreach (ICard cardInHand in player.Hand)
{
if (!Object.ReferenceEquals(cardInHand, card))
{
if ((cardInHand.Type & CardType.Victory) == CardType.Victory &&
(cardInHand.Type & CardType.Action) != CardType.Action)
discards.Add(cardInHand);
else if ((Game.Base.Cards)cardInHand.CardEnum == Game.Base.Cards.Cellar)
discards.Add(cardInHand);
}
}
if (discards.Count > 0)
{
turn.PlayAction(card, discards);
continue;
}
}
card = Utils.GetCard<Smithy>(player.Hand);
if (card != null)
{
turn.PlayAction(card, null);
continue;
}
card = Utils.GetCard<Mine>(player.Hand);
if (card != null)
{
ICard targetCard = Utils.GetCard<Copper>(player.Hand);
if (targetCard != null && game.HasAvailable(Game.Base.Cards.Silver))
{
turn.PlayAction(card, new Mine.MineData { Card = targetCard, TargetType = Game.Base.Cards.Silver });
continue;
}
targetCard = Utils.GetCard<Silver>(player.Hand);
if (targetCard != null && game.HasAvailable(Game.Base.Cards.Gold))
{
turn.PlayAction(card, new Mine.MineData { Card = targetCard, TargetType = Game.Base.Cards.Gold });
continue;
}
}
card = Utils.GetCard<Militia>(player.Hand);
if (card != null)
{
turn.PlayAction(card, null);
continue;
}
card = Utils.GetCard<Woodcutter>(player.Hand);
if (card != null)
{
turn.PlayAction(card, null);
continue;
}
card = Utils.GetCard<Moat>(player.Hand);
if (card != null)
{
turn.PlayAction(card, null);
continue;
}
break;
}
}
示例3: BuyPhase
public void BuyPhase(IGame game, ITurn turn, IPlayer player)
{
foreach (ICard card in player.Hand)
{
if ((card.Type & CardType.Treasure) == CardType.Treasure)
turn.PlayTreasure(card);
}
while (turn.Buys > 0)
{
bool bought = true;
if (turn.Treasure >= 8 && game.HasAvailable(Game.Base.Cards.Province))
turn.BuyCard(Game.Base.Cards.Province);
else if (turn.Treasure >= 6 && game.HasAvailable(Game.Base.Cards.Gold))
turn.BuyCard(Game.Base.Cards.Gold);
else if (turn.Treasure >= 5 && game.HasAvailable(Game.Base.Cards.Mine) && (Count(player, "Mine") / Count(player, "Cards")) < TuningParameters.Get<double>("MineRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Mine);
Increment(player, "Mine");
}
else if (turn.Treasure >= 5 && game.HasAvailable(Game.Base.Cards.Market) && (Count(player, "Market") / Count(player, "Cards")) < TuningParameters.Get<double>("MarketRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Market);
Increment(player, "Market");
}
else if (turn.Treasure >= 4 && game.HasAvailable(Game.Base.Cards.Smithy) && (Count(player, "Smithy") / Count(player, "Cards")) < TuningParameters.Get<double>("SmithyRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Smithy);
Increment(player, "Smithy");
}
else if (turn.Treasure >= 4 && game.HasAvailable(Game.Base.Cards.Militia) && (Count(player, "Militia") / Count(player, "Cards")) < TuningParameters.Get<double>("MilitiaRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Militia);
Increment(player, "Militia");
}
else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Village) && (Count(player, "Village") / Count(player, "Cards")) < TuningParameters.Get<double>("VillageRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Village);
Increment(player, "Village");
}
else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Woodcutter) && (Count(player, "Woodcutter") / Count(player, "Cards")) < TuningParameters.Get<double>("WoodcutterRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Woodcutter);
Increment(player, "Woodcutter");
}
else if (turn.Treasure >= 3 && game.HasAvailable(Game.Base.Cards.Silver))
turn.BuyCard(Game.Base.Cards.Silver);
else if (turn.Treasure >= 2 && game.HasAvailable(Game.Base.Cards.Cellar) && (Count(player, "Cellar") / Count(player, "Cards")) < TuningParameters.Get<double>("CellarRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Cellar);
Increment(player, "Cellar");
}
else if (turn.Treasure >= 2 && game.HasAvailable(Game.Base.Cards.Moat) && (Count(player, "Moat") / Count(player, "Cards")) < TuningParameters.Get<double>("MoatRatio", 0))
{
turn.BuyCard(Game.Base.Cards.Moat);
Increment(player, "Moat");
}
else if (turn.Treasure >= 2 && game.HasAvailable(Game.Base.Cards.Estate))
turn.BuyCard(Game.Base.Cards.Estate);
else
bought = false;
if (bought)
{
Increment(player, "Cards");
continue;
}
else
break;
}
}