diff --git a/core/app/Initializer.java b/core/app/Initializer.java index 6d0dd0dcb023505a9f62270012ddf3b48c35600e..c66f1960d817ad83a0cba80b942485b042a2d944 100644 --- a/core/app/Initializer.java +++ b/core/app/Initializer.java @@ -34,7 +34,8 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Field field = new Field("neighbourField"); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.addMapElement(field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); model.getColonel().step(); break; @@ -49,8 +50,8 @@ public class Initializer { { initColonelNextToWall(model); Portal portal = new Portal("portal", Color.BLUE); - portal.setField(model.getColonel().getField().getNeighbour(Direction.RIGHT)); - model.getColonel().getField().getNeighbour(Direction.RIGHT).addElement(portal); + portal.setField(model.getMapElement(2)); + model.getMapElement(2).addElement(portal); switch(version.get(1)) { case 1: @@ -60,6 +61,7 @@ public class Initializer { case 2: { Field otherField = new Field("otherSideField"); + model.addMapElement(otherField); Wall otherWall = new Wall("otherSideWall"); otherWall.setField(otherField); otherField.addElement(otherWall); @@ -67,11 +69,15 @@ public class Initializer { otherSidePortal.setField(otherField); otherField.addElement(otherSidePortal); portal.setOtherSide(otherSidePortal); + Field thirdField = new Field("otherSideNeighbour"); + model.addMapElement(thirdField); + otherField.setNeighbour(Direction.RIGHT, thirdField); break; } case 3: { Field otherField = new Field("otherSideField"); + model.addMapElement(otherField); Wall otherWall = new Wall("otherSideWall"); otherWall.setField(otherField); otherField.addElement(otherWall); @@ -80,6 +86,7 @@ public class Initializer { otherField.addElement(otherSidePortal); portal.setOtherSide(otherSidePortal); Field thirdField = new Field("otherSideNeighbour"); + model.addMapElement(thirdField); Box otherSideBox = new Box("otherSideBox"); otherSideBox.setField(thirdField); thirdField.addElement(otherSideBox); @@ -110,8 +117,8 @@ public class Initializer { case 1: { Box box = new Box("weightBox"); - box.setField(model.getColonel().getField().getNeighbour(Direction.RIGHT)); - model.getColonel().getField().getNeighbour(Direction.RIGHT).addElement(box); + box.setField(model.getMapElement(2)); + model.getMapElement(2).addElement(box); break; } case 2: @@ -144,10 +151,11 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Field field = new Field("neighbourField"); + model.addMapElement(field); ZPM zpm = new ZPM("ZPM"); zpm.setField(field); field.addElement(zpm); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); model.getColonel().step(); break; @@ -156,10 +164,11 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Field field = new Field("neighbourField"); + model.addMapElement(field); Gate gate = new Gate("gate"); gate.setField(field); field.addElement(gate); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); model.getColonel().step(); break; @@ -168,7 +177,8 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Field field = new Field("neighbourField"); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.addMapElement(field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); switch(version.get(1)) { @@ -228,8 +238,8 @@ public class Initializer { { initColonelNextToWall(model); Portal portal = new Portal("portal", Color.BLUE); - portal.setField(model.getColonel().getField().getNeighbour(Direction.RIGHT)); - model.getColonel().getField().getNeighbour(Direction.RIGHT).addElement(portal); + portal.setField(model.getMapElement(2)); + model.getMapElement(2).addElement(portal); switch(version.get(1)) { case 1: @@ -279,8 +289,8 @@ public class Initializer { case 1: { Box weightBox = new Box("weightBox"); - weightBox.setField(model.getColonel().getField().getNeighbour(Direction.RIGHT)); - model.getColonel().getField().getNeighbour(Direction.RIGHT).addElement(weightBox); + weightBox.setField(model.getMapElement(2)); + model.getMapElement(2).addElement(weightBox); break; } case 2: @@ -321,10 +331,11 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Field field = new Field("neighbourField"); + model.addMapElement(field); Gate gate = new Gate("gate"); gate.setField(field); field.addElement(gate); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); switch(version.get(1)) { @@ -346,10 +357,11 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Field field = new Field("neighbourField"); + model.addMapElement(field); ZPM zpm = new ZPM("ZPM"); zpm.setField(field); field.addElement(zpm); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); switch(version.get(1)) { @@ -371,7 +383,8 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Field field = new Field("neighbourField"); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.addMapElement(field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); switch(version.get(1)) { @@ -412,8 +425,8 @@ public class Initializer { { initColonelNextToLibra(model); Box weightBox = new Box("weightBox"); - weightBox.setField(model.getColonel().getField().getNeighbour(Direction.RIGHT)); - model.getColonel().getField().getNeighbour(Direction.RIGHT).addElement(weightBox); + weightBox.setField(model.getMapElement(2)); + model.getMapElement(2).addElement(weightBox); switch(version.get(1)) { case 1: @@ -433,13 +446,17 @@ public class Initializer { case 23: { initEmptyPlaceWithColonel(model); + + Field tmp = model.getMapElement(1); switch (version.get(1)) { case 1: { Field f = new Field("neighbourField"); - model.getColonel().getField().setNeighbour(Direction.RIGHT, f); + model.addMapElement(f); + model.getMapElement(1).setNeighbour(Direction.RIGHT, f); model.getColonel().setDirection(Direction.RIGHT); + tmp = f; break; } case 2: @@ -451,16 +468,13 @@ public class Initializer { { case 1: { - Field tmp = model.getColonel().getField(); - while(tmp.getNeighbour(Direction.RIGHT) != null) - { - tmp = tmp.getNeighbour(Direction.RIGHT); - } Field f = new Field("boxField"); + model.addMapElement(f); tmp.setNeighbour(Direction.RIGHT, f); Box box = new Box("box"); box.setField(f); f.addElement(box); + tmp = f; break; } case 2: @@ -472,16 +486,13 @@ public class Initializer { { case 1: { - Field tmp = model.getColonel().getField(); - while(tmp.getNeighbour(Direction.RIGHT) != null) - { - tmp = tmp.getNeighbour(Direction.RIGHT); - } Field f = new Field("ravineField"); + model.addMapElement(f); tmp.setNeighbour(Direction.RIGHT, f); Ravine ravine = new Ravine("ravine"); ravine.setField(f); f.addElement(ravine); + tmp = f; break; } case 2: @@ -493,16 +504,13 @@ public class Initializer { { case 1: { - Field tmp = model.getColonel().getField(); - while(tmp.getNeighbour(Direction.RIGHT) != null) - { - tmp = tmp.getNeighbour(Direction.RIGHT); - } Field f = new Field("zpmField"); + model.addMapElement(f); tmp.setNeighbour(Direction.RIGHT, f); ZPM zpm = new ZPM("zpm"); zpm.setField(f); f.addElement(zpm); + tmp = f; break; } case 2: @@ -514,17 +522,14 @@ public class Initializer { { case 1: { - Field tmp = model.getColonel().getField(); - while(tmp.getNeighbour(Direction.RIGHT) != null) - { - tmp = tmp.getNeighbour(Direction.RIGHT); - } Field f = new Field("doorField"); + model.addMapElement(f); tmp.setNeighbour(Direction.RIGHT, f); Door door = new Door("openDoor"); door.setField(f); f.addElement(door); door.setOpen(true); + tmp = f; break; } case 2: @@ -536,16 +541,13 @@ public class Initializer { { case 1: { - Field tmp = model.getColonel().getField(); - while(tmp.getNeighbour(Direction.RIGHT) != null) - { - tmp = tmp.getNeighbour(Direction.RIGHT); - } Field f = new Field("libraField"); + model.addMapElement(f); tmp.setNeighbour(Direction.RIGHT, f); Libra libra = new Libra("emptyLibra"); libra.setField(f); f.addElement(libra); + tmp = f; break; } case 2: @@ -553,12 +555,8 @@ public class Initializer { break; } } - Field tmp = model.getColonel().getField(); - while(tmp.getNeighbour(Direction.RIGHT) != null) - { - tmp = tmp.getNeighbour(Direction.RIGHT); - } Field field = new Field("blastField"); + model.addMapElement(field); tmp.setNeighbour(Direction.RIGHT, field); switch(version.get(7)) { @@ -609,10 +607,11 @@ public class Initializer { { initEmptyPlaceWithColonel(model); Libra libra = new Libra("libra"); - model.getColonel().getField().addElement(libra); + model.getMapElement(1).addElement(libra); libra.setField(model.getColonel().getField()); Field field = new Field("neighbour"); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.addMapElement(field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); model.getColonel().step(); break; @@ -635,9 +634,10 @@ public class Initializer { initEmptyPlaceWithColonel(model); Wall wall = new Wall("wall"); Field field = new Field("neighbourField"); + model.addMapElement(field); wall.setField(field); field.addElement(wall); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); } @@ -646,9 +646,10 @@ public class Initializer { initEmptyPlaceWithColonel(model); Ravine ravine = new Ravine("ravine"); Field field = new Field("neighbourField"); + model.addMapElement(field); ravine.setField(field); field.addElement(ravine); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); } @@ -657,9 +658,10 @@ public class Initializer { initEmptyPlaceWithColonel(model); Box box = new Box("box"); Field field = new Field("neighbourField"); + model.addMapElement(field); box.setField(field); field.addElement(box); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); } @@ -668,11 +670,12 @@ public class Initializer { initEmptyPlaceWithColonel(model); Libra libra = new Libra("libra"); Field field = new Field("neighbourField"); + model.addMapElement(field); libra.setField(field); Door door = new Door("door"); libra.setDoor(door); field.addElement(libra); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); } @@ -689,9 +692,10 @@ public class Initializer { door = new Door("closedDoor"); } Field field = new Field("neighbourField"); + model.addMapElement(field); door.setField(field); field.addElement(door); - model.getColonel().getField().setNeighbour(Direction.RIGHT, field); + model.getMapElement(1).setNeighbour(Direction.RIGHT, field); model.getColonel().setDirection(Direction.RIGHT); door.setOpen(isOpen); } diff --git a/core/game/Model.java b/core/game/Model.java index 3a31394031ebc445625b963d84ece81c2f8102f9..0db8703c785d63aeaf524a4951993ae38097bcd6 100644 --- a/core/game/Model.java +++ b/core/game/Model.java @@ -40,23 +40,23 @@ public class Model { public void setColonel(Colonel colonel) { - CustomLogger.entry(Name, "setColonel"); this.colonel = colonel; - CustomLogger.exit(Name, "setColonel"); } public Colonel getColonel() { - CustomLogger.entry(Name, "setColonel"); - CustomLogger.exit(Name, "setColonel", colonel.getName()); return colonel; } public void addMapElement(Field field) { - String arr[] = {field.getName()}; map.add(field); } + + public Field getMapElement(int num) + { + return map.get((num-1)); + } public void resetMapReq() { diff --git a/core/log/CustomLogger.java b/core/log/CustomLogger.java index a516b6ec907c331abffce1bfe225aeaae49fe93c..ea29685b2ceb1cf5aa8d6b8550c69f0fcb2dbcfc 100644 --- a/core/log/CustomLogger.java +++ b/core/log/CustomLogger.java @@ -96,6 +96,7 @@ public class CustomLogger StringBuilder message = new StringBuilder(); message.append(question); + message.append(' '); CustomLogger.log(message.toString(), LogType.CONFIG); } @@ -122,7 +123,7 @@ public class CustomLogger message.append(", "); } } - message.append(") ?"); + message.append(")? "); } CustomLogger.log(message.toString(), LogType.CONFIG); diff --git a/core/mapobjs/defobjs/DefaultElement.java b/core/mapobjs/defobjs/DefaultElement.java index 920741c16e4309ebacf58dfbe638dbeb97bb6527..f67ff4f7d9bd9878a738ed5baa4f246ef70535b1 100644 --- a/core/mapobjs/defobjs/DefaultElement.java +++ b/core/mapobjs/defobjs/DefaultElement.java @@ -28,9 +28,7 @@ public class DefaultElement implements IElement public void setField(Field f) { - CustomLogger.entry(name, "getField"); this.ownField = f; - CustomLogger.exit(name, "getField", ownField.getName()); return; } diff --git a/core/mapobjs/defobjs/Field.java b/core/mapobjs/defobjs/Field.java index e0b022744e2c028ffd906d7fb4289d18468b24c7..afecb2357ea25d666c19d05bc819b20d829f864e 100644 --- a/core/mapobjs/defobjs/Field.java +++ b/core/mapobjs/defobjs/Field.java @@ -22,33 +22,26 @@ public class Field implements IElement { public void addElement (DefaultElement elem){ String[] params = {elem.getName()}; - CustomLogger.entry(name, "addElement", params); elements.add(elem); - CustomLogger.exit(name,"addElement",params); } public void setNeighbour (Direction dir, Field ne ){ String[] params = {ne.getName(), dir.name()}; - CustomLogger.entry(name, "setNeighbour", params); switch (dir) { case UP: neighbours[0] = ne; - CustomLogger.exit(name,"setNeighbour",params); break; case RIGHT: neighbours[1] = ne; - CustomLogger.exit(name,"setNeighbour",params); break; case DOWN: neighbours[2] = ne; - CustomLogger.exit(name,"setNeighbour",params); break; case LEFT: neighbours[3] = ne; - CustomLogger.exit(name,"setNeighbour",params); break; } } diff --git a/core/mapobjs/defobjs/Portal.java b/core/mapobjs/defobjs/Portal.java index ccc96fce4cdd5786619da5a9ee36f5440edebd1d..bd94f9c05824925768316fab0c59f2ee6bf3e58f 100644 --- a/core/mapobjs/defobjs/Portal.java +++ b/core/mapobjs/defobjs/Portal.java @@ -11,7 +11,7 @@ import mapobjs.movobjs.Colonel; * Two colors are possible, only one of each can exist at the same time. * In case of two Portals if the colonel steps into one, he comes out on the other one. * - * @author Temesv�ri Fanni + * @author Temesv�ri Fanni */ public class Portal extends DefaultElement { private int side; @@ -20,9 +20,7 @@ public class Portal extends DefaultElement { public void setOtherSide(Portal otherSide) { String params[]={otherSide.getName()}; - CustomLogger.entry(name, "setOtherSide", params); this.otherSide = otherSide; - CustomLogger.exit(name, "setOtherSide", params, "true"); } private Color color; diff --git a/core/mapobjs/movobjs/Colonel.java b/core/mapobjs/movobjs/Colonel.java index 0a6280dede0e54b5a7bad468a77638b9c8b263b8..8d8b9b95895de9df4a56633698594028c230db25 100644 --- a/core/mapobjs/movobjs/Colonel.java +++ b/core/mapobjs/movobjs/Colonel.java @@ -21,10 +21,7 @@ public class Colonel extends DefaultElement implements IMovable { } public void setBox(Box box) { - String arr[]={box.getName()}; - CustomLogger.entry(name, "setBox", arr); this.box = box; - CustomLogger.exit(name, "meet", arr, "false"); } @Override public boolean meet(Bullet bullet) { @@ -92,8 +89,6 @@ public class Colonel extends DefaultElement implements IMovable { } public Direction getDirection() { - CustomLogger.entry(name, "getDirection"); - CustomLogger.exit(name, "getDirection"); return this.dir; }