Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits committed Oct 16, 2019
1 parent 23d9247 commit 83e2657
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import xyz.devosmium.games.textadventureengine.menus.MainMenu;

/**
Expand All @@ -13,7 +12,6 @@ public class App {
private static Logger logger = LoggerFactory.getLogger(App.class);
private static AreaCollection areas;


public static void main(String[] args) {
logger.debug("Starting game");
new MainMenu();
Expand Down
86 changes: 43 additions & 43 deletions src/main/java/xyz/devosmium/games/textadventureengine/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,55 @@

public class Game {

Player player = null;
Player player = null;

String intro = "You blink your eyes open, and stand up.";
String intro = "You blink your eyes open, and stand up.";

public Game(Player player, PlayerType type) {
this.player = player;
try {
switch (type) {
case NEW:
MessageQueue.add(intro);
gamePrompt(player, true);
break;
case RETURNING:
MessageQueue.add("How did you get here?");
gamePrompt(player, false);
break;
default:
MessageQueue.add("Invalid type.");
throw new Exception("Invalid player type");
}
} catch (DeathException de) {
System.out.println(de.getMessage());
new MainMenu();
} catch (Exception e) {
System.exit(-1);
}
public Game(Player player, PlayerType type) {
this.player = player;
try {
switch (type) {
case NEW:
MessageQueue.add(intro);
gamePrompt(player, true);
break;
case RETURNING:
MessageQueue.add("How did you get here?");
gamePrompt(player, false);
break;
default:
MessageQueue.add("Invalid type.");
throw new Exception("Invalid player type");
}
} catch (DeathException de) {
System.out.println(de.getMessage());
new MainMenu();
} catch (Exception e) {
System.exit(-1);
}
}

protected void gamePrompt(Player player, boolean newPlayer) throws DeathException {
boolean contPrompt = true;
if (newPlayer) {
MessageQueue.add("Welcome, " + player.getName() + ". Have fun!");
} else {
MessageQueue.add("How'd you get here?");
}

do {

String command = MessageQueue.take();
protected void gamePrompt(Player player, boolean newPlayer)
throws DeathException {
boolean contPrompt = true;
if (newPlayer) {
MessageQueue.add("Welcome, " + player.getName() + ". Have fun!");
} else {
MessageQueue.add("How'd you get here?");
}

EngineCommandManager commandManager = new EngineCommandManager(player, command);
commandManager.executeCommand();
do {

String command = MessageQueue.take();

// player.getHealth();
// if (Integer.parseInt(health) <= 0) {
// throw new DeathException("Death");
// }
} while (contPrompt);
EngineCommandManager commandManager =
new EngineCommandManager(player, command);
commandManager.executeCommand();

}
// player.getHealth();
// if (Integer.parseInt(health) <= 0) {
// throw new DeathException("Death");
// }
} while (contPrompt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@

public class Area {

private String areaName;
private int areaID;
private ArrayList<Location> areaLocations;
private String areaName;
private int areaID;
private ArrayList<Location> areaLocations;

public Area(String areaName, int areaID) {
this.areaName = areaName;
this.areaID = areaID;
areaLocations = new ArrayList<Location>();
}
public Area(String areaName, int areaID) {
this.areaName = areaName;
this.areaID = areaID;
areaLocations = new ArrayList<Location>();
}

public int getAreaID() {
return areaID;
}
public int getAreaID() { return areaID; }

public String getAreaName() {
return areaName;
}
public String getAreaName() { return areaName; }

public void registerLocation(Location location) {
areaLocations.add(location);
}
public void registerLocation(Location location) {
areaLocations.add(location);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,64 @@
/**
* AreaCollection
*
* The AreaCollection will be responsible for collecting and storing Areas of the game. AreaCollection is an optional
* storage for Areas. Only 1 AreaCollection should be initialized in the Game world and be used as the primary storage
* for retrieving Areas.
* The AreaCollection will be responsible for collecting and storing Areas of
* the game. AreaCollection is an optional storage for Areas. Only 1
* AreaCollection should be initialized in the Game world and be used as the
* primary storage for retrieving Areas.
*
* @author Jessie Vela
* @version 1.0
* @since 15 OCT 2019
*/
public class AreaCollection {
private ArrayList<Area> areaCollection;
private ArrayList<Area> areaCollection;

/**
* AreaCollection constructor initializes the ArrayList that will hold the Area objects.
*/
public AreaCollection() {
areaCollection = new ArrayList<Area>();
}
/**
* AreaCollection constructor initializes the ArrayList that will hold the
* Area objects.
*/
public AreaCollection() { areaCollection = new ArrayList<Area>(); }

/**
* Adds an Area to the AreaCollection.
*
* @param area The Area object to be stored into the ArrayList
*/
public void addAreaObject(Area area) {
this.areaCollection.add(area);
}
/**
* Adds an Area to the AreaCollection.
*
* @param area The Area object to be stored into the ArrayList
*/
public void addAreaObject(Area area) { this.areaCollection.add(area); }

/**
* Searches the AreaCollection for an Area with the matching name. If found Area object matching the name is
* returned, else null is returned signifying no Area matching name is present.
*
* returns null.
* @param areaName The name of the Area to be searched for in the ArrayList.
* @return Returns the Area Object if found. Else null to indicate it is not found.
*/
public Area searchAreaByName(String areaName){
for (Area name : areaCollection) {
if(name.getAreaName() != null && name.getAreaName().equals(areaName))
return name;
}
return null;
/**
* Searches the AreaCollection for an Area with the matching name. If found
* Area object matching the name is returned, else null is returned signifying
* no Area matching name is present.
*
* returns null.
* @param areaName The name of the Area to be searched for in the ArrayList.
* @return Returns the Area Object if found. Else null to indicate it is not
* found.
*/
public Area searchAreaByName(String areaName) {
for (Area name : areaCollection) {
if (name.getAreaName() != null && name.getAreaName().equals(areaName))
return name;
}
return null;
}

/**
* Searches the AreaCollection for an Area with a matching ID. If found the Area object matching the ID is
* returned, else null is returned. signifying no Area matching ID is present.
*
* @param areaNum The unique ID of the Area to be searched for in the ArrayList.
* @return Returns the Area Object if found. Else null is returned to indicate it is not found.
*/
public Area searchAreaByID(int areaNum){
for (Area id : areaCollection) {
if(id.getAreaID() == areaNum)
return id;
}
return null;
/**
* Searches the AreaCollection for an Area with a matching ID. If found the
* Area object matching the ID is returned, else null is returned. signifying
* no Area matching ID is present.
*
* @param areaNum The unique ID of the Area to be searched for in the
* ArrayList.
* @return Returns the Area Object if found. Else null is returned to indicate
* it is not found.
*/
public Area searchAreaByID(int areaNum) {
for (Area id : areaCollection) {
if (id.getAreaID() == areaNum)
return id;
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package xyz.devosmium.games.textadventureengine.locations;

import java.util.ArrayList;

import xyz.devosmium.games.textadventureengine.mobiles.Mobile;
import xyz.devosmium.games.textadventureengine.util.Coordinate;

Expand All @@ -14,35 +13,35 @@ public class LocationFactory {

private ArrayList<Location> locations;

public ArrayList<Location> getLocations() { return locations;}

public ArrayList<Location> getLocations() { return locations; }

public LocationFactory() {
locations = new ArrayList<Location>();
}
public LocationFactory() { locations = new ArrayList<Location>(); }

/**
* Creates a new location with Mobiles.
*
*
* @param coordinates The coordinates of the location in the world
* @param shortString The title of the location
* @param longString The scenic description of the room
* @param mobiles An ArrayList of Mobile instances
* @return The Location instance
*/
public Location buildLocation(Coordinate coordinates, String shortString, String longString, ArrayList<Mobile> mobiles) {
Location newLoc = new Location(coordinates, shortString, longString, mobiles);
public Location buildLocation(Coordinate coordinates, String shortString,
String longString, ArrayList<Mobile> mobiles) {
Location newLoc =
new Location(coordinates, shortString, longString, mobiles);

return newLoc;
}

/**
* Creates a new Location without Mobiles.
*
*
* @see buildLocation()
* @return The Location instance
*/
public Location buildLocation(Coordinate coordinates, String shortString, String longString) {
public Location buildLocation(Coordinate coordinates, String shortString,
String longString) {
Location newLoc = new Location(coordinates, shortString, longString);

return newLoc;
Expand All @@ -56,7 +55,8 @@ public Location buildLocation(Coordinate coordinates, String shortString, String
* @param longString The scenic description of the room
* @param area The area to add the location to
*/
public Location addLocation(Coordinate coordinates, String shortString, String longString, Area area) {
public Location addLocation(Coordinate coordinates, String shortString,
String longString, Area area) {
Location newLoc = new Location(coordinates, shortString, longString);
area.registerLocation(newLoc);

Expand All @@ -71,7 +71,9 @@ public Location addLocation(Coordinate coordinates, String shortString, String l
* @param longString The scenic description of the room
* @param area The area to add the location to
*/
public Location addLocation(Coordinate coordinates, String shortString, String longString, ArrayList<Mobile> mobiles, Area area) {
public Location addLocation(Coordinate coordinates, String shortString,
String longString, ArrayList<Mobile> mobiles,
Area area) {
Location newLoc = new Location(coordinates, shortString, longString);
area.registerLocation(newLoc);

Expand Down

0 comments on commit 83e2657

Please sign in to comment.