public GameEngine(IPrinter printer, IReader inputReader, CommandFactory commandFactory, Validator validator, Game game)
 {
     this.Scoreboard = Scoreboard.Instance;
     this.Printer = printer;
     this.InputReader = inputReader;
     this.CommandFactory = commandFactory;
     this.Validator = validator;
     this.Game = game;
 }
Пример #2
0
 public IEnumerable <Common.Score> GetScoresPerGame(Common.Game game)
 {
     return(controller.GetScoresPerGame(game.ToPOCO()).Select(s => s.ToDTO()));
 }
Пример #3
0
 public Common.Score CreateScore(int points, Common.Game game, Common.User user)
 {
     return(controller.CreateScore(points, game.ToPOCO(), user.ToPOCO()).ToDTO());
 }
Пример #4
0
        private static void CheckForLonelyPlayers()
        {
            int contadorSolitarios = listaJogadores.Count(x => x.PlayerStatus == PlayerStatus.Waiting);
            if (contadorSolitarios >= 2)
            {
                while (contadorSolitarios > 1)
                {
                    Player player1 = listaJogadores.Find(x => x.PlayerStatus == PlayerStatus.Waiting);
                    Player player2 = listaJogadores.Find(x => x.PlayerStatus == PlayerStatus.Waiting && x != player1);

                    player1.PlayerStatus = PlayerStatus.Playing;
                    player2.PlayerStatus = PlayerStatus.Playing;

                    //Verificar equipas
                    if (player1.Equipa == player2.Equipa)
                    {
                        if (player1.Equipa == Team.Alliance)
                        {
                            player2.Equipa = Team.Coalition;
                        }
                        else
                        {
                            player2.Equipa = Team.Alliance;
                        }
                    }

                    Game jogo = new Game(player1, player2);
                    listaJogos.Add(jogo);
                    player1.CurrentGame = jogo;
                    player2.CurrentGame = jogo;

                    if (player1.Equipa == Team.Alliance)
                    {
                        SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamAlliance), player1);
                        SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamCoalition), player2);
                    }
                    else
                    {
                        SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamAlliance), player2);
                        SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamCoalition), player1);
                    }

                    IniciarJogo(player1, player2, jogo);

                    Console.WriteLine("\nNovo jogo começado entre jogadores solitários.");
                    EscreverStats();

                    contadorSolitarios -= 2;
                }
            }
        }
Пример #5
0
        private static void MatchMaking(Player player)
        {
            Player waitingPlayer = listaJogadores.Find(x => x.PlayerStatus == PlayerStatus.Waiting);

            if (waitingPlayer != null)
            {
                //Temos um jogador à espera de adversário!
                waitingPlayer.PlayerStatus = PlayerStatus.Playing;
                player.PlayerStatus = PlayerStatus.Playing;
                Game jogo = new Game(waitingPlayer, player);
                listaJogos.Add(jogo);
                waitingPlayer.CurrentGame = jogo;
                player.CurrentGame = jogo;

                Console.WriteLine("Novo jogador iniciou um novo jogo!");

                if (player.Equipa == Team.Alliance)
                {
                    SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamAlliance), player);
                    SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamCoalition), waitingPlayer);
                }
                else
                {
                    SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamCoalition), player);
                    SendMessage(new ControlMessage(MessageType.Control, ControlCommand.TeamAlliance), waitingPlayer);
                }

                IniciarJogo(waitingPlayer, player, jogo);
            }
            else
            {
                player.PlayerStatus = PlayerStatus.Waiting;
                Console.WriteLine("Novo jogador foi colocado em espera.");
                SendMessage(new ControlMessage(MessageType.Control, ControlCommand.Lobby), player);
            }
        }
Пример #6
0
 private static void IniciarJogo(Player player1, Player player2, Game jogo)
 {
     player1.PlayerStatus = PlayerStatus.Playing;
     player2.PlayerStatus = PlayerStatus.Playing;
     if (random.NextDouble() > 0.5)
     {
         SendMessage(new ControlMessage(MessageType.Control, ControlCommand.StartGameYourTurn), player1);
         SendMessage(new ControlMessage(MessageType.Control, ControlCommand.StartGameAdversaryTurn), player2);
         jogo.currentPlayer = player1;
     }
     else
     {
         SendMessage(new ControlMessage(MessageType.Control, ControlCommand.StartGameAdversaryTurn), player1);
         SendMessage(new ControlMessage(MessageType.Control, ControlCommand.StartGameYourTurn), player2);
         jogo.currentPlayer = player2;
     }
 }
Пример #7
0
 public bool SaveGame(Game game)
 {
     return this._dalLogics.SaveGame(game);
 }