0% found this document useful (0 votes)
5 views10 pages

Final Project Documentation

The document outlines a turn-based combat game project developed by a group named Java Infinity, led by Cleford C. Carlos. Players can choose between two specialties, Warrior or Mage, and take turns attacking a CPU opponent while managing their health points (HP). The game features a cooldown system for special skills, a randomized damage system, and ends when either the player or CPU's HP reaches zero.

Uploaded by

rowiljay16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views10 pages

Final Project Documentation

The document outlines a turn-based combat game project developed by a group named Java Infinity, led by Cleford C. Carlos. Players can choose between two specialties, Warrior or Mage, and take turns attacking a CPU opponent while managing their health points (HP). The game features a cooldown system for special skills, a randomized damage system, and ends when either the player or CPU's HP reaches zero.

Uploaded by

rowiljay16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Turn-Base Combat Game

Course and Section: 11-ITE-06

Instructor: Narvasa, Jan Julliene S.

Group Name: Java Infinity (Group No. 3)

Leader: Carlos, Cleford C

Group Members:

1. Meneses, Jojo
2. Bautista, Merabel
3. Soriano, Rowiljay

Submission Date: December 20, 2024

PROJECT DESCRIPTION
Objective of the Game:

The goal of the game is to defeat the opponent (CPU) by reducing their
health points (HP) to zero while managing your own HP strategically.
Players must carefully choose their action attack, defend, or use a special
skill to outlast and overcome the CPU.

Game Concept:

The game is a simple turn-based battle simulator where the player


competes against a CPU opponent. At the start, the player selects a
specialty: Warrior or Mage, each offering unique abilities to enhance
gameplay strategy.

- Warrior: Deals double damage on their next attack using their special
skill.

- Mage: Recovers 20 HP when using their special skill.

Both the player and the CPU take turns choosing actions, such as
attacking for damage, defending to block attacks, or using special skills
(with a cool-down period). Victory is achieved when an opponent’s HP
drops to zero.

FEATURES
Core Features:

1. Player Specialties:
I. Warrior: Specializes in delivering powerful attacks by doubling
damage.
II. Mage: Focuses on survival by healing 20 HP using their special
skill.
2. Damage System: Randomized attack damage ranges between 6 to
12 points for balanced and unpredictable gameplay.
3. Cool down System: Special skills require a 5-turn cooldown,
encouraging strategic timing and decision-making.
4. Winning Condition: The game ends when either the player or the
CPU’s HP drops to zero, determining the winner.
Optional Features:

1. Multiple Rounds: Best-of-three or other match formats for extended


play.
2. Multiplayer Mode: Two-player mode for competitive play.

GAME DESIGN
Game Flow Chart:

Process the Display Round


START
actions Summary

YES

Input a
player name
Is the
CPU’s Is the Player’s
action NO
HP ≤ 0 or
valid?
CPU’s HP ≤ 0?
Select a specialty NO
1. Warrior
2. Mage
YES

CPU’s Turn

Announce the
NO
YES Winner
Is the
Player’s
Specialty
Valid? Is the
Player’s
action
valid?
YES NO END

The game begins

Player’s Turn
Game Rules

1. Both the player and CPU start with 100 HP.


2. Players alternate turns, choosing from Attack, Defend, or Special
Skill actions.
3. Attacks deal randomized damage between 6–12 points.
4. Defending blocks the opponent’s attack completely.
5. Special skills have unique effects:
I. Warrior: Deals double damage.
II. Mage: Heals 20 HP.
III. Special skills have a cool-down period of 5 turns after use.
6. The game ends when either the player’s or CPU’s HP drops to 0. The
winner is the last one standing.

IMPLEMENTATION
Code Overview

 Classes and Methods Used:


The game uses a single class (JavaINFINTY) containing all the game
logic. Player input is handled using the Scanner class, and random
events (e.g., damage calculation, CPU actions) are managed with
the Random class.
 Key Variables:
1. playerHp and cpuHp: Track current health points.
2. playerSkillChoice and cpuSkillChoice: Determine whether the
player/CPU is a Warrior or Mage.
3. playerSkillCooldown and cpuSkillCooldown: Handle the cool-
down timers for special skills.
4. playerUsedSkill and cpuUsedSkill: Indicate if a special skill was
used during a turn.

 Game Loops and Logic:


The game runs inside a while loop that continues until either the
player or CPU’s HP reaches zero. During each iteration:

1. The player selects an action.


2. The CPU randomly chooses an action, ensuring valid moves
(e.g., special skills only if off cooldown).
3. Damage or effects are applied based on the chosen actions.
4. HP and cool-down timers are updated.
5. A round summary is displayed.
Challenges Encountered

1. Input Validation: Ensuring players entered valid options (1, 2, or


3) required implementing checks and re-prompting users. This was
solved with a while loop to filter invalid inputs.
2. Cool down Management: Preventing the CPU from using special
skills while on cooldown required additional logic to reselect its
action.
3. Game Balance: Finding the right damage range and cool-down
length for fair gameplay involved multiple testing iterations.

CONCLUSION AND REFLECTION:

What Went Well:

 The core mechanics (turn-based system, damage calculation, and


special skills) worked smoothly and provided an engaging
experience.
 The random CPU actions and damage system added
unpredictability.
 Clear prompts and input validation ensured user-friendly gameplay.

Lesson Learned:

 Planning game logic with flowcharts makes implementation easier.


 Playtesting is essential to identify bugs and balance gameplay
mechanics.
 Simplicity in design can still create an enjoyable experience with the
right mechanics.

Future Improvements:

 Add difficulty levels, such as smarter CPU behaviour or higher


damage output.
 Introduce new player and CPU specialties for more strategic options.
 Develop a graphical interface to enhance the user experience.
 Implement multiplayer support for players to compete against each
other.
APPENDIX:

1 import java.util.Scanner;
2 import java.util.Random;
3
4 public class JavaINFINTY {
5 public static void main(String[] args) {
6 Scanner scanner = new Scanner(System.in);
7 Random random = new Random();
8
9 // Initialize player and CPU stats
10 System.out.print("Enter your name: ");
11 String playerName = scanner.nextLine();
12 System.out.println("Choose your specialty:");
13 System.out.println("1. Warrior (Double damage in next attack)");
14 System.out.println("2. Mage (Recover 20 HP)");
15
16 // Loop until the player chooses a valid specialty
17 // player special skill
18 int playerSkillChoice = 0;
19 while (playerSkillChoice != 1 && playerSkillChoice != 2) {
20 System.out.print("Enter your choice (1 or 2): ");
21 playerSkillChoice = scanner.nextInt();
22 System.out.println("");
23
24 if (playerSkillChoice == 1) {
25 System.out.println(playerName + " chose Warrior.");
26
27 } else if (playerSkillChoice == 2) {
28 System.out.println(playerName + " chose Mage.");
29 } else {
30 System.out.println("Invalid choice. Please select 1 for Warrior or 2 for
Mage.");
31 }
32 }
33
34 // cpu special skill
35 int cpuSkillChoice = random.nextInt(2) + 1; // printing cpu choice
36 if (cpuSkillChoice == 1){
37 System.out.println("Cpu chose Warrior");
38 }else{
39 System.out.println("Cpu chose Mage");
40 }
41 System.out.println("\
n---------------------------------------------------------------------------------------------------");
42
43 // declaring HP and special skill cooldown
44 int playerHp = 100;
45 int cpuHp = 100;
46 int playerSkillCooldown = 0;
47 int cpuSkillCooldown = 0;
48 boolean playerUsedSkill = false;
49 boolean cpuUsedSkill = false;
50
51
52 System.out.println("\nLet the battle begin!");
53
54 while (playerHp > 0 && cpuHp > 0) { // loop until player or cpu hp comes down
to 0
55 // Display player options
56 System.out.println("\n" + playerName + "'s Turn:");
57 System.out.println("1. Attack");
58 System.out.println("2. Defend");
59 System.out.println("3. Special Skill (" + (playerSkillCooldown == 0 ? "Ready" :
playerSkillCooldown + " rounds left") + ")");
60
61 // player's action
62 int playerAction = 0;
63 while (true){
64 System.out.print("\nChoose your action: ");
65 playerAction = scanner.nextInt(); // scanner that will accept the player's
action
66
67 if (playerAction == 3 && playerSkillCooldown > 0){ // filter for invalid
actions
68 System.out.println("Special skill is still on cooldown!");
69 } else if (playerAction >= 1 && playerAction <= 3) {
70 break;
71 } else {
72 System.out.println("Invalid choice. Please select a valid option (1, 2, or
3).");
73 }
74 }
75
76 // CPU's action randomizer
77 int cpuAction = random.nextInt(3) + 1;
78 while (cpuAction == 3 && cpuSkillCooldown > 0) { // forces cpu to reselect
action if it chooses the special skill while it's on cooldown.
79 cpuAction = random.nextInt(3) + 1;
80 }
81
82 // initializing variables for DAMAGE and DEFEND
83 int playerDamage = 0;
84 int cpuDamage = 0;
85 boolean playerDefend = false;
86 boolean cpuDefend = false;
87
88 // process of players action
89 switch (playerAction) {
90 case 1 : // attack
91 playerDamage = random.nextInt(7) + 6; // Random damage (6-12)
92 System.out.println(playerName + " attacks and deals " + playerDamage
+ " damage!");
93 break;
94
95 case 2 : // defend
96 System.out.println(playerName + " is defending.");
97 playerDefend = true;
98 break;
99
100 case 3 : // special skill
101 if (playerSkillChoice == 1) {
102 playerDamage = (random.nextInt(7) + 6) * 2;
103 System.out.println(playerName + " uses Warrior's Special Skill and
deals " + playerDamage + " damage!");
104 } else {
105 playerHp = Math.min(playerHp + 20, 100);
106 System.out.println(playerName + " uses Mage's Special Skill and
recovers 20 HP!");
107 }
108 playerUsedSkill = true;
109 playerSkillCooldown = 5;
110 break;
111
112 default :
113 System.out.println("Invalid choice. Skipping turn.");
114
115 }
116
117 // process of Cpu action
118 switch (cpuAction) {
119 case 1 : // attack
120 cpuDamage = random.nextInt(7) + 6; // Random damage (6-12)
121 System.out.println("CPU attacks and deals " + cpuDamage + "
damage!");
122 break;
123
124 case 2 : // defend
125 System.out.println("CPU is defending.");
126 cpuDefend = true;
127 break;
128
129 case 3 : // special skill
130 if (cpuSkillChoice == 1) {
131 cpuDamage = (random.nextInt(7) + 6) * 2;
132 System.out.println("CPU uses Warrior's Special Skill and deals " +
cpuDamage + " damage!");
133 } else {
134 cpuHp = Math.min(cpuHp + 20, 100);
135 System.out.println("CPU uses Mage's Special Skill and recovers 20
HP!");
136 }
137 cpuUsedSkill = true;
138 cpuSkillCooldown = 5;
139 break;
140
141 }
142
143 // defending mechanics
144 if (playerDefend && cpuDamage > 0) {
145 System.out.println(playerName + " negates the CPU's attack!");
146 cpuDamage = 0; // Negate damage if defending
147 }
148 if (cpuDefend && playerDamage > 0) {
149 System.out.println("CPU negates " + playerName + "'s attack!");
150 playerDamage = 0; // Negate damage if defending
151 }
152 if (cpuDefend && playerDefend) {
153 System.out.println("No damage was inflicted");
154 }
155
156
157 // damage
158 cpuHp -= playerDamage;
159 playerHp -= cpuDamage;
160
161
162 // cooldown mechanics
163 if (playerSkillCooldown > 0) {
164 playerSkillCooldown--; // decrease the value of a variable by one
165 }
166 if (cpuSkillCooldown > 0) {
167 cpuSkillCooldown--; // decrease the value of a variable by one
168 }
169
170
171 // display
172 System.out.println("\nRound Summary:");
173 System.out.println(playerName + "'s HP: " + playerHp);
174 System.out.println("CPU's HP: " + cpuHp);
175 if (playerUsedSkill) {
176 System.out.println(playerName + " used their special skill this round!");
177 playerUsedSkill = false;
178 }
179 if (cpuUsedSkill) {
180 System.out.println("CPU used their special skill this round!");
181 cpuUsedSkill = false;
182 }
183 System.out.println("\
n---------------------------------------------------------------------------------------------------");
184 }
185
186 // winning process
187 System.out.println("\nGame Over!");
188 if (playerHp > 0) {
189 System.out.println("Congratulations " + playerName + ", you win!");
190 } else {
191 System.out.println("CPU wins! Better luck next time.");
192 }
193 scanner.close();
194
195 }
196 }

You might also like