Colour code is. yellow is Home.java. red is Variables.java. green is Battle.java... Names of Classes
package client;
import java.util.Scanner;
public class Home {
public static void main(String[] args) throws InterruptedException {
String Name;
String Title;
// variables, high value.
MainMenu();
System.out.println("Please type in your name");
Scanner input = new Scanner(System.in);
Name = input.next();
System.out.println("Name = " + Name);
System.out.println("Loading.");
Thread.sleep(1500L);
System.out.println("Please type in a Title you want... etc Knight");
Scanner input2 = new Scanner(System.in);
Title = input2.next();
System.out.println("Title = " + Title);
System.out.println("Loading.");
Thread.sleep(1500L);
Battle ShowBattle = new Battle();
// HOMETOWN.
ShowBattle.UseVariables.SetLevel(1);
ShowBattle.UseVariables.SetMaxHealth(ShowBattle.UseVariables.Level*11);
ShowBattle.UseVariables.SetHealth(ShowBattle.UseVariables.getMaxHealth());
ShowBattle.UseVariables.SetMinDamage(ShowBattle.UseVariables.Level);
ShowBattle.UseVariables.SetMaxDamage(ShowBattle.UseVariables.getMinDamage()+ShowBattle.UseVariables.getMaxHealth()-ShowBattle.UseVariables.Level-3);
ShowBattle.UseVariables.SetExpNeed(ShowBattle.UseVariables.Level*100+ShowBattle.UseVariables.getMaxHealth());
String HomeCommand;
Scanner input1 = new Scanner(System.in);
boolean Homeloop = false;
while (Homeloop == false) {
System.out.println("*************************************************");
System.out.println("Your Name is " + Name + " The " + Title);
System.out.println("Your level is: " + ShowBattle.UseVariables.getLevel());
System.out.println("Your Health is: " + ShowBattle.UseVariables.getHealth() + "/" + ShowBattle.UseVariables.getMaxHealth());
System.out.println("Your Current exp is: " + ShowBattle.UseVariables.getExp());
System.out.println("exp need for leveling up: " + ShowBattle.UseVariables.getExpNeed());
System.out.println("Your Current Gold is: " + ShowBattle.UseVariables.getGold());
System.out.println("This is your HomeTown, Type in, 'battle', 'heal', 'blacksmith' and 'quit'");
HomeCommand = input1.next();
// HomeTown Command
if (HomeCommand.equalsIgnoreCase("battle")) {
System.out.println("You are in a Fight, To begin Fighting, type in 'fight'");
if (ShowBattle.UseVariables.getLevel()<=1) {
ShowBattle.UseVariables.SetEnemyName("Man");
}
else if (ShowBattle.UseVariables.getLevel()<=2) {
ShowBattle.UseVariables.SetEnemyName("Guard");
}
else if (ShowBattle.UseVariables.getLevel()<=3) {
ShowBattle.UseVariables.SetEnemyName("LightGuard");
}
else if (ShowBattle.UseVariables.getLevel()<=4) {
ShowBattle.UseVariables.SetEnemyName("HeavyGuard");
}
else if (ShowBattle.UseVariables.getLevel()<=5) {
ShowBattle.UseVariables.SetEnemyName("Palidin");
}
else if (ShowBattle.UseVariables.getLevel()<=6) {
ShowBattle.UseVariables.SetEnemyName("Knight");
}
else if (ShowBattle.UseVariables.getLevel()<=7) {
ShowBattle.UseVariables.SetEnemyName("Goblin");
}
else if (ShowBattle.UseVariables.getLevel()<=8) {
ShowBattle.UseVariables.SetEnemyName("Orc");
}
else if (ShowBattle.UseVariables.getLevel()<=9) {
ShowBattle.UseVariables.SetEnemyName("Troll");
}
else if (ShowBattle.UseVariables.getLevel()<=10) {
ShowBattle.UseVariables.SetEnemyName("DeathNight");
}
else if (ShowBattle.UseVariables.getLevel()>=11) {
ShowBattle.UseVariables.SetEnemyName("DeathKing");
}
ShowBattle.BattleCommence();
}
else if (HomeCommand.equalsIgnoreCase("blacksmith")) {
System.out.println("This is BlackSmith");
boolean BlackSmithloop = false;
while (BlackSmithloop == false) {
String BlackSmithOption;
// if statement for blacksmith.
Scanner input11 = new Scanner(System.in);
System.out.println("*************************************************");
System.out.println("Welcome to BlackSmith");
System.out.println("Type in 'upgrade' or 'back'");
System.out.println("Loading.");
Thread.sleep(1500L);
BlackSmithOption = input11.next();
if (BlackSmithOption.equalsIgnoreCase("upgrade")) {
System.out.println("Upgrading");
int Price = 0;
System.out.println("Would you like to upgrade your weapon Skill.");
if (ShowBattle.UseVariables.getWeaponLvl()<=0) {
Price = 50;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=1) {
Price = 100;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=2) {
Price = 200;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=3) {
Price = 400;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=4) {
Price = 800;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=5) {
Price = 1600;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=6) {
Price = 3200;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=7) {
Price = 6400;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=8) {
Price = 12800;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=9) {
Price = 25600;
}
else if (ShowBattle.UseVariables.getWeaponLvl()<=10) {
Price = 51200;
}
else {
System.out.println("Sorry you cant upgrad anymore...");
BlackSmithloop = true;
}
System.out.println("it will cost you " + Price + " Gold, Type in 'yes' or 'no'");
boolean Priceloop = false;
while (Priceloop == false) {
String Answer2;
Scanner input22 = new Scanner(System.in);
Answer2 = input22.next();
if (Answer2.equalsIgnoreCase("yes")) {
if (ShowBattle.UseVariables.getGold() >= Price) {
ShowBattle.UseVariables.SetGold(ShowBattle.UseVariables.getGold()-Price);
System.out.println("You have upgraded your weapon lvl");
System.out.println("Loading.");
Thread.sleep(1500L);
Priceloop = true;
}
else if (ShowBattle.UseVariables.getGold() < Price) {
System.out.println("Sorry you can't afford that...");
Priceloop = true;
}
else {
System.out.println("Unkown Command");
}
}
}
}
else if (BlackSmithOption.equalsIgnoreCase("back")) {
System.out.println("You leave store");
System.out.println("Loading.");
Thread.sleep(1500L);
BlackSmithloop = true;
}
else {
System.out.println("Unkown Command");
}
}
}
else if (HomeCommand.equalsIgnoreCase("heal")) {
System.out.println("*************************************************");
System.out.println("You are HEALED");
ShowBattle.UseVariables.SetHealth(ShowBattle.UseVariables.getMaxHealth());
System.out.println("Loading.");
Thread.sleep(1500L);
}
else if (HomeCommand.equalsIgnoreCase("quit")) {
System.out.println("*************************************************");
System.out.println("You are quiting... Bye");
System.out.println("Loading.");
Thread.sleep(1500L);
Homeloop = true;
}
else {
System.out.println("Unkown Command");
}
} // End of boolean
System.exit(0);
}
public static void MainMenu () throws InterruptedException {
boolean MainMenuloop = false;
while (MainMenuloop == false) {
System.out.println("Welcome To RPG");
System.out.println("*************************************************");
System.out.println("Would you like to play this Game, 'yes' or 'no'");
Scanner input1 = new Scanner(System.in);
String AnswerMain;
AnswerMain = input1.next();
if (AnswerMain.equalsIgnoreCase("yes")) {
System.out.println("Loading.");
Thread.sleep(1500L);
MainMenuloop = true;
}
else if (AnswerMain.equalsIgnoreCase("no")) {
System.out.println("You are Leaving Game");
System.out.println("Loading.");
Thread.sleep(1500L);
System.exit(0);
}
else {
System.out.println("Unkown Command");
}
}
}
}
package client;
public class Variables {
public int Level;
private int MaxHealth;
private int Health;
private int MinDamage;
private int MaxDamage;
private int Exp;
private int ExpNeed;
private int EnemyLevel = Level;
private int EnemyHealth = EnemyLevel*9;
private int EnemyDamage = MinDamage+MaxHealth-Level-5;
private int DealDamageOff;
private String EnemyName;
private int WeaponLvl;
private int Gold;
int FirstTimeInBattle = 0;
public Variables () {
}
public void SetLevel (int NameLevel) {
Level = NameLevel;
}
public int getLevel () {
return Level;
} // new line
public void SetMaxHealth (int NameMaxHealth) {
MaxHealth = NameMaxHealth;
}
public int getMaxHealth () {
return MaxHealth;
} // new line
public void SetHealth (int NameHealth) {
Health = NameHealth;
}
public int getHealth () {
return Health;
} // new line
public void SetMinDamage (int NameMinDamage) {
MinDamage = NameMinDamage;
}
public int getMinDamage () {
return MinDamage;
} // new line
public void SetMaxDamage (int NameMaxDamage) {
MaxDamage = NameMaxDamage;
}
public int getMaxDamage () {
return MaxDamage;
} // new line
public void SetDealDamageOff (int NameDealDamageOff) {
DealDamageOff = NameDealDamageOff;
}
public int getDealDamageOff () {
return DealDamageOff;
} // new line
public void SetEnemyDamage (int NameEnemyDamage) {
EnemyDamage = NameEnemyDamage;
}
public int getEnemyDamage () {
return EnemyDamage;
} // new line
public void SetEnemyLevel (int NameEnemyLevel) {
EnemyLevel = NameEnemyLevel;
}
public int getEnemyLevel () {
return EnemyLevel;
} // new line
public void SetEnemyHealth (int NameEnemyHealth) {
EnemyHealth = NameEnemyHealth;
}
public int getEnemyHealth () {
return EnemyHealth;
} // new line
public void SetExp (int NameExp) {
Exp = NameExp;
}
public int getExp () {
return Exp;
} // new line
public void SetExpNeed (int NameExpNeed) {
ExpNeed = NameExpNeed;
}
public int getExpNeed () {
return ExpNeed;
} // new line
public void SetEnemyName (String NameEnemyName) {
EnemyName = NameEnemyName;
}
public String getEnemyName () {
return EnemyName;
} // new line
public void SetWeaponLvl (int NameWeaponLvl) {
WeaponLvl = NameWeaponLvl;
}
public int getWeaponLvl () {
return WeaponLvl;
} // new line
public void SetGold (int NameGold) {
Gold = NameGold;
}
public int getGold () {
return Gold;
} // new line
}
package client;
import java.util.Random;
import java.util.Scanner;
public class Battle extends Variables{
// put stuff in here
Variables UseVariables = new Variables();
public Battle() {
}
// put other publics in here
public void BattleCommence () throws InterruptedException {
boolean Battleloop = false;
while (Battleloop == false) {
UseVariables.SetEnemyLevel(UseVariables.getLevel());
UseVariables.SetEnemyHealth(UseVariables.getEnemyLevel()*9);
UseVariables.SetEnemyDamage(UseVariables.getMaxHealth()/2);
String BattleOption;
// This is where the if statement goes.
System.out.println("Loading.");
Thread.sleep(1500L);
Scanner input = new Scanner(System.in);
BattleOption = input.next();
if (BattleOption.equalsIgnoreCase("fight")) {
System.out.println("Fight Commands, 'hit' and 'flee'");
System.out.println("Name of Monster is: " + UseVariables.getEnemyName());
System.out.println("Enemy level: " + UseVariables.getEnemyLevel());
boolean Hitloop = false;
while (Hitloop == false) {
BattleOption = input.next();
System.out.println("*************************************************");
System.out.println("Your Health is: " + UseVariables.getHealth());
System.out.println("Enemy Health is: " + UseVariables.getEnemyHealth());
if (BattleOption.equalsIgnoreCase("hit")) {
System.out.println("*************************************************");
System.out.println("You are in battle");
Random randomGenerator = new Random();
System.out.println("Loading."); // Waiting so it is not flooding.
Thread.sleep(1500L);
UseVariables.SetDealDamageOff(UseVariables.getMinDamage()+randomGenerator.nextInt(UseVariables.getMaxDamage()));
UseVariables.SetEnemyHealth(UseVariables.getEnemyHealth()-UseVariables.getDealDamageOff());
System.out.println("You Hit: "+UseVariables.getDealDamageOff() + " Enemy Health is: " + UseVariables.getEnemyHealth());
if (UseVariables.getEnemyHealth()<= 0) {
System.out.println("You have Kill the Enemy");
UseVariables.SetExp(UseVariables.getExp() + (UseVariables.getEnemyLevel()*25));
Random randomGenerator2 = new Random();
int RandomGold;
RandomGold = 1+randomGenerator2.nextInt(UseVariables.getLevel()*5);
RandomGold *= UseVariables.getLevel();
UseVariables.SetGold(UseVariables.getGold()+RandomGold);
System.out.println("You have received exp * your level...");
System.out.println("You have Looted " + RandomGold + " Gold");
System.out.println("Current exp " + UseVariables.getExp());
System.out.println("Current Gold " + UseVariables.getGold());
if (UseVariables.getExp() >= UseVariables.getExpNeed()) {
UseVariables.SetLevel(UseVariables.getLevel()+1);
UseVariables.SetMaxHealth(UseVariables.getLevel()*11);
UseVariables.SetHealth(UseVariables.getMaxHealth());
UseVariables.SetMinDamage(UseVariables.getLevel());
UseVariables.SetMaxDamage(UseVariables.getMaxHealth()/2+UseVariables.getWeaponLvl());
UseVariables.SetExp(0);
UseVariables.SetExpNeed(UseVariables.getLevel()*100+UseVariables.getMaxHealth());
System.out.println("you level up");
}
System.out.println("Loading.");
Thread.sleep(1500L);
Hitloop = true;
}
if (UseVariables.getEnemyHealth()>=1) {
System.out.println("*************************************************");
System.out.println("Enemy's turn now");
Random randomGenerator1 = new Random();
System.out.println("Loading.");
Thread.sleep(1500L);
UseVariables.SetDealDamageOff(UseVariables.getEnemyLevel()+randomGenerator1.nextInt(UseVariables.getEnemyDamage()));
UseVariables.SetHealth(UseVariables.getHealth()-UseVariables.getDealDamageOff());
System.out.println("Enemy Hit: "+UseVariables.getDealDamageOff() + " Your Health is: " + UseVariables.getHealth());
if (UseVariables.getHealth()<= 0) {
System.out.println("You have died.");
UseVariables.SetHealth(0);
System.out.println("Please go back and heal");
System.out.println("Loading.");
Thread.sleep(1500L);
Hitloop = true;
}
}
}
else if (BattleOption.equalsIgnoreCase("flee")) {
System.out.println("Loading.");
Thread.sleep(1500L);
Hitloop = true;
}
else {
System.out.println("Unkown Command");
}
}
}
else if (BattleOption.equalsIgnoreCase("back")) {
System.out.println("You leave battle");
Battleloop = true;
}
else {
System.out.println("Unkown Command");
}
System.out.println("Loading.");
Thread.sleep(1500L);
Battleloop = true;
}
}
}
No comments:
Post a Comment