Browse Source

refactoring: changed spelling in getCell method in Cell

remotes/origin/playerRefactoring
fdai7910 11 months ago
parent
commit
3e236d7847
  1. 6
      src/main/java/pacmanGame/GameManager.java
  2. 4
      src/main/java/pacmanGame/Map.java
  3. 4
      src/main/java/pacmanGame/Player.java
  4. 2
      src/main/java/pacmanGame/VisualizerPlainText.java
  5. 2
      src/main/java/pacmanGame/VisualizerPlainTextUltra.java
  6. 14
      src/test/java/pacmanTests/CellTest.java
  7. 6
      src/test/java/pacmanTests/MapTest.java

6
src/main/java/pacmanGame/GameManager.java

@ -79,11 +79,11 @@ public class GameManager {
}
public void spawnFruit() {
map.GetCell(map.playerSpawn).type = randomFruit();
map.getCell(map.playerSpawn).type = randomFruit();
}
public void destroyFruit() {
map.GetCell(map.playerSpawn).type = "empty";
map.getCell(map.playerSpawn).type = "empty";
}
public String randomFruit() {
@ -128,7 +128,7 @@ public class GameManager {
}
public void updatePlayerCell() {
map.GetCell(player.position).triggerItem();
map.getCell(player.position).triggerItem();
}
public void makeGhostEdible(int timeStopPillEffect) {

4
src/main/java/pacmanGame/Map.java

@ -111,7 +111,7 @@ public class Map {
}
public Cell GetCell(Vector2 pos) {
public Cell getCell(Vector2 pos) {
if (pos.isWithin(size)) {
return cells[pos.x][pos.y];
@ -141,7 +141,7 @@ public class Map {
for(int x = 0; x < size.x; x++) {
for(int y = 0; y < size.y; y++) {
Vector2 pos = new Vector2(x,y);
Cell cell = GetCell(pos);
Cell cell = getCell(pos);
if(cell.type.equals("wall")) {
tempMap[x][y] = 'w';
}

4
src/main/java/pacmanGame/Player.java

@ -19,7 +19,7 @@ public class Player {
public void Move() {
Vector2 newPosition = position.Add(direction);
boolean newPosIsWall = gameManager.map.GetCell(newPosition).type.equals("wall");
boolean newPosIsWall = gameManager.map.getCell(newPosition).type.equals("wall");
if(!newPosIsWall) {
position = newPosition;
@ -56,7 +56,7 @@ public class Player {
public void checkInput(Vector2 input) {
Vector2 newPosition = position.Add(input);
boolean newPosIsWall = gameManager.map.GetCell(newPosition).type.equals("wall");
boolean newPosIsWall = gameManager.map.getCell(newPosition).type.equals("wall");
if(!newPosIsWall) {
direction = input;
savedDirection = null;

2
src/main/java/pacmanGame/VisualizerPlainText.java

@ -54,7 +54,7 @@ public class VisualizerPlainText implements Visualizer {
for(int y = 0; y < map.size.y; y++) {
for(int x = 0; x < map.size.x; x++) {
Cell cell = map.GetCell(new Vector2(x, map.size.y - 1 - y));
Cell cell = map.getCell(new Vector2(x, map.size.y - 1 - y));
if(gameManager.isPaused && 5 < y && y <= 10){

2
src/main/java/pacmanGame/VisualizerPlainTextUltra.java

@ -168,7 +168,7 @@ public class VisualizerPlainTextUltra implements Visualizer {
}
for(int x = 0; x < map.size.x; x++) {
Cell cell = map.GetCell(new Vector2(x, map.size.y - 1 - y));
Cell cell = map.getCell(new Vector2(x, map.size.y - 1 - y));
boolean containsGhosts = false;
boolean containsPlayer = false;

14
src/test/java/pacmanTests/CellTest.java

@ -14,7 +14,7 @@ class CellTest {
void cell_triggerItem_505cherryScore() {
// arrange
GameManager gameManager = new GameManager();
Cell cell = gameManager.map.GetCell(new Vector2(0,0));
Cell cell = gameManager.map.getCell(new Vector2(0,0));
cell.type = "cherry";
int expectedScore = 505;
// act
@ -28,7 +28,7 @@ class CellTest {
void cell_triggerItem_10dotScore() {
// arrange
GameManager gameManager = new GameManager();
Cell cell = gameManager.map.GetCell(new Vector2(0,0));
Cell cell = gameManager.map.getCell(new Vector2(0,0));
cell.type = "dot";
int expectedScore = 10;
// act
@ -42,7 +42,7 @@ class CellTest {
void cell_triggerItem_100pillScore() {
// arrange
GameManager gameManager = new GameManager();
Cell cell = gameManager.map.GetCell(new Vector2(0,0));
Cell cell = gameManager.map.getCell(new Vector2(0,0));
cell.type = "pill";
int expectedScore = 100;
// act
@ -56,7 +56,7 @@ class CellTest {
void cell_triggerItem_405strawberryScore() {
// arrange
GameManager gameManager = new GameManager();
Cell cell = gameManager.map.GetCell(new Vector2(0,0));
Cell cell = gameManager.map.getCell(new Vector2(0,0));
cell.type = "strawberry";
int expectedScore = 405;
// act
@ -70,7 +70,7 @@ class CellTest {
void cell_triggerItem_305orangeScore() {
// arrange
GameManager gameManager = new GameManager();
Cell cell = gameManager.map.GetCell(new Vector2(0,0));
Cell cell = gameManager.map.getCell(new Vector2(0,0));
cell.type = "orange";
int expectedScore = 305;
// act
@ -84,7 +84,7 @@ class CellTest {
void cell_triggerItem_205appleScore() {
// arrange
GameManager gameManager = new GameManager();
Cell cell = gameManager.map.GetCell(new Vector2(0,0));
Cell cell = gameManager.map.getCell(new Vector2(0,0));
cell.type = "apple";
int expectedScore = 205;
// act
@ -98,7 +98,7 @@ class CellTest {
void cell_triggerItem_3crystalMoveSpeed() {
// arrange
GameManager gameManager = new GameManager();
Cell cell = gameManager.map.GetCell(new Vector2(0,0));
Cell cell = gameManager.map.getCell(new Vector2(0,0));
cell.type = "crystal";
int expectedMoveSpeed = 3;
// act

6
src/test/java/pacmanTests/MapTest.java

@ -49,9 +49,9 @@ class MapTest {
Cell expectedMiddle = testMap.cells[1][1];
Cell expectedBottomRight = testMap.cells[2][0];
// act
Cell topLeft = testMap.GetCell(new Vector2(0, 2));
Cell middle = testMap.GetCell(new Vector2(1, 1));
Cell bottomRight = testMap.GetCell(new Vector2(2, 0));
Cell topLeft = testMap.getCell(new Vector2(0, 2));
Cell middle = testMap.getCell(new Vector2(1, 1));
Cell bottomRight = testMap.getCell(new Vector2(2, 0));
// assert
assertThat(expectedTopLeft).isEqualTo(topLeft);
assertThat(expectedMiddle).isEqualTo(middle);

Loading…
Cancel
Save