diff options
author | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
---|---|---|
committer | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
commit | ced3d03bdb3ce866d832e03fb212865140905a9a (patch) | |
tree | 2a16c2063a46d3c354ce1585029dda3124f6ad93 /V3/AI/Internal/AttackStrategy.cs | |
parent | 0394dccaf06e1009e591a6ff4d645895574724c1 (diff) | |
download | V3-ced3d03bdb3ce866d832e03fb212865140905a9a.tar.gz V3-ced3d03bdb3ce866d832e03fb212865140905a9a.tar.bz2 |
Diffstat (limited to 'V3/AI/Internal/AttackStrategy.cs')
-rw-r--r-- | V3/AI/Internal/AttackStrategy.cs | 48 |
1 files changed, 48 insertions, 0 deletions
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 +{ + /// <summary> + /// A simple strategy for the computer player that tells him to attack the + /// enemy creatures. + /// </summary> + internal class AttackStrategy : IStrategy + { + /// <summary> + /// Updates the current state according to the game situtation. + /// </summary> + /// <param name="state">the current state</param> + /// <param name="worldView">the current view of the game world</param> + /// <returns>the next state indicated by this strategy</returns> + 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; + } + } +} |