-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionsBuilder.cs
More file actions
55 lines (44 loc) · 1.44 KB
/
ActionsBuilder.cs
File metadata and controls
55 lines (44 loc) · 1.44 KB
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
49
50
51
52
53
54
55
using System.Numerics;
static class ActionsBuilder
{
const string BUILD = "BUILD";
const string MOVE = "MOVE";
const string SPAWN = "SPAWN";
const string WAIT = "WAIT";
const string MESSAGE = "MESSAGE";
public static string Build (Field field)
{
return $"{BUILD} {field.PositionLog()};";
}
public static string Spawn (Field field, int amount)
{
return $"{SPAWN} {amount} {field.PositionLog()};";
}
public static string Move (Field from, Field to, int amount)
{
int secureAmount = SecureAmount(from, amount);
return $"{MOVE} {secureAmount} {from.PositionLog()} {to.PositionLog()};";
}
public static string Move (Field from, int toX ,int toY , int amount)
{
int secureAmount = SecureAmount(from, amount);
return $"{MOVE} {secureAmount} {from.PositionLog()} {toX} {toY};";
}
public static string Move (byte fromX ,byte fromY , byte toX ,byte toY , int amount)
{
return $"{MOVE} {amount} {fromX} {fromY} {toX} {toY};";
}
static int SecureAmount(Field from, int amount){
int secureAmount = amount;
if(amount > from.units)
{
Console.Error.WriteLine($"!!! Tried to move from {from.PositionLog()} {amount}, autoReduced!");
secureAmount = from.units;
}
return secureAmount;
}
public static string Wait ()
{
return WAIT;
}
}