Conversation
There was a problem hiding this comment.
Pull request overview
This PR represents a homework submission for a Java battle game assignment (IronBattle). The implementation introduces a turn-based combat system featuring two character types (Warriors and Wizards) with resource management mechanics. However, the PR contains critical bugs, improper file inclusions, and formatting issues that need to be addressed.
Changes:
- Implemented complete Java battle game with character classes (Warriors, Wizards), abstract Characters base class, and Attacker interface
- Added Maven project configuration with Java 17 support
- Modified README.md (appears to have broken image rendering)
Reviewed changes
Copilot reviewed 7 out of 20 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| Battle/src/main/java/org/example/Attacker.java | Defines interface for attackable characters |
| Battle/src/main/java/org/example/Characters.java | Abstract base class with HP and alive status management |
| Battle/src/main/java/org/example/Warriors.java | Warrior character implementation with stamina-based attacks |
| Battle/src/main/java/org/example/Wizards.java | Wizard character implementation with mana-based attacks |
| Battle/src/main/java/org/example/Main.java | Game entry point with battle system and character creation |
| Battle/pom.xml | Maven project configuration |
| Battle/target/classes/**/*.class | Compiled bytecode files (should not be committed) |
| .idea/* | IntelliJ IDEA configuration files (should not be committed) |
| README.md | Updated with escaped markdown syntax breaking image rendering |
Files not reviewed (8)
- .idea/.gitignore: Language not supported
- .idea/compiler.xml: Language not supported
- .idea/encodings.xml: Language not supported
- .idea/homework-java-ironbattle.iml: Language not supported
- .idea/jarRepositories.xml: Language not supported
- .idea/misc.xml: Language not supported
- .idea/modules.xml: Language not supported
- .idea/vcs.xml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private boolean isAlive=true; | ||
| public Characters(String name,int hp){ | ||
| this.id = UUID.randomUUID().toString(); | ||
| this.name=name; | ||
| this.hp=hp; | ||
| this.isAlive=true; | ||
| } | ||
| public String getName(){ | ||
| return name; | ||
| } | ||
| public void setName(String name){ | ||
| this.name=name; | ||
| } | ||
| public int getHp(){ | ||
| return hp; | ||
| } | ||
| public void setHp(int hp){ | ||
| this.hp=hp; | ||
| if(this.hp<0) { | ||
| this.hp=0; | ||
| isAlive=false; | ||
| }} | ||
| public boolean getAlive(){return isAlive;} | ||
| public void setAlive(boolean isAlive){ | ||
| this.isAlive=isAlive; |
There was a problem hiding this comment.
Inconsistent spacing around operators. Lines 10-12 have inconsistent spacing around the '=' operator (no spaces), which differs from standard Java formatting conventions.
| private boolean isAlive=true; | |
| public Characters(String name,int hp){ | |
| this.id = UUID.randomUUID().toString(); | |
| this.name=name; | |
| this.hp=hp; | |
| this.isAlive=true; | |
| } | |
| public String getName(){ | |
| return name; | |
| } | |
| public void setName(String name){ | |
| this.name=name; | |
| } | |
| public int getHp(){ | |
| return hp; | |
| } | |
| public void setHp(int hp){ | |
| this.hp=hp; | |
| if(this.hp<0) { | |
| this.hp=0; | |
| isAlive=false; | |
| }} | |
| public boolean getAlive(){return isAlive;} | |
| public void setAlive(boolean isAlive){ | |
| this.isAlive=isAlive; | |
| private boolean isAlive = true; | |
| public Characters(String name, int hp){ | |
| this.id = UUID.randomUUID().toString(); | |
| this.name = name; | |
| this.hp = hp; | |
| this.isAlive = true; | |
| } | |
| public String getName(){ | |
| return name; | |
| } | |
| public void setName(String name){ | |
| this.name = name; | |
| } | |
| public int getHp(){ | |
| return hp; | |
| } | |
| public void setHp(int hp){ | |
| this.hp = hp; | |
| if (this.hp < 0) { | |
| this.hp = 0; | |
| isAlive = false; | |
| }} | |
| public boolean getAlive(){return isAlive;} | |
| public void setAlive(boolean isAlive){ | |
| this.isAlive = isAlive; |
| } else { this.mana += 2; | ||
| System.out.println(getName() + " out of mana! Recovers 2 mana."); | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Inconsistent indentation. The closing braces are misaligned with the rest of the code structure. Lines 42-44 should maintain consistent indentation throughout the else block.
| } else { this.mana += 2; | |
| System.out.println(getName() + " out of mana! Recovers 2 mana."); | |
| } | |
| } | |
| } else { | |
| this.mana += 2; | |
| System.out.println(getName() + " out of mana! Recovers 2 mana."); | |
| } | |
| } |
| @@ -0,0 +1,49 @@ | |||
| package org.example; | |||
| import java.util.concurrent.ThreadLocalRandom; | |||
| public class Warriors extends Characters implements Attacker { | |||
There was a problem hiding this comment.
Inconsistent spacing. There is an extra space after 'extends' before 'Characters'. Java style guides recommend single spaces between keywords and types.
| public class Warriors extends Characters implements Attacker { | |
| public class Warriors extends Characters implements Attacker { |
| this.mana=ThreadLocalRandom.current().nextInt(10,51); | ||
| this.intelligence=ThreadLocalRandom.current().nextInt(1,51); |
There was a problem hiding this comment.
Inconsistent spacing around operators. The assignment operators should have consistent spacing. Lines 8-9 have inconsistent spacing around the '=' operator (no spaces).
| this.mana=ThreadLocalRandom.current().nextInt(10,51); | |
| this.intelligence=ThreadLocalRandom.current().nextInt(1,51); | |
| this.mana = ThreadLocalRandom.current().nextInt(10,51); | |
| this.intelligence = ThreadLocalRandom.current().nextInt(1,51); |
| this.stamina=ThreadLocalRandom.current().nextInt(10,51); | ||
| this.strength=ThreadLocalRandom.current().nextInt(1,11); |
There was a problem hiding this comment.
Inconsistent spacing around operators. The assignment operators should have consistent spacing. Lines 8-9 have inconsistent spacing around the '=' operator (no spaces).
| this.stamina=ThreadLocalRandom.current().nextInt(10,51); | |
| this.strength=ThreadLocalRandom.current().nextInt(1,11); | |
| this.stamina = ThreadLocalRandom.current().nextInt(10, 51); | |
| this.strength = ThreadLocalRandom.current().nextInt(1, 11); |
| public class Wizards extends Characters implements Attacker { | ||
| private int mana; | ||
| private int intelligence; | ||
| public Wizards(String name){ |
There was a problem hiding this comment.
Missing space after keyword. There should be a space between 'public' and 'Wizards' in the constructor declaration to follow Java formatting conventions.
| public Wizards(String name){ | |
| public Wizards(String name){ |
| this.hp=0; | ||
| isAlive=false; | ||
| }} | ||
| public boolean getAlive(){return isAlive;} |
There was a problem hiding this comment.
Inconsistent spacing. Line 29 should have consistent spacing around braces and the return statement, following Java formatting conventions.
| public boolean getAlive(){return isAlive;} | |
| public boolean getAlive() { | |
| return isAlive; | |
| } |
| @@ -1,4 +1,4 @@ | |||
|  | |||
| \ | |||
There was a problem hiding this comment.
Incorrect markdown syntax. The backslash before the exclamation mark escapes the markdown image syntax, causing the image not to render. Remove the backslash before the exclamation mark.
| \ | |
|  |
| System.out.println(getName() + " casts FIREBALL! Deals " + damage + " damage."); | ||
| } else if (this.mana >= 1) { | ||
| int damage = 2; | ||
| this.mana += 1; |
There was a problem hiding this comment.
Logic error in attack method. When the wizard uses a STAFF attack (line 37-41), the mana is being incremented (+= 1) instead of decremented. This allows wizards to gain mana while attacking, which contradicts the resource management logic. The staff attack should either cost mana or not modify it, not increase it.
| this.mana += 1; | |
| this.mana -= 1; |
| System.out.println(getName() + " uses HEAVY ATTACK! Deals " + damage + " damage."); | ||
| } else if (this.stamina >= 1) { | ||
| int damage = this.strength / 2; | ||
| this.stamina += 1; |
There was a problem hiding this comment.
Logic error in attack method. When the warrior uses a WEAK ATTACK (line 37-41), the stamina is being incremented (+= 1) instead of decremented. This allows warriors to gain stamina while attacking, which contradicts the resource management logic. The weak attack should cost stamina, not increase it.
| this.stamina += 1; | |
| this.stamina -= 1; |
No description provided.