public Game(Random random, GameConfig gameConfig, IGameLog gameLog) { this.random = random; this.gameConfig = gameConfig; this.gameLog = gameLog; this.gameIndex = Game.RecycledGameIndices.GetInteger(); }
public void AddGainActivity(IGameLog log, Player player, CardCost upToCost, ICard source) { var activity = Activities.GainACardCostingUpToX(log, player, upToCost, player.Hand, source); activity.Specification.CardTypeRestriction = typeof(ITreasureCard); _activities.Add(activity); }
public static IActivity ChooseYesOrNo(IGameLog log, Player player, string message, ICard source, Action ifYes, Action ifNo) { var choiceActivity = new ChoiceActivity(log, player, message, source, Choice.Yes, Choice.No); choiceActivity.ActOnChoice = c => { if (c == Choice.Yes) { if (ifYes != null) { ifYes(); } } else { if (ifNo != null) { ifNo(); } } }; return(choiceActivity); }
public WebJobGame(IGameLog log, int numberOfColumns = 7, int numberOfRows = 6, int numberToWin = 4) { this.board = new Board(numberOfColumns, numberOfRows); this.rules = new Rules(numberToWin); this.numberToWin = numberToWin; this.log = log; }
public GameState( IGameLog gameLog, IPlayerAction[] players, GameConfig gameConfig, Random random, IEnumerable<CardCountPair>[] startingDeckPerPlayer = null) { int playerCount = players.Length; this.gameLog = gameLog; this.cardGameSubset = gameConfig.cardGameSubset; this.supplyPiles = gameConfig.GetSupplyPiles(playerCount, random); this.nonSupplyPiles = gameConfig.GetNonSupplyPiles(); this.mapCardToPile = new MapOfCards<PileOfCards>(this.cardGameSubset); this.BuildMapOfCardToPile(); this.players = new PlayerCircle(playerCount, players, this.gameLog, random, this.cardGameSubset); this.hasPileEverBeenGained = new MapPileOfCardsToProperty<bool>(this.supplyPiles); this.pileEmbargoTokenCount = new MapPileOfCardsToProperty<int>(this.supplyPiles); this.trash = new BagOfCards(this.cardGameSubset); this.GainStartingCards(gameConfig); this.players.AllPlayersDrawInitialCards(gameConfig); foreach (PileOfCards cardPile in this.supplyPiles) { cardPile.ProtoTypeCard.DoSpecializedSetupIfInSupply(this); } }
internal PlayerState(IPlayerAction actions, int playerIndex, IGameLog gameLog, Random random, CardGameSubset gameSubset) { this.gameLog = gameLog; this.actions = new PlayerActionWithSelf(actions, this); this.playPhase = PlayPhase.NotMyTurn; this.random = random; this.playerIndex = playerIndex; // duplicates this.allOwnedCards = new BagOfCards(gameSubset); this.cardsInPlay = new BagOfCards(gameSubset, this.allOwnedCards); this.cardsInPlayAtBeginningOfCleanupPhase = new BagOfCards(gameSubset); // partition this.islandMat = new BagOfCards(gameSubset, this.allOwnedCards); this.nativeVillageMat = new BagOfCards(gameSubset, this.allOwnedCards); this.deck = new ListOfCards(gameSubset, this.allOwnedCards); this.discard = new BagOfCards(gameSubset, this.allOwnedCards); this.cardsBeingPlayed = new ListOfCards(gameSubset, this.allOwnedCards); // a stack for recursion this.cardsBeingRevealed = new BagOfCards(gameSubset, this.allOwnedCards); this.hand = new BagOfCards(gameSubset, this.allOwnedCards); this.cardsPlayed = new BagOfCards(gameSubset, this.cardsInPlay); this.durationCards = new BagOfCards(gameSubset, this.cardsInPlay); this.cardsToReturnToHandAtStartOfTurn = new BagOfCards(gameSubset, this.allOwnedCards); this.cardToPass = new SingletonCardHolder(this.allOwnedCards); this.cardBeingDiscarded = new ListOfCards(gameSubset, this.allOwnedCards); this.turnCounters = new PlayerTurnCounters(gameSubset); }
public SelectFromRevealedCardsActivity(IGameLog log, Player player, RevealZone revealZone, string message, ISelectionSpecification selectionSpecification, ICard source) : base(log, player, message, selectionSpecification, source) { RevealedCards = revealZone; // HACK. I'm ignoring the activity type on the selection specification. Not sure what to do here. Type = ActivityType.SelectFromRevealed; }
public SelectFromRevealedCardsActivity(IGameLog log, Player player, RevealZone revealZone, string message, ISelectionSpecification selectionSpecification) : base(log, player, message, selectionSpecification) { RevealedCards = revealZone; // HACK. I'm ignoring the activity type on the selection specification. Not sure what to do here. Type = ActivityType.SelectFromRevealed; }
public static ISelectCardsActivity PutCardFromHandOnTopOfDeck(IGameLog log, Player player, string message) { return new SelectCardsActivity (log, player, message, SelectionSpecifications.SelectExactlyXCards(1)) { AfterCardsSelected = cards => player.Deck.MoveToTop(cards.Single()) }; }
public static IActivity SelectARevealedCardToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, string message) { return new SelectFromRevealedCardsActivity(log, player, revealZone, message, SelectionSpecifications.SelectExactlyXCards(1)) { AfterCardsSelected = cards => player.Deck.MoveToTop(cards.Single()) }; }
public static IEnumerable<IActivity> SelectMultipleRevealedCardsToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone) { var count = revealZone.Count(); return count.Items( (i) => SelectARevealedCardToPutOnTopOfDeck(log, player, revealZone, string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count)) ); }
protected ActivityBase(IGameLog log, Player player, string message, ActivityType type) { Log = log; Player = player; Message = message; Type = type; Id = Guid.NewGuid(); }
public void LogReveal(IGameLog log) { if(this.CardCount > 0) log.LogMessage("{0} revealed {1}.", Owner.Name, this); else { log.LogMessage("{0} revealed nothing.", Owner.Name); } }
private PlayerState[] players; // circular list, higher numbers to the left; #endregion Fields #region Constructors public PlayerCircle(int playerCount, IPlayerAction[] players, IGameLog gameLog, Random random, CardGameSubset gameSubset) { this.players = new PlayerState[playerCount]; for (int playerIndex = 0; playerIndex < this.players.Length; ++playerIndex) { this.players[playerIndex] = new PlayerState(players[playerIndex], playerIndex, gameLog, random, gameSubset); } this.currentPlayerIndex = 0; }
public Engine(SquareDiagonalMap map, IGameLog log) { Map = map; Turn = 0; Log = log; OnPreTurn = PreTurnLog; OnPostTurn = PostTurnLog; OnTurn = TurnLog; }
protected ActivityBase(IGameLog log, Player player, string message, ActivityType type, ICard source) { Log = log; Player = player; Message = message; Type = type; Id = Guid.NewGuid(); Hint = ActivityHint.None; Source = source == null ? string.Empty : source.Name; }
public void LogReveal(IGameLog log) { if (this.CardCount > 0) { log.LogMessage("{0} revealed {1}.", Owner.Name, this); } else { log.LogMessage("{0} revealed nothing.", Owner.Name); } }
public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules, IGameLog log) { if (GetType().Assembly.Location.Contains("TakeForever")) { System.Threading.Thread.Sleep(TimeSpan.FromMinutes(10)); } if (_random.NextDouble() > 0.5) { return Round1Move.Paper; } return Round1Move.Rock; }
public Manager(IGameLog managerLog, IGameLog gameLog, TRepository gameTypesRepository) { _log = managerLog; _gameLog = gameLog; _repository = gameTypesRepository; EventInfo[] events = typeof(Tdest).GetEvents(); foreach (var ev in events) { _possibleEvents[ev.Name] = ev; } }
public static ISelectCardsActivity PutCardFromHandOnTopOfDeck(IGameLog log, Player player, string message, ICard source) { return new SelectCardsActivity (log, player, message, SelectionSpecifications.SelectExactlyXCards(1), source) { AfterCardsSelected = cards => { player.Deck.MoveToTop(cards.Single()); log.LogMessage("{0} put a card on top of the deck", player.Name); }, Hint = ActivityHint.RedrawCards }; }
public static SelectPileActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, CardZone destination) { return new SelectPileActivity(log, player, string.Format("Select a card to gain of cost {0} or less", cost), SelectionSpecifications.SelectPileCostingUpToX(cost)) { AfterPileSelected = pile => { var card = pile.TopCard; card.MoveTo(destination); log.LogGain(player, card); } }; }
public static ISelectCardsActivity PutCardFromHandOnTopOfDeck(IGameLog log, Player player, string message, ICard source) { return(new SelectCardsActivity (log, player, message, SelectionSpecifications.SelectExactlyXCards(1), source) { AfterCardsSelected = cards => { player.Deck.MoveToTop(cards.Single()); log.LogMessage("{0} put a card on top of the deck.", player.Name); }, Hint = ActivityHint.RedrawCards }); }
public static SelectPileActivity GainACardCostingExactlyX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source) { return new SelectPileActivity(log, player, string.Format("Select a card to gain with a cost of exactly {0}", cost), SelectionSpecifications.SelectPileCostingExactlyX(cost), source) { AfterPileSelected = pile => { var card = pile.TopCard; card.MoveTo(destination); log.LogGain(player, card); }, Hint = ActivityHint.GainCards }; }
public Game(IEnumerable <Player> players, CardBank bank, IGameLog log) { if (!players.Any()) { throw new ArgumentException("There must be at least one player"); } _players = new List <Player>(players); Bank = bank; Log = log; Trash = new TrashPile(); _gameTurns = GameTurns().GetEnumerator(); _gameTurns.MoveNext(); }
public Game(IEnumerable<Player> players, CardBank bank, IGameLog log) { if(!players.Any()) throw new ArgumentException("There must be at least one player"); _players = new List<Player>(players); Bank = bank; Log = log; Trash = new TrashPile(); _gameTurns = GameTurns().GetEnumerator(); _gameTurns.MoveNext(); }
public static ISelectCardsActivity PutCardOfTypeFromHandOnTopOfDeck(IGameLog log, Player player, string message, Type cardType, ICard source) { var spec = SelectionSpecifications.SelectExactlyXCards(1); spec.CardTypeRestriction = cardType; return new SelectCardsActivity (log, player, message, spec, source) { AfterCardsSelected = cards => { var card = cards.Single(); player.Deck.MoveToTop(card); log.LogMessage("{0} put a {1} on top of the deck.", player.Name, card.Name); }, Hint = ActivityHint.RedrawCards }; }
public static IActivity SelectARevealedCardToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, string message, ICard source) { return(new SelectFromRevealedCardsActivity(log, player, revealZone, message, SelectionSpecifications.SelectExactlyXCards(1), source) { AfterCardsSelected = cards => { player.Deck.MoveToTop(cards.Single()); if (revealZone.CardCount == 1) { var lastCard = revealZone.Single(); player.Deck.MoveToTop(lastCard); //log.LogMessage("{0} put a {1} on top.", player.Name, lastCard.Name); } }, Hint = ActivityHint.RedrawCards }); }
public static ISelectCardsActivity PutCardOfTypeFromHandOnTopOfDeck(IGameLog log, Player player, string message, Type cardType, ICard source) { var spec = SelectionSpecifications.SelectExactlyXCards(1); spec.CardTypeRestriction = cardType; return(new SelectCardsActivity (log, player, message, spec, source) { AfterCardsSelected = cards => { var card = cards.Single(); player.Deck.MoveToTop(card); log.LogMessage("{0} put a {1} on top of the deck.", player.Name, card.Name); }, Hint = ActivityHint.RedrawCards }); }
public static IActivity GainAnActionCardCostingUpToX(IGameLog log, Player player, int cost, ICard source, bool optional) { var activity = new SelectPileActivity(log, player, string.Format("Select an action card to gain of cost {0} or less.", cost), SelectionSpecifications.SelectPileCostingUpToX(cost), source) { AfterPileSelected = pile => { var card = pile.TopCard; card.MoveTo(player.Discards); log.LogGain(player, card); }, Hint = ActivityHint.GainCards }; activity.Specification.CardTypeRestriction = typeof(IActionCard); activity.IsOptional = optional; return(activity); }
public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules, IGameLog log) { string youLastMove = you.LastMove == null ? String.Empty : you.LastMove.ToString().Trim(); string opponentLastMove = opponent.LastMove == null ? String.Empty : opponent.LastMove.ToString().Trim(); string url = String.Format(template, this.teamUrl, this.roundGuid, youLastMove, you.Points, you.TeamName, opponentLastMove, opponent.Points, opponent.TeamName, rules.MaximumGames, rules.PointsToWin); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { string move = new StreamReader(stream).ReadToEnd(); return Round1Move.Moves[move]; } } }
public SelectCardsActivity(IGameLog log, Player player, string message, ISelectionSpecification specification) : base(log, player, message, specification.ActivityType) { Specification = specification; }
public void AddGainActivity(IGameLog log, Player player, CardCost upToCost) { var activity = Activities.GainACardCostingUpToX(log, player, upToCost, player.Hand); activity.Specification.CardTypeRestriction = typeof (ITreasureCard); _activities.Add(activity); }
public GainACardActivity(IGameLog log, Player player, string message, ISelectionSpecification specification, CardZone destination, ICard source) : base(log, player, message, specification, source) { _destination = destination; Hint = ActivityHint.GainCards; }
public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, ICard source) { return GainACardCostingUpToX(log, player, cost, player.Discards, source); }
public static IActivity ChooseYesOrNo(IGameLog log, Player player, string message, ICard source, Action ifYes) { return(ChooseYesOrNo(log, player, message, source, ifYes, null)); }
public ChoiceActivity(IGameLog log, Player player, string message, ICard source, params Choice[] options) : base(log, player, message, ActivityType.MakeChoice, source) { AllowedOptions = options; }
public static IEnumerable<ISelectCardsActivity> PutMultipleCardsFromHandOnTopOfDeck(IGameLog log, Player player, int count) { return count.Items(i => PutCardFromHandOnTopOfDeck(log, player, string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count))); }
public static ISelectCardsActivity SelectActionToPlayMultipleTimes(TurnContext context, Player player, IGameLog log, ICard source, int count) { var activity = new SelectCardsActivity( log, player, string.Format("Select an action to play {0} times", count), SelectionSpecifications.SelectExactlyXCards(1), source); activity.Hint = ActivityHint.PlayCards; activity.Specification.CardTypeRestriction = typeof(IActionCard); activity.AfterCardsSelected = cards => { var actionCard = cards.OfType <IActionCard>().Single(); log.LogMessage("{0} selected {1} to be played {2} times.", player.Name, actionCard.Name, count); actionCard.MoveTo(context.ActivePlayer.PlayArea); count.Times(() => context.AddEffect(source, new PlayCardEffect(actionCard))); }; return(activity); }
public static GainACardActivity GainACardCostingExactlyX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source) { return(new GainACardActivity(log, player, string.Format("Select a card to gain with a cost of exactly {0}.", cost), SelectionSpecifications.SelectPileCostingExactlyX(cost), destination, source)); }
public ChooseBasedOnRevealedCardsActivity(IGameLog log, Player player, RevealZone revealZone, string message, ICard source, params Choice[] options) : base(log, player, message, source, options) { RevealedCards = revealZone; }
public ConfigurationLoader(IGameLog log) { _log = log; }
public Move MakeMove(IPlayer you, IPlayer opponent, GameRules rules, IGameLog log) { return moves[random.Next(3)]; }
public GainUtility(IGameLog log, CardBank bank, Player player) { _log = log; _player = player; _bank = bank; }
public static SelectPileActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost) { return GainACardCostingUpToX(log, player, cost, player.Discards); }
public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source) { return(new GainACardActivity(log, player, string.Format("Select a card to gain of cost {0} or less.", cost), SelectionSpecifications.SelectPileCostingUpToX(cost), destination, source)); }
public static IActivity ChooseYesOrNo(IGameLog log, Player player, string message, Action ifYes, Action ifNo) { var choiceActivity = new ChoiceActivity(log, player, message, Choice.Yes, Choice.No); choiceActivity.ActOnChoice = c => { if (c == Choice.Yes) { if (ifYes != null) ifYes(); } else { if(ifNo != null) ifNo(); } }; return choiceActivity; }
public SelectPileActivity(IGameLog log, Player player, string message, ISelectionSpecification specification, ICard source) : base(log, player, message, specification.ActivityType, source) { Specification = specification; }
public static IActivity ChooseYesOrNo(IGameLog log, Player player, string message, Action ifYes) { return ChooseYesOrNo(log, player, message, ifYes, null); }
public static ISelectCardsActivity SelectActionToPlayMultipleTimes(TurnContext context, Player player, IGameLog log, ICard source, int count) { var activity = new SelectCardsActivity( log, player, string.Format("Select an action to play {0} times", count), SelectionSpecifications.SelectExactlyXCards(1), source); activity.Hint = ActivityHint.PlayCards; activity.Specification.CardTypeRestriction = typeof(IActionCard); activity.AfterCardsSelected = cards => { var actionCard = cards.OfType<IActionCard>().Single(); log.LogMessage("{0} selected {1} to be played {2} times.", player.Name, actionCard.Name, count); actionCard.MoveTo(context.ActivePlayer.PlayArea); count.Times(() => context.AddEffect(source, new PlayCardEffect(actionCard))); }; return activity; }
public static IEnumerable <IActivity> SelectMultipleRevealedCardsToPutOnTopOfDeck(IGameLog log, Player player, RevealZone revealZone, ICard source) { var count = revealZone.Count(); if (count == 1) { throw new ArgumentException("The reveal zone only contains one card. Cannot select multiples."); } return(count.Items( (i) => SelectARevealedCardToPutOnTopOfDeck(log, player, revealZone, string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count), source) ).Take(count - 1)); }
public Service4(IGameLog log, TypeRepository rep) { }
public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, ICard source) { return(GainACardCostingUpToX(log, player, cost, player.Discards, source)); }
public static GainACardActivity GainACardCostingUpToX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source) { return new GainACardActivity(log, player, string.Format("Select a card to gain of cost {0} or less.", cost), SelectionSpecifications.SelectPileCostingUpToX(cost), destination, source); }
public static IEnumerable <ISelectCardsActivity> PutMultipleCardsFromHandOnTopOfDeck(IGameLog log, Player player, int count, ICard source) { return(count.Items(i => PutCardFromHandOnTopOfDeck(log, player, string.Format("Select the {0} (of {1}) card to put on top of the deck.", i.ToOrderString(), count), source))); }
public static GainACardActivity GainACardCostingExactlyX(IGameLog log, Player player, CardCost cost, CardZone destination, ICard source) { return new GainACardActivity(log, player, string.Format("Select a card to gain with a cost of exactly {0}.", cost), SelectionSpecifications.SelectPileCostingExactlyX(cost), destination, source); }
public MatchRepository(IDataContextWrapper context, IGameLog gameLog) { _context = context; _gameLog = gameLog; }