blob: d108b1f97b6efe659fe909c50beb09aa105942bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;
}
}
}
|