Пример #1
0
        private async void PrimaryForm_Load(object sender, EventArgs e)
        {
            this.cbBlack.Items.Clear();
            this.cbBlack.Items.Add("Human");
            this.cbBlack.Items.AddRange(AISystems.AIPrograms.ToArray());
            this.cbWhite.Items.Clear();
            this.cbWhite.Items.Add("Human");
            this.cbWhite.Items.AddRange(AISystems.AIPrograms.ToArray());
            this.cbWhoPlaysOnline.Items.Clear();
            this.cbWhoPlaysOnline.Items.Add("Human");
            this.cbWhoPlaysOnline.Items.AddRange(AISystems.AIPrograms.ToArray());
            this.cbWhite.SelectedIndex          = 0;
            this.cbBlack.SelectedIndex          = 0;
            this.cbWhoPlaysOnline.SelectedIndex = 0;

            igs = new IgsConnection();
            igs.Events.IncomingLine        += IgsIncomingLine;
            igs.Events.IncomingChatMessage += Igs_IncomingChatMessage;
            igs.Events.Beep                 += Igs_Beep;
            igs.Events.UnhandledLine        += Igs_UnhandledLine;
            igs.Events.IncomingMatchRequest += Igs_IncomingMatchRequest;
            igs.Events.IncomingShoutMessage += Igs_IncomingShoutMessage;
            igs.Events.OutgoingLine         += Igs_OutgoingLine;
            igs.Events.MatchRequestAccepted += Igs_MatchRequestAccepted;
            igs.Events.MatchRequestDeclined += Igs_MatchRequestDeclined;
            if (!await igs.ConnectAsync())
            {
                MessageBox.Show("Connection to IGS failed.");
                return;
            }
            if (!await igs.LoginAsync("OmegaGo1", "123456789"))
            {
                MessageBox.Show("Login failed.");
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes server
 /// </summary>
 private void InitializeServer(IgsConnection serverConnection)
 {
     serverConnection.RegisterConnector(IgsConnector);
     IgsConnector.TimeControlShouldAdjust += IgsConnector_TimeControlShouldAdjust;
     IgsConnector.GameScoredAndCompleted  += IgsConnector_GameScoredAndCompleted;
     IgsConnector.Disconnected            += IgsConnector_Disconnected;
     IgsConnector.GameEndedByServer       += IgsConnector_GameEndedByServer;
 }
Пример #3
0
 public IgsGameBuilder Connection(IgsConnection connection)
 {
     if (connection == null)
     {
         throw new ArgumentNullException(nameof(connection));
     }
     _connection = connection;
     return(this);
 }
Пример #4
0
 /// <summary>
 /// Initializes the IGS connection
 /// </summary>
 private static void InitIgsConnection()
 {
     _igsConnection = new IgsConnection();
     _igsConnection.Events.PersonalInformationUpdate += IgsUserUpdate;
     _igsConnection.Events.IncomingMatchRequest      += Pandanet_IncomingMatchRequest;
     _igsConnection.Events.MatchRequestAccepted      += Pandanet_MatchRequestAccepted;
     _igsConnection.Events.MatchRequestDeclined      += Pandanet_MatchRequestDeclined;
     _igsConnection.Events.ErrorMessageReceived      += Pandanet_ErrorMessageReceived;
     Mvx.Resolve <ITimerService>()
     .StartTimer(TimeSpan.FromSeconds(10), () => { _igsConnection.Commands.AreYouThere(); });
 }
Пример #5
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);
        }
Пример #6
0
 public IgsConnector(IgsGameController igsGameController, IgsConnection connnection)
 {
     _connnection    = connnection;
     _gameController = igsGameController;
 }
Пример #7
0
 public IgsPlayerBuilder(StoneColor color, IgsConnection pandanet) : base(color)
 {
     this._pandanet = pandanet;
 }
Пример #8
0
 public IgsGame(IgsGameInfo info, IRuleset ruleset, PlayerPair players, IgsConnection serverConnection) : base(info)
 {
     Controller = new IgsGameController(Info, ruleset, players, serverConnection);
 }