コード例 #1
0
ファイル: GameState.cs プロジェクト: otac0n/Therefore
        private GameState(
            Game game,
            ReadOnlyCollection<string> playerIds,
            ReadOnlyCollection<Card> deck,
            ReadOnlyDictionary<string, int> scores,
            ReadOnlyDictionary<string, ReadOnlyCollection<Card>> hands,
            int dealer,
            int turn,
            ReadOnlyCollection<Premise> proof,
            bool isRoundOver)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }

            this.game = game;

            this.playerIds = playerIds;
            this.deck = deck;
            this.scores = scores;
            this.hands = hands;
            this.dealer = dealer;
            this.turn = turn;
            this.proof = proof;
            this.isRoundOver = isRoundOver;
        }
コード例 #2
0
ファイル: GameController.cs プロジェクト: otac0n/Therefore
        public ActionResult New()
        {
            var gameId = MvcApplication.GetNextGameId();
            var cacheKey = "Game" + gameId;
            var game = new Game(new[] { "A", "B", "C", "D" });
            HttpContext.Cache[cacheKey] = game;

            return RedirectToAction("Play", new { id = gameId });
        }
コード例 #3
0
ファイル: GameState.cs プロジェクト: otac0n/Therefore
        public GameState(Game game, IList<string> playerIds)
        {
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }

            this.game = game;

            this.playerIds = playerIds.ToList().AsReadOnly();

            var deck = ShuffleNewDeck();
            var hands = DealCards(deck, this.playerIds);
            var turn = GetNextPlayer(this.dealer, this.playerIds.Count);

            this.deck = deck.ToList().AsReadOnly();
            this.scores = playerIds.ToDictionary(p => p, p => 0).AsReadOnly();
            this.hands = hands.ToDictionary(h => h.Key, h => h.Value.AsReadOnly()).AsReadOnly();
            this.dealer = turn;
            this.turn = turn;
            this.proof = (from i in Enumerable.Range(0, 4)
                          select new Premise(new List<PlacementCard>())).ToList().AsReadOnly();
            this.isRoundOver = false;
        }