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."); } }
/// <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; }
public IgsGameBuilder Connection(IgsConnection connection) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } _connection = connection; return(this); }
/// <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(); }); }
/// <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); }
public IgsConnector(IgsGameController igsGameController, IgsConnection connnection) { _connnection = connnection; _gameController = igsGameController; }
public IgsPlayerBuilder(StoneColor color, IgsConnection pandanet) : base(color) { this._pandanet = pandanet; }
public IgsGame(IgsGameInfo info, IRuleset ruleset, PlayerPair players, IgsConnection serverConnection) : base(info) { Controller = new IgsGameController(Info, ruleset, players, serverConnection); }