public override async void Process(KgsConnection connection) { Debug.WriteLine("Success. Now getting info."); var roomsArray = new int[this.Rooms.Length]; for (int i = 0; i < this.Rooms.Length; i++) { roomsArray[i] = this.Rooms[i].ChannelId; } connection.Events.RaisePersonalInformationUpdate(this.You); connection.Events.RaiseSystemMessage("Requesting room names..."); connection.Events.RaiseLoginPhaseChanged(KgsLoginPhase.RequestingRoomNames); await connection.MakeUnattendedRequestAsync("ROOM_NAMES_REQUEST", new { Rooms = roomsArray }); connection.Events.RaiseSystemMessage("Joining global lists..."); connection.Events.RaiseLoginPhaseChanged(KgsLoginPhase.JoiningGlobalLists); await connection.Commands.GlobalListJoinRequestAsync("CHALLENGES"); await connection.Commands.GlobalListJoinRequestAsync("ACTIVES"); await connection.Commands.GlobalListJoinRequestAsync("FANS"); connection.Events.RaiseSystemMessage("On-login outgoing message burst complete."); connection.LoggedIn = true; connection.LoggingIn = false; connection.Events.RaiseLoginPhaseChanged(KgsLoginPhase.Done); connection.Events.RaiseLoginComplete(LoginResult.Success); }
public override void Process(KgsConnection connection) { connection.Events.RaiseErrorNotification("CHALLENGE_DECLINE"); #pragma warning disable 4014 connection.Commands.GenericUnjoinAsync(this.ChannelId); #pragma warning restore 4014 }
public override void Process(KgsConnection connection) { foreach (var ev in SgfEvents) { ev.ExecuteAsIncoming(connection, connection.Data.GetGame(ChannelId)); } }
public override void Process(KgsConnection connection) { foreach (var info in Rooms) { connection.Data.SetRoomName(info.ChannelId, info.Name); } }
public override void Process(KgsConnection connection) { // Yeah, we cannot await here. I don't think it's a big deal. We'll see. #pragma warning disable 4014 connection.Commands.GameTimeExpiredAsync(this.ChannelId); #pragma warning restore 4014 }
public override void Process(KgsConnection connection) { connection.Data.UnjoinChannel(ChannelId); // TODO (future expansion): If this is a room, it can be removed from the list of rooms. // However, it is also possible that a different downstream message is responsible for this. // Research needed. }
public override void Process(KgsConnection connection) { connection.Data.JoinGlobalChannel(ChannelId, ContainerType); foreach (var channel in Games) { connection.Data.GetChannel <KgsGameContainer>(ChannelId)?.AddChannel(channel, connection); } }
/// <summary> /// Initializes the KGS connection /// </summary> /// <returns></returns> private static void InitKgsConnection() { _kgsConnection = new KgsConnection(); _kgsConnection.Events.PersonalInformationUpdate += KgsUserUpdate; _kgsConnection.Events.GameJoined += Kgs_GameJoined; _kgsConnection.Events.NotificationErrorMessage += KgsNotificationErrorMessage; _kgsConnection.Events.ChallengeJoined += Kgs_ChallengeJoined; Mvx.Resolve <ITimerService>() .StartTimer(TimeSpan.FromSeconds(10), async() => { await _kgsConnection.Commands.WakeUpAsync(); }); }
public ChallengeForm(KgsChallenge challenge, KgsConnection connection) { InitializeComponent(); this.challenge = challenge; this._connection = connection; this.lblInfo.Text = challenge.ToString(); connection.Events.Unjoin += Events_Unjoin; challenge.StatusChanged += ChallengeStatusChanged; RefreshEvents(); }
public KgsGameBuilder(KgsGameInfo info, KgsConnection connection) { this._info = info; this.BoardSize(info.BoardSize); this.CountingType(Rules.CountingType.Territory); this.HandicapPlacementType(Phases.HandicapPlacement.HandicapPlacementType.Fixed); this.Komi(info.Komi); this._connection = connection; this.Handicap(info.NumberOfHandicapStones); }
public override void Process(KgsConnection connection) { var challenge = connection.Data.GetChannel <KgsChallenge>(this.ChannelId); if (challenge != null) { challenge.IncomingChallenge = this.Proposal; challenge.Events.Add("RECEIVED A CHALLENGE"); challenge.RaiseStatusChanged(); } }
public override void Process(KgsConnection connection) { KgsChallenge createdChallenge = KgsChallenge.FromChannel(Game); if (createdChallenge != null) { createdChallenge.OwnedByUs = true; connection.Data.JoinChallenge(createdChallenge); } createdChallenge.RaiseStatusChanged(); }
public override void Process(KgsConnection connection) { var challenge = connection.Data.GetChannel <KgsChallenge>(this.ChannelId); if (challenge != null) { challenge.Events.Add(this.Type); challenge.Acceptable = true; challenge.CreatorsNewProposal = Proposal; challenge.RaiseStatusChanged(); } }
public override void Process(KgsConnection connection) { connection.Data.JoinRoom(this.ChannelId); if (Games != null) { connection.Data.GetChannel <KgsRoom>(ChannelId)?.UpdateGames(Games, connection); } (connection.Data.GetChannel(this.ChannelId) as KgsRoom).Users.Clear(); foreach (var user in Users) { connection.Data.AddUserToChannel(this.ChannelId, user); } }
public override void Process(KgsConnection connection) { var challenge = connection.Data.GetChannel <KgsChallenge>(this.ChannelId); if (challenge != null) { connection.Data.JoinChallenge(challenge); } foreach (var user in Users) { connection.Data.AddUserToChannel(this.ChannelId, user); } }
public KgsGameController( KgsGameInfo kgsGameInfo, IRuleset ruleset, PlayerPair players, KgsConnection serverConnection) : base(kgsGameInfo, ruleset, players, serverConnection) { Info = kgsGameInfo; KgsConnector = new KgsConnector(this, serverConnection); Chat = new ChatService(KgsConnector); Server = serverConnection; RegisterConnector(KgsConnector); KgsConnector.GameEndedByServer += KgsConnector_GameEndedByServer; }
public override void Process(KgsConnection connection) { var channel = connection.Data.GetChannel(this.ChannelId); KgsChallenge challenge = channel as KgsChallenge; if (challenge != null) { challenge.Events.Add(this.Type); } else { Debug.WriteLine("That was supposed to be a challenge."); } }
public void UpdateGames(GameChannel[] games, KgsConnection connection) { foreach (var g in games) { var existingGame = AllChannelsCollection.FirstOrDefault(kgc => kgc.ChannelId == g.ChannelId); if (existingGame != null) { existingGame.UpdateFrom(g); } else { AddChannel(g, connection); } } }
public override void Process(KgsConnection connection) { KgsGameInfo info = KgsGameInfo.FromGameJoin(this); if (info == null) { return; } var channel = connection.Data.GetChannel(this.ChannelId); if (channel == null) { channel = connection.Data.CreateGame(KgsTrueGameChannel.FromGameInfo(info, this.ChannelId)); } var blackPlayer = new KgsPlayerBuilder(Game.StoneColor.Black, connection) .Name(info.Black.Name) .Rank(info.Black.Rank) .Build(); if (info.Black.Name == connection.Username) { blackPlayer = new HumanPlayerBuilder(Game.StoneColor.Black).Name(info.Black.Name).Rank(info.Black.Rank).Build(); } var whitePlayer = new KgsPlayerBuilder(Game.StoneColor.White, connection) .Name(info.White.Name) .Rank(info.White.Rank) .Build(); if (info.White.Name == connection.Username) { whitePlayer = new HumanPlayerBuilder(Game.StoneColor.White).Name(info.White.Name).Rank(info.White.Rank).Build(); } var ongame = new KgsGameBuilder(info, connection) .BlackPlayer(blackPlayer) .WhitePlayer(whitePlayer) .Build(); connection.Data.JoinGame(ongame, channel as KgsTrueGameChannel); foreach (var ev in SgfEvents) { ev.ExecuteAsIncoming(connection, ongame); } connection.Events.RaiseGameJoined(ongame); }
public void AddChannel(GameChannel channel, KgsConnection connection) { var kChallenge = KgsChallenge.FromChannel(channel); if (kChallenge != null) { connection.Data.EnsureChannelExists(kChallenge); Challenges.Add(kChallenge); AllChannelsCollection.Add(kChallenge); return; } var kGame = KgsTrueGameChannel.FromChannel(channel); if (kGame != null) { connection.Data.EnsureChannelExists(kGame); Games.Add(kGame); AllChannelsCollection.Add(kGame); return; } }
public override void Process(KgsConnection connection) { KgsGame game = connection.Data.GetGame(ChannelId); if (game != null) { if (this.Clocks != null) { if (this.Clocks[Role.White] != null) { game.Controller.Players.White.Clock.UpdateFromClock(this.Clocks[Role.White]); } if (this.Clocks[Role.Black] != null) { game.Controller.Players.Black.Clock.UpdateFromClock(this.Clocks[Role.Black]); } } game.Controller.DoneId = DoneId; if (this.Actions != null) { if (this.Actions.Any(action => action.Action == "SCORE")) { if (game.Controller.Phase.Type != Modes.LiveGame.Phases.GamePhaseType.LifeDeathDetermination) { game.Controller.SetPhase(Modes.LiveGame.Phases.GamePhaseType.LifeDeathDetermination); } } } if (this.BlackDoneSent && !game.Controller.BlackDoneReceived) { game.Controller.BlackDoneReceived = true; game.Controller.KgsConnector.RaiseDoneReceived(game.Controller.Players.Black); } if (this.WhiteDoneSent && !game.Controller.WhiteDoneReceived) { game.Controller.WhiteDoneReceived = true; game.Controller.KgsConnector.RaiseDoneReceived(game.Controller.Players.White); } } }
public override void Process(KgsConnection connection) { var myGame = connection.Data.GetGame(this.ChannelId); connection.Events.RaiseUndoRequestReceived(myGame); }
public KgsPlayerBuilder(StoneColor color, KgsConnection connection) : base(color) { this._connection = connection; }
public override void Process(KgsConnection connection) { connection.LogoutAndDisconnect(Text ?? ""); }
public KgsAgent(StoneColor color, KgsConnection pandanet) : base(color) { this._connection = pandanet; }
public override void Process(KgsConnection connection) { connection.Data.GetChannel <KgsGameContainer>(ChannelId)?.RemoveGame(GameId); }
public override void Process(KgsConnection connection) { connection.Data.GetChannel <KgsGameContainer>(ChannelId)?.UpdateGames(Games, connection); }
public override void Process(KgsConnection connection) { connection.LoggingIn = false; connection.Events.RaiseLoginComplete(LoginResult.FailureWrongPassword); }
public override void Process(KgsConnection connection) { connection.Data.UnjoinChannel(ChannelId); }
public override void Process(KgsConnection connection) { }