Skip to content

Commit

Permalink
Merge pull request #62 from tannerlie/branch-fix-checkstyle
Browse files Browse the repository at this point in the history
Fix checkstyles
  • Loading branch information
tannerlie committed Apr 3, 2024
2 parents cfa721f + 75332e4 commit 9379bcb
Show file tree
Hide file tree
Showing 24 changed files with 78 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/main/java/Hint/HintHandler.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Hint;
package hint;

import map.BaseMap;
import textbox.TextBox;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Hint/Trigger.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Hint;
package hint;

public class Trigger {
protected String message;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/InventoryItems/Consumable.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package InventoryItems;
package inventoryitems;

public class Consumable extends ShopItem { //we assume all consumables are for 1 turn only
protected int healAmt;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/InventoryItems/ShopItem.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package InventoryItems;
package inventoryitems;

public abstract class ShopItem {
protected String description;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Math/MathPool.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Math;
package math;

import java.util.Random;
import java.util.ArrayList;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Math/MathQuestion.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Math;
package math;

public class MathQuestion {
private final String question;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public abstract class Command {
protected String commandDescription;
protected BaseMap currentMap;

public abstract void execute();

public Command() {
commandDescription = "Impossible";
currentMap = null;
}

public abstract void execute();

public void execute(Scanner in) {

}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/command/fight/FightingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public void execute(Scanner in) {
int yPos = storedMaps.get(BaseMap.currentMap).getInteractY();
storedMaps.get(BaseMap.currentMap).clearSpot(xPos, yPos);
currentMap.handleLootingByPlayer();
}
else if (currentMap.getPlayerDeath()){
} else if (currentMap.getPlayerDeath()){
currentMap.handleDeath();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/command/fight/RunningCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import command.Command;
import map.BaseMap;
import map.BattleInterface.BattleInterface;
import map.battleinterface.BattleInterface;

import static map.BaseMap.storedMaps;
import static map.MapGenerator.FIRST_MAP_IDENTITY;
Expand Down
21 changes: 16 additions & 5 deletions src/main/java/command/mapmove/InteractingCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@

import interactable.InteractableEntity;
import interactable.ShopKeeper;
import interactable.enemies.*;
import interactable.enemies.Centaur;
import interactable.enemies.Dragon;
import interactable.enemies.Demon;
import interactable.enemies.Gryphon;
import interactable.enemies.Goblin;
import map.BaseMap;
import map.ShopMap;
import map.BattleInterface.BattleInterface;
import map.battleinterface.BattleInterface;

import java.util.Objects;

import static map.BaseMap.*;
import static map.MapGenerator.*;
import static map.BaseMap.storedMaps;
import static map.BaseMap.mapIndex;
import static map.MapGenerator.CENTAUR;
import static map.MapGenerator.DEMON;
import static map.MapGenerator.DRAGON;
import static map.MapGenerator.GOBLIN;
import static map.MapGenerator.GRYPHON;
import static map.MapGenerator.SHOP;

public class InteractingCommand extends MapMoveCommand {

Expand Down Expand Up @@ -83,7 +93,8 @@ public void execute() {
break;
case SHOP: //some shopkeeper
ShopMap shopMap;
ShopKeeper shopkeeper = new ShopKeeper("src/main/resources/ShopKeeper/ShopKeeper", "Hi welcome to my shop!");
ShopKeeper shopkeeper = new ShopKeeper("src/main/resources/ShopKeeper/ShopKeeper",
"Hi welcome to my shop!");
shopMap = new ShopMap(playerStatus, textBox, shopkeeper);
shopMap.initMap(30, 0); // Set appropriate width and height
//shopMap.printShopItems();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/filereader/FileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.File;
import java.io.*;
import java.util.ArrayList;
import java.io.FileInputStream;

public class FileReader {
private final String filePath;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/filereader/filepath/EnemiesDesignFilePath.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

public class EnemiesDesignFilePath {

public final static String GOBLIN_PATH = "enemiesDesign/goblin.txt";
public final static String CENTAUR_PATH = "enemiesDesign/centaur.txt";
public final static String DEMON_PATH = "enemiesDesign/demon.txt";
public final static String GRYPHON_PATH = "enemiesDesign/gryphon.txt";
public final static String DRAGON_PATH = "enemiesDesign/dragon.txt";
public static final String GOBLIN_PATH = "enemiesDesign/goblin.txt";
public static final String CENTAUR_PATH = "enemiesDesign/centaur.txt";
public static final String DEMON_PATH = "enemiesDesign/demon.txt";
public static final String GRYPHON_PATH = "enemiesDesign/gryphon.txt";
public static final String DRAGON_PATH = "enemiesDesign/dragon.txt";

public EnemiesDesignFilePath() {
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/interactable/Enemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public Enemy(int dmg, int def, int hp, int xCoordinate, int yCoordinate, int exp
this.health = hp;
this.x = xCoordinate;
this.y = yCoordinate;
this.exp_dropped = exp;
this.money_dropped = money;
this.expDropped = exp;
this.moneyDropped = money;
}

public int getHealth(){
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/interactable/InteractableEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
public abstract class InteractableEntity {
protected int x;
protected int y;
protected int exp_dropped;
protected int money_dropped;
protected int expDropped;
protected int moneyDropped;
protected String name;

public abstract int getHealth();
Expand All @@ -18,11 +18,11 @@ public abstract class InteractableEntity {
public abstract String getFilePath();

public int getExp_dropped(){
return exp_dropped;
return expDropped;
}

public int getMoney_dropped(){
return money_dropped;
return moneyDropped;
}
public int getHeight() {
return 0;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/interactable/ShopKeeper.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package interactable;

import InventoryItems.Consumable;
import InventoryItems.ShopItem;
import main.CalculaChroniclesOfTheAlgorithmicKingdom;
import inventoryitems.Consumable;
import inventoryitems.ShopItem;

import java.util.ArrayList;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/interactable/enemies/Dragon.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public String getName() {
public void setName(String name) {
this.name = name;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main;


import Hint.HintHandler;
import hint.HintHandler;
import command.Command;
import map.BaseMap;
import map.FirstMap;
import map.BattleInterface.BattleInterface;
import map.battleinterface.BattleInterface;
import parser.Parser;
import textbox.PlayerStatus;
import textbox.TextBox;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/map/BattleInterface/BattleInterface.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package map.BattleInterface;
package map.battleinterface;

import interactable.Enemy;
import interactable.InteractableEntity;
Expand All @@ -7,12 +7,11 @@
import textbox.PlayerStatus;
import textbox.TextBox;
import ui.Ui;
import Math.MathQuestion;
import Math.MathPool;
import math.MathQuestion;
import math.MathPool;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class BattleInterface extends BaseMap {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/map/FirstMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.ArrayList;

public class FirstMap extends BaseMap {
protected String DIFFICULTY_MODIFIER = "easy"; //can use to determine question difficulty
protected String difficultyModifier = "easy"; //can use to determine question difficulty

@Override
public void enableFight() {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/map/MapGenerator.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package map;

import interactable.enemies.Gryphon;

import java.util.concurrent.ThreadLocalRandom;

public class MapGenerator {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/map/ShopMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import textbox.TextBox;

import java.util.ArrayList;
import InventoryItems.ShopItem;


public class ShopMap extends BaseMap{
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ public Command parseCommand(String userCommand) {
command = (currentMap != mapIndex.get(FIRST_MAP_IDENTITY)) ? new RunningCommand() : new ErrorCommand();
break;
case MOVE_FORWARD:
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ? new MovingForwardCommand(userCommand) : new ErrorCommand();
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ?
new MovingForwardCommand(userCommand) : new ErrorCommand();
break;
case MOVE_DOWNWARD:
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ? new MovingDownwardCommand(userCommand) : new ErrorCommand();
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ?
new MovingDownwardCommand(userCommand) : new ErrorCommand();
break;
case MOVE_LEFT:
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ? new MovingLeftCommand(userCommand) : new ErrorCommand();
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ?
new MovingLeftCommand(userCommand) : new ErrorCommand();
break;
case MOVE_RIGHT:
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ? new MovingRightCommand(userCommand) : new ErrorCommand();
command = (currentMap == mapIndex.get(FIRST_MAP_IDENTITY)) ?
new MovingRightCommand(userCommand) : new ErrorCommand();
break;
case QUIT:
command = new QuitCommand();
Expand Down
45 changes: 23 additions & 22 deletions src/main/java/ui/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import map.BaseMap;
import textbox.PlayerStatus;
import textbox.TextBox;
import Math.MathQuestion;
import math.MathQuestion;
import java.util.ArrayList;

public class Ui {
Expand Down Expand Up @@ -55,27 +55,6 @@ public void printTextbox(String message){ //for custom messages
printDividingLine();
}

public void printMap(ArrayList<ArrayList<Character>> map, Enemy monster) {
printDividingLine();
String healthInfo = " Health: " + monster.getHealth(); // Health information as a string

for (int rowIndex = 0; rowIndex < map.size(); rowIndex++) {
ArrayList<Character> row = map.get(rowIndex);

// Overlay the health information on the first row directly within the ASCII art
if (rowIndex == 0) {
StringBuilder firstRowWithHealth = getStringBuilder(row, healthInfo);
System.out.println(firstRowWithHealth.toString());
} else {
for (char cell : row) {
System.out.print(cell);
}
System.out.println();
}
}
printDividingLine();
}

private static StringBuilder getStringBuilder(ArrayList<Character> row, String healthInfo) {
StringBuilder firstRowWithHealth = new StringBuilder();
for (int cellIndex = 0; cellIndex < row.size(); cellIndex++) {
Expand All @@ -102,6 +81,28 @@ public void printMap(BaseMap map) {
}
printDividingLine();
}

public void printMap(ArrayList<ArrayList<Character>> map, Enemy monster) {
printDividingLine();
String healthInfo = " Health: " + monster.getHealth(); // Health information as a string

for (int rowIndex = 0; rowIndex < map.size(); rowIndex++) {
ArrayList<Character> row = map.get(rowIndex);

// Overlay the health information on the first row directly within the ASCII art
if (rowIndex == 0) {
StringBuilder firstRowWithHealth = getStringBuilder(row, healthInfo);
System.out.println(firstRowWithHealth.toString());
} else {
for (char cell : row) {
System.out.print(cell);
}
System.out.println();
}
}
printDividingLine();
}

public void printEnemy(BaseMap map) {
printDividingLine();
for (ArrayList<Character> row : map.getMapData()) {
Expand Down
4 changes: 0 additions & 4 deletions src/test/java/parser/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@


import command.Command;
import command.ErrorCommand;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

public class ParserTest {

private Parser parser;
Expand Down

0 comments on commit 9379bcb

Please sign in to comment.