This commit is contained in:
parent
f76a59215c
commit
d03d8a7996
@ -8,6 +8,7 @@ import org.studiorailgun.sim.character.gen.PlayerCharSourcer;
|
|||||||
import org.studiorailgun.sim.eval.GameCommandParser;
|
import org.studiorailgun.sim.eval.GameCommandParser;
|
||||||
import org.studiorailgun.sim.eval.Simulator;
|
import org.studiorailgun.sim.eval.Simulator;
|
||||||
import org.studiorailgun.sim.space.gen.WorldGenerator;
|
import org.studiorailgun.sim.space.gen.WorldGenerator;
|
||||||
|
import org.studiorailgun.sim.space.util.LocationResolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The game loop
|
* The game loop
|
||||||
@ -27,6 +28,7 @@ public class GameLoop {
|
|||||||
GameCommandParser.init();
|
GameCommandParser.init();
|
||||||
Globals.world = WorldGenerator.generateWorld();
|
Globals.world = WorldGenerator.generateWorld();
|
||||||
Globals.playerCharacter = PlayerCharSourcer.getPlayerCharacter();
|
Globals.playerCharacter = PlayerCharSourcer.getPlayerCharacter();
|
||||||
|
Globals.playerCharacter.move(LocationResolver.first(Globals.world));
|
||||||
|
|
||||||
try (Scanner scan = new Scanner(System.in)) {
|
try (Scanner scan = new Scanner(System.in)) {
|
||||||
String prompt = "";
|
String prompt = "";
|
||||||
|
|||||||
@ -104,6 +104,14 @@ public class Character {
|
|||||||
this.locationId = locationId;
|
this.locationId = locationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location this character is in
|
||||||
|
* @return The location
|
||||||
|
*/
|
||||||
|
public Location getLocation(){
|
||||||
|
return Globals.world.getLocation(this.locationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
package org.studiorailgun.sim.eval.command;
|
package org.studiorailgun.sim.eval.command;
|
||||||
|
|
||||||
|
import org.studiorailgun.Globals;
|
||||||
|
import org.studiorailgun.sim.space.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for look command
|
* Handler for look command
|
||||||
*/
|
*/
|
||||||
@ -9,7 +12,8 @@ public class LookCommand {
|
|||||||
* Handles a look command
|
* Handles a look command
|
||||||
*/
|
*/
|
||||||
public static void handle(String input){
|
public static void handle(String input){
|
||||||
System.out.println("Look command..");
|
Location playerLoc = Globals.playerCharacter.getLocation();
|
||||||
|
playerLoc.describe();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,14 @@ public class Location {
|
|||||||
*/
|
*/
|
||||||
transient List<Item> items = new LinkedList<Item>();
|
transient List<Item> items = new LinkedList<Item>();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the location
|
||||||
|
*/
|
||||||
|
public void describe(){
|
||||||
|
System.out.println("A " + type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param type The type of the location
|
* @param type The type of the location
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.studiorailgun.sim.space.gen;
|
package org.studiorailgun.sim.space.gen;
|
||||||
|
|
||||||
|
import org.studiorailgun.Globals;
|
||||||
import org.studiorailgun.sim.space.Location;
|
import org.studiorailgun.sim.space.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,6 +15,7 @@ public class LocationGenerator {
|
|||||||
*/
|
*/
|
||||||
public static Location generate(String type){
|
public static Location generate(String type){
|
||||||
Location rVal = new Location(type);
|
Location rVal = new Location(type);
|
||||||
|
Globals.world.registerLocation(rVal);
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user