1 package micropolisj.research;
3 import java.io.Serializable;
4 import java.util.HashSet;
5 import java.util.ResourceBundle;
7 import micropolisj.engine.MapState;
8 import micropolisj.engine.MicropolisTool;
12 int rocketNameDecider = 0;
13 int policeNameDecider = 0;
14 int fireNameDecider = 0;
15 int pollNameDecider = 0;
16 int rocketDescDecider = 0;
17 int policeDescDecider = 0;
18 int fireDescDecider = 0;
19 int pollDescDecider = 0;
21 static ResourceBundle strings = ResourceBundle.getBundle(
"micropolisj.GuiStrings");
24 static int[][] needed = {
30 int height = 2, width = 2;
31 static int[] positionsX = {
38 static int[] positionsY = {
48 new RocketNode(1, 1000),
new RocketNode(2, 2500),
new RocketNode(3, 5000)
49 ,
new PoliceNode(1, 150),
new PoliceNode(2, 350),
new PoliceNode(3, 650)
50 ,
new FiremanNode(1, 150),
new FiremanNode(2, 350),
new FiremanNode(3, 650)
51 ,
new EnvironmentNode(1, 150),
new EnvironmentNode(2, 350),
new EnvironmentNode(3, 650)
55 boolean isReachable(HashSet<Integer> reached_nodes,
int node_id) {
56 for(
int nid : needed[node_id]) {
57 if(!reached_nodes.contains(nid))
65 class RocketNode
implements ResearchNode {
70 public RocketNode(
int st,
int cost){
76 public String getName() {
78 switch(rocketNameDecider) {
81 return strings.getString(
"research.ROCKET_T1_NAME");
85 return strings.getString(
"research.ROCKET_T2_NAME");
88 rocketNameDecider = 0;
89 return strings.getString(
"research.ROCKET_T3_NAME");
92 throw new Error(
"unreachable Research String");
97 public String getDesc() {
99 switch(rocketDescDecider) {
101 rocketDescDecider ++;
102 return strings.getString(
"research.ROCKET_T1_DESCRIPTION");
105 rocketDescDecider ++;
106 return strings.getString(
"research.ROCKET_T2_DESCRIPTION");
109 rocketDescDecider = 0;
110 return strings.getString(
"research.ROCKET_T3_DESCRIPTION");
113 throw new Error(
"unreachable Research String");
118 public String getIcon() {
119 return "/firestation.png";
123 public int getCost() {
131 public void makeChanges(ResearchState state) {
132 state.rocketResearch = id;
133 state.toolBtns.get(MicropolisTool.ROCKET).setVisible(
true);
137 class PoliceNode
implements ResearchNode {
142 public PoliceNode(
int st,
int cost){
148 public String getName() {
150 switch(policeNameDecider) {
152 policeNameDecider ++;
153 return strings.getString(
"research.POLICE_T1_NAME");
156 policeNameDecider ++;
157 return strings.getString(
"research.POLICE_T2_NAME");
160 policeNameDecider = 0;
161 return strings.getString(
"research.POLICE_T3_NAME");
164 throw new Error(
"unreachable Research String");
169 public String getDesc() {
171 switch(policeDescDecider) {
173 policeDescDecider ++;
174 return strings.getString(
"research.POLICE_T1_DESCRIPTION");
177 policeDescDecider ++;
178 return strings.getString(
"research.POLICE_T2_DESCRIPTION");
181 policeDescDecider = 0;
182 return strings.getString(
"research.POLICE_T3_DESCRIPTION");
185 throw new Error(
"unreachable Research String");
190 public String getIcon() {
191 return "/firestation.png";
195 public int getCost() {
199 public void makeChanges(ResearchState state) {
200 state.policeResearch = id;
204 class FiremanNode
implements ResearchNode {
209 public FiremanNode(
int st,
int cost){
215 public String getName() {
217 switch(fireNameDecider) {
220 return strings.getString(
"research.FIRE_T1_NAME");
224 return strings.getString(
"research.FIRE_T2_NAME");
228 return strings.getString(
"research.FIRE_T3_NAME");
231 throw new Error(
"unreachable Research String");
236 public String getDesc() {
238 switch(fireDescDecider) {
241 return strings.getString(
"research.FIRE_T1_DESCRIPTION");
245 return strings.getString(
"research.FIRE_T2_DESCRIPTION");
249 return strings.getString(
"research.FIRE_T3_DESCRIPTION");
252 throw new Error(
"unreachable Research String");
257 public String getIcon() {
258 return "/firestation.png";
262 public int getCost() {
266 public void makeChanges(ResearchState state) {
267 state.firemanResearch = id;
271 class EnvironmentNode
implements ResearchNode {
276 public EnvironmentNode(
int st,
int cost){
282 public String getName() {
284 switch(pollNameDecider) {
287 return strings.getString(
"research.POLL_T1_NAME");
291 return strings.getString(
"research.POLL_T2_NAME");
295 return strings.getString(
"research.POLL_T3_NAME");
298 throw new Error(
"unreachable Research String");
303 public String getDesc() {
305 switch(pollDescDecider) {
308 return strings.getString(
"research.POLL_T1_DESCRIPTION");
312 return strings.getString(
"research.POLL_T2_DESCRIPTION");
316 return strings.getString(
"research.POLL_T3_DESCRIPTION");
319 throw new Error(
"unreachable Research String");
324 public String getIcon() {
325 return "/firestation.png";
329 public int getCost() {
333 public void makeChanges(ResearchState state) {
334 state.environmentResearch = id;