ported from perforce
This commit is contained in:
37
RobotAndDonkey.Game/Intents/DonkeyIntent.cs
Normal file
37
RobotAndDonkey.Game/Intents/DonkeyIntent.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RobotAndDonkey.Game.Board;
|
||||
using RobotAndDonkey.Game.Cards;
|
||||
using RobotAndDonkey.Game.Data;
|
||||
using RobotAndDonkey.Game.Execution.Results;
|
||||
using RobotAndDonkey.Game.GameState;
|
||||
using RobotAndDonkey.Game.Pois;
|
||||
|
||||
namespace RobotAndDonkey.Game.Intents;
|
||||
|
||||
public class DonkeyIntent(Card card, Cell donkeyCell, int energyCost) : Intent(energyCost)
|
||||
{
|
||||
public override void Run(Guid requestId, CoreLoop coreLoop, List<Intent> newIntents, List<Result> results)
|
||||
{
|
||||
if (coreLoop.HasDonkey && donkeyCell.Poi == null)
|
||||
{
|
||||
coreLoop.HasDonkey = false;
|
||||
donkeyCell.Poi = new Donkey();
|
||||
results.Add(new PoiResult(requestId, new(coreLoop.Board), donkeyCell.Poi, donkeyCell.Hex));
|
||||
newIntents.Add(new ModifyCurrency(new(0, -Balancing.Instance.DonkeyMaxCarryBonus, 0, 0, 0, 0)));
|
||||
}
|
||||
else if (!coreLoop.HasDonkey && donkeyCell.Poi is Donkey donkey)
|
||||
{
|
||||
coreLoop.HasDonkey = true;
|
||||
donkeyCell.Poi = null;
|
||||
results.Add(new PoiResult(requestId, new(coreLoop.Board), donkey, donkeyCell.Hex));
|
||||
newIntents.Add(new ModifyCurrency(new(0, Balancing.Instance.DonkeyMaxCarryBonus, 0, 0, 0, 0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
results.Add(new InvalidInstructionResult(requestId, EInvalidReason.NoTarget, card, donkeyCell));
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString() => "Donkey, " + base.ToString();
|
||||
}
|
||||
Reference in New Issue
Block a user