public virtual WritableCard Clone(WritableCard outputType) { WritableCard clone = new WritableCard(); clone.CopyFrom(this); return(clone); }
public TournamentPlayer DesignNewDeck(TournamentPlayer player, Tournament Tournament) { TournamentPlayer newPlayer = player.Clone(); // Choose a new random card IList <ReadableCard> legalCards = player.Referee.LegalCards; WritableCard newCard = legalCards[player.Random.Next(legalCards.Count)].Clone((WritableCard)null); newCard.ID = IDFactory.NewID(); // replace an existing card with the new card newPlayer.RemoveCard(newPlayer.MainDeck.First()); newPlayer.AddCard(newCard); return(newPlayer); }
public Writable_GamePlayer(TournamentPlayer source) { this.Initialize(); // copy the deck and keep a pointer to the strategy LinkedList <ReadableCard> cards = new LinkedList <ReadableCard>(); foreach (ReadableCard readableCard in source.MainDeck) { WritableCard writableCard = readableCard.Clone((WritableCard)null); writableCard.ControllerID = this.GetID((Readable_GamePlayer)null); cards.AddLast(writableCard); } this.Deck = WritableQueue <ReadableCard> .ShuffledQueue(cards); this.sourcePlayer = source; }
public TournamentPlayer(Random random, Referee referee) { this.Random = random; this.Referee = referee; // make a random deck this.Strategy = new MiniMaxStrategy(new DefaultHearthstoneGameEvaluator(), 1000); int i; LinkedList <ReadableCard> cards = new LinkedList <ReadableCard>(); IList <ReadableCard> legalCards = referee.LegalCards; for (i = 0; i < referee.Starting_DeckSize; i++) { WritableCard newCard = legalCards[this.Random.Next(legalCards.Count)].Clone((WritableCard)null); //WritableCard newCard = legalCards[0].Clone((WritableCard)null); newCard.ID = IDFactory.NewID(); cards.AddLast(newCard); } this.mainDeck = cards; // set up some mutation strategies this.MutationCounts = new Dictionary <DeckMutationStrategy, double>(); this.MutationCounts[new DeckMutationStrategy()] = 6; }
public override void Process(Game game) { Writable_GamePlayer player = null; int numCards = this.numCards_provider.GetValue(this, game, default(int)); if (numCards >= 1) { player = this.playerProvider.GetValue(this, game, (Writable_GamePlayer)null); } for (int i = 0; i < numCards; i++) { // draw another card ReadableCard card = this.cardProvider.GetValue(this, game, (ReadableCard)null); if (card != null && card.Get_ControllerID() == null) { // This only ever happens if the card isn't in the game yet, so it works to just clone it here WritableCard writable = card.Clone((WritableCard)null); writable.ControllerID = this.ControllerID; card = writable; } player.TryToDrawCard(card, game); } }
public override WritableCard Clone(WritableCard outputType) { return(this.Clone((Writable_MonsterCard)null)); }