本文整理汇总了C#中ICard类的典型用法代码示例。如果您正苦于以下问题:C# ICard类的具体用法?C# ICard怎么用?C# ICard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ICard类属于命名空间,在下文中一共展示了ICard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deal
/// <summary>
/// Deals the specified players.
/// </summary>
/// <param name="players">The players.</param>
/// <param name="cardsOnBoard">The cards on board.</param>
public void Deal(IList<IParticipant> players, ICard[] cardsOnBoard)
{
this.Shuffle();
int toTakeFromDeckIndex = 0;
// deal cards to players
foreach (IParticipant player in players.Where(p => p.IsInGame))
{
this.DealCardsToPlayers(player, ref toTakeFromDeckIndex);
}
// place cards on board
Point boardCardsPosition = GlobalVariables.BoardCardsPlace;
int positionCardChangeX = boardCardsPosition.X;
for (int i = 0; i < 5; i++)
{
this.DealCardsOnBoard(
cardsOnBoard,
i,
ref toTakeFromDeckIndex,
boardCardsPosition,
ref positionCardChangeX);
}
// turn the player cards up
foreach (var player in players.Where(p => p.IsInGame && p is Player))
{
player.Hand.CurrentCards[0].IsFacingUp = true;
player.Hand.CurrentCards[1].IsFacingUp = true;
}
}
示例2: SaveChangesToCard
private void SaveChangesToCard(IUserSet currentUserSet, ICard currentCard)
{
Card existingCard = FindCard(currentUserSet, currentCard);
Card modifiedCard = (Card)currentCard;
Type typeOfExistingCard = existingCard.GetType();
Type typeOfModifiedCard = modifiedCard.GetType();
List<PropertyInfo> propertiesExistingCard = new List<PropertyInfo>(typeOfExistingCard.GetRuntimeProperties());
List<PropertyInfo> propertiesModifiedCard = new List<PropertyInfo>(typeOfModifiedCard.GetRuntimeProperties());
// check if the properties are changed in the meantime. Should not be.
for (int i = 0; i < propertiesExistingCard.Count; i++)
{
if(propertiesExistingCard[i].Name == propertiesModifiedCard[i].Name)
{
propertiesExistingCard[i].SetValue(existingCard, propertiesModifiedCard[i].GetValue(modifiedCard));
}
else
{
throw new ArrayTypeMismatchException("Cannot save the modified Card information",
new Exception(
"The type of the card is changed, because the properties ofthe existing and modified cards are not the same "));
}
}
}
示例3: Verify
protected override VerifierResult Verify(Player source, ICard card, List<Player> targets)
{
if (targets == null || targets.Count == 0)
{
return VerifierResult.Partial;
}
if (targets.Count > 1)
{
return VerifierResult.Fail;
}
Player player = targets[0];
if (player == source)
{
return VerifierResult.Fail;
}
if (!ShunChaiAdditionalCheck(source, player, card))
{
return VerifierResult.Fail;
}
if (Game.CurrentGame.Decks[player, DeckType.Hand].Count == 0 &&
Game.CurrentGame.Decks[player, DeckType.DelayedTools].Count == 0 &&
Game.CurrentGame.Decks[player, DeckType.Equipment].Count == 0)
{
return VerifierResult.Fail;
}
return VerifierResult.Success;
}
示例4: Main
/// <summary>
/// The entry point of the program.
/// </summary>
private static void Main()
{
try
{
IHandEvaluator handEvaluator = new HandEvaluator();
ICard[] cards = new ICard[]
{
new Card(CardRank.Queen, CardSuit.Hearts),
new Card(CardRank.Queen, CardSuit.Spades),
new Card(CardRank.Ten, CardSuit.Hearts),
new Card(CardRank.Queen, CardSuit.Diamonds),
new Card(CardRank.Queen, CardSuit.Clubs)
};
IHand hand = new Hand(cards);
Console.WriteLine(handEvaluator.GetCategory(hand) == HandCategory.FourOfAKind);
IHand handFromString = new Hand("7♠ 5♣ 4♦ 3♦ 2♣");
Console.WriteLine(handFromString);
}
catch (ArgumentException aex)
{
Console.WriteLine(aex.Message);
}
}
示例5: Process
protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
{
IUiProxy ui = Game.CurrentGame.UiProxies[source];
if (source.IsDead) return;
List<DeckPlace> places = new List<DeckPlace>();
places.Add(new DeckPlace(dest, DeckType.Hand));
places.Add(new DeckPlace(dest, DeckType.Equipment));
places.Add(new DeckPlace(dest, DeckType.DelayedTools));
List<string> resultDeckPlace = new List<string>();
resultDeckPlace.Add(ResultDeckName);
List<int> resultDeckMax = new List<int>();
resultDeckMax.Add(1);
List<List<Card>> answer;
if (!ui.AskForCardChoice(new CardChoicePrompt(ChoicePrompt), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(true), out answer))
{
Trace.TraceInformation("Player {0} Invalid answer", source.Id);
answer = new List<List<Card>>();
answer.Add(Game.CurrentGame.PickDefaultCardsFrom(places));
}
Card theCard = answer[0][0];
if (ShunChaiDest(source, dest).DeckType == DeckType.Discard)
{
Game.CurrentGame.HandleCardDiscard(dest, new List<Card>() { theCard });
}
else
{
Game.CurrentGame.HandleCardTransferToHand(dest, source, new List<Card>() { theCard });
}
}
示例6: Process
public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard cardr)
{
Trace.Assert(dests == null || dests.Count == 0);
Trace.Assert(card is Card);
Card c = (Card)card;
Install(source, c);
}
示例7: Verify
protected override VerifierResult Verify(Player source, ICard card, List<Player> targets)
{
if (Game.CurrentGame.IsDying.Count == 0 && targets != null && targets.Count >= 1)
{
return VerifierResult.Fail;
}
if (Game.CurrentGame.IsDying.Count > 0 && (targets == null || targets.Count != 1))
{
return VerifierResult.Fail;
}
if (Game.CurrentGame.IsDying.Count == 0)
{
if (source[JiuUsed] == 1)
{
return VerifierResult.Fail;
}
}
else
{
if (targets[0] != source)
{
return VerifierResult.Fail;
}
}
return VerifierResult.Success;
}
示例8: Attack
public override void Attack(Player victim, TurnContext context, ICard source)
{
var victoryTypes = victim.Hand.OfType<IVictoryCard>()
.WithDistinctTypes()
.ToList();
if(victoryTypes.Count() > 1)
{
var activity = Activities.PutCardOfTypeFromHandOnTopOfDeck(context.Game.Log, victim,
"Select a victory card to put on top",
typeof (IVictoryCard),
source);
_activities.Add(activity);
}
else if(victoryTypes.Any())
{
var card = victoryTypes.Single();
victim.Deck.MoveToTop(card);
context.Game.Log.LogMessage("{0} put a {1} on top of the deck.", victim.Name, card.Name);
}
else
{
context.Game.Log.LogRevealHand(victim);
}
}
示例9: Process
public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard readonlyCard)
{
DeckType wuguDeck = new DeckType("WuGu");
DeckType wuguFakeDeck = new DeckType("WuGuFake");
CardsMovement move = new CardsMovement();
move.Cards = new List<Card>();
for (int i = 0; i < dests.Count; i++)
{
Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
Card c = Game.CurrentGame.DrawCard();
move.Cards.Add(c);
}
move.To = new DeckPlace(null, wuguDeck);
Game.CurrentGame.MoveCards(move);
fakeMapping = new Dictionary<Card, Card>();
Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
foreach (var c in Game.CurrentGame.Decks[null, wuguDeck])
{
var faked = new Card(c);
faked.Place = new DeckPlace(null, wuguFakeDeck);
Game.CurrentGame.Decks[null, wuguFakeDeck].Add(faked);
fakeMapping.Add(faked, c);
}
Game.CurrentGame.NotificationProxy.NotifyWuGuStart(new DeckPlace(null, wuguFakeDeck));
base.Process(source, dests, card, readonlyCard);
Game.CurrentGame.NotificationProxy.NotifyWuGuEnd();
Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
if (Game.CurrentGame.Decks[null, wuguDeck].Count > 0)
{
move = new CardsMovement();
move.Cards = new List<Card>(Game.CurrentGame.Decks[null, wuguDeck]);
move.To = new DeckPlace(null, DeckType.Discard);
Game.CurrentGame.MoveCards(move);
}
}
示例10: GetJudgeCardTrigger
public GetJudgeCardTrigger(Player p, ISkill skill, ICard card, bool permenant = false)
{
Owner = p;
jSkill = skill;
jCard = card;
doNotUnregister = permenant;
}
示例11: TagAndNotify
public override void TagAndNotify(Player source, List<Player> dests, ICard card, GameAction action = GameAction.Use)
{
if (this.IsReforging(source, null, null, dests))
{
if (card is CompositeCard)
{
foreach (Card c in (card as CompositeCard).Subcards)
{
c.Log.Source = source;
c.Log.GameAction = GameAction.Reforge;
}
}
else
{
var c = card as Card;
Trace.Assert(card != null);
c.Log.Source = source;
c.Log.GameAction = GameAction.Reforge;
}
Game.CurrentGame.NotificationProxy.NotifyReforge(source, card);
return;
}
base.TagAndNotify(source, dests, card, action);
}
示例12: CmdDestroyCard
public void CmdDestroyCard(ICard card)
{
if(card.cardtype == ECardType.MONSTER_CARD)
{
for(int i = 0; i < monsterCards.Length; i++)
{
if(card == monsterCards[i])
{
DestroyMonsterCard(i);
return;
}
}
}
else if(card.cardtype != ECardType.UNKNOWN)
{
for(int i = 0; i < effectCards.Length; i++)
{
if(card == effectCards[i])
{
DestroyEffectCard(i);
return;
}
}
}
}
示例13: Attack
public override void Attack(Player victim, TurnContext context, ICard source)
{
var swindledCard = victim.Deck.TopCard;
if(swindledCard == null)
{
context.Game.Log.LogMessage("{0} did not have any cards to be swindled.", victim.Name);
return;
}
context.Trash(victim, swindledCard);
var candidates = context.Game.Bank.Piles.Where(p => p.IsEmpty == false && p.TopCard.Cost == swindledCard.Cost);
if(candidates.Count() == 0)
{
context.Game.Log.LogMessage("There are no cards of cost {0}.", swindledCard.Cost);
}
else if (candidates.Count() == 1)
{
var pile = candidates.Single();
var card = pile.TopCard;
card.MoveTo(victim.Discards);
context.Game.Log.LogGain(victim, card);
}
else
{
var activity = Activities.SelectACardForOpponentToGain(context, context.ActivePlayer, victim, swindledCard.Cost, source);
_activities.Add(activity);
}
}
示例14: Verify
public override VerifierResult Verify(Player source, ICard card, List<Player> targets, bool isLooseVerify)
{
if (targets == null || targets.Count == 0)
{
return VerifierResult.Partial;
}
if (!isLooseVerify && targets.Count > 1)
{
return VerifierResult.Fail;
}
foreach (var player in targets)
{
if (player == source)
{
return VerifierResult.Fail;
}
if (!ShunChaiAdditionalCheck(source, player, card))
{
return VerifierResult.Fail;
}
if (Game.CurrentGame.Decks[player, DeckType.Hand].Count == 0 &&
Game.CurrentGame.Decks[player, DeckType.DelayedTools].Count == 0 &&
Game.CurrentGame.Decks[player, DeckType.Equipment].Count == 0)
{
return VerifierResult.Fail;
}
}
return VerifierResult.Success;
}
示例15: DamageDealt
public DamageDealt(IGame game, ICard source, ICardInPlay target, byte damage)
: base(game)
{
this.Source = source;
this.Target = target;
this.damage = damage;
}