Example #1
0
        /// <summary>
        /// Creates IGS game controller
        /// </summary>
        /// <param name="gameInfo">Game info</param>
        /// <param name="ruleset">Ruleset</param>
        /// <param name="players">Players</param>
        /// <param name="serverConnection">Connection to IGS server</param>
        public IgsGameController(
            IgsGameInfo gameInfo,
            IRuleset ruleset,
            PlayerPair players,
            IgsConnection serverConnection) :
            base(gameInfo, ruleset, players, serverConnection)
        {
            Info = gameInfo;

            //create and register connector
            IgsConnector = new IgsConnector(this, serverConnection);
            Chat         = new ChatService(IgsConnector);
            RegisterConnector(IgsConnector);
            Server = serverConnection;
            InitializeServer(serverConnection);
        }
Example #2
0
        /// <summary>
        /// Registers a IGS game connector
        /// </summary>
        /// <param name="connector">Connector</param>
        internal void RegisterConnector(IgsConnector connector)
        {
            if (connector == null)
            {
                throw new ArgumentNullException(nameof(connector));
            }
            if (_availableConnectors.ContainsKey(connector.GameId))
            {
                // (Petr) Right, so, the way it works is this:
                // At a single moment, there can be only one game with an ID on the server. However, as soon as
                // that game ends (for any reason), the server is free to reassign its ID to a newly created game.
                // This does happen in practice, often immediately, because new games are always being created.
                // The IgsConnection class IS catching most of the messages that cause a game to be deleted and
                // if that happens, it is removed from _gamesYouHaveOpened. A game-deletion message should arrive for
                // all games that we have opened before we receive any information about a new game with the same ID,
                // BUT I'm certainly not sure that I handle all these messages correctly or that I catch all of them.
                // This part of the protocol (and my implementation in this area) is rather messy.

                // In any case, however, when this method is called, it means that the old connector will
                // never receive another message from the server so we can just overwrite it.
            }
            _availableConnectors[connector.GameId] = connector;
        }
 /// <summary>
 /// Creates IGS handicap placement phase
 /// </summary>
 /// <param name="gameController"></param>
 public IgsHandicapPlacementPhase(IgsGameController gameController) : base(gameController)
 {
     _connector = gameController.IgsConnector;
 }