public async Task UndoPleaseAsync(KgsGameInfo info) { await kgsConnection.MakeUnattendedRequestAsync("GAME_UNDO_REQUEST", new { ChannelId = info.ChannelId }); }
public async Task ObserveGameAsync(KgsGameInfo gameInfo) { await kgsConnection.MakeUnattendedRequestAsync("JOIN_REQUEST", new { ChannelId = gameInfo.ChannelId }); }
public async Task MakeMove(RemoteGameInfo remoteInfo, Move move) { KgsGameInfo kgsInfo = (KgsGameInfo)remoteInfo; if (move.Kind == MoveKind.Pass) { await kgsConnection.MakeUnattendedRequestAsync("GAME_MOVE", new { ChannelId = kgsInfo.ChannelId, Loc = "PASS" }); } else { await kgsConnection.MakeUnattendedRequestAsync("GAME_MOVE", new { ChannelId = kgsInfo.ChannelId, Loc = new { X = move.Coordinates.X, Y = KgsCoordinates.OurToTheirs(move.Coordinates.Y, kgsInfo.BoardSize) } }); } }
public async Task ChatAsync(KgsGameInfo info, string text) { await kgsConnection.MakeUnattendedRequestAsync("CHAT", new { ChannelId = info.ChannelId, Text = text }); }
public async Task AllowUndoAsync(RemoteGameInfo remoteInfo) { KgsGameInfo kgsInfo = (KgsGameInfo)remoteInfo; await kgsConnection.MakeUnattendedRequestAsync("GAME_UNDO_ACCEPT", new { ChannelId = kgsInfo.ChannelId }); }
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 async Task LifeDeathDone(RemoteGameInfo remoteInfo) { KgsGameInfo kgsInfo = (KgsGameInfo)remoteInfo; var game = kgsConnection.Data.GetGame(kgsInfo.ChannelId); await kgsConnection.MakeUnattendedRequestAsync("GAME_SCORING_DONE", new { ChannelId = kgsInfo.ChannelId, DoneId = game.Controller.DoneId }); }
public async Task LifeDeathMarkLife(Position position, RemoteGameInfo remoteInfo) { KgsGameInfo kgsInfo = (KgsGameInfo)remoteInfo; await kgsConnection.MakeUnattendedRequestAsync("GAME_MARK_LIFE", new { ChannelId = kgsInfo.ChannelId, Alive = true, X = position.X, Y = KgsCoordinates.OurToTheirs(position.Y, kgsInfo.BoardSize) }); }
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) { 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 async Task AddTime(RemoteGameInfo remoteInfo, TimeSpan additionalTime) { KgsGameInfo kgsInfo = (KgsGameInfo)remoteInfo; string opponentsRole = "black"; if (kgsInfo.Black.Name == kgsConnection.Username) { opponentsRole = "white"; } await kgsConnection.MakeUnattendedRequestAsync("GAME_ADD_TIME", new { ChannelId = kgsInfo.ChannelId, Role = opponentsRole, Time = (float)additionalTime.TotalSeconds }); }