41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using RobotAndDonkey.Game.Board;
|
|
using RobotAndDonkey.Game.Execution.Results;
|
|
using RobotAndDonkey.Game.GameState;
|
|
using RobotAndDonkey.Game.Intents;
|
|
|
|
namespace RobotAndDonkey.Game.Modifiers;
|
|
|
|
public record DroughtModifier(EModifierDuration Duration) : Modifier(EModifierKind.Cell, EModifierId.Drought, Duration)
|
|
{
|
|
protected override DroughtModifier CreateInstance() => new(Duration);
|
|
|
|
public override void OnAdded(Entity owner, List<Intent> newIntents)
|
|
{
|
|
if (owner is not Cell cell)
|
|
throw new NotSupportedException("Drought is only allowed in cells.");
|
|
|
|
cell.Type = cell.Type switch
|
|
{
|
|
ECellType.Fertile => ECellType.Grass,
|
|
ECellType.Grass => ECellType.Dry,
|
|
_ => throw new NotSupportedException("Drought only works on Fertile and Grass")
|
|
};
|
|
}
|
|
|
|
public override void OnRemoved(Entity owner, List<Intent> newIntents)
|
|
{
|
|
if (owner is not Cell cell)
|
|
throw new NotSupportedException("Drought is only allowed in cells.");
|
|
|
|
cell.Type = cell.Type switch
|
|
{
|
|
ECellType.Grass => ECellType.Fertile,
|
|
ECellType.Dry => ECellType.Grass,
|
|
_ => throw new NotSupportedException("Drought can only be removed from Dry and Grass")
|
|
};
|
|
}
|
|
|
|
public override string ToolTip => "Humidity was reduced from this land, reducing fertility and maybe drying out.";
|
|
} |