Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 77 additions & 2 deletions Main/Combat.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,84 @@
package Main;
import java.util.Random;

public class Combat {
// initialize participants
private MechaBeast player;
private MechaBeast enemy;
private boolean playerWon;

private Random rand = new Random();

public Combat(MechaBeast player, MechaBeast enemy) {
this.player = player;
this.enemy = enemy;
}

public boolean getOutcome() {
return playerWon;
}

//Battle mechanics
public void begin() {
System.out.println("\n ╔════════════════════════════════════════╗");
System.out.println("║ BATTLE START ║");
System.out.println("╚════════════════════════════════════════╝");

int round = 1;
while (player.isAlive() && enemy.isAlive()) {
System.out.println("\n=== ROUND " + round++ + "! ===");
playerTurn();
if (!enemy.isAlive()) {
break;
}
enemyTurn();
if (!player.isAlive()) {
break;
}
}

checkOutcome();
}

//Damage calculations
//Battle UI
private int calculateDamage(MechaBeast attacker, MechaBeast defender) {
// example ra ni since wla pay skills
int minPower = 500, maxPower = 1000;
int baseDamage = rand.nextInt(maxPower - minPower + 1) + minPower;
double mult = attacker.getType().getEffectivenessAgainst(defender.getType());

return (int) (baseDamage * mult);
}

//Battle UIs
private void playerTurn() {
System.out.println("\nYOUR BEAST!");
takeDamage(enemy, calculateDamage(player, enemy));

}

private void enemyTurn() {
System.out.println("\nENEMY'S TURN!");
takeDamage(enemy, calculateDamage(player, enemy));
}

public void takeDamage(MechaBeast beast, int damage) {
beast.setCurrentHp(beast.getCurrentHp() - damage);
System.out.println(beast.getName() + " took " + damage + " damage! (HP: " + beast.getCurrentHp() + "/" + beast.getMaxHp() + ")");
if (beast.getCurrentHp() < 0) {
beast.setCurrentHp(0);
}
}


//Victory/defeat conditions
//Skill cooldown and mana management
private void checkOutcome() {
if (player.isAlive()) {
playerWon = true;
} else {
playerWon = false;
}
}

//Skill cooldown and mana management
}
5 changes: 4 additions & 1 deletion Main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static void main(String[] args) {
// Introduction
storyManager.playIntroduction();


// Beast Selection
System.out.println("\n╔════════════════════════════════════════╗");
System.out.println("║ SELECT YOUR MECHA BEASTS ║");
Expand All @@ -43,6 +44,7 @@ public static void main(String[] args) {

List<MechaBeast> availableBeasts = MechaBeastFactory.getAllStarterBeasts();


// Display Beast Selection Table
System.out.println("┌────┬─────────────┬──────────┬──────┬───────┬───────┐");
System.out.println("│ # │ Name │ Type │ HP │ Speed │ Mana │");
Expand Down Expand Up @@ -179,12 +181,13 @@ public static void main(String[] args) {
System.out.println("║ YOUR TEAM IS READY! ║");
System.out.println("╚════════════════════════════════════════╝");


System.out.println("\nYour team:");
for (int i = 0; i < player.getMechaBeasts().size(); i++) {
MechaBeast beast = player.getMechaBeasts().get(i);
System.out.printf("%d. %s (%s)%n", (i + 1), beast.getName(), beast.getType().getDisplayName());
}

System.out.println("\nProfessor Ai-P: Excellent choices! Now let's begin the test!");
System.out.println("\n[Press ENTER to continue]");
scanner.nextLine();
Expand Down
10 changes: 10 additions & 0 deletions Main/MechaBeast.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public void addSkill(Skill skill) {
}
}

// setter & getter for currentHp (since no Skill class yet)
public void setCurrentHp(int hp) {
this.currentHp = hp;
}
public int getCurrentHp() {
return currentHp;
}

public String getName() {
return name;
}
Expand Down Expand Up @@ -153,6 +161,8 @@ public double getEffectivenessAgainst(ElementType defenderType) {
if (defenderType == DARK || defenderType == ELECTRIC) return 2.0;
if (defenderType == FIRE || defenderType == EARTH) return 0.5;
break;
default:
break;
}

return 1.0;
Expand Down
4 changes: 4 additions & 0 deletions Main/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public List<MechaBeast> getMechaBeasts() {
return mechaBeasts;
}

public MechaBeast getActiveBeast() {
return mechaBeasts.get(0); // For simplicity, always return the first beast
}


//progression
//Player.Player statistics
Expand Down
50 changes: 30 additions & 20 deletions Main/StoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,19 @@ public void playStage1AlphaVillage() {
System.out.println("You encountered a Mecha Beast!");

// Tutorial battle sequence
//condition if madaug sa tutorial
/*
// Initialize player's MechaBeast to Kingmantis
Combat fight = new Combat(MechaBeastFactory.createKingmantis(), MechaBeastFactory.createVineratops());

if () {
fight.begin();

if (fight.getOutcome()) {
System.out.println("\nAnnouncer: You have successfully completed the tutorial.");
System.out.println("You may now continue.");
System.out.println(player.getName() + " (catching breath): That... felt too real.");

playAlphaBossBattle();
}
*/


}

Expand All @@ -139,10 +141,13 @@ private void playAlphaBossBattle() {
pressEnterToContinue();

System.out.println("\nBoss battle begins...");

// Alpha Boss Battle
//condition if madaug sa alpha boss
/*
if () {
Combat fight = new Combat(MechaBeastFactory.createKingmantis(), MechaBeastFactory.createGekuma());

fight.begin();

if (fight.getOutcome()) {
System.out.println("\nAltair falls to one knee...");
System.out.println();
System.out.println("Altair (breathing heavily): You... you lack bond with your beasts,");
Expand All @@ -164,7 +169,7 @@ private void playAlphaBossBattle() {
playStage1Ending();
}

*/

}

private void playStage1Ending() {
Expand Down Expand Up @@ -223,9 +228,11 @@ private void playAceTrainerBattle() {
pressEnterToContinue();

// Ace Trainer Battle
//condition if madaug sa ace jazz
/*
if () {
Combat fight = new Combat(MechaBeastFactory.createKingmantis(), MechaBeastFactory.createPirrot());

fight.begin();

if (fight.getOutcome()) {
System.out.println("\nAce Jazz: You've surpassed us all. Take this Challenge Ticket,");
System.out.println("you've earned it. With it, you're worthy of the Tournament Trial.");
System.out.println();
Expand All @@ -234,7 +241,7 @@ private void playAceTrainerBattle() {
System.out.println("You may now attempt the Tournament Trial!");
pressEnterToContinue();
}
*/


}

Expand Down Expand Up @@ -263,9 +270,11 @@ private void playTournamentTrial() {
pressEnterToContinue();

// Tournament Trial Battle
//condition if madaug sa trialmaster
/*
if () {
Combat fight = new Combat(MechaBeastFactory.createKingmantis(), MechaBeastFactory.createVoltchu());

fight.begin();

if (fight.getOutcome()) {
System.out.println("\nTrialmaster: You have beaten me. You are qualified for the tournament!");
System.out.println("And I suppose I'll answer some of your questions.");
System.out.println();
Expand All @@ -290,7 +299,7 @@ private void playTournamentTrial() {
pressEnterToContinue();
}

*/

}

public void playStage3Collapse() {
Expand Down Expand Up @@ -348,13 +357,14 @@ private void playFinalBoss() {
System.out.println("╚════════════════════════════════════════╝");

// Final Glitch Battle
//condition if madaug sa final boss
/*
if () {
Combat fight = new Combat(MechaBeastFactory.createKingmantis(), MechaBeastFactory.createWoltrix());

fight.begin();

if (fight.getOutcome()) {
playEnding();
}

*/
}

private void playEnding() {
Expand Down