|
11 | 11 | import model.Event; |
12 | 12 | import network.data.Message; |
13 | 13 |
|
| 14 | +import javax.xml.bind.SchemaOutputResolver; |
14 | 15 | import java.io.IOException; |
15 | 16 | import java.util.*; |
16 | 17 |
|
|
19 | 20 | */ |
20 | 21 | public class MitosisGameLogic implements GameLogic { |
21 | 22 |
|
22 | | - private final long GAME_LONG_TIME_TURN = 500; |
| 23 | + private final long GAME_LONG_TIME_TURN = 10;//TODO 500 |
23 | 24 |
|
24 | 25 | private static final String RESOURCE_PATH_CLIENTS = "resources/mitosis/clients.conf"; |
25 | 26 |
|
@@ -327,18 +328,14 @@ public void simulateEvents(Event[] terminalEvent, Event[] environmentEvent, Even |
327 | 328 | } |
328 | 329 | } |
329 | 330 |
|
330 | | - /*for (GameEvent event: gainResourceEvents) { |
331 | | - Cell cell = null; |
332 | | - for (Team team: mTeams) { |
333 | | - if (team.getCellById(event.getGameObjectId()) != null) |
334 | | - cell = team.getCellById(event.getGameObjectId()); |
| 331 | + for(Team team : mTeams) |
| 332 | + { |
| 333 | + int score = 0; |
| 334 | + for (Cell cell: team.getCells()) { |
| 335 | + score += cell.getEnergy(); |
335 | 336 | } |
336 | | - if (cell == null) continue; |
337 | | -
|
338 | | - // check if the location of the cell is of type resource |
339 | | - if (map.at(cell.getPos().x, cell.getPos().y).equals(Block.TYPE_RESOURCE)) |
340 | | - cell.gainResource(); |
341 | | - }*/ |
| 337 | + team.setScore(score); |
| 338 | + } |
342 | 339 | ctx.incTurn(); |
343 | 340 | } |
344 | 341 |
|
@@ -496,4 +493,19 @@ public Event[] makeEnvironmentEvents() { |
496 | 493 | public boolean isGameFinished() { |
497 | 494 | return ctx.getTurn() >= GAME_LONG_TIME_TURN; |
498 | 495 | } |
| 496 | + |
| 497 | + @Override |
| 498 | + public void terminate() |
| 499 | + { |
| 500 | + if(mTeams.length > 0) { |
| 501 | + for (int i = 0; i < mTeams.length; i++) { |
| 502 | + if(i > 0) |
| 503 | + { |
| 504 | + System.out.print(", "); |
| 505 | + } |
| 506 | + System.out.print(mTeams[i].getScore()); |
| 507 | + } |
| 508 | + System.out.println(); |
| 509 | + } |
| 510 | + } |
499 | 511 | } |
0 commit comments