From: Hendrik B. <nh...@us...> - 2013-09-28 07:40:38
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/mapstuff/game In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20870/src/games/stendhal/server/entity/mapstuff/game Modified Files: SokobanBoard.java Log Message: fixed missdetection of walls as boxes in successful completion detection Index: SokobanBoard.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/mapstuff/game/SokobanBoard.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SokobanBoard.java 28 Sep 2013 07:39:20 -0000 1.10 --- SokobanBoard.java 28 Sep 2013 07:40:34 -0000 1.11 *************** *** 38,41 **** --- 38,42 ---- private final LinkedList<Entity> entitiesToCleanup = new LinkedList<Entity>(); private final Set<Pair<Integer, Integer>> containerLocations = new HashSet<Pair<Integer, Integer>>(); + private final List<Block> boxes = new LinkedList<Block>(); private final SokobanListener sokobanListener; *************** *** 75,80 **** */ public void loadLevel(int lvl) { clear(); ! levelStart = System.currentTimeMillis() / 1000; this.level = lvl; int levelOffset = (level - 1) * (HEIGHT + 1) + 1; --- 76,84 ---- */ public void loadLevel(int lvl) { + String temp = playerName; clear(); ! playerName = temp; ! ! levelStart = System.currentTimeMillis(); this.level = lvl; int levelOffset = (level - 1) * (HEIGHT + 1) + 1; *************** *** 149,154 **** this.getZone().remove(entity); } ! entitiesToCleanup.clear(); containerLocations.clear(); playerName = null; } --- 153,159 ---- this.getZone().remove(entity); } ! boxes.clear(); containerLocations.clear(); + entitiesToCleanup.clear(); playerName = null; } *************** *** 179,182 **** --- 184,188 ---- this.getZone().addMovementListener(block); entitiesToCleanup.add(block); + boxes.add(block); } *************** *** 278,282 **** private boolean isTimeout() { long diff = System.currentTimeMillis() - levelStart; ! int allowedSec = 3 * 60 + level * 30; if (level == 1) { allowedSec = 60; --- 284,288 ---- private boolean isTimeout() { long diff = System.currentTimeMillis() - levelStart; ! int allowedSec = 4 * 60 + level * 60; if (level == 1) { allowedSec = 60; *************** *** 292,304 **** */ private boolean checkLevelCompleted() { ! for (Entity entity : entitiesToCleanup) { ! if (entity instanceof Block) { ! Pair<Integer, Integer> point = new Pair<Integer, Integer>( ! Integer.valueOf(entity.getX()), Integer.valueOf(entity.getY())); ! // if this block is not on a container position, the level is not completed ! if (!containerLocations.contains(point)) { ! return false; ! } } } --- 298,308 ---- */ private boolean checkLevelCompleted() { ! for (Block entity : boxes) { ! Pair<Integer, Integer> point = new Pair<Integer, Integer>( ! Integer.valueOf(entity.getX()), Integer.valueOf(entity.getY())); ! // if this block is not on a container position, the level is not completed ! if (!containerLocations.contains(point)) { ! return false; } } *************** *** 330,335 **** // level completed? if (checkLevelCompleted()) { - clear(); sokobanListener.onSuccess(playerName, level); return; } --- 334,339 ---- // level completed? if (checkLevelCompleted()) { sokobanListener.onSuccess(playerName, level); + clear(); return; } |