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() { public void spawnFruit() {
map.GetCell(map.playerSpawn).type = randomFruit();
map.getCell(map.playerSpawn).type = randomFruit();
} }
public void destroyFruit() { public void destroyFruit() {
map.GetCell(map.playerSpawn).type = "empty";
map.getCell(map.playerSpawn).type = "empty";
} }
public String randomFruit() { public String randomFruit() {
@ -128,7 +128,7 @@ public class GameManager {
} }
public void updatePlayerCell() { public void updatePlayerCell() {
map.GetCell(player.position).triggerItem();
map.getCell(player.position).triggerItem();
} }
public void makeGhostEdible(int timeStopPillEffect) { 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)) { if (pos.isWithin(size)) {
return cells[pos.x][pos.y]; return cells[pos.x][pos.y];
@ -141,7 +141,7 @@ public class Map {
for(int x = 0; x < size.x; x++) { for(int x = 0; x < size.x; x++) {
for(int y = 0; y < size.y; y++) { for(int y = 0; y < size.y; y++) {
Vector2 pos = new Vector2(x,y); Vector2 pos = new Vector2(x,y);
Cell cell = GetCell(pos);
Cell cell = getCell(pos);
if(cell.type.equals("wall")) { if(cell.type.equals("wall")) {
tempMap[x][y] = 'w'; tempMap[x][y] = 'w';
} }

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

@ -19,7 +19,7 @@ public class Player {
public void Move() { public void Move() {
Vector2 newPosition = position.Add(direction); 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) { if(!newPosIsWall) {
position = newPosition; position = newPosition;
@ -56,7 +56,7 @@ public class Player {
public void checkInput(Vector2 input) { public void checkInput(Vector2 input) {
Vector2 newPosition = position.Add(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) { if(!newPosIsWall) {
direction = input; direction = input;
savedDirection = null; 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 y = 0; y < map.size.y; y++) {
for(int x = 0; x < map.size.x; x++) { 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){ 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++) { 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 containsGhosts = false;
boolean containsPlayer = false; boolean containsPlayer = false;

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

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

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

@ -49,9 +49,9 @@ class MapTest {
Cell expectedMiddle = testMap.cells[1][1]; Cell expectedMiddle = testMap.cells[1][1];
Cell expectedBottomRight = testMap.cells[2][0]; Cell expectedBottomRight = testMap.cells[2][0];
// act // 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 // assert
assertThat(expectedTopLeft).isEqualTo(topLeft); assertThat(expectedTopLeft).isEqualTo(topLeft);
assertThat(expectedMiddle).isEqualTo(middle); assertThat(expectedMiddle).isEqualTo(middle);

Loading…
Cancel
Save