Untitled

Anonymous
plain_text
04/30/2026 1:46 AM
10.2 KB
8
Indexable
import java.util.Random;
import java.util.Scanner;

public class BRGame {
        public static void main(String[] args) {
                    Scanner sc = new Scanner(System.in);
                            Random rand = new Random();

                                    int health = 100;
                                            int enemiesDefeated = 0;
                                                    int rankPoints = 0;

                                                            System.out.println("=== BR Ranked Mode (Offline) ===");

                                                                    while (health > 0) {
                                                                                    System.out.println("\nAn enemy appears!");
                                                                                                int enemyHealth = rand.nextInt(50) + 30;

                                                                                                            while (enemyHealth > 0) {
                                                                                                                                System.out.println("Your Health: " + health + " | Enemy Health: " + enemyHealth);
                                                                                                                                                System.out.println("1. Attack  2. Run");

                                                                                                                                                                int choice = sc.nextInt();

                                                                                                                                                                                if (choice == 1) {
                                                                                                                                                                                                        int damage = rand.nextInt(20) + 5;
                                                                                                                                                                                                                            int enemyDamage = rand.nextInt(15) + 5;

                                                                                                                                                                                                                                                enemyHealth -= damage;
                                                                                                                                                                                                                                                                    health -= enemyDamage;

                                                                                                                                                                                                                                                                                        System.out.println("You hit enemy for " + damage);
                                                                                                                                                                                                                                                                                                            System.out.println("Enemy hits you for " + enemyDamage);
                                                                                                                                                                                } else {
                                                                                                                                                                                                        System.out.println("You escaped!");
                                                                                                                                                                                                                            break;
                                                                                                                                                                                }
                                                                                                            }

                                                                                                                        if (enemyHealth <= 0) {
                                                                                                                                            enemiesDefeated++;
                                                                                                                                                            rankPoints += 20;
                                                                                                                                                                            System.out.println("Enemy defeated! Rank Points +20");
                                                                                                                        }

                                                                                                                                    if (health <= 0) {
                                                                                                                                                        System.out.println("\nYou died 💀");
                                                                                                                                                                        break;
                                                                                                                                    }

                                                                                                                                                System.out.println("Continue? (yes/no)");
                                                                                                                                                            String cont = sc.next();
                                                                                                                                                                        if (!cont.equalsIgnoreCase("yes")) break;
                                                                    }

                                                                            System.out.println("\n=== Game Over ===");
                                                                                    System.out.println("Enemies Defeated: " + enemiesDefeated);
                                                                                            System.out.println("Rank Points: " + rankPoints);
        }
}
                                                                                                                                    }
                                                                                                                        }
                                                                                                                                                                                }
                                                                                                                                                                                }
                                                                                                            }
                                                                    }
        }
}
Editor is loading...
Leave a Comment