From ced3d03bdb3ce866d832e03fb212865140905a9a Mon Sep 17 00:00:00 2001 From: Thomas Leyh Date: Sun, 24 Jul 2016 08:14:18 +0200 Subject: Add project files. --- V3/AI/Internal/AttackStrategy.cs | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 V3/AI/Internal/AttackStrategy.cs (limited to 'V3/AI/Internal/AttackStrategy.cs') diff --git a/V3/AI/Internal/AttackStrategy.cs b/V3/AI/Internal/AttackStrategy.cs new file mode 100644 index 0000000..d108b1f --- /dev/null +++ b/V3/AI/Internal/AttackStrategy.cs @@ -0,0 +1,48 @@ +namespace V3.AI.Internal +{ + /// + /// A simple strategy for the computer player that tells him to attack the + /// enemy creatures. + /// + internal class AttackStrategy : IStrategy + { + /// + /// Updates the current state according to the game situtation. + /// + /// the current state + /// the current view of the game world + /// the next state indicated by this strategy + public AiState Update(AiState state, IWorldView worldView) + { + switch (state) + { + case AiState.Idle: + if (worldView.InitialPlebsCount - worldView.PlebsCount > 3) + { + return AiState.DefendPeasants; + } + break; + case AiState.DefendPeasants: + if (worldView.PlebsCount < worldView.InitialPlebsCount * 0.75 || worldView.EnemyCount > 20) + { + return AiState.AttackCreatures; + } + break; + case AiState.AttackCreatures: + if (worldView.NecromancerHealth < 0.1) + { + return AiState.AttackNecromancer; + } + break; + case AiState.AttackNecromancer: + if (worldView.NecromancerHealth >= 0.1) + { + return AiState.AttackCreatures; + } + break; + } + + return state; + } + } +} -- cgit v1.2.1