Esempio n. 1
0
        public bool Move(Command move)
        {
            Player p = GetPlayer(move.Name);

            if (p == null)
            {
                return(false);
            }

            int x     = Convert.ToInt32(move.X);
            int y     = Convert.ToInt32(move.Y);
            int value = Convert.ToInt32(move.Value);

            if (!SudokuGrid.FillValue(x, y, value))
            {
                return(false);
            }

            AddAction(p, String.Format("move#{0}#{1}#{2}#{3}", p.Name, x, y, value));

            if (SudokuGrid.IsFinish)
            {
                Locker.EnterWriteLock();
                try
                {
                    Parent.Remove(this);
                }
                finally
                {
                    Locker.ExitWriteLock();
                }

                Command cmd = new Command(Parent, null, new string[] { "win", p.Name, this.Id.ToString() });
                cmd.Execute();

                AddAction(p, String.Format("win#{0}#{1}", p.Name, Id));
            }

            return(true);
        }