Chess/Advice/CurrentAdvice.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FourWayClimbingDemo.Chess.Advice
{
public sealed class CurrentAdvice : BaseAdvice
{
private ChessBoard _chessBoard;
private Player _player;
private ChessPiece _chessPiece;
public CurrentAdvice(ChessBoard chessBoard, Player player, ChessPiece chessPiece) {
this._chessBoard = chessBoard;
this._player = player;
this._chessPiece = chessPiece;
}
public override int Execute()
{
AdviceStatusEnum status = AdviceStatusEnum.None;
var posLeft = _chessBoard.GetChessPieceAround(_chessPiece,Dir.LEFT);
var posRight = _chessBoard.GetChessPieceAround(_chessPiece, Dir.RIGHT);
var posTop = _chessBoard.GetChessPieceAround(_chessPiece, Dir.TOP);
var posBottom = _chessBoard.GetChessPieceAround(_chessPiece, Dir.BOTTOM);
if (posLeft != null && posRight != null) {
if (_chessBoard.IsEmpty(posLeft.Value) && !_chessBoard.IsEmpty(posRight.Value) && !_player.IsMyChessPiece(posRight.Value))
{
status = CompareAdviceStatus(status, AdviceStatusEnum.当前_被吃);
}
else if (_chessBoard.IsEmpty(posRight.Value) && !_chessBoard.IsEmpty(posLeft.Value) && !_player.IsMyChessPiece(posLeft.Value))
{
status = CompareAdviceStatus(status, AdviceStatusEnum.当前_被吃);
}
else {
status = CompareAdviceStatus(status, AdviceStatusEnum.当前_安全);
}
}
if (posTop != null && posBottom != null)
{
if (_chessBoard.IsEmpty(posTop.Value) && !_chessBoard.IsEmpty(posBottom.Value) && !_player.IsMyChessPiece(posBottom.Value))
{
status = CompareAdviceStatus(status, AdviceStatusEnum.当前_被吃);
}
else if (_chessBoard.IsEmpty(posBottom.Value) && !_chessBoard.IsEmpty(posTop.Value) && !_player.IsMyChessPiece(posTop.Value))
{
status = CompareAdviceStatus(status, AdviceStatusEnum.当前_被吃);
}
else
{
status = CompareAdviceStatus(status, AdviceStatusEnum.当前_安全);
}
}
后面还有 7 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。