Ejemplo n.º 1
0
        public bool isThisIsPlayerNow(LiuhePlayer p)
        {
            if (p == _Players[_PlayerNow])
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public bool placeChess(LiuhePlayer player, int xx, int yy, int dir)
        {
            if (!isThisIsPlayerNow(player))
            {
                Debug.Log("当前并非此玩家的回合,无法操作");
                return(false);
            }

            LiuheChessBoard lcb = this._GameBoard.getCopy();

            if (!Rules.Rules.tryPlaceChessToGameBoard(lcb, xx, yy, dir, player))
            {
                Debug.Log("落子失败!");
                return(false);
            }

            _GameBoard.addNewChess(xx, yy, dir, player._PlayerIndex);

            updateChessBoard();

            return(true);
        }
Ejemplo n.º 3
0
        public static void Log(LiuhePlayer lp)
        {
            string str = "" + lp._PlayerIndex + "号玩家 是 ";

            switch (lp._Type)
            {
            case PLAYER_TYPE.LOCAL:
                str += "本地玩家";
                break;

            case PLAYER_TYPE.AI:
                str += "AI玩家";
                break;

            case PLAYER_TYPE.NETWORK:
                str += "网络玩家";
                break;

            default:
                break;
            }
            Debug.Log(str);
        }
Ejemplo n.º 4
0
        public static bool tryPlaceChessToGameBoard(LiuheChessBoard board, int xx, int yy, int dir, LiuhePlayer lp)
        {
            GridValidState gvs = getGridValidState(board, xx, yy);

            if (gvs != GridValidState.VOID)
            {
                LiuheLogger.Log(gvs);
                return(false);
            }

            int ss = board.places.Count;

            if (ss > 2)
            {
                Debug.Log("严重问题!! 过去存储超过限额!");
            }

            if (ss == 1)
            {
                PlaceMemory pm = board.places[0];
                if (pm.placeOwnner == lp._PlayerIndex)
                {
                    Debug.Log("该玩家这回合已经下过了!");
                    return(false);
                }
                if (pm.chessDir == dir)
                {
                    Debug.Log("这个方向是禁手方向!");
                    return(false);
                }
            }
            else if (ss == 2)
            {
                PlaceMemory pm0 = board.places[0];
                PlaceMemory pm1 = board.places[1];
                if (pm1.placeOwnner == lp._PlayerIndex)
                {
                    Debug.Log("该玩家这回合已经下过了!");
                    return(false);
                }
                if (pm0.chessDir == dir || pm1.chessDir == dir)
                {
                    Debug.Log("这个方向是禁手方向!");
                    return(false);
                }
            }


            int idm = board.addNewChess(xx, yy, dir, lp._PlayerIndex);

            if (idm < 0)
            {
                Debug.Log("此位置存在错误!");
                return(false);
            }

            GameBoardCalculateItself(board);

            if (board.findChessByIdnum(idm).health <= 0)
            {
                Debug.Log("下在此处生命值会不够!");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
        public static LiuheChessBoard getTryResult(LiuheChessBoard board, int xx, int yy, int dir, LiuhePlayer lp)
        {
            GridValidState gvs = getGridValidState(board, xx, yy);

            if (gvs != GridValidState.VOID)
            {
                LiuheLogger.Log(gvs);
                return(null);
            }
            int idm = board.addNewChess(xx, yy, dir, lp._PlayerIndex);

            if (idm < 0)
            {
                //Debug.Log("此位置存在错误!");
                return(null);
            }

            GameBoardCalculateItself(board);

            return(board);
        }