29 protected int sizeX; |
29 protected int sizeX; |
30 protected int sizeY; |
30 protected int sizeY; |
31 protected int waterLevel = 0; |
31 protected int waterLevel = 0; |
32 protected int flooding = 0; |
32 protected int flooding = 0; |
33 protected int robotWaterproof = 10; |
33 protected int robotWaterproof = 10; |
|
34 protected int growth = 25; |
|
35 protected int razorsCount = 0; |
34 protected static Pattern minePattern = Pattern |
36 protected static Pattern minePattern = Pattern |
35 .compile("(?s)(.*?)(\n\n(Water.*|Flooding.*|Waterproof.*|Trampoline.*)|$)"); |
37 .compile("(?s)(.*?)(\n\n(Water.*|Flooding.*|Waterproof.*|Trampoline.*|Growth.*|Razors.*)|$)"); |
36 protected static Pattern waterPattern = Pattern.compile("(?s).*(?<=.*Water )(\\d+).*"); |
38 protected static Pattern waterPattern = Pattern.compile("(?s).*(?<=.*Water )(\\d+).*"); |
37 protected static Pattern floodingPattern = Pattern.compile("(?s).*(?<=.*Flooding )(\\d+).*"); |
39 protected static Pattern floodingPattern = Pattern.compile("(?s).*(?<=.*Flooding )(\\d+).*"); |
38 protected static Pattern waterproofPattern = Pattern.compile("(?s).*(?<=.*Waterproof )(\\d+).*"); |
40 protected static Pattern waterproofPattern = Pattern.compile("(?s).*(?<=.*Waterproof )(\\d+).*"); |
|
41 protected static Pattern growthPattern = Pattern.compile("(?s).*(?<=.*Growth )(\\d+).*"); |
|
42 protected static Pattern razorsPattern = Pattern.compile("(?s).*(?<=.*Razors )(\\d+).*"); |
39 protected static Pattern trampolinePattern = Pattern |
43 protected static Pattern trampolinePattern = Pattern |
40 .compile("(?s).*?Trampoline ([A-I]) targets ([1-9]).*"); |
44 .compile("(?s).*?Trampoline ([A-I]) targets ([1-9]).*"); |
41 protected static String firstTrampolineRegexp = "(?s).*?Trampoline ([A-I]) targets ([1-9])"; |
45 protected static String firstTrampolineRegexp = "(?s).*?Trampoline ([A-I]) targets ([1-9])"; |
42 |
46 |
43 public Mine(String text) { |
47 public Mine(String text) { |
59 } |
63 } |
60 text += "\n"; |
64 text += "\n"; |
61 } |
65 } |
62 text = text.replaceAll("\n*$", ""); |
66 text = text.replaceAll("\n*$", ""); |
63 text += "\n\n"; |
67 text += "\n\n"; |
64 if (waterLevel != 0 || flooding != 0 || robotWaterproof != 10) { |
68 if (waterLevel != 0) { |
65 text += "Water " + waterLevel + "\n"; |
69 text += "Water " + waterLevel + "\n"; |
|
70 } |
|
71 if (flooding != 0) { |
66 text += "Flooding " + flooding + "\n"; |
72 text += "Flooding " + flooding + "\n"; |
67 text += "Waterproof " + robotWaterproof + "\n"; |
73 } |
68 } |
74 text += "Waterproof " + robotWaterproof + "\n"; |
69 for (CellContent trampoline : CellContent.values()) { |
75 for (CellContent trampoline : CellContent.values()) { |
70 if (trampoline.getTrampolineTarget() != null) |
76 if (trampoline.getTrampolineTarget() != null) |
71 text += "Trampoline " + trampoline.toText() + " targets " + trampoline.getTrampolineTarget().toText() |
77 text += "Trampoline " + trampoline.toText() + " targets " + trampoline.getTrampolineTarget().toText() |
72 + "\n"; |
78 + "\n"; |
|
79 } |
|
80 text += "Growth " + growth + "\n"; |
|
81 if (razorsCount != 0) { |
|
82 text += "Razors " + razorsCount + "\n"; |
73 } |
83 } |
74 text = text.replaceAll("\n*$", ""); |
84 text = text.replaceAll("\n*$", ""); |
75 return text; |
85 return text; |
76 } |
86 } |
77 |
87 |
143 trampoline.setTrampolineTarget(target); |
153 trampoline.setTrampolineTarget(target); |
144 } else |
154 } else |
145 break; |
155 break; |
146 trampolines = trampolines.replaceFirst(firstTrampolineRegexp, ""); |
156 trampolines = trampolines.replaceFirst(firstTrampolineRegexp, ""); |
147 } |
157 } |
|
158 |
|
159 // Growth and razorsCount |
|
160 String sGrowth = ""; |
|
161 String sRazors = ""; |
|
162 Matcher growthMatcher = growthPattern.matcher(metadata); |
|
163 if (growthMatcher.matches()) { |
|
164 sGrowth = growthMatcher.group(1); |
|
165 } |
|
166 Matcher razorsMatcher = razorsPattern.matcher(metadata); |
|
167 if (razorsMatcher.matches()) { |
|
168 sRazors = razorsMatcher.group(1); |
|
169 } |
|
170 if (sGrowth.length() > 0) |
|
171 growth = Integer.parseInt(sGrowth); |
|
172 if (sRazors.length() > 0) |
|
173 razorsCount = Integer.parseInt(sRazors); |
148 } |
174 } |
149 } |
175 } |
150 |
176 |
151 public Cell getCell(Coordinate coordinate) { |
177 public Cell getCell(Coordinate coordinate) { |
152 if (coordinate == null) |
178 if (coordinate == null) |