public static ValueProvider <ReadableCard, Controlled> FromController() { ValueProvider <Writable_GamePlayer, Controlled> controllerProvider = new WritableController_Provider(); ValueProvider <ReadableCard, Writable_GamePlayer> cardProvider = new DrawFromDeck_Provider(); return(new ChainProvider <ReadableCard, Writable_GamePlayer, Controlled>(cardProvider, controllerProvider)); }
// A DrawEffect that has its controller draw 1 card from his/her deck public DrawEffect() { this.Initialize(new WritableController_Provider(), DrawFromDeck_Provider.FromController(), new ConstantValueProvider <int, Controlled>(1)); }
// A DrawEffect that has a particular player draw 1 card from his/her deck public DrawEffect(ValueProvider <Writable_GamePlayer, Controlled> playerProvider) { this.Initialize(playerProvider, DrawFromDeck_Provider.FromController(), new ConstantValueProvider <int, Controlled>(1)); }
public Game NewGame(List <TournamentPlayer> players) { if (players.Count != 2) { throw new ArgumentException("Hearthstone games must have exactly 2 players"); } Game game = new Game(this); int numBonusCards = 0; foreach (TournamentPlayer templatePlayer in players) { if (templatePlayer.MainDeck.Count() != this.Starting_DeckSize) { throw new ArgumentException("Hearthstone decks must start with exactly 30 cards"); } Writable_GamePlayer newPlayer = new Writable_GamePlayer(templatePlayer); newPlayer.InitializeHealth(30); game.AddPlayer(newPlayer); // draw a bunch of cards from the player's deck DrawEffect drawEffect = new DrawEffect(new ConstantValueProvider <Writable_GamePlayer, Controlled>(newPlayer), DrawFromDeck_Provider.FromController(), new ConstantValueProvider <int, Controlled>(this.Starting_HandSize + numBonusCards)); drawEffect.ControllerID = newPlayer.GetID((Readable_GamePlayer)null); drawEffect.Process(game); // potentially draw a Coin too DrawEffect bonusCards = new DrawEffect(new ConstantValueProvider <Writable_GamePlayer, Controlled>(newPlayer), new ConstantValueProvider <ReadableCard, Controlled>(HearthstoneReferee.Coin), new ConstantValueProvider <int, Controlled>(numBonusCards)); bonusCards.ControllerID = newPlayer.GetID((Readable_GamePlayer)null); bonusCards.Process(game); // each player gets one more card than the previous and one additional Coin numBonusCards++; } return(game); }