- Removed unfinished RPG command
This commit is contained in:
@@ -5,47 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import commands.characters.CommandCharacterMain;
|
||||
import commands.general.CommandBeansShow;
|
||||
import commands.general.CommandBenchmark;
|
||||
import commands.general.CommandBetBeans;
|
||||
import commands.general.CommandBetHistory;
|
||||
import commands.general.CommandBlurry;
|
||||
import commands.general.CommandBoop;
|
||||
import commands.general.CommandCatch;
|
||||
import commands.general.CommandChangeIndicator;
|
||||
import commands.general.CommandChoose;
|
||||
import commands.general.CommandColiru;
|
||||
import commands.general.CommandColor;
|
||||
import commands.general.CommandCrouton;
|
||||
import commands.general.CommandDBFlush;
|
||||
import commands.general.CommandDBStats;
|
||||
import commands.general.CommandDoWork;
|
||||
import commands.general.CommandEightBall;
|
||||
import commands.general.CommandFetch;
|
||||
import commands.general.CommandGiveBeans;
|
||||
import commands.general.CommandHelp;
|
||||
import commands.general.CommandHelpBuilder;
|
||||
import commands.general.CommandInfo;
|
||||
import commands.general.CommandInvite;
|
||||
import commands.general.CommandJDoodle;
|
||||
import commands.general.CommandLeaderboard;
|
||||
import commands.general.CommandMap;
|
||||
import commands.general.CommandPerish;
|
||||
import commands.general.CommandPing;
|
||||
import commands.general.CommandRPEnd;
|
||||
import commands.general.CommandRPG;
|
||||
import commands.general.CommandRPStart;
|
||||
import commands.general.CommandRating;
|
||||
import commands.general.CommandRemind;
|
||||
import commands.general.CommandRole;
|
||||
import commands.general.CommandRoll;
|
||||
import commands.general.CommandShutdown;
|
||||
import commands.general.CommandStark;
|
||||
import commands.general.CommandStats;
|
||||
import commands.general.CommandTeey;
|
||||
import commands.general.CommandTweet;
|
||||
import commands.general.CommandWolfram;
|
||||
import commands.general.CommandYeet;
|
||||
import commands.general.*;
|
||||
import commands.guildrole.CommandGuildRoleMain;
|
||||
import commands.mod.CommandModMain;
|
||||
import commands.music.CommandMusicMain;
|
||||
@@ -116,7 +76,6 @@ public class CommandManager
|
||||
|
||||
// Mod
|
||||
this.register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("mod"), new CommandModMain(KittyRole.Mod, KittyRating.Safe));
|
||||
|
||||
// General
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public class RPGArmor extends RPGItem
|
||||
{
|
||||
int defense;
|
||||
|
||||
public RPGArmor()
|
||||
{
|
||||
super("Tattered Clothes", "The remains of your first sewing project. You did a pretty good job!", 5);
|
||||
defense = 1;
|
||||
}
|
||||
|
||||
public long getDefense() { return defense; }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public class RPGBattleContext
|
||||
{
|
||||
public RPGState stateRef;
|
||||
|
||||
public RPGBattleContext(RPGState state)
|
||||
{
|
||||
this.stateRef = state;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public abstract class RPGCommand
|
||||
{
|
||||
public RPGCommand() { }
|
||||
|
||||
// OVERRIDE ME
|
||||
public abstract String onRun(RPGState state, RPGInput input);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public class RPGEnemy extends RPGUnit
|
||||
{
|
||||
RPGWeapon attack;
|
||||
RPGArmor armor;
|
||||
|
||||
long expValue;
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public final class RPGExpTable
|
||||
{
|
||||
public static long expFloor(long level)
|
||||
{
|
||||
if(level > Levels.length - 1)
|
||||
level = Levels.length - 1;
|
||||
|
||||
else if (level <= 0)
|
||||
level = 1;
|
||||
|
||||
return Levels[(int) level];
|
||||
}
|
||||
|
||||
public static long expCeil(long level)
|
||||
{
|
||||
if(level > Levels.length - 1)
|
||||
level = Levels.length - 1;
|
||||
|
||||
else if (level <= 0)
|
||||
level = 1;
|
||||
|
||||
return Levels[(int) (level + 1)];
|
||||
}
|
||||
public static long levelFromEXP(long exp)
|
||||
{
|
||||
if(exp < 0)
|
||||
exp = 0;
|
||||
|
||||
for(int i = 0; i < Levels.length; ++i)
|
||||
{
|
||||
if(Levels[i] > exp)
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
return Levels.length - 1;
|
||||
}
|
||||
|
||||
// Based on D&D Pathfinder levels
|
||||
public static long Levels[] =
|
||||
{
|
||||
0, // level 0
|
||||
0, // level 1
|
||||
3000, // level 2
|
||||
7500, // level 3
|
||||
14000, // level 4
|
||||
23000, // level 5
|
||||
35000, // level 6
|
||||
53000, // level 7
|
||||
77000, // level 8
|
||||
115000, // level 9
|
||||
160000, // level 10
|
||||
235000, // level 11
|
||||
330000, // level 12
|
||||
475000, // level 13
|
||||
665000, // level 14
|
||||
955000, // level 15
|
||||
1350000, // level 16
|
||||
1900000, // level 17
|
||||
2700000, // level 18
|
||||
3850000, // level 19
|
||||
5350000 // level 20
|
||||
};
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import commands.rpg.RPGCommandBattleFight;
|
||||
import commands.rpg.RPGCommandBattleRun;
|
||||
import commands.rpg.RPGCommandExplore;
|
||||
import commands.rpg.RPGCommandInfo;
|
||||
import commands.rpg.RPGCommandStats;
|
||||
import core.rpg.RPGInput;
|
||||
|
||||
// Holds the framework for the text RPG, for any number of users
|
||||
public class RPGFramework
|
||||
{
|
||||
// User ID to user state. Users are conceptually just an ID.
|
||||
public HashMap<String, RPGState> gameStates;
|
||||
public HashMap<String, RPGCommand> gameCommands;
|
||||
|
||||
// Ctor
|
||||
public 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());
|
||||
}
|
||||
|
||||
// Primary external
|
||||
public String run(String userID, String inputRaw)
|
||||
{
|
||||
RPGState state = lookupState(userID);
|
||||
RPGInput input = new RPGInput(inputRaw);
|
||||
return executeCommand(input.key, state, input);
|
||||
}
|
||||
|
||||
// Get state for executing a command
|
||||
public RPGState lookupState(String userID)
|
||||
{
|
||||
RPGState state;
|
||||
synchronized(gameStates)
|
||||
{
|
||||
// Note: Hardcoded right now. Later: Extract.
|
||||
state = gameStates.get(userID);
|
||||
|
||||
if(state == null)
|
||||
{
|
||||
state = new RPGState(userID);
|
||||
gameStates.put(userID, state);
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
// Registers a 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("Registered " + commandName);
|
||||
}
|
||||
|
||||
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 null;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
import utils.StringUtils;
|
||||
|
||||
public class RPGInput
|
||||
{
|
||||
public String raw;
|
||||
public String key;
|
||||
public String value;
|
||||
|
||||
public RPGInput(String raw)
|
||||
{
|
||||
this.raw = raw;
|
||||
this.key = "";
|
||||
this.value = "";
|
||||
|
||||
if(raw == null || raw.length() == 0)
|
||||
return;
|
||||
|
||||
raw = raw.trim();
|
||||
int whitespacePos = StringUtils.findFirstWhitespace(raw);
|
||||
|
||||
if(whitespacePos == -1)
|
||||
{
|
||||
key = raw;
|
||||
return;
|
||||
}
|
||||
|
||||
key = raw.substring(0, whitespacePos).trim();
|
||||
value = raw.substring(whitespacePos).trim();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public abstract class RPGItem
|
||||
{
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected int value;
|
||||
|
||||
// Defaults
|
||||
public RPGItem() { this("unknown"); }
|
||||
public RPGItem(String name) { this(name, "nothig is known about this item"); }
|
||||
public RPGItem(String name, String description) { this(name, description, 1); }
|
||||
|
||||
// Ctor
|
||||
public RPGItem(String name, String description, int value)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() { return name; }
|
||||
public String getDescription() { return description; }
|
||||
public long getValue() { return value; }
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
|
||||
public class RPGLog
|
||||
{
|
||||
public static void log(String toWrite)
|
||||
{
|
||||
GlobalLog.log(LogFilter.Command, "[RPG] " + toWrite);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
// This is for testing only, and generally doesn't run unless it's specified.
|
||||
public class RPGMain
|
||||
{
|
||||
private static RPGFramework framework;
|
||||
private static Scanner scanner;
|
||||
|
||||
public static void RPGmain(String[] args)
|
||||
{
|
||||
init();
|
||||
while(run()) { };
|
||||
shutdown();
|
||||
}
|
||||
|
||||
// Initializes stuff (small factory, ish)
|
||||
private static void init()
|
||||
{
|
||||
framework = new RPGFramework();
|
||||
scanner = new Scanner(System.in);
|
||||
}
|
||||
|
||||
// Main loop
|
||||
private static boolean run()
|
||||
{
|
||||
// move outside
|
||||
String out = framework.run("Test", scanner.nextLine());
|
||||
RPGLog.log(out);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
private static void shutdown()
|
||||
{
|
||||
scanner.close();
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public class RPGPlayer extends RPGUnit
|
||||
{
|
||||
private String name;
|
||||
private long gold;
|
||||
private long exp;
|
||||
|
||||
RPGWeapon weapon;
|
||||
RPGArmor armor;
|
||||
|
||||
public RPGPlayer()
|
||||
{
|
||||
super();
|
||||
|
||||
name = "Wanderer";
|
||||
healthCurrent = 5;
|
||||
healthMax = 5;
|
||||
gold = 0;
|
||||
weapon = new RPGWeapon();
|
||||
armor = new RPGArmor();
|
||||
}
|
||||
|
||||
// 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; };
|
||||
|
||||
// Setters
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
// Interactions
|
||||
public void applyEXP(int expToGive)
|
||||
{
|
||||
if(expToGive < 0)
|
||||
expToGive = 0;
|
||||
|
||||
exp += expToGive;
|
||||
}
|
||||
|
||||
public void giveGold(long amount)
|
||||
{
|
||||
if(amount < 0)
|
||||
amount = 0;
|
||||
|
||||
gold += amount;
|
||||
}
|
||||
|
||||
public void spendGold(long amount)
|
||||
{
|
||||
if(amount < 0)
|
||||
amount = 0;
|
||||
|
||||
gold -= amount;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
// Holds specific state information for a given user and their world
|
||||
public class RPGState
|
||||
{
|
||||
// General
|
||||
public String userID;
|
||||
|
||||
// Stats and gameplay
|
||||
public RPGPlayer player;
|
||||
public RPGBattleContext battleContext;
|
||||
|
||||
public RPGState(String userID)
|
||||
{
|
||||
this.userID = userID;
|
||||
this.player = new RPGPlayer();
|
||||
this.battleContext = null;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
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; }
|
||||
|
||||
// Generic implementation. Consider implementing armor in
|
||||
// derived classes, for example.
|
||||
public void applyDamage(int value)
|
||||
{
|
||||
if(value < 0)
|
||||
value = 0;
|
||||
|
||||
healthCurrent -= value;
|
||||
}
|
||||
|
||||
// Generic implementation. Consider applying boosts in
|
||||
// derived classes, for example.
|
||||
public void applyHealing(int value)
|
||||
{
|
||||
if(value < 0)
|
||||
value = 0;
|
||||
|
||||
healthCurrent += value;
|
||||
|
||||
if(healthCurrent > healthMax)
|
||||
healthCurrent = healthMax;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package core.rpg;
|
||||
|
||||
public class RPGWeapon extends RPGItem
|
||||
{
|
||||
private long attack;
|
||||
private double accuracy;
|
||||
|
||||
RPGWeapon()
|
||||
{
|
||||
super("Singed Stick", "A really cool stick that you found! You poked at your campfire last night with it a bit, so the end is a bit toasty.", 2);
|
||||
attack = 1;
|
||||
accuracy = 0.8;
|
||||
}
|
||||
|
||||
public long getAttack() { return attack; }
|
||||
public double getAccuracy() { return accuracy; }
|
||||
}
|
||||
Reference in New Issue
Block a user