Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #104 from CSC207-2022F-UofT/idea-warnings
Browse files Browse the repository at this point in the history
Fix nearly all IDEA Warnings
  • Loading branch information
6167656e74323431 authored Dec 9, 2022
2 parents 4751c46 + 6a9bd6e commit d902c64
Show file tree
Hide file tree
Showing 88 changed files with 602 additions and 409 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ repositories {
}

dependencies {
implementation 'junit:junit:4.13.1'
testImplementation 'org.jetbrains:annotations:20.1.0'
implementation 'junit:junit:4.13.2'
testImplementation 'org.jetbrains:annotations:23.0.0'
compileOnly 'org.jetbrains:annotations:23.0.0'
testImplementation('org.junit.jupiter:junit-jupiter:5.6.0')
testImplementation('org.junit.jupiter:junit-jupiter:5.9.0')

implementation 'com.opencsv:opencsv:5.7.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@

import static com.mg105.utils.DataAccessConstants.PARTY_DATA_PATH;

/**
* PartyDataAccess implements the data access layer.
*/
public class PartyDataAccess implements PartyDataInterface {

private final static int NUMBER_OF_MOVES_PER_CHARACTER = 2;
private final MoveDataAccess moveDataAccess;

/**
* Creates a new instance of PartyDataAccess
*
* @param moveDataAccess an object that can access data about usable moves
*/

Expand Down Expand Up @@ -138,6 +142,7 @@ public void changeCharacterStat(@NotNull String name, @NotNull String stat, int

/**
* Returns objects representing the moves a party member has
*
* @param memberAttributes an array of attributes a party member has
* @return objects representing the moves a party member has
* @see MoveDetails
Expand All @@ -151,6 +156,7 @@ public void changeCharacterStat(@NotNull String name, @NotNull String stat, int

/**
* Returns the moves a party member has from a given array of their attributes
*
* @param memberAttributes an array of attributes of a party member
* @return an array of move names
*/
Expand All @@ -166,6 +172,7 @@ public void changeCharacterStat(@NotNull String name, @NotNull String stat, int

/**
* Returns an array of objects representing moves based on the given move name
*
* @param moveNames an array of move names
* @return an array of objects representing moves
* @see MoveDetails
Expand All @@ -189,6 +196,7 @@ public void changeCharacterStat(@NotNull String name, @NotNull String stat, int
/**
* Returns the appropriate column number based on the desired stat
* returns -1 iff provided an invalid stat
*
* @param rowName the desired stat
* @return an integer representing the column that stat is located in the "database"
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@

public abstract class DataStorageCreator implements CreateDataStorage {

@NotNull private final String path;
@NotNull
private final String path;

@NotNull private final String[][] initialData;
@NotNull
private final String[][] initialData;

/**
* Creates a new instance of DataStorageCreator
* @param path the file path to create data to
*
* @param path the file path to create data to
* @param initialData the inital data to create
*/

public DataStorageCreator(@NotNull String path, @NotNull String[][] initialData){
this.path = path;
this.initialData = initialData;
}
public DataStorageCreator(@NotNull String path, @NotNull String[][] initialData) {
this.path = path;
this.initialData = initialData;
}

/**
* Creates a data storage system for the specific aspect of the game this class pertains to
Expand All @@ -55,8 +58,7 @@ public void createDataStorage() {
writer.close();

}
}
catch(IOException e) {
} catch (IOException e) {
e.getStackTrace();
}
}
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/com/mg105/data_control/creator/MoveDataCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,27 @@ public class MoveDataCreator extends DataStorageCreator {
/**
* Creates a new instance of MoveDataCreator
*/
public MoveDataCreator(){
public MoveDataCreator() {
super(MOVE_DATA_PATH, getInitialData());

}

/**
* Returns the data about the moves in the initial state of the game (aka a "new game file")
*
* @return the data about the moves in the initial state of the game
*/
private static @NotNull String[][] getInitialData(){

String[] header = {"name","moveChange","damageChange","isFriendly"};
String[] m1 = {SLOW_SWING,"-3","0",IS_FALSE};
String[] m2 = {NULLIFY,"0","-3",IS_FALSE};
String[] m3 = {STRONG_SWING,"-4","0",IS_FALSE};
String[] m4 = {STRONG_HEAL,"6","0",IS_TRUE};
String[] m5 = {WEAK_HEAL,"3","0",IS_TRUE};
String[] m6 = {REINFORCE,"2","1",IS_TRUE};
String[] m7 = {SURPRISE_ATTACK,"-5","0",IS_FALSE};
String[] m8 = {SABOTAGE,"-2","-2",IS_FALSE};
private static @NotNull String[][] getInitialData() {

String[] header = {"name", "moveChange", "damageChange", "isFriendly"};
String[] m1 = {SLOW_SWING, "-3", "0", IS_FALSE};
String[] m2 = {NULLIFY, "0", "-3", IS_FALSE};
String[] m3 = {STRONG_SWING, "-4", "0", IS_FALSE};
String[] m4 = {STRONG_HEAL, "6", "0", IS_TRUE};
String[] m5 = {WEAK_HEAL, "3", "0", IS_TRUE};
String[] m6 = {REINFORCE, "2", "1", IS_TRUE};
String[] m7 = {SURPRISE_ATTACK, "-5", "0", IS_FALSE};
String[] m8 = {SABOTAGE, "-2", "-2", IS_FALSE};
return new String[][]{header, m1, m2, m3, m4, m5, m6, m7, m8};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@ public class PartyDataCreator extends DataStorageCreator {
/**
* Creates a new instance of party data creator
*/
public PartyDataCreator(){
public PartyDataCreator() {
super(PARTY_DATA_PATH, getInitialData());

}

/**
* Returns the data about the party in the initial state of the game (aka a "new game file")
*
* @return the data about the party in the initial state of the game
*/
private static @NotNull String[][] getInitialData(){
private static @NotNull String[][] getInitialData() {

String[] header = {"name",MAX_HP,DAMAGE,SPEED,"isOpponent","moveName","moveName"};
String[] p1 = {ALL_PARTY_MEMBER_NAMES[0],"30","4","5",IS_FALSE, SLOW_SWING, NULLIFY};
String[] p2 = {ALL_PARTY_MEMBER_NAMES[1],"20","5","8",IS_FALSE, STRONG_SWING, WEAK_HEAL};
String[] p3 = {ALL_PARTY_MEMBER_NAMES[2],"25","4","6",IS_FALSE, STRONG_HEAL, REINFORCE};
String[] p4 = {ALL_PARTY_MEMBER_NAMES[3],"15","9","10",IS_FALSE, SURPRISE_ATTACK, SABOTAGE};
String[] header = {"name", MAX_HP, DAMAGE, SPEED, "isOpponent", "moveName", "moveName"};
String[] p1 = {ALL_PARTY_MEMBER_NAMES[0], "30", "4", "5", IS_FALSE, SLOW_SWING, NULLIFY};
String[] p2 = {ALL_PARTY_MEMBER_NAMES[1], "20", "5", "8", IS_FALSE, STRONG_SWING, WEAK_HEAL};
String[] p3 = {ALL_PARTY_MEMBER_NAMES[2], "25", "4", "6", IS_FALSE, STRONG_HEAL, REINFORCE};
String[] p4 = {ALL_PARTY_MEMBER_NAMES[3], "15", "9", "10", IS_FALSE, SURPRISE_ATTACK, SABOTAGE};
return new String[][]{header, p1, p2, p3, p4};


Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/mg105/entities/Battle.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
* and the order in which they would move, along with a number of upgrade tokens upon victory.
*/
public class Battle {
//battleStatus: 0 for in progress, -1 for loss, 1 for win
private int battleStatus;
private final ArrayList<BattleCharacter> opponents;
private final ArrayList<BattleCharacter> playerCharacters;
private final ArrayList<BattleCharacter> moveQueue = new ArrayList<>();
//battleStatus: 0 for in progress, -1 for loss, 1 for win
private int battleStatus;

/**
* Creates a new Battle instance with ongoing status, given BattleCharacters, and a Queue of the characters sorted
* by their speed stats.
*
* @param opponents a collection of opponent BattleCharacters.
* @param party a collection of player BattleCharacters.
* @param party a collection of player BattleCharacters.
*/
public Battle(ArrayList<BattleCharacter> opponents, ArrayList<BattleCharacter> party) {
this.battleStatus = 0;
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/mg105/entities/BattleCharacter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* specific character.
*/
public class BattleCharacter implements Comparable<BattleCharacter> {
private final String name;
private final boolean isOpponent;
private final Move[] moves = new Move[2];
private int hp;
private int maxHp;
private final String name;
private int dmg;
private int speed;
private final boolean isOpponent;
private final Move[] moves = new Move[2];

/**
* Creates a new BattleCharacter with the given stats.
Expand Down Expand Up @@ -126,6 +126,9 @@ public void modifyHealth(int healthChange) {
}
}

/**
* Ensure this BattleCharacter is completely healed. (Has their maximum health value.
*/
public void fullHealCharacter() {
this.modifyHealth(this.getMaxHp());
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/mg105/entities/Consumable.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
public interface Consumable {

/**
*This method allow a character to use an item on themselves. It does NOT remove an item from the inventory.
* @param state the state of the game
* This method allow a character to use an item on themselves. It does NOT remove an item from the inventory.
*
* @param state the state of the game
* @param characterName the name of the character to use the item on
*/
void consume(@NotNull GameState state, @NotNull String characterName);
Expand Down
52 changes: 25 additions & 27 deletions src/main/java/com/mg105/entities/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
*/

public class GameState {
private Room lastRoom;
private Room currentRoom;

private OpponentSet currOpponent;
private final ArrayList<BattleCharacter> party;
private final WalkingCharacter walkingCharacter;
private final Inventory inventory;
private Battle currEncounter = null;

//Potentially useless. Keeps track of party characters who faint in battle.
private final ArrayList<BattleCharacter> fainted = new ArrayList<>();
private Room lastRoom;
private Room currentRoom;
private OpponentSet currOpponent;
private Battle currEncounter = null;

/**
* Create a new game state.
Expand Down Expand Up @@ -110,7 +108,7 @@ public BattleCharacter getFaintedPartyMember(@NotNull String characterName) thro

/**
* Removes the given fainted party
* This should only be done to fainted party members who's hp is about to become above zero
* This should only be done to fainted party members whose hp is about to become above zero
*
* @param characterName the name of the party member that is fainted
*/
Expand Down Expand Up @@ -177,6 +175,15 @@ public void setMap(@NotNull Room firstRoom, @NotNull Room lastRoom) {
return currentRoom;
}

/**
* Set the current room. room must be graph-connected to the rest of the map.
*
* @param room the room to be set.
*/
public void setCurrentRoom(@NotNull Room room) {
this.currentRoom = room;
}

/**
* Returns the active Battle, or null if there is none.
*
Expand Down Expand Up @@ -222,6 +229,17 @@ public ArrayList<BattleCharacter> getParty() {
return this.party;
}

/**
* Sets these BattleCharacters as the party
* This function should really only ever be called once
*
* @param party the battles character to the set the party to
*/
public void setParty(@NotNull BattleCharacter[] party) {
this.party.clear();
this.party.addAll(Arrays.asList(party));
}

/**
* Returns an ArrayList of the player's fainted characters.
*
Expand Down Expand Up @@ -260,24 +278,4 @@ public boolean isCurrentRoomLastRoom() {
// the same configuration.
return currentRoom == lastRoom;
}

/**
* Set the current room. room must be graph-connected to the rest of the map.
*
* @param room the room to be set.
*/
public void setCurrentRoom(@NotNull Room room) {
this.currentRoom = room;
}

/**
* Sets these BattleCharacters as the party
* This function should really only ever be called once
*
* @param party the battles character to the set the party to
*/
public void setParty(@NotNull BattleCharacter[] party) {
this.party.clear();
this.party.addAll(Arrays.asList(party));
}
}
11 changes: 7 additions & 4 deletions src/main/java/com/mg105/entities/GiveTutorial.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@

import com.mg105.utils.TutorialTexts;

/** Data for what actions player has completed, contains methods for mutating the data */
/**
* Data for what actions player has completed, contains methods for mutating the data
*/
public class GiveTutorial {

private boolean moved;
private boolean attacked;
private boolean usedItem;

/** Constructor for GiveTutorial entity
/**
* Constructor for GiveTutorial entity
*
* @param moved whether player has moved
* @param moved whether player has moved
* @param attacked whether player has attacked
* @param usedItem whether player has opened a chest
* */
*/
public GiveTutorial(boolean moved, boolean attacked, boolean usedItem) {
this.moved = moved;
this.attacked = attacked;
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/mg105/entities/Inventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,19 @@ public boolean removeItem(@NotNull String itemName) {
}
return false;
}

/**
* Removes all the items from the inventory.
*/
public void removeAll() {
for (int i = numberOfItems() - 1; i >=0; i--) {
this.items.remove(i);
}
items.clear();
}

/**
* Uses the item on the given character
*
* @param state The current state of the game
* @param itemName The name of the item to use
* @param state The current state of the game
* @param itemName The name of the item to use
* @param characterName the character to use the item on
* @return true iff the item with a name of itemName was used
* @see Item
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/mg105/entities/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
*/

public abstract class Item {
@NotNull final private String NAME;
@NotNull
final private String NAME;

/**
* Creates a new instance of item
*
* @param name the name of the item
*/
public Item(@NotNull String name) {
Expand Down
Loading

0 comments on commit d902c64

Please sign in to comment.