Added Comments to the New Tests and Object Files
This commit is contained in:
parent
6db97df7b8
commit
2905e4fb1f
|
@ -8,19 +8,34 @@ public class PlayerData {
|
|||
//TODO Write Tests
|
||||
private List<PlayerWorld> playerWorlds;
|
||||
|
||||
|
||||
/**
|
||||
* Inits a new Player Object
|
||||
*/
|
||||
public PlayerData() {
|
||||
playerWorlds = new ArrayList<PlayerWorld>();
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a world to the playerWorlds Array
|
||||
* @param world the world data object to be added
|
||||
*/
|
||||
public void addWorld(PlayerWorld world) {
|
||||
playerWorlds.add(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the current count of worlds that the player owns
|
||||
* @return
|
||||
*/
|
||||
public int getWorldCount() {
|
||||
return playerWorlds.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the world at a certain index
|
||||
* @param index index of the world you want
|
||||
* @return the World Data Object
|
||||
*/
|
||||
public PlayerWorld getWorldAt(int index) {
|
||||
return playerWorlds.get(index);
|
||||
}
|
||||
|
|
|
@ -4,11 +4,21 @@ public class PlayerWorld {
|
|||
private int worldNumber;
|
||||
private long lastLoaded;
|
||||
|
||||
/**
|
||||
* Creates an new Player World Data Structure if the worldNumber given
|
||||
* @param worldNumber the index of the world held by the player
|
||||
*/
|
||||
public PlayerWorld(int worldNumber) {
|
||||
this.worldNumber = worldNumber;
|
||||
this.lastLoaded = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the world player index
|
||||
* (player index = the index of the world in the player's
|
||||
* world array)
|
||||
* @return the world number
|
||||
*/
|
||||
public int getWorldNumber() {
|
||||
return worldNumber;
|
||||
}
|
||||
|
|
|
@ -13,10 +13,21 @@ import java.util.Map;
|
|||
public class WorldSystemData {
|
||||
|
||||
public Map<String, PlayerData> players;
|
||||
|
||||
/**
|
||||
* Creates the WorldSystemData objects
|
||||
* and creates a blank map to hold player data
|
||||
* with the uuid is the key
|
||||
*/
|
||||
public WorldSystemData() {
|
||||
players = new HashMap<String, PlayerData>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Player to the data record
|
||||
* @param uuid the UUID of the player to be added
|
||||
* @return returns whether the player was added successfully or not
|
||||
*/
|
||||
public Boolean addplayer(String uuid) {
|
||||
if (players.get(uuid) == null) {
|
||||
players.put(uuid, new PlayerData());
|
||||
|
@ -25,16 +36,30 @@ public class WorldSystemData {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a world Object to the player specified
|
||||
* @param uuid the UUID of the player
|
||||
* @param world the World Object to be added
|
||||
*/
|
||||
public void addWorldToPlayer(String uuid, PlayerWorld world) {
|
||||
if (players.get(uuid) != null) {
|
||||
players.get(uuid).addWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Amount of playerdata stored by WorldSystem
|
||||
* @return player count
|
||||
*/
|
||||
public int getPlayers() {
|
||||
return players.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the player data of the specifed uuid
|
||||
* @param uuid the UUID of the player you want
|
||||
* @return returns the player data object
|
||||
*/
|
||||
public PlayerData getPlayer(String uuid) {
|
||||
return players.get(uuid);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
|
||||
public class TestPlayerData {
|
||||
|
||||
/**
|
||||
* Tests the Basic Initalization of a PlayerData Object
|
||||
*/
|
||||
@Test
|
||||
public void testPlayerDataInit() {
|
||||
PlayerData pd = new PlayerData();
|
||||
|
@ -14,19 +17,33 @@ public class TestPlayerData {
|
|||
assertEquals(0, pd.getWorldCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests adding one world to the player
|
||||
*/
|
||||
@Test
|
||||
public void testAddWorld() {
|
||||
PlayerData pd = new PlayerData();
|
||||
|
||||
pd.addWorld(new PlayerWorld(pd.getWorldCount()));
|
||||
assertEquals(1, pd.getWorldCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests adding multiple worlds to the player
|
||||
*/
|
||||
@Test
|
||||
public void testAddMultipleWorlds() {
|
||||
PlayerData pd = new PlayerData();
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
pd.addWorld(new PlayerWorld(pd.getWorldCount()));
|
||||
}
|
||||
assertEquals(6, pd.getWorldCount());
|
||||
assertEquals(5, pd.getWorldCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests geting a world at a specified index
|
||||
*/
|
||||
@Test
|
||||
public void testGetWorldAtIndex() {
|
||||
PlayerData pd = new PlayerData();
|
||||
|
|
|
@ -6,12 +6,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
|
||||
public class TestPlayerWorld {
|
||||
|
||||
/**
|
||||
* Tests the basic initiazlization of a new World with an id of 0
|
||||
*/
|
||||
@Test
|
||||
public void testPlayerWorldInit() {
|
||||
PlayerWorld pw = new PlayerWorld(0);
|
||||
assertEquals(0,pw.getWorldNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the initiazlization of a world with a index other than 0
|
||||
*/
|
||||
@Test
|
||||
public void testPlayerWorldInit2() {
|
||||
PlayerWorld pw = new PlayerWorld(6);
|
||||
|
|
|
@ -6,6 +6,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
|
||||
public class TestWorldSystemData {
|
||||
|
||||
/**
|
||||
* Test the base initiaztaion of the WorldSystemData Object
|
||||
*/
|
||||
@Test
|
||||
public void testWorldSystemDataInit() {
|
||||
WorldSystemData wsd = new WorldSystemData();
|
||||
|
@ -13,6 +16,9 @@ public class TestWorldSystemData {
|
|||
assertEquals(0, wsd.getPlayers());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests adding a basic player
|
||||
*/
|
||||
@Test
|
||||
public void testAddPlayer() {
|
||||
WorldSystemData wsd = new WorldSystemData();
|
||||
|
@ -23,6 +29,9 @@ public class TestWorldSystemData {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test adding multiple Players
|
||||
*/
|
||||
@Test
|
||||
public void testAddMultiplePlayers() {
|
||||
WorldSystemData wsd = new WorldSystemData();
|
||||
|
@ -38,7 +47,9 @@ public class TestWorldSystemData {
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests adding Duplicate PLayers
|
||||
*/
|
||||
@Test
|
||||
public void testAddDulpicatePlayer() {
|
||||
WorldSystemData wsd = new WorldSystemData();
|
||||
|
@ -51,6 +62,9 @@ public class TestWorldSystemData {
|
|||
assertEquals(1, wsd.getPlayers());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests adding a world to a player
|
||||
*/
|
||||
@Test
|
||||
public void testAddWorldToPlayer() {
|
||||
WorldSystemData wsd = new WorldSystemData();
|
||||
|
@ -62,7 +76,9 @@ public class TestWorldSystemData {
|
|||
assertEquals(1, wsd.getPlayer("Blank_UUID").getWorldCount());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests adding mulitple worlds a player
|
||||
*/
|
||||
@Test
|
||||
public void testAddMultipleWorldsToPlayer() {
|
||||
WorldSystemData wsd = new WorldSystemData();
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue