本文整理汇总了C#中CardCollection类的典型用法代码示例。如果您正苦于以下问题:C# CardCollection类的具体用法?C# CardCollection怎么用?C# CardCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CardCollection类属于命名空间,在下文中一共展示了CardCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCardsToDrag
/// <summary>
///
/// </summary>
/// <param name="pt"></param>
/// <returns></returns>
public override CardCollection GetCardsToDrag( Point pt )
{
// Loop backwards through all cards in this collection
// and when we find a card that fits the bill, we return
// that card and all cards on top of that card.
// Also note that we don't allow dragging cards which are
// face down.
int i = base.Count - 1;
for ( ; i >= 0; i-- )
{
Card c = base.m_cards[ i ];
if ( c.Contains( pt ) && c.FaceUp )
{
break;
}
}
if ( i != -1 )
{
CardCollection cards = new CardCollection( );
cards.AddRange( base.m_cards.GetRange( i, base.Count - i ) );
return cards;
}
return null;
}
示例2: TestAlternatingColors
public void TestAlternatingColors( )
{
CardCollection coll = new CardCollection( );
// An empty one is also alternating:
Assert.AreEqual( coll.IsAlternatingColors( ), true );
coll.Add( new Card( Suit.Clubs, 10, true, null ) );
// So is a collection of only one element:
Assert.AreEqual( coll.IsAlternatingColors( ), true );
// Then, add a few cards of alternating colors:
coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
coll.Add( new Card( Suit.Clubs, 7, true, null ) );
coll.Add( new Card( Suit.Diamonds, 11, true, null ) );
coll.Add( new Card( Suit.Spades, 7, true, null ) );
coll.Add( new Card( Suit.Hearts, 11, true, null ) );
coll.Add( new Card( Suit.Clubs, 7, true, null ) );
// This should hold:
Assert.AreEqual( coll.IsAlternatingColors( ), true );
// Finally, remove a card in the middle:
coll.RemoveAt( 2 );
// ... which should make it no longer alternating:
Assert.AreEqual( coll.IsAlternatingColors( ), false );
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
HttpResponse<string> response = Unirest.get("https://omgvamp-hearthstone-v1.p.mashape.com/cards?collectible=1")
.header("X-Mashape-Key", "Y6G2Ve8iAOmshQFq4sGVgvBtI1HVp1CVLrWjsnPikTu4oqy2EK")
.asJson<string>();
CardCollection collection = new CardCollection();
collection = JsonConvert.DeserializeObject<CardCollection>(response.Body);
List<Card> cards = new List<Card>();
cards.AddRange(collection.basic);
cards.AddRange(collection.classic);
cards.AddRange(collection.naxxramas);
cards.AddRange(collection.gvg);
cards.AddRange(collection.blackrock);
cards.AddRange(collection.grandTournament);
cards.AddRange(collection.leagueOfExplorers);
DataAccessLayer layer1 = new DataAccessLayer();
try
{
layer1.InsertCardsToDb(cards);
}
catch (Exception)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertBox", "alert('Kortit jo kannassa');", true);
}
//Grid.DataSource = cards as IEnumerable<Card>;
Grid.DataSource = cards as IEnumerable<Card>;
Grid.DataBind();
}
示例4: Test_DetermineWinners_FullHouse_TwoWinners
public void Test_DetermineWinners_FullHouse_TwoWinners()
{
Player winner1 = new Player("Winner1", 1000);
winner1.Cards.Add(new Card(Rank.Two, Suit.Spades));
winner1.Cards.Add(new Card(Rank.Two, Suit.Hearts));
Player winner2 = new Player("Winner2", 1000);
winner2.Cards.Add(new Card(Rank.Two, Suit.Diamonds));
winner2.Cards.Add(new Card(Rank.Two, Suit.Clubs));
CardCollection communityCards = new CardCollection();
communityCards.Add(new Card(Rank.Three, Suit.Hearts));
communityCards.Add(new Card(Rank.Six, Suit.Clubs));
communityCards.Add(new Card(Rank.King, Suit.Hearts));
communityCards.Add(new Card(Rank.King, Suit.Spades));
communityCards.Add(new Card(Rank.King, Suit.Diamonds));
HandEvaluator eval = new HandEvaluator();
Hand hand1 = eval.GetBestHand(winner1.Cards + communityCards);
Hand hand2 = eval.GetBestHand(winner2.Cards + communityCards);
Assert.AreEqual(0, HandEvaluator.Compare(hand1, hand2));
}
示例5: CheckCardExistence
internal static CardBehaviour CheckCardExistence(CardCollection cardType, GameObject player, GameObject systemObject)
{
if (player != null)
{
if(systemObject != null)
{
var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType && x.Player == player && x.System == systemObject);
return cardBehaviour;
}
else
{
var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType && x.Player == player);
return cardBehaviour;
}
}
else
{
if (systemObject != null)
{
var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType && x.System == systemObject);
return cardBehaviour;
}
else
{
var cardBehaviour = CardObjectList.Find(x => x.CardType == cardType);
return cardBehaviour;
}
}
}
示例6: CardCollection_AdditionTest
public void CardCollection_AdditionTest()
{
CardCollection left = new CardCollection();
ColorettoCard card1 = new ColorettoCard(ColorettoCardColors.Blue);
ColorettoCard card2 = new ColorettoCard(ColorettoCardColors.Brown);
ColorettoCard card3 = new ColorettoCard(ColorettoCardColors.Gray);
left = left.Add(card1);
left = left.Add(card2);
left = left.Add(card3);
CardCollection right = new CardCollection();
card1 = new ColorettoCard(ColorettoCardColors.Blue);
card2 = new ColorettoCard(ColorettoCardColors.Brown);
card3 = new ColorettoCard(ColorettoCardColors.Gray);
right = right.Add(card1);
right = right.Add(card2);
right = right.Add(card3);
CardCollection added = left + right;
Assert.AreEqual<int>(6, added.Count);
Assert.AreEqual<int>(9, added.Score);
}
示例7: GetOpponentCards
public ICollection<Card> GetOpponentCards(ICollection<Card> myCards, ICollection<Card> playedCards, Card activeTrumpCard, CardSuit suit)
{
var playerCards = new CardCollection
{
new Card(suit, CardType.Nine),
new Card(suit, CardType.Jack),
new Card(suit, CardType.Queen),
new Card(suit, CardType.King),
new Card(suit, CardType.Ten),
new Card(suit, CardType.Ace),
};
foreach (var card in myCards.Where(x => x.Suit == suit))
{
playerCards.Remove(card);
}
foreach (var card in playedCards.Where(x => x.Suit == suit))
{
playerCards.Remove(card);
}
if (activeTrumpCard != null)
{
playerCards.Remove(activeTrumpCard);
}
return playerCards;
}
示例8: getAllCards
public CardCollection getAllCards()
{
CardCollection allCards = new CardCollection ();
allCards.addList (hand.getCards());
allCards.addList (deck.getCards ());
allCards.addList (discardPile.getCards ());
return allCards;
}
示例9: Player
public Player(string name, double chips, PlayerState state, string gatewayServerId)
{
Name = name;
Chips = chips;
State = state;
GatewayServerId = gatewayServerId;
Cards = new CardCollection();
}
示例10: Hand
public Hand(CardCollection cards, Combination HandType)
: base(cards)
{
if (cards == null || cards.Count <= 0)
throw new InvalidOperationException("You cannot add an empty collection of cards to a hand.");
m_cmbBestCombination = HandType;
base.Sort();
m_cdHighCard = base[base.Count - 1];
}
示例11: AddTest
public void AddTest()
{
var cc = new CardCollection();
cc.Add(new Card("TEST1", "Test1"));
cc.Add("TEST2", new Card("TEST2", "Test2"));
// Test add with existing keyword
}
示例12: CopyToShouldWorkProperly
public void CopyToShouldWorkProperly()
{
var card1 = new Card(CardSuit.Club, CardType.Ace); // 1
var card2 = new Card(CardSuit.Spade, CardType.King); // 52
var collection = new CardCollection { card1, card2 };
var array = new Card[2];
collection.CopyTo(array, 0);
Assert.IsTrue(array.Contains(card1));
Assert.IsTrue(array.Contains(card2));
}
示例13: CreateEnemyCollection
public static CardCollection CreateEnemyCollection()
{
// Create enemy deck collection and return
CardCollection enemyDeck = new CardCollection();
foreach (string c in EnemyDeck1)
{
enemyDeck.Add(CardData.CreateCardFromName(c));
}
return enemyDeck;
}
示例14: AddCards
/// <summary>
/// SuitPile overrides the default behaviour of AddCards, since there are
/// restrictions to what kind of cards can be added where.
/// </summary>
/// <param name="cards"></param>
/// <returns></returns>
public override bool AddCards( CardCollection cards )
{
if ( cards.Count > 0
&& CanAddCard( cards[ 0 ] )
&& cards.IsAscendingRank( ) )
{
return base.AddCards( cards );
}
return false;
}
示例15: CardCollection
public static CardCollection operator +(Card c1, Card c2)
{
CardCollection summCollection = new CardCollection();
if (c1 != null)
summCollection.Add(c1);
if (c2 != null)
summCollection.Add(c2);
return summCollection;
}