forked from nus-cs2113-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic map, textbox and status bar
- Loading branch information
Showing
8 changed files
with
156 additions
and
26 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 |
---|---|---|
|
@@ -4,6 +4,5 @@ | |
public class MovingRightCommand extends MapMoveCommand { | ||
@Override | ||
public void execute() { | ||
|
||
} | ||
} |
14 changes: 7 additions & 7 deletions
14
src/main/java/main/CalculaChroniclesOfTheAlgorithmicKingdom.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
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
package map; | ||
|
||
public class FirstMap extends Map{ | ||
protected String DIFFICULTY_MODIFIER = "easy"; //can use to determine question difficulty | ||
} |
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 |
---|---|---|
@@ -1,8 +1,77 @@ | ||
package map; | ||
|
||
import command.Command; | ||
import java.util.ArrayList; | ||
|
||
public abstract class Map { | ||
public abstract void initMap(); | ||
public abstract void nextMapBasedOnCommand(Command userCommand); | ||
protected int width; | ||
protected int height; | ||
protected ArrayList<ArrayList<Character>> storedMap; | ||
protected int playerX; | ||
protected int playerY; | ||
protected String mapName; | ||
|
||
|
||
|
||
public void initMap(int givenWidth, int givenHeight){ | ||
this.width = givenWidth; | ||
this.height = givenHeight; | ||
this.storedMap = new ArrayList<>(height); | ||
|
||
for (int i = 0; i < height; i += 1){ | ||
ArrayList<Character> row = new ArrayList<>(width); | ||
for (int j = 0; j < width; j += 1){ | ||
row.add('.'); | ||
} | ||
storedMap.add(row); | ||
} | ||
} | ||
|
||
|
||
public ArrayList<ArrayList<Character>> getStoredMap() { | ||
return storedMap; | ||
} | ||
|
||
public void initPlayerLocation(int x, int y){ | ||
if (x >= 0 && x < width && y >= 0 && y < height){ | ||
storedMap.get(y).set(x, 'P'); | ||
this.playerX = x; | ||
this.playerY = y; | ||
} | ||
} | ||
|
||
|
||
public void movePlayerUpOne(){ | ||
if (this.playerY - 1 >= 0){ | ||
storedMap.get(playerY).set(playerX, '.'); | ||
storedMap.get(playerY - 1).set(playerX, 'P'); | ||
} | ||
} | ||
|
||
|
||
public void movePlayerDownOne(){ | ||
if (this.playerY + 1 < height){ | ||
storedMap.get(playerY).set(playerX, '.'); | ||
storedMap.get(playerY + 1).set(playerX, 'P'); | ||
} | ||
} | ||
|
||
|
||
public void movePlayerLeftOne(){ | ||
if (this.playerX - 1 >= 0){ | ||
storedMap.get(playerY).set(playerX, '.'); | ||
storedMap.get(playerY).set(playerX - 1, 'P'); | ||
} | ||
} | ||
|
||
|
||
public void movePlayerRightOne(){ | ||
if (this.playerY + 1 < width){ | ||
storedMap.get(playerY).set(playerX, '.'); | ||
storedMap.get(playerY).set(playerX + 1, 'P'); | ||
} | ||
} | ||
|
||
public void nextMapBasedOnCommand(Command userCommand){ | ||
userCommand.execute(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,38 @@ | ||
package textbox; | ||
|
||
|
||
public class PlayerStatus { | ||
public void showPlayerStatus(){ | ||
private int playerHealth; | ||
private int playerMoney; | ||
private int playerExp; | ||
|
||
public PlayerStatus(int startHealth, int startMoney, int startExp){ | ||
this.playerHealth = startHealth; | ||
this.playerMoney = startMoney; | ||
this.playerExp = startExp; | ||
} | ||
|
||
public int getPlayerHealth(){ | ||
return this.playerHealth; | ||
} | ||
|
||
public int getPlayerMoney(){ | ||
return this.playerMoney; | ||
} | ||
|
||
public int getPlayerExp(){ | ||
return this.playerExp; | ||
} | ||
|
||
public void setPlayerExp(int playerExp) { | ||
this.playerExp = playerExp; | ||
} | ||
|
||
public void setPlayerHealth(int playerHealth) { | ||
this.playerHealth = playerHealth; | ||
} | ||
|
||
public void setPlayerMoney(int playerMoney) { | ||
this.playerMoney = playerMoney; | ||
} | ||
} |
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
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