27 lines
960 B
C#
27 lines
960 B
C#
using RobotAndDonkey.Game.Board;
|
|
using RobotAndDonkey.Game.Execution.Results;
|
|
using RobotAndDonkey.Game.GameState;
|
|
using RobotAndDonkey.Game.Pois;
|
|
|
|
namespace RobotAndDonkey.Game.Intents;
|
|
|
|
public class Turn(Cell cell, int delta) : Intent
|
|
{
|
|
public override void Run(Guid requestId, CoreLoop coreLoop, List<Intent> newIntents, List<Result> results)
|
|
{
|
|
var avatar = (Avatar)cell.Poi!;
|
|
var newDirection = ((int)avatar.Direction + Delta) % 6;
|
|
if (newDirection < 0)
|
|
newDirection += 6;
|
|
avatar.Direction = (EDirection)newDirection;
|
|
results.Add(new PoiResult(requestId, new(coreLoop.Board), avatar, cell.Hex));
|
|
|
|
base.Run(requestId, coreLoop, newIntents, results);
|
|
}
|
|
|
|
public override bool IsValid(CoreLoop coreLoop) => base.IsValid(coreLoop) && cell.Poi is Avatar;
|
|
|
|
public int Delta { get; set; } = delta;
|
|
|
|
public override string ToString() => $"Turn by {Delta}, " + base.ToString();
|
|
} |