= Converted formatting for the core rpg
This commit is contained in:
@@ -10,5 +10,5 @@ public class RPGArmor extends RPGItem
|
||||
defense = 1;
|
||||
}
|
||||
|
||||
public long GetDefense() { return defense; }
|
||||
public long getDefense() { return defense; }
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ public abstract class RPGCommand
|
||||
public RPGCommand() { }
|
||||
|
||||
// OVERRIDE ME
|
||||
public abstract String OnRun(RPGState state, RPGInput input);
|
||||
public abstract String onRun(RPGState state, RPGInput input);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package core.rpg;
|
||||
|
||||
public final class RPGExpTable
|
||||
{
|
||||
public static long EXPFloor(long level)
|
||||
public static long expFloor(long level)
|
||||
{
|
||||
if(level > Levels.length - 1)
|
||||
level = Levels.length - 1;
|
||||
@@ -13,7 +13,7 @@ public final class RPGExpTable
|
||||
return Levels[(int) level];
|
||||
}
|
||||
|
||||
public static long EXPCeil(long level)
|
||||
public static long expCeil(long level)
|
||||
{
|
||||
if(level > Levels.length - 1)
|
||||
level = Levels.length - 1;
|
||||
@@ -23,7 +23,7 @@ public final class RPGExpTable
|
||||
|
||||
return Levels[(int) (level + 1)];
|
||||
}
|
||||
public static long LevelFromEXP(long exp)
|
||||
public static long levelFromEXP(long exp)
|
||||
{
|
||||
if(exp < 0)
|
||||
exp = 0;
|
||||
|
||||
@@ -22,24 +22,24 @@ public class RPGFramework
|
||||
this.gameStates = new HashMap<String, RPGState>();
|
||||
this.gameCommands = new HashMap<String, RPGCommand>();
|
||||
|
||||
RegisterCommand("stats", new RPGCommandStats());
|
||||
RegisterCommand("about", new RPGCommandInfo());
|
||||
RegisterCommand("info", new RPGCommandInfo());
|
||||
RegisterCommand("explore", new RPGCommandExplore());
|
||||
RegisterCommand("run", new RPGCommandBattleRun());
|
||||
RegisterCommand("fight", new RPGCommandBattleFight());
|
||||
registerCommand("stats", new RPGCommandStats());
|
||||
registerCommand("about", new RPGCommandInfo());
|
||||
registerCommand("info", new RPGCommandInfo());
|
||||
registerCommand("explore", new RPGCommandExplore());
|
||||
registerCommand("run", new RPGCommandBattleRun());
|
||||
registerCommand("fight", new RPGCommandBattleFight());
|
||||
}
|
||||
|
||||
// Primary external
|
||||
public String Run(String userID, String inputRaw)
|
||||
public String run(String userID, String inputRaw)
|
||||
{
|
||||
RPGState state = LookupState(userID);
|
||||
RPGState state = lookupState(userID);
|
||||
RPGInput input = new RPGInput(inputRaw);
|
||||
return ExecuteCommand(input.key, state, input);
|
||||
return executeCommand(input.key, state, input);
|
||||
}
|
||||
|
||||
// Get state for executing a command
|
||||
public RPGState LookupState(String userID)
|
||||
public RPGState lookupState(String userID)
|
||||
{
|
||||
RPGState state;
|
||||
synchronized(gameStates)
|
||||
@@ -58,23 +58,23 @@ public class RPGFramework
|
||||
}
|
||||
|
||||
// Registers a command
|
||||
private void RegisterCommand(String commandName, RPGCommand command)
|
||||
private void registerCommand(String commandName, RPGCommand command)
|
||||
{
|
||||
commandName = commandName.toLowerCase();
|
||||
if(gameCommands.put(commandName, command) != null)
|
||||
RPGLog.Log("Managed to register the same RPG command twice! Not ideal!");
|
||||
RPGLog.log("Managed to register the same RPG command twice! Not ideal!");
|
||||
|
||||
RPGLog.Log("Registered " + commandName);
|
||||
RPGLog.log("Registered " + commandName);
|
||||
}
|
||||
|
||||
private String ExecuteCommand(String name, RPGState state, RPGInput input)
|
||||
private String executeCommand(String name, RPGState state, RPGInput input)
|
||||
{
|
||||
synchronized(gameCommands)
|
||||
{
|
||||
RPGCommand command = gameCommands.get(name.toLowerCase());
|
||||
|
||||
if(command != null && state != null)
|
||||
return command.OnRun(state, input);
|
||||
return command.onRun(state, input);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -19,7 +19,7 @@ public abstract class RPGItem
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String GetName() { return name; }
|
||||
public String GetDescription() { return description; }
|
||||
public long GetValue() { return value; }
|
||||
public String getName() { return name; }
|
||||
public String getDescription() { return description; }
|
||||
public long getValue() { return value; }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import utils.LogFilter;
|
||||
|
||||
public class RPGLog
|
||||
{
|
||||
public static void Log(String toWrite)
|
||||
public static void log(String toWrite)
|
||||
{
|
||||
GlobalLog.Log(LogFilter.Command, "[RPG] " + toWrite);
|
||||
}
|
||||
|
||||
@@ -10,29 +10,29 @@ public class RPGMain
|
||||
|
||||
public static void RPGmain(String[] args)
|
||||
{
|
||||
Init();
|
||||
while(Run()) { };
|
||||
Shutdown();
|
||||
init();
|
||||
while(run()) { };
|
||||
shutdown();
|
||||
}
|
||||
|
||||
// Initializes stuff (small factory, ish)
|
||||
private static void Init()
|
||||
private static void init()
|
||||
{
|
||||
framework = new RPGFramework();
|
||||
scanner = new Scanner(System.in);
|
||||
}
|
||||
|
||||
// Main loop
|
||||
private static boolean Run()
|
||||
private static boolean run()
|
||||
{
|
||||
// move outside
|
||||
String out = framework.Run("Test", scanner.nextLine());
|
||||
RPGLog.Log(out);
|
||||
String out = framework.run("Test", scanner.nextLine());
|
||||
RPGLog.log(out);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
private static void Shutdown()
|
||||
private static void shutdown()
|
||||
{
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
@@ -22,17 +22,17 @@ public class RPGPlayer extends RPGUnit
|
||||
}
|
||||
|
||||
// Getters
|
||||
public long GetEXP() { return exp; }
|
||||
public long GetGold() { return gold; }
|
||||
public String GetName() { return name; }
|
||||
public RPGArmor GetArmor() { return armor; };
|
||||
public RPGWeapon GetWeapon() { return weapon; };
|
||||
public long getEXP() { return exp; }
|
||||
public long getGold() { return gold; }
|
||||
public String getName() { return name; }
|
||||
public RPGArmor getArmor() { return armor; };
|
||||
public RPGWeapon getWeapon() { return weapon; };
|
||||
|
||||
// Setters
|
||||
public void SetName(String name) { this.name = name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
// Interactions
|
||||
public void ApplyEXP(int expToGive)
|
||||
public void applyEXP(int expToGive)
|
||||
{
|
||||
if(expToGive < 0)
|
||||
expToGive = 0;
|
||||
@@ -40,7 +40,7 @@ public class RPGPlayer extends RPGUnit
|
||||
exp += expToGive;
|
||||
}
|
||||
|
||||
public void GiveGold(long amount)
|
||||
public void giveGold(long amount)
|
||||
{
|
||||
if(amount < 0)
|
||||
amount = 0;
|
||||
@@ -48,7 +48,7 @@ public class RPGPlayer extends RPGUnit
|
||||
gold += amount;
|
||||
}
|
||||
|
||||
public void SpendGold(long amount)
|
||||
public void spendGold(long amount)
|
||||
{
|
||||
if(amount < 0)
|
||||
amount = 0;
|
||||
|
||||
@@ -5,13 +5,13 @@ public abstract class RPGUnit
|
||||
protected int healthMax;
|
||||
protected int healthCurrent;
|
||||
|
||||
public int GetHealthMax() { return healthMax; }
|
||||
public int GetHealthCurrent() { return healthCurrent; }
|
||||
public boolean IsAlive() { return healthCurrent > 0; }
|
||||
public int getHealthMax() { return healthMax; }
|
||||
public int getHealthCurrent() { return healthCurrent; }
|
||||
public boolean isAlive() { return healthCurrent > 0; }
|
||||
|
||||
// Generic implementation. Consider implementing armor in
|
||||
// derived classes, for example.
|
||||
public void ApplyDamage(int value)
|
||||
public void applyDamage(int value)
|
||||
{
|
||||
if(value < 0)
|
||||
value = 0;
|
||||
@@ -21,7 +21,7 @@ public abstract class RPGUnit
|
||||
|
||||
// Generic implementation. Consider applying boosts in
|
||||
// derived classes, for example.
|
||||
public void ApplyHealing(int value)
|
||||
public void applyHealing(int value)
|
||||
{
|
||||
if(value < 0)
|
||||
value = 0;
|
||||
|
||||
@@ -12,6 +12,6 @@ public class RPGWeapon extends RPGItem
|
||||
accuracy = 0.8;
|
||||
}
|
||||
|
||||
public long GetAttack() { return attack; }
|
||||
public double GetAccuracy() { return accuracy; }
|
||||
public long getAttack() { return attack; }
|
||||
public double getAccuracy() { return accuracy; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user