Skip to content

Commit

Permalink
Added initial board and player interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
obi1kenobi committed Sep 22, 2012
1 parent a7aa9a2 commit a9efa7a
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Mazebuilder/src/com/mazebuilder/gameplay/Board.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.mazebuilder.gameplay;

public interface Board {

/** Number of tiles in the horizontal board direction. **/
int tilesAcross();

/** Number of tiles in the vertical board direction. **/
int tilesDown();

/** Returns the location of the given player. Uses identity (==) comparisons. **/
Location getPlayerLocation(Player p);

/**
* Returns the new location of the given player. Will return the same location if the move is impossible.
* Does not jump walls. Uses identity (==) comparisons.
**/
Location movePlayer(Player p, Direction d);

/**
* Returns the new location of the given player. Will return the same location if the move is impossible (player cannot jump or no wall to jump).
* Uses identity (==) comparisons.
**/
Location jumpPlayer(Player p, Direction d, Direction... bonusesToSpend);

/**
* Sets a wall on the given tile, in the direction given. Returns true if the wall was successfully set, false otherwise (if a wall is already there).
*/
boolean setWall(Location l, Direction d);

}
20 changes: 20 additions & 0 deletions Mazebuilder/src/com/mazebuilder/gameplay/Direction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.mazebuilder.gameplay;

public enum Direction {

LEFT(1),
UP(2),
RIGHT(4),
DOWN(8);

private int value;

private Direction(int value) {
this.value = value;
}

public int value() {
return value;
}

}
15 changes: 15 additions & 0 deletions Mazebuilder/src/com/mazebuilder/gameplay/Location.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mazebuilder.gameplay;

import com.mazebuilder.renderer.BoardRendererOptions;

public interface Location {

int getRow();

int getColumn();

int toPixelX(BoardRendererOptions b);

int toPixelY(BoardRendererOptions b);

}
23 changes: 23 additions & 0 deletions Mazebuilder/src/com/mazebuilder/gameplay/Player.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mazebuilder.gameplay;

import com.google.common.collect.Multiset;

public interface Player {

String getName();

boolean canJump();

/** Should be called every turn -- will handle matters such as drawing movement bonuses etc. **/
boolean executeTurn();

/** Returns the set of bonuses for the player. **/
Multiset<Direction> getBonuses();

/** Returns the number of bonuses the player needs to spend to jump a wall **/
int bonusesToJump();

/** Removes a bonus from the player. **/
boolean spendBonus(Direction d);

}
13 changes: 13 additions & 0 deletions Mazebuilder/src/com/mazebuilder/renderer/BoardRendererOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mazebuilder.renderer;

public interface BoardRendererOptions {

int tileHeight();

int tileWidth();

int wallHeight();

int wallWidth();

}

0 comments on commit a9efa7a

Please sign in to comment.