Inspiration
Decided to create a command-line game for practice and for stickers.
What it does
It is a mini Battle Simulator. You have the option to fight 3 enemies by punching them, kicking them, or slapping them.
How we built it
Built it using Java
Challenges we ran into
Actually setting it up and planning it out took me a while
Accomplishments that we're proud of
It slightly works!
What we learned
I need ALOT more practice with Java
What's next for Command Line Game
Probably fixing the tiny bugs I have.
package first;
import java.util.Random;
import java.util.Scanner;
public class BattleSim {
private int playerHealth;
private int bossHealth;
private int bossChosen;
// 1 = human
// 2 = monster
// 3 = Creator
public BattleSim(int health, int boss, int BossHealth){
playerHealth = health;
bossChosen = boss;
bossHealth = BossHealth;
}
public static void main(String[] args) {
Random random = new Random();
int bossDecider = random.nextInt(4);
int healthForBoss = 0;
switch(bossDecider) {
case(0):
healthForBoss = 100;
break;
case(1):
healthForBoss = 100;
break;
case(2):
healthForBoss = 200;
break;
case(3):
healthForBoss = 9999;
break;
}
BattleSim game = new BattleSim(100, bossDecider, healthForBoss);
switch(game.bossChosen) {
case(0):
case(1):
System.out.println("WOAH! A WILD HUMAN HAS APPEARED! KILL IT!");
Scanner scanner = new Scanner(System.in);
while(!(game.bossHealth <= 0) && game.playerHealth > 0) {
System.out.println("ATTACK!! YOU MAY punch, kick, or slap.");
int playerPunch = random.nextInt(30);
int playerKick = random.nextInt(40);
int playerSlap = random.nextInt(50);
String inputAttack = scanner.nextLine().toLowerCase();
if(inputAttack.equals("punch")) {
game.bossHealth -= playerPunch;
game.playerHealth -= humanEnemy();
System.out.println("YOOOO YOU DID " + playerPunch + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + humanEnemy() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
else if(inputAttack.equals("kick")) {
game.bossHealth -= playerKick;
game.playerHealth -= humanEnemy();
System.out.println("YOOOO YOU DID " + playerKick + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + humanEnemy() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
else if(inputAttack.equals("slap")){
game.bossHealth -= playerSlap;
game.playerHealth -= humanEnemy();
System.out.println("YOOOO YOU DID " + playerSlap + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + humanEnemy() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
}
if(game.playerHealth <= 0) {
System.out.println("YOU LOSE! GET BETTER LOL");
}
else if(game.bossHealth <= 0) {
System.out.println("OMG HEY YOU WON! YOURE SO COOL CAN I GET YOUR AUTOGRAPH PLEASE.");
}
scanner.close();
break;
case(2):
System.out.println("HOLD UP BRO! A WILD MONSTER HAS APPEARED! gET ReaDY THIS IS GONNA BE A TUFF FIGHT!!");
Scanner scanner2 = new Scanner(System.in);
while(!(game.bossHealth <= 0) && game.playerHealth > 0) {
System.out.println("BEAT IT UPPPP!!!! YOU MAY punch, kick, or slap.");
int playerPunch2 = random.nextInt(30);
int playerKick2 = random.nextInt(40);
int playerSlap2 = random.nextInt(50);
String inputAttack = scanner2.nextLine().toLowerCase();
if(inputAttack.equals("punch")) {
game.bossHealth -= playerPunch2;
game.playerHealth -= monsterEnemy();
System.out.println("YOOOO YOU DID " + playerPunch2 + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + monsterEnemy() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
else if(inputAttack.equals("kick")) {
game.bossHealth -= playerKick2;
game.playerHealth -= monsterEnemy();
System.out.println("YOOOO YOU DID " + playerKick2 + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + monsterEnemy() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
else if(inputAttack.equals("slap")){
game.bossHealth -= playerSlap2;
game.playerHealth -= monsterEnemy();
System.out.println("YOOOO YOU DID " + playerSlap2 + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + monsterEnemy() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
}
if(game.playerHealth <= 0) {
System.out.println("YOU LOSE! GET BETTER LOL");
}
else if(game.bossHealth <= 0) {
System.out.println("OMG HEY YOU WON! YOURE SO COOL CAN I GET YOUR AUTOGRAPH PLEASE.");
}
scanner2.close();
break;
case(3):
System.out.println("wait... IT'S GOD! WAIT SHOOT, WE'RE DEF GONNA LOSE. UHHHH, CHARGE!!!");
Scanner scanner3 = new Scanner(System.in);
while(!(game.bossHealth <= 0) && game.playerHealth > 0) {
System.out.println("ATTACK!! YOU MAY punch, kick, or slap.");
int playerPunch3 = random.nextInt(30);
int playerKick3 = random.nextInt(40);
int playerSlap3 = random.nextInt(50);
String inputAttack = scanner3.nextLine().toLowerCase();
if(inputAttack.equals("punch")) {
game.bossHealth -= playerPunch3;
game.playerHealth -= creatorGOD();
System.out.println("YOOOO YOU DID " + playerPunch3 + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + creatorGOD() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
else if(inputAttack.equals("kick")) {
game.bossHealth -= playerKick3;
game.playerHealth -= creatorGOD();
System.out.println("YOOOO YOU DID " + playerKick3 + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + creatorGOD() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
else if(inputAttack.equals("slap")){
game.bossHealth -= playerSlap3;
game.playerHealth -= creatorGOD();
System.out.println("YOOOO YOU DID " + playerSlap3 + " DAMAGE! The boss has " + game.bossHealth + " health left! " + "HOWEVER! THE BOSS HIT YOU FOR " + creatorGOD() + " DAMAGE! YOU HAVE " + game.playerHealth + " HEALTH LEFT!");
}
}
if(game.playerHealth <= 0) {
System.out.println("YOU LOSE! GET BETTER LOL");
}
else if(game.bossHealth <= 0) {
System.out.println("OMG HEY YOU WON! YOURE SO COOL CAN I GET YOUR AUTOGRAPH PLEASE.");
}
scanner3.close();
break;
}
}
public static int humanEnemy() {
Random humanRandom = new Random();
int randomPunchDamage = humanRandom.nextInt(20);
int randomKickDamage = humanRandom.nextInt(30);
int randomSlapDamage = humanRandom.nextInt(40);
int humanChance = humanRandom.nextInt(5);
if(humanChance == 1 || humanChance == 2 || humanChance == 0) {
return randomPunchDamage;
}
else if(humanChance == 3 || humanChance == 4) {
return randomKickDamage;
}
else {
return randomSlapDamage;
}
}
public static int monsterEnemy() {
Random monsterRandom = new Random();
int monsterPunchDamage = monsterRandom.nextInt(30);
int monsterKickDamage = monsterRandom.nextInt(40);
int monsterSlapDamage = monsterRandom.nextInt(50);
int monsterChance = monsterRandom.nextInt(6);
if(monsterChance == 0 || monsterChance == 1 || monsterChance == 2) {
return monsterPunchDamage;
}
else if(monsterChance == 3 || monsterChance == 4 || monsterChance == 5) {
return monsterKickDamage;
}
else {
return monsterSlapDamage;
}
}
public static int creatorGOD() {
Random creatorRandom = new Random();
int creatorSmiteDamage = creatorRandom.nextInt(90);
return creatorSmiteDamage;
}
}
Log in or sign up for Devpost to join the conversation.