Chess/Advice/ResultAdvice.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FourWayClimbingDemo.Chess.Advice
{
    public sealed class ResultAdvice:BaseAdvice
    {
        private ChessBoard _chessBoard;
        private Player _player;
        private ChessPiece _chessPiece;
        private Dir _dir;
        public ResultAdvice(ChessBoard chessBoard, Player player, ChessPiece chessPiece, Dir dir) {
            this._chessBoard = chessBoard;
            this._player = player;
            this._chessPiece = chessPiece;
            this._dir = dir;
        }

        public override int Execute()
        {
            AdviceStatusEnum status = AdviceStatusEnum.None;
            //棋子下一步棋位
            var pos = _chessBoard.GetChessPieceAround(_chessPiece, _dir);
            if (pos != null && !_chessBoard.IsEmpty(pos.Value)) {
                //棋子吃子了,则再下一步棋位
                pos = _chessBoard.GetChessPieceAround(pos.Value,_dir);                
            }

            if (pos != null) 
            {
                if (Dir.TOP != NegativeDir(_dir)) {
                    var pos1 = _chessBoard.GetChessPieceAround(pos.Value,Dir.TOP);
                    if (pos1 == null || _chessBoard.IsEmpty(pos1.Value) || _player.IsMyChessPiece(pos1.Value))
                    {
                        status = CompareAdviceStatus(status, AdviceStatusEnum.落子_安全);                     
                    }
                    else {
                        status = CompareAdviceStatus(status, AdviceStatusEnum.落子_被吃);
                    }
                }
                if (Dir.BOTTOM != NegativeDir(_dir))
                {
                    var pos1 = _chessBoard.GetChessPieceAround(pos.Value, Dir.BOTTOM);
                    if (pos1 == null || _chessBoard.IsEmpty(pos1.Value) || _player.IsMyChessPiece(pos1.Value))
                    {
                        status = CompareAdviceStatus(status, AdviceStatusEnum.落子_安全);
                    }
                    else
                    {
                        status = CompareAdviceStatus(status, AdviceStatusEnum.落子_被吃);
                    }
                }
                if (Dir.LEFT != NegativeDir(_dir))
                {
                    var pos1 = _chessBoard.GetChessPieceAround(pos.Value, Dir.LEFT);
                    if (pos1 == null || _chessBoard.IsEmpty(pos1.Value) || _player.IsMyChessPiece(pos1.Value))
                    {
后面还有 27 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。