Esempio n. 1
0
        /// <summary>
        ///     Only for tests
        /// </summary>
        public Player(int id, Guid guid, TeamColor team, PlayerType preferredRole,
                      PlayerBoard board, Location location)
        {
            Id                      = id;
            Team                    = team;
            Role                    = preferredRole;
            PlayerGuid              = guid;
            GameId                  = 0;
            PlayerBoard             = board;
            PlayerBoard.Players[id] = new PlayerInfo(id, team, preferredRole, location);

            _stateCoordinator = new StateCoordinator("", team, preferredRole);
        }
Esempio n. 2
0
        public void InitializePlayer(int id, Guid guid, TeamColor team, PlayerType role, PlayerBoard board,
                                     Location location, LoggingMode loggingMode)
        {
            var factory = new LoggerFactory();

            VerboseLogger = new VerboseLogger(factory.GetPlayerLogger(id), loggingMode);

            Id                      = id;
            Team                    = team;
            Role                    = role;
            PlayerGuid              = guid;
            GameId                  = 0;
            PlayerBoard             = board;
            PlayerBoard.Players[id] = new PlayerInfo(id, team, role, location);
            _stateCoordinator       = new StateCoordinator("", team, role);
        }
Esempio n. 3
0
        public Player(ICommunicationClient communicationClient, string gameName, TeamColor preferredColor,
                      PlayerType preferredRole, IErrorsMessagesFactory errorsMessagesFactory, LoggingMode loggingMode, Dictionary <TeamColor, StrategyGroup> strategyGroups)
        {
            CommunicationClient    = communicationClient;
            _gameName              = gameName;
            _preferredColor        = preferredColor;
            _preferredRole         = preferredRole;
            _errorsMessagesFactory = errorsMessagesFactory;
            _strategyGroups        = strategyGroups;

            var factory = new LoggerFactory();

            VerboseLogger = new VerboseLogger(factory.GetPlayerLogger(0), loggingMode);

            _stateCoordinator = new StateCoordinator(gameName, preferredColor, preferredRole);
            new Thread(() => CommunicationClient.Connect(HandleConnectionError, HandleResponse)).Start();
            CommunicationClient.Send(_stateCoordinator.Start());
        }
Esempio n. 4
0
 private void RestartStateCoordinator()
 {
     _stateCoordinator.StopTimers();
     _stateCoordinator = new StateCoordinator(_gameName, _preferredColor, _preferredRole);
 }