-
Notifications
You must be signed in to change notification settings - Fork 0
/
PockyRunner.java
178 lines (146 loc) · 4.44 KB
/
PockyRunner.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package Maestus.Porkyman;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class PockyRunner {
private static Scanner sn;
private static boolean askNickname;
private static int[] availablePockymon = { 157, 258, 722, 727 };
private static String[] availablePockymonNames = { "Typhlosion", "Mudkip", "Rowlet", "Incineroar" };
public static void main(String[] args) {
List<Player> theHungerGames = new LinkedList<Player>();
sn = new Scanner(System.in);
int team = 0;
askNickname = true;
System.out.println("Welcome to Pockymon Coliseum! How many players are we expecting today?");
int n = requestNum();
for (int i = 0; i < n; i++) {
theHungerGames.add(makeHumanPlayer(team));
team = (team + 1) % 2;
}
System.out.println("Ah, excellent! And how many competitors are we expecting?");
n = requestNum();
for (int i = 0; i < n; i++) {
theHungerGames.add(makeComputerPlayer(team));
team = (team + 1) % 4;
}
System.out.println("Alrighties, that's all of the questions for now. May luck smile on you today.");
Player[] mayTheOdds = new Player[theHungerGames.size()];
for (int i = 0; i < theHungerGames.size(); i++) {
mayTheOdds[i] = theHungerGames.get(i);
}
PockymonBattle DEATH = new PockymonBattle(mayTheOdds);
DEATH.start();
}
private static Player makeHumanPlayer(int team) {
int pokeball = requestPockymon();
askNickname = true;
return new HumanPlayer(generatePockymon(pokeball, team), new HiPotion());
}
private static Player makeComputerPlayer(int team) {
int rand = (int)(Math.ceil(availablePockymon.length * Math.random()) % availablePockymon.length);
// Maybe naming the enemy's pokemon would be funny?
askNickname = false;
return new ComputerPlayer(generatePockymon(availablePockymon[rand], team), new HiPotion());
}
private static Pockymon generatePockymon(int n, int team) {
String nickname = "";
final List<Skill> doStuff = new LinkedList<Skill>();
doStuff.add(new StringSkill());
doStuff.add(new StringSkill());
doStuff.add(new StringSkill());
if (askNickname)
nickname = requestNickname();
switch (n) {
case 157: {
if (nickname.equals(""))
nickname = "Tyco";
doStuff.add(new Eruption());
return new Typhlosion(nickname, doStuff, team);
}
case 258: {
if (nickname.equals(""))
nickname = "Mudkipz";
doStuff.add(new BubbleBeam());
return new Mudkip(nickname, doStuff, team);
}
case 722: {
if (nickname.equals(""))
nickname = "Birb";
doStuff.add(new Synthesis());
return new Rowlet(nickname, doStuff, team);
}
case 727: {
if (nickname.equals(""))
nickname = "Barcat Barcat";
doStuff.add(new DarkestLariat());
return new Incineroar(nickname, doStuff, team);
}
default: {
doStuff.add(new Eruption());
return new Typhlosion("Typhlosion", doStuff, team);
}
}
}
private static void printChoices() {
String s = "";
for (int i = 0; i < availablePockymon.length; i++) {
s += "#" + availablePockymon[i] + ": " + availablePockymonNames[i] + "\n";
}
System.out.println(s);
}
private static int requestPockymon() {
String s = null;
int n = -1;
boolean done = false;
System.out.println("Please choose any of the following pockymon.");
printChoices();
do {
s = sn.nextLine();
try {
n = Integer.parseInt(s);
for (int i = 0; i < availablePockymon.length; i++) {
if (n == availablePockymon[i])
return n;
}
} catch (NumberFormatException nfe) {
for (int i = 0; i < availablePockymonNames.length; i++) {
if (s.equals(availablePockymonNames[i]))
return availablePockymon[i];
}
if (s.equals("Quit") || s.equals("quit") || s.equals("q") || s.equals("Q")) {
System.exit(0);
}
}
} while (!done);
return -1;
}
private static int requestNum() {
String s = null;
int n = -1;
boolean done = false;
do {
s = sn.nextLine();
try {
n = Integer.parseInt(s);
if (n >= 0)
return n;
} catch (NumberFormatException nfe) {
System.out.println("Please type a number.");
if (s.equals("Quit") || s.equals("quit") || s.equals("q") || s.equals("Q")) {
System.exit(0);
}
}
} while (!done);
return -1;
}
private static String requestNickname() {
String s = null;
boolean done = false;
System.out.println("Mmmm yes, and what might be its wonderful name?");
do {
s = sn.nextLine();
return s;
} while (!done);
}
}