Ejemplo n.º 1
0
        public void LoadSGF(Guid gameId, string sgf)
        {
            // Get a Fuego instance and start it up.
            FuegoInstance inst = null;

            try
            {
                inst = GetFuegoInstance(gameId, GoOperation.Undo);
                inst.EnsureRunning();
                inst.LoadSGF(sgf);
            }
            // ReSharper disable RedundantCatchClause
            catch (Exception)
            {
                throw;
            }
            // ReSharper restore RedundantCatchClause
            finally
            {
                if (inst != null)
                {
                    inst.CurrentOperation = GoOperation.Idle;
                }
            }
        }
Ejemplo n.º 2
0
        public string SaveSGF(Guid gameId)
        {
            // Get a Fuego instance and start it up.
            FuegoInstance inst = null;

            try
            {
                inst = GetFuegoInstance(gameId, GoOperation.Undo);
                inst.EnsureRunning();
                var svg = inst.SaveSGF();

                return(svg);
            }
            // ReSharper disable RedundantCatchClause
            catch (Exception)
            {
                throw;
            }
            // ReSharper restore RedundantCatchClause
            finally
            {
                if (inst != null)
                {
                    inst.CurrentOperation = GoOperation.Idle;
                }
            }
        }
Ejemplo n.º 3
0
        public GoGameState Undo(Guid gameId)
        {
            // Get a Fuego instance and start it up.
            FuegoInstance inst = null;

            try
            {
                inst = GetFuegoInstance(gameId, GoOperation.Undo);
                inst.EnsureRunning();
                inst.Undo();
                inst.CurrentOperation = GoOperation.Idle;

                return(_goGRepository.GetGameState(gameId));
            }
            // ReSharper disable RedundantCatchClause
            catch (Exception)
            {
                throw;
            }
            // ReSharper restore RedundantCatchClause
            finally
            {
                if (inst != null)
                {
                    inst.CurrentOperation = GoOperation.Idle;
                }
            }
        }
Ejemplo n.º 4
0
        public GoMove Hint(Guid gameId, GoColor color)
        {
            // Get a Fuego instance and start it up.
            FuegoInstance inst = null;

            try
            {
                inst = GetFuegoInstance(gameId, GoOperation.Hint);
                inst.EnsureRunning();
                var result = inst.Hint(color);

                return(result);
            }
            // ReSharper disable RedundantCatchClause
            catch (Exception)
            {
                throw;
            }
            // ReSharper restore RedundantCatchClause
            finally
            {
                if (inst != null)
                {
                    inst.CurrentOperation = GoOperation.Idle;
                }
            }
        }
Ejemplo n.º 5
0
        public void GenMove(Guid gameId, GoColor color, out GoMove newMove, out GoMoveResult result)
        {
            // Get a Fuego instance and start it up.
            FuegoInstance inst = null;

            try
            {
                inst = GetFuegoInstance(gameId, GoOperation.GenMove);
                inst.EnsureRunning();
                inst.GenMove(color, out newMove, out result);
            }
// ReSharper disable RedundantCatchClause
            catch (Exception)
            {
                throw;
            }
// ReSharper restore RedundantCatchClause
            finally
            {
                if (inst != null)
                {
                    inst.CurrentOperation = GoOperation.Idle;
                }
            }
        }
Ejemplo n.º 6
0
        public GoMoveResult Play(Guid gameId, GoMove move)
        {
            if (move == null)
            {
                throw new ArgumentNullException("move");
            }

            // Get a Fuego instance and start it up.
            FuegoInstance inst = null;

            try
            {
                GoOperation op;
                switch (move.MoveType)
                {
                case MoveType.Normal:
                    op = GoOperation.NormalMove;
                    break;

                case MoveType.Pass:
                    op = GoOperation.Pass;
                    break;

                case MoveType.Resign:
                    op = GoOperation.Resign;
                    break;

                default:
                    throw new Exception("Unrecognized move type: " + move.MoveType);
                }
                inst = GetFuegoInstance(gameId, op);
                inst.EnsureRunning();
                var result = inst.Play(move);

                return(result);
            }
// ReSharper disable RedundantCatchClause
            catch (Exception)
            {
                throw;
            }
// ReSharper restore RedundantCatchClause
            finally
            {
                if (inst != null)
                {
                    inst.CurrentOperation = GoOperation.Idle;
                }
            }
        }