Esempio n. 1
0
        public IPlayer Start()
        {
            Console.WriteLine("Game started....");
            var allRelayConnections = (from current in NetworkComms.GetExistingConnection() where current != null select current).ToArray();

            foreach (var relayConnection in allRelayConnections)
            {
                relayConnection.SendObject("Message", "Game started...");
            }
            List <string> playerNames = this.allPlayers.Select(x => x.Name).ToList();

            foreach (InternalPlayer player in this.allPlayers)
            {
                StartGameContext StartGameContext = new StartGameContext(playerNames, this.initialMoney);
                player.StartGame(StartGameContext);
                player.Connection.SendObject("StartGameContext", StartGameContext);
            }

            while (this.allPlayers.Count(x => x.PlayerMoney.Money > 0) > 1)
            {
                var smallBlind = SmallBlinds[(this.HandsPlayed) / 10];
                this.HandsPlayed++;
                IHandLogic hand = this.HandsPlayed % 2 == 1
                               ? new TwoPlayersHandLogic(new[] { this.firstPlayer, this.secondPlayer }, this.HandsPlayed, smallBlind)
                               : new TwoPlayersHandLogic(new[] { this.secondPlayer, this.firstPlayer }, this.HandsPlayed, smallBlind);

                hand.Play();
            }

            var winner = this.allPlayers.FirstOrDefault(x => x.PlayerMoney.Money > 0);

            foreach (var player in this.allPlayers)
            {
                EndGameContext EndGameContext = new EndGameContext(winner.Name);
                player.EndGame(EndGameContext);
                player.Connection.SendObject("EndGameContext", EndGameContext);
            }

            return(winner);
        }
 public override void StartGame(StartGameContext context)
 {
     base.StartGame(context);
     this.startGameMoney = context.StartMoney;
 }
Esempio n. 3
0
 public void StartGame(StartGameContext context)
 {
     this.state.StartGame(context);
 }
Esempio n. 4
0
 public override void StartGame(StartGameContext context)
 {
     this.currentGameTotalHandsCount = 0;
     this.state.StartGame(context);
     base.StartGame(context);
 }
 public virtual void StartGame(StartGameContext context)
 {
     this.Player.StartGame(context);
 }
Esempio n. 6
0
 public virtual void StartGame(StartGameContext context)
 {
 }
 public virtual void StartGame(StartGameContext context)
 {
     this.Player.StartGame(context);
 }
 public virtual void StartGame(StartGameContext context)
 {
 }
 public override void StartGame(StartGameContext context)
 {
     this.currentGameTotalHandsCount = 0;
     this.state.StartGame(context);
     base.StartGame(context);
 }
Esempio n. 10
0
 public override void StartGame(StartGameContext context)
 {
     //this.initialMoney = context.StartMoney;
     base.StartGame(context);
 }
Esempio n. 11
0
 public override void StartGame(StartGameContext context)
 {
     base.StartGame(context);
 }
Esempio n. 12
0
 public override void StartGame(StartGameContext context)
 {
     this.Money = context.StartMoney;
     base.StartGame(context);
 }
 public void StartGame(StartGameContext context)
 {
     this.state.StartGame(context);
 }
Esempio n. 14
0
 public override void StartGame(StartGameContext context)
 {
     this.PlayerMoney = new InternalPlayerMoney(context.StartMoney);
     base.StartGame(context);
 }