forked from helloplz/MazeBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial board and player interfaces.
- Loading branch information
1 parent
a7aa9a2
commit a9efa7a
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
13
Mazebuilder/src/com/mazebuilder/renderer/BoardRendererOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} |