public BoardInitArgs GetTestBoardInitArgs() { EnemyManager.CreateEnemy(); CardPile cardPile = new CardPile(); cardPile.InitCardPileFully(); int tmp = random.Next(4) + 1; Enemy enemy = EnemyManager.enemies[tmp - 1]; enemy.Init(cardPile); Player player = this.player; if (player == null) { player = new Player(CardBuilder.SearchCardByName("雷诺·杰克逊").NewCard()); } BoardInitArgs boardInitArgs = new BoardInitArgs { player = player, enemy = enemy, cardPile = cardPile, level = tmp }; //Debug.Log(boardInitArgs.player + "this"); return(boardInitArgs); }
public static void CreateEnemy() { lowEnemies = new List <Enemy>() { new OldMurkEye(), new SilverbackPatriarch() }; midEnemies = new List <Enemy>() { new Boom(), new Millificent(), new Jaraxxus(), new Trion() }; enemies = new List <Enemy> { lowEnemies.GetOneRandomly() }; List <Enemy> tmpEnemies = midEnemies; tmpEnemies.Shuffle(); foreach (var item in tmpEnemies) { if (enemies.Count == 3) { break; } enemies.Add(item); } enemies.Add(new Curator()); foreach (var enemy in enemies) { enemy.InitCardPile(CardPile.GetFullCardPile()); } }
/// <summary> /// Transfer the given card from source pile to target. Cannot transfer from a pile to itself. Card must /// belong to source, and not to target. /// </summary> /// <param name="mover">Specificies the movement logic used for this transfer.</param> /// <param name="source">Pile from which the card is being taken.</param> /// <param name="target">Pile the card is entering.</param> public void TransferCard(Card card, Mover mover, CardPile source, CardPile target) { if (card == null) { throw new ArgumentNullException("card"); } if (mover == null) { throw new ArgumentNullException("mover"); } ICardPile src = GetPile(source); ICardPile tar = GetPile(target); if (!src.Contains(card)) { throw new ArgumentException("This card does not belong to the source pile.", "card"); } if (tar.Contains(card)) { throw new ArgumentException("This card already belongs to the target pile.", "card"); } src.Remove(card); tar.Add(card, mover); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); Deck d = new Deck(13); Player p = new Player(); CardPile cp = new CardPile(); Console.WriteLine("Deck\n" + d); d.Shuffle(); Console.WriteLine("Deck\n" + d); p.DrawTo(6, d); Console.WriteLine("Deck\n" + d); Console.WriteLine("Player\n" + p); p.PlayCard(2, cp); Console.WriteLine("Deck\n" + d); Console.WriteLine("Player\n" + p); Console.WriteLine("CardPile\n" + cp); p.PlayCard(2, cp); Console.WriteLine("Deck\n" + d); Console.WriteLine("Player\n" + p); Console.WriteLine("CardPile\n" + cp); }
//Take the passed pile and put it on top of this one public void PlaceOnTop(CardPile <T> otherPile) { for (int i = 0; i < otherPile.Count(); i++) { this.PlaceOnTop(otherPile.DrawBottom()); } }
public Player(string nick) { _nick = nick; _score = 0; _hand = new CardPile<Card>(); _hand.SortOnDisplay = true; }
//Create Draw Pile public static CardPile SetDrawPile() { CardPile drawPile = new CardPile(true); drawPile.ShufflePile(); return(drawPile); }
private static int[] tableCardsInPlay = new int[8]; //the amount if playable cards per table. index at 1 to allow index to match table number //Game Setup public static void SetUpGame() { drawPile = new CardPile(true); discardPile = new CardPile(); suitPileOne = new CardPile(); suitPileTwo = new CardPile(); suitPileThree = new CardPile(); suitPileFour = new CardPile(); drawPile.Shuffle(); discardPile.Add(drawPile.DealOneCard()); tableau1 = TableauInitialise(1); tableau2 = TableauInitialise(2); tableau3 = TableauInitialise(3); tableau4 = TableauInitialise(4); tableau5 = TableauInitialise(5); tableau6 = TableauInitialise(6); tableau7 = TableauInitialise(7); //sets up the cards in play array, with the index at 1 tableCardsInPlay[0] = 0; for (int i = 1; i < tableCardsInPlay.Length; i++) { tableCardsInPlay[i] = 1; } }
} //end CleanBlock // /// <summary> /// Reassign the updated table /// </summary> /// <param name="tmp">CardPile: temporary table</param> /// <param name="tableNum">int: Old table number</param> /// <param name="inPlay">int: table number need to assign</param> private static void SetNewTable(CardPile tmp, int tableNum, int inPlay) { tableCardsInPlay[tableNum] = inPlay; switch (tableNum) { case 1: tableau1 = tmp; break; case 2: tableau2 = tmp; break; case 3: tableau3 = tmp; break; case 4: tableau4 = tmp; break; case 5: tableau5 = tmp; break; case 6: tableau6 = tmp; break; case 7: tableau7 = tmp; break; } }
public void AddCard(CardData card, CardPile pile) { cardList.Add(card); card.indexInDeck = cardList.Count - 1; pile.AddCard(cardList.Count - 1); SetTotalCardsInDeck(); }
[Command] void CmdPlay(GameObject cardObject) { if (Deck.gameOver || (Deck.turn % Deck.numPlayers) + 1 != assignedNumber) { // cheater! it isn't your turn return; } Deck.UpdateTurn(true); Card card = cardObject.GetComponent <Card> (); Deck.cardsInPlay [card.colorIndex - 1, card.number - 1]--; CardPile playPile = (GameObject.FindGameObjectWithTag("Column" + card.colorIndex)).GetComponent <CardPile> (); StartCoroutine(DrawCard(card.pileTag, card.pileSlot)); if (playPile.Count + 1 == card.number) { card.pileTag = "Column" + card.colorIndex; card.pileSlot = card.number - 1; if (card.number == 5) { Hints.remaining++; } Deck.CheckGameOver(true, card.colorIndex); } else { card.pileTag = "RejectedPile"; card.pileSlot = 0; Bomb.fuse--; StartCoroutine(RejectCard(cardObject)); Deck.CheckGameOver(false, card.colorIndex); } }
public void Test_Game_Shuffle(bool createDeck) { const int numberOfShuffles = 1; IBattleOutput battleOutput = new Fake_BattleOutput(); Game game = new Game(battleOutput); CardPile deck = new CardPile(); if (createDeck) { game.CreateDeck(deck); } List <Card> preShuffleCards = deck.GetAll(); deck.Shuffle(numberOfShuffles); List <Card> postShuffleCards = deck.GetAll(); Assert.True(preShuffleCards.Count == postShuffleCards.Count); if (!createDeck) { Assert.Equal <Card>(preShuffleCards, postShuffleCards); } else { Assert.NotEqual <Card>(preShuffleCards, postShuffleCards); foreach (Card card in preShuffleCards) { Assert.Contains(postShuffleCards, c => (string.Equals(c.Name, card.Name) && (c.Value == card.Value))); } } }
public void Init(CardPile cardPile) { InitCardPile(cardPile); InitUpgrade(); InitTag(); CalculateFitMap(); }
public void ShowSummary(List <Card> heros, List <Card> treasures, CardPile cardPile) { SelectBoard.selectPileAction = n => { selectPileAction?.Invoke(0); }; SelectBoard.ShowSummary(heros, treasures, cardPile); }
public void ShuffleTestForJustThreeCards() { HashSet <string> allStates = new HashSet <string>(); var objectUnderTest = new CardPile { Cards = new List <Card> { new Card { Rank = "2", Suit = Constants.Suits.Clubs }, new Card { Rank = "3", Suit = Constants.Suits.Spades }, new Card { Rank = "2", Suit = Constants.Suits.Hearts } } }; var initialState = CardPileRepresentation(objectUnderTest); allStates.Add(initialState); int numberOfShuffles = 10000; for (int i = 0; i < numberOfShuffles; i++) { objectUnderTest.Shuffle(); allStates.Add(CardPileRepresentation(objectUnderTest)); } //with that many shuffles, we should see all 6 possible states that 3 cards can be in Assert.True(allStates.Count == 6); }
public static void CheckGameOver(bool played, int color) { if (Bomb.fuse == 0 || singleton._turn == singleton.endTurn) { singleton._gameOver = true; return; } // end game if play piles are completed for (int i = 1; i <= 5; i++) { GameObject playPileObject = GameObject.FindGameObjectWithTag("Column" + i); CardPile playPile = playPileObject.GetComponent <CardPile> (); int playPileCount = playPile.Count; if (played && color == i) { playPileCount++; } if (playPileCount < 5 && cardsInPlay [i - 1, playPileCount] > 0) { singleton._gameOver = false; return; } } // nothing left to play singleton._gameOver = true; }
internal static CardPile GetFullCardPile() { CardPile cardPile = new CardPile(); cardPile.InitCardPileFully(); return(cardPile); }
public static CardPile GetEmptyCardPile() { CardPile cardPile = new CardPile(); cardPile.InitSpecialCards(); return(cardPile); }
/// <summary> /// Sets up class variables. /// </summary> public static void SetUpGame() { cardPile = new CardPile(true); numOfGamesWon[0] = 0; numOfGamesWon[1] = 0; cardPile.Shuffle(); }//end of SetUpGame
private void PairFinding() { deck = deck.Shuffle(); int found = 0; for (int trial = 0; trial < TRIALS; trial++) { Card a = rand.NextCard(); Card b = rand.NextCard(); List<Card> list = deck.ToList(); int id = -1; bool reversed = false; for (int i = 0; i < list.Count; i++) { if (list[i] == a) { if (i > 0 && list[i - 1].Rank == b.Rank) { id = i - 1; reversed = true; break; } if (i < list.Count - 1 && list[i + 1].Rank == b.Rank) { id = i; break; } } } if (id != -1) { found++; PrintLnF(string.Format("[TRIAL {0:0000}]: ", trial) + "&a&*Sequence " + a.Rank.ToCustomString() + " && " + b.Rank.ToCustomString() + " found at: &r" + id.ToString() + " &9 \t" + (reversed ? b.ToCustomString() + ", " + a.ToCustomString() : a.ToCustomString() + ", " + b.ToCustomString()) + "&r"); } else { PrintLnF(string.Format("[TRIAL {0:0000}]: ", trial) + "&c&*Sequence " + a.Rank.ToCustomString() + " && " + b.Rank.ToCustomString() + " not found.&r"); } } PrintLnF("\r&6Results:"); double pHat = (double)found / (double)TRIALS; PrintLnF(" &5p^ = " + pHat.ToString()); double sigma = Math.Sqrt((pHat * (1 - pHat)) / (double)TRIALS); PrintLnF(" &eo` = " + sigma.ToString()); double lower = pHat - (1.96 * sigma); double upper = pHat + (1.96 * sigma); PrintLnF(" &995% Confidence in [" + lower.ToString() + ", " + upper.ToString() + "]"); }
public CardDeck() { //instantiate card piles AllCards = new CardPile(); DrawPile = new CardPile(); DiscardPile = new CardPile(); ExilePile = new CardPile(); }
public void TestAddCardRunsWithoutErrors() { CardPile pile = new CardPile(); pile.AddCard(new Card(Suit.Hearts, FaceValue.Seven)); pile.AddCard(new Card(Suit.Hearts, FaceValue.Nine)); pile.AddCard(new Card(Suit.Diamonds, FaceValue.Jack)); }
public bool IsContainingSpy() { if (CardPile.Any(k => k.Key is SpyUnit)) { return(true); } return(false); }
public void AddCards(CardData[] cards, CardPile pile) { // TODO: Find a less repetitive way of doing that (reduce amount of UpdateVue called in pile)? foreach (CardData card in cards) { AddCard(card, pile); } }
public bool IsContainingStrongUnit() { if (CardPile.Any(k => (k.Key is UnitCard) && (k.Key as UnitCard).AttackValue >= 5 && !(k.Key is HeroUnit))) { return(true); } return(false); }
public static void SetUpGame() { cardPile = new CardPile(true); cardPile.Shuffle(); hands[0] = new Hand(); hands[1] = new Hand(); hands[2] = new Hand(); }
void Start() { cardPile = GetComponent <CardPile>(); gridLayout = GetComponent <GridLayoutGroup>(); rectTransform = GetComponent <RectTransform>(); cardPileWidth = rectTransform.rect.width; }
public bool IsContainingUnit() { if (CardPile.Any(k => (k.Key is UnitCard) && !(k.Key is HeroUnit))) { return(true); } return(true); }
public bool IsContainingMedic() { if (CardPile.Any(k => k.Key is MedicUnit)) { return(true); } return(false); }
public static List <Card> FullDeckInOrder() { CardPile cardPile = new CardPile(true); List <Card> allCards = cardPile.DealCards(cardPile.GetCount()); allCards.Reverse(); return(allCards); }
// A randomiser for the cards, thus, knowing cards will be different (when dealing) public static void PlayForDeal() { totalPoints[1] = 0; CardPile cardPile = new CardPile(true); cardPile.Shuffle(); hands[1].Add(cardPile.DealOneCard()); }
public static void SetupGame() { cardPile = new CardPile(true); cardPile.Shuffle(); suitPiles = new Hand[4]; FillTableaus(); FillCardPile(); }
public static CardPile<Card> GetEffectDeck(bool super) { CardPile<Card> deck = new CardPile<Card>(); deck.Add(RandomWildDrawCard.GetDeckContents(super)); deck.Add(SelfInflictedDrawThreeCard.GetDeckContents(super)); deck.Add(SelfInflictedLoseThreeCard.GetDeckContents(super)); deck.Add(QuestionCard.GetDeckContents(super)); return deck; }
public State(Action<string> spub, Action<string, string> spriv, bool super) { Send = spub; SendPriv = spriv; Players = new TurnManager(); DrawDeck = CardSetup.GetDrawDeck(super); DrawEffectDeck = CardSetup.GetEffectDeck(super); DiscardPile = new CardPile<Card>(); }
public override void SelectPile(CardPile pile) { base.SelectPile(pile); var card = pile.TopCard; card.MoveTo(_destination); Log.LogGain(Player, card); if (AfterCardGained != null) AfterCardGained(card); }
public virtual void SelectPile(CardPile pile) { if (pile != null) { CheckPile(pile); if(AfterPileSelected != null) AfterPileSelected(pile); } else { if (IsOptional == false) throw new InvalidOperationException("No pile selected, but activity is not optional!"); } IsSatisfied = true; }
private static void Load(CardType t) { // Load from 'cah_[color].txt' string file = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "cah_" + Enum.GetName(typeof(CardType), t).ToLower() + ".txt"; if (!File.Exists(file)) throw new FileNotFoundException("Failed to get card list from '" + file + "'"); CardPile<Card> pile = new CardPile<Card>(); using (StreamReader f = new StreamReader(file)) { while (!f.EndOfStream) { string l = f.ReadLine(); // Skip comments and empty strings if (String.IsNullOrWhiteSpace(l) || l.StartsWith(";")) continue; // Else use exactly what it has else pile.Add(new Card(t, l)); } } if (t == CardType.White) _white = pile; else _black = pile; }
/* * Colors always evenly distributed * * UNO: * 2 each 0-9 * 2 R * 2 S * 2 DT * 4 WILD * 4 WD4 * * Super: * 3 0-9 * 1 1337 * 3 DT * 1 DF * 3 R * 3 S * 2 SX * 4 WILD * 4 WD4 * 4 WMD3 * 4 SWD4 * 4 RWD4 * 4 WTF * 8 ! * 16 $ * 4 DH * 1 ASDF (1/15 chance) * * Super effect: * 8 SID3 * 4 RW/D * 4 3DIS * 4 ? */ public static CardPile<Card> GetDrawDeck(bool super) { CardPile<Card> deck = new CardPile<Card>(); deck.Add(AsdfCard.GetDeckContents(super)); deck.Add(DollarCard.GetDeckContents(super)); deck.Add(DrawFourCard.GetDeckContents(super)); deck.Add(DrawHandCard.GetDeckContents(super)); deck.Add(DrawTwoCard.GetDeckContents(super)); deck.Add(ExclamationCard.GetDeckContents(super)); deck.Add(NumberCard.GetDeckContents(super)); deck.Add(ReverseCard.GetDeckContents(super)); deck.Add(ReverseWildDrawFourCard.GetDeckContents(super)); deck.Add(SkipCard.GetDeckContents(super)); deck.Add(SkipXCard.GetDeckContents(super)); deck.Add(SuperWildDrawFourCard.GetDeckContents(super)); deck.Add(WildCard.GetDeckContents(super)); deck.Add(WildDrawFourCard.GetDeckContents(super)); deck.Add(WildMassDrawThreeCard.GetDeckContents(super)); deck.Add(WtfCard.GetDeckContents(super)); return deck; }
public bool IsMatch(CardPile pile) { return IsMatch(new[] {pile.TopCard}); }
public const int OFFSET_PER_CARD = 2; // px #endregion Fields #region Constructors public GCardStack(CardPile initialPile, Vector2 position = null, bool flipTop = false) { InnerPile = initialPile; CanFlipTop = flipTop; Position = position ?? new Vector2(0, 0); }
public bool IsMatch(CardPile pile) { if (pile.IsEmpty) return false; return IsMatch(new[] {pile.TopCard}); }
protected void CheckPile(CardPile pile) { if (!Specification.IsMatch(pile)) throw new ArgumentException("Pile does not match specification!", "pile"); }
public Player(string name) { Name = name; Points = 0; _hand = new CardPile<Card>(); }
public virtual void SelectPile(CardPile pile) { CheckPile(pile); AfterPileSelected(pile); IsSatisfied = true; }