diff --git a/cicaprojekt/PlayerBase.java b/cicaprojekt/PlayerBase.java index 233e825..4a0c1bf 100644 --- a/cicaprojekt/PlayerBase.java +++ b/cicaprojekt/PlayerBase.java @@ -1,11 +1,34 @@ package cicaprojekt; +/** + * A játékban megjelenő személyeket reprezentáló osztály. + */ public class PlayerBase implements Destroyable { + /** + * A csempe, amelyen a személy áll. + */ protected Tile currentTile; + /** + * Az irány, amerre a személy néz. + */ protected Direction facingDirection; + /** + * A személy neve. + */ protected String name; + /** + * A személy elpusztulását számontartó változó. + */ protected boolean destroyed; + /** + * Az osztály konstruktora. Kezdetben a személy életben van és a kapott + * értékekre állítódnak be a tulajdonságai. + * + * @param name a személy neve + * @param startTile a csempe, ahol kezd + * @param startDirection az irány, ahova kezdetben néz + */ public PlayerBase(String name, Tile startTile, Direction startDirection) { this.name = name; currentTile = startTile; @@ -13,25 +36,51 @@ public class PlayerBase implements Destroyable { destroyed = false; } + /** + * A személy nevével és aktuális tartózkodási helyével tér vissza. + * + * @return a személy neve és aktuális csempéje + */ @Override public String toString() { return String.format("%s: %s", name, currentTile); } + /** + * A személy elpusztulását megvalósító függvény. + * + * @see Game#playerBaseDestroyed(PlayerBase) + */ @Override public void destroy() { destroyed = true; Game.instance.playerBaseDestroyed(this); } + /** + * A személy aktuális tartózkodási helyével tér vissza. + * + * @return aktuális csempe + */ public Tile getCurrentTile() { return currentTile; } + /** + * A személy aktuális tartózkodási helyét állítja be a kapott csempére. + * + * @param newCurrentTile a kapott csempe + */ public void setCurrentTile(Tile newCurrentTile) { currentTile = newCurrentTile; } + /** + * A személy mozgását megvalósító függvény, amely keretében a személy + * egy csempényit próbál lépni a kapott irányba. + * + * @param direction a kapott irány + */ public void move(Direction direction) { if(!isDestroyed()) { this.setFacingDirection(direction); @@ -49,6 +98,9 @@ public class PlayerBase implements Destroyable { public void pickZPM(Tile tile) { /* PlayerBase does not collect ZPM modules */ } + /** + * A személy balra forgatását megvalósító függvény. + */ public void rotateLeft() { switch (facingDirection) { case NORTH: @@ -66,6 +118,9 @@ public class PlayerBase implements Destroyable { } } + /** + * A személy jobbra forgatását megvalósító függvény. + */ public void rotateRight() { switch (facingDirection) { case NORTH: @@ -83,14 +138,30 @@ public class PlayerBase implements Destroyable { } } + /** + * A függvény a személy aktuális nézési irányával tér vissza. + * + * @return irány, amerre a személy néz + */ public Direction getFacingDirection() { return facingDirection; } + /** + * Beállítja a kapott értékre, hogy arra nézzen a személy. + * + * @param direction kapott irány + */ public void setFacingDirection(Direction direction) { facingDirection = direction; } + /** + * Igazzal tér vissza, ha a személy elpusztult, hamissal, ha nem. + * + * @return true, ha elpusztult + * false, egyébként + */ public boolean isDestroyed(){ return destroyed; }