forked from svarogdaal/battle-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomizer.java
61 lines (55 loc) · 1.38 KB
/
Customizer.java
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
56
57
58
59
60
61
package BattleSimulator;
public class Customizer
{
public static Army customizeArmy(String name, int n)
{
if (n == 1)
{
System.out.print("\nSet total number of units: ");
int number = InputTester.checkInteger();
return setRandomArmy(name, number);
}
else
{
System.out.print("\nSet army name: ");
String customName = InputTester.unchecked();
System.out.println();
return setCustomArmy(customName);
}
}
public static BasicUnit[][] customizeStrategy(int n, Army army1, Army army2)
{
if (n == 1)
{
int number = 1 + (int)(Math.random() * 4);
switch (number)
{
case 1:
return Strategies.aggressive(army1, army2);
case 2:
return Strategies.cooperativeAggressive(army1, army2);
case 3:
return Strategies.defensive(army1);
default:
return Strategies.mixed(army1, army2);
}
}
else if (n == 2)
return Strategies.aggressive(army1, army2);
else if (n == 3)
return Strategies.cooperativeAggressive(army1, army2);
else if (n == 4)
return Strategies.defensive(army1);
else
return Strategies.mixed(army1, army2);
}
public static Army setRandomArmy(String name, int n)
{
return new Army(name, n);
}
public static Army setCustomArmy(String name)
{
System.out.printf("Input units for *%s* army...\n\n", name);
return new Army(name);
}
}