Initial Commit

Initial commit of project.
This commit is contained in:
Alex Stewart
2019-03-09 01:21:44 -08:00
parent e54e9653ed
commit 13420951b1
124 changed files with 5883 additions and 0 deletions
@@ -0,0 +1,38 @@
package commands.rpg;
import core.rpg.RPGCommand;
import core.rpg.RPGInput;
import core.rpg.RPGState;
public class RPGCommandBattleFight extends RPGCommand
{
@Override
public String OnRun(RPGState state, RPGInput input)
{
if(state.battleContext == null)
return "```There's nothing to fight!```";
String out = null;
String reward = null;
out = "No one ever trained you to fight, so you do a silly dance and it weirds your opponent out and they leave. (i need to implement this still)";
reward = "+150xp";
state.battleContext = null;
state.player.ApplyEXP(150);
if(out != null && reward != null)
{
out += "\n";
out += "\n";
out += "[" + reward + "]";
}
if(out != null)
out = "```\n" + out + "```";
return out;
}
}
+36
View File
@@ -0,0 +1,36 @@
package commands.rpg;
import core.rpg.RPGCommand;
import core.rpg.RPGInput;
import core.rpg.RPGState;
public class RPGCommandBattleRun extends RPGCommand
{
@Override
public String OnRun(RPGState state, RPGInput input)
{
if(state.battleContext == null)
return "```There's nothing to run from!```";
long lostGold = (long)(state.player.GetGold() * .1);
String out = null;
state.player.SpendGold(lostGold);
state.battleContext = null;
out = "You duck behind a tree and manage to escape from encounter just barely!";
if(lostGold > 0)
{
out += " As you make your final move to escape, you accidentally drop some of your gold behind. You don't dare try to go back and pick it up.";
out += "\n";
out += "\n";
out += "[-" + lostGold + "gp]";
}
if(out != null)
out = "```\n" + out + "```";
return out;
}
}
+97
View File
@@ -0,0 +1,97 @@
package commands.rpg;
import java.util.Random;
import core.rpg.RPGBattleContext;
import core.rpg.RPGCommand;
import core.rpg.RPGInput;
import core.rpg.RPGState;
public class RPGCommandExplore extends RPGCommand
{
private class Chance
{
double rand;
float lastSection;
public Chance(float percentChanceTotal)
{
rand = new Random().nextDouble() * percentChanceTotal;
lastSection = 0;
}
public boolean Next(float amount)
{
lastSection += amount;
return rand < lastSection;
}
}
@Override
public String OnRun(RPGState state, RPGInput input)
{
Chance chance = new Chance(100);
String out = null;
String reward = null;
if(state.battleContext != null)
return "```You can't explore right now, you're in a fight! Try either 'fight' or 'run'!```";
if(chance.Next(20))
{
out = "A creature jumps out of a bush at you!";
reward = "Prepare to fight!";
state.battleContext = new RPGBattleContext(state);
}
else if(chance.Next(20))
{
final int gp = 1;
out = "As you take a stroll, you spy a small shiny glint from a bush and decide to investigate! Looks like it's your lucky day!";
reward = "+" + gp + "gp";
state.player.GiveGold(gp);
}
else if(chance.Next(20))
{
final int healing = 1;
final int xp = 25;
out = "You head out on a lovely stroll down a familiar path - the sun is out and the birds are chirping! Nothing much comes of it, but you feel refreshed.";
reward = "+" + xp + "xp, +" + healing + "hp";
state.player.ApplyHealing(healing);
state.player.ApplyEXP(xp);
}
else if(chance.Next(20))
{
final int xp = 75;
final int damage = 1;
out = "Today's the day you head out on a new path. You find a lot of little nicknacks and trinkets on the trail, but leave them be. The trail gets really steep, the rocks jagged, but you keep going. Eventually, you make it out to the other side into a small but pleasant town, and collapse on a bench to catch your breath.";
reward = "+" + xp + "xp, -" + damage + "hp";
state.player.ApplyEXP(xp);
state.player.ApplyDamage(damage);
}
else
{
final int hp = 2;
out = "You step outside but it starts to rain. You decide not to do much today, and hang about the inn and the tavern.";
reward = "+" + hp + "hp";
state.player.ApplyHealing(hp);
}
if(out != null && reward != null)
{
out += "\n";
out += "\n";
out += "[" + reward + "]";
}
if(out != null)
out = "```\n" + out + "```";
return out;
}
}
+92
View File
@@ -0,0 +1,92 @@
package commands.rpg;
import core.rpg.RPGArmor;
import core.rpg.RPGCommand;
import core.rpg.RPGInput;
import core.rpg.RPGState;
import core.rpg.RPGWeapon;
public class RPGCommandInfo extends RPGCommand
{
@Override
public String OnRun(RPGState state, RPGInput input)
{
String out = null;
switch(input.value.trim().toLowerCase())
{
case "weapon":
case "weapo":
case "weap":
case "wea":
case "we":
case "w":
case "wepon":
case "wepo":
case "wep":
case "hand":
case "att":
case "attack":
out = WeaponStats(state.player.GetWeapon());
break;
case "armour":
case "armou":
case "armor":
case "armr":
case "armo":
case "arm":
case "ar":
case "a":
case "def":
case "defense":
case "body":
case "dress":
case "wear":
case "outfit":
out = ArmorStats(state.player.GetArmor());
break;
}
if(out != null)
out = "```\n" + out + "```";
return out;
}
private String WeaponStats(RPGWeapon weapon)
{
if(weapon == null)
return null;
String out = "";
out += "[" + weapon.GetName() + "]";
out += "\n";
out += " att: " + weapon.GetAttack();
out += "\n";
out += "value: " + weapon.GetValue() + "gp";
out += "\n";
out += "\n";
out += weapon.GetDescription();
return out;
}
private String ArmorStats(RPGArmor armor)
{
if(armor == null)
return null;
String out = "";
out += "[" + armor.GetName() + "]";
out += "\n";
out += " def: " + armor.GetDefense();
out += "\n";
out += "value: " + armor.GetValue() + "gp";
out += "\n";
out += "\n";
out += armor.GetDescription();
return out;
}
}
+61
View File
@@ -0,0 +1,61 @@
package commands.rpg;
import core.rpg.RPGArmor;
import core.rpg.RPGCommand;
import core.rpg.RPGExpTable;
import core.rpg.RPGInput;
import core.rpg.RPGPlayer;
import core.rpg.RPGState;
import core.rpg.RPGWeapon;
public class RPGCommandStats extends RPGCommand
{
@Override
public String OnRun(RPGState state, RPGInput input)
{
RPGPlayer player = state.player;
long exp = player.GetEXP();
long level = RPGExpTable.LevelFromEXP(player.GetEXP());
long ceil = RPGExpTable.EXPCeil(level);
String indent = "";
String linebreak = "\n";
String out = "";
out += indent + "[" + player.GetName() + ", lv. " + level + "]";
out += indent + linebreak;
out += indent + "_______________";
out += indent + linebreak;
out += indent + " EXP: " + exp;
out += indent + " (until next: " + (ceil - exp) + ")";
out += indent + linebreak;
out += indent + " Gold: " + player.GetGold();
out += indent + linebreak;
out += indent + "Health: " + player.GetHealthCurrent() + "/" + player.GetHealthMax();
out += indent + linebreak;
RPGWeapon weapon = player.GetWeapon();
out += indent + "_____";
out += indent + linebreak;
out += indent + "Weapon: " + weapon.GetName();
out += indent + linebreak;
out += indent + " att: " + weapon.GetAttack();
out += indent + linebreak;
RPGArmor armor = player.GetArmor();
out += indent + "_____";
out += indent + linebreak;
out += indent + "Armor: " + armor.GetName();
out += indent + linebreak;
out += indent + " def: " + armor.GetDefense() ;
out += indent + linebreak;
out += indent + linebreak;
out += "Use 'info armor' / 'info weapon' for details!";
return "```\n" + out + "```";
}
}