示例#1
0
        public Task RejectUndoAsync(RemoteGameInfo remoteInfo)
        {
            var igsGameInfo = (IgsGameInfo)remoteInfo;

            this.igsConnection.MakeUnattendedRequest("noundo " + igsGameInfo.IgsIndex);
            return(CompletedTask);
        }
示例#2
0
        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)
                    }
                });
            }
        }
示例#3
0
        public Task UndoLifeDeath(RemoteGameInfo remoteInfo)
        {
            var igsGameInfo = (IgsGameInfo)remoteInfo;

            this.igsConnection.MakeUnattendedRequest("undo " + igsGameInfo.IgsIndex);
            return(IgsCommands.CompletedTask);
        }
示例#4
0
        public InGameForm(RemoteGameInfo info, RemoteGameController onlineGameController, IServerConnection server)
        {
            InitializeComponent();
            _isOnline = onlineGameController != null;

            this._onlineGameController = onlineGameController;
            if (onlineGameController != null)
            {
                _gameInfo = info;
                _server   = server;
            }

            if (_server is IgsConnection)
            {
                var connection = (_server as IgsConnection);
                bLocalUndo.Visible = false;
                connection.Events.ErrorMessageReceived += _igs_ErrorMessageReceived;
                //    this._igs.UndoRequestReceived += _igs_UndoRequestReceived;
                //connection.Events.UndoDeclined += _igs_UndoDeclined;
                bAddTimeToMyOpponent.Visible = true;
                bResumeAsBlack.Visible       = false;
            }
            else if (_server is KgsConnection)
            {
            }
            else
            {
                bAddTimeToMyOpponent.Visible = false;
                bUndoPlease.Visible          = false;
                bUndoYes.Visible             = false;
                bUndoNo.Visible = false;
            }
            RefreshBoard();
        }
示例#5
0
 public async Task UnobserveAsync(RemoteGameInfo remoteInfo)
 {
     var kgsInfo = remoteInfo as KgsGameInfo;
     await kgsConnection.MakeUnattendedRequestAsync("UNJOIN_REQUEST", new
     {
         ChannelId = kgsInfo.ChannelId
     });
 }
示例#6
0
 public async Task Resign(RemoteGameInfo remoteInfo)
 {
     var kgsInfo = (KgsGameInfo)remoteInfo;
     await kgsConnection.MakeUnattendedRequestAsync("GAME_RESIGN", new
     {
         ChannelId = kgsInfo.ChannelId,
     });
 }
示例#7
0
 public async Task AllowUndoAsync(RemoteGameInfo remoteInfo)
 {
     KgsGameInfo kgsInfo = (KgsGameInfo)remoteInfo;
     await kgsConnection.MakeUnattendedRequestAsync("GAME_UNDO_ACCEPT", new
     {
         ChannelId = kgsInfo.ChannelId
     });
 }
示例#8
0
        public async Task Resign(RemoteGameInfo remoteInfo)
        {
            var igsGameInfo = (IgsGameInfo)remoteInfo;
            var response    = await this.igsConnection.MakeRequestAsync("resign " + igsGameInfo.IgsIndex);

            if (!response.IsError)
            {
                this.igsConnection.HandleIncomingResignation(igsGameInfo, this.igsConnection.Username);
            }
        }
示例#9
0
        public async Task UnobserveAsync(RemoteGameInfo remoteInfo)
        {
            var igsGameInfo = (IgsGameInfo)remoteInfo;
            var igsGame     = igsConnection.GamesBeingObserved.FirstOrDefault(gm => gm.Info.IgsIndex == igsGameInfo.IgsIndex);

            if (igsGame != null)
            {
                await this.EndObserving(igsGame);
            }
        }
示例#10
0
 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
     });
 }
示例#11
0
        public Task AddTime(RemoteGameInfo remoteInfo, TimeSpan additionalTime)
        {
            if (additionalTime.Seconds != 0)
            {
                throw new ArgumentException("IGS only supports adding whole minutes", nameof(additionalTime));
            }
            var igsGameInfo = (IgsGameInfo)remoteInfo;

            this.igsConnection.MakeUnattendedRequest("addtime " + igsGameInfo.IgsIndex + " " + additionalTime.Minutes);
            return(IgsCommands.CompletedTask);
        }
示例#12
0
 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)
     });
 }
示例#13
0
        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
            });
        }
示例#14
0
        public Task MakeMove(RemoteGameInfo remoteInfo, Move move)
        {
            var game = (IgsGameInfo)remoteInfo;

            switch (move.Kind)
            {
            case MoveKind.PlaceStone:
                this.igsConnection.MakeUnattendedRequest(move.Coordinates.ToIgsCoordinates() + " " + game.IgsIndex);
                break;

            case MoveKind.Pass:
                this.igsConnection.MakeUnattendedRequest("pass " + game.IgsIndex);
                break;
            }
            return(IgsCommands.CompletedTask);
        }
示例#15
0
        public async Task LifeDeathMarkDeath(Position position, RemoteGameInfo remoteInfo)
        {
            var igsGameInfo = (IgsGameInfo)remoteInfo;

            await this.igsConnection.MakeRequestAsync(position.ToIgsCoordinates() + " " + igsGameInfo.IgsIndex);
        }
示例#16
0
        public async Task LifeDeathDone(RemoteGameInfo remoteInfo)
        {
            var igsGameInfo = (IgsGameInfo)remoteInfo;

            await this.igsConnection.MakeRequestAsync("done " + igsGameInfo.IgsIndex);
        }
示例#17
0
 public Task UndoLifeDeath(RemoteGameInfo remoteInfo)
 {
     // Life/death works a little differently in KGS.
     return(CompletedTask);
 }
示例#18
0
        public async Task AllowUndoAsync(RemoteGameInfo remoteInfo)
        {
            var igsGameInfo = (IgsGameInfo)remoteInfo;

            await MakeRequestAsync("undo " + igsGameInfo.IgsIndex);
        }
示例#19
0
 public Task RejectUndoAsync(RemoteGameInfo remoteInfo)
 {
     // At KGS, to reject an undo, simply ignore it.
     return(CompletedTask);
 }
 public RemoteLifeAndDeathPhase(RemoteGameController controller) : base(controller)
 {
     _serverConnection = controller.Server;
     _remoteGameInfo   = controller.Info;
 }
示例#21
0
 /// <summary>
 /// Creates a remote game controller
 /// </summary>
 /// <param name="remoteGameInfo">Info about the remote game</param>
 /// <param name="ruleset">Ruleset that guides the game</param>
 /// <param name="players">Players playing the game</param>
 /// <param name="serverConnection">Server connection</param>
 protected RemoteGameController(RemoteGameInfo remoteGameInfo, IRuleset ruleset, PlayerPair players, IServerConnection serverConnection) : base(remoteGameInfo, ruleset, players)
 {
     Info   = remoteGameInfo;
     Server = serverConnection;
 }