- Dua pemain berbeda bermain bergantian
- Turn-based dengan validasi aksi lengkap
- Victory conditions: HP = 0 atau surrender
- Karakter dengan speed tinggi jalan duluan
- Jika speed sama โ coin flip (random)
- Contoh: Wind (50 SPD) > Fire (30 SPD) > Water (10 SPD) > Earth (5 SPD)
Fire > Wind > Earth > Water > Fire
- Advantage = 1.5x damage
- Disadvantage = 0.75x damage
- Message display: "Sangat efektif!" atau "Kurang efektif..."
- Burn ๐ฅ: -5 HP per turn (3 turns) dari Fireball
- Freeze โ๏ธ: Skip turn dari Ice Blast (2 turns)
- Effects dapat stack dan terus berjalan setiap turn
Setiap karakter punya 4 skill:
- Basic Attack (0 FP)
- Guard (0 FP)
- Heal (10 FP) - heal = ATK ร 1.5
- Special Elemental Skill (20-30 FP)
- Fire: Fireball (high damage + burn)
- Water: Ice Blast (medium damage + freeze)
- Earth: Rock Throw
- Wind: Air Slash
- Max 50 FP
- Regenerasi +10 FP per turn
- Skill special butuh 20-30 FP
- Display bar yang real-time
- Live display HP bar dengan character
- FP bar visualization
- Status effects display
- Damage numbers
- Critical hit messages
- Dodge messages
- Elemental advantage messages
- Burn/Freeze effect messages
- Battle log setiap aksi
- Dodge: Chance based on speed difference (max 30%)
- Critical Hit: Speed / 4.0 (max 25%)
- Defense: Kurangi damage sebelum diapply
- Elemental Multiplier: Applied sebelum defense
- Accuracy Calculation: Semua mekanik terintegrasi
- Setiap aksi dicatat di BattleLog
- Bisa display action terakhir atau semua
- Membantu understanding game flow
src/main/java/com/game/battle/
โโโ Battle.java (482 lines) โ Main logic
โโโ BattleState.java (13 lines) โ State enum
โโโ BattleAction.java (73 lines) โ Action recording
โโโ BattleLog.java (77 lines) โ Log management
โโโ BattleSimulator.java (209 lines) โ Interactive mode
โโโ BattleDemo.java (198 lines) โ Automated demo
Documentation:
โโโ BATTLE_SYSTEM.md โ Dokumentasi lengkap
โโโ QUICK_START.md โ Quick reference guide
| Karakter | HP | ATK | DEF | SPD | Element | Keunikan |
|---|---|---|---|---|---|---|
| Fire ๐ฅ | 100 | 35โญ | 15 | 30 | FIRE | High damage, medium speed |
| Water ๐ง | 120โญ | 25 | 25โญ | 10 | WATER | Balanced, freeze attack |
| Earth ๐ | 140โญ | 25 | 30โญ | 5 | EARTH | Tank, very high defense |
| Wind ๐จ | 90 | 30 | 10 | 50โญ | WIND | Glasscannon, super fast |
java -cp target/classes com.game.battle.BattleSimulator- Pemain 1 pilih karakter
- Pemain 2 pilih karakter
- Pertarungan dimulai
- Setiap turn: pilih skill 1-4 atau 0 untuk surrender
- Lihat hasil pertarungan
java -cp target/classes com.game.battle.BattleDemo- AI memilih skill otomatis
- Heal saat HP < 40%
- Use special skill saat FP cukup
- Basic attack sebagai fallback
Fire beats Wind
Wind beats Earth
Earth beats Water
Water beats Fire
Setiap karakter punya strengths & weaknesses
- Fire: High ATK โ bisa one-shot
- Water: High HP/DEF + Freeze โ control game
- Earth: Tank supreme โ defensive
- Wind: High SPD โ agility advantage
- Basic attack 0 FP โ always available
- Special skill 20-30 FP โ strategic cooldown
- +10 FP per turn โ balance resource
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PERTARUNGAN DIMULAI! โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ Pyro (HP: 100/100)
โ๏ธ vs
โ๏ธ Aqua (HP: 120/120)
๐ฒ Penentuan Giliran:
Pyro memiliki speed lebih tinggi! Jalan duluan!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
TURN 1 - Pyro GILIRAN
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ PLAYER 1 Pyro โ [โโโโโโโโโโโโโโโโโโโโ] 100/100 HP
โ FP: [โกโกโกโกโกโกโกโกโกโก] 50/50
๐ก๏ธ PLAYER 2 Aqua โ [โโโโโโโโโโโโโโโโโโโโ] 120/120 HP
โ FP: [โกโกโกโกโกโกโกโกโกโก] 50/50
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Skill tersedia untuk Pyro:
1. Basic Attack (FP Cost: 0)
2. Guard (FP Cost: 0)
3. Heal (FP Cost: 10)
4. Fireball (FP Cost: 25)
Pyro menembakkan bola api ke Aqua!
Kurang efektif...
Aqua menerima 14 kerusakan.
Aqua terbakar! (Burn)
โก Memproses Status Effects...
Aqua menerima 5 damage dari Burn!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
TURN 1 - Aqua GILIRAN
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Aqua membekukan Pyro dengan Ice Blast!
Sangat efektif!
Pyro menerima 33 kerusakan.
Pyro membeku! (Freeze)
// Get active effect names (for display)
public List<String> getActiveEffectNames()
// Update status effects (process effects)
public void updateStatusEffects()- Battle.java โ Inti sistem
- BattleState.java โ State management
- BattleAction.java โ Action recording
- BattleLog.java โ Log management
- BattleSimulator.java โ UI interactive
- BattleDemo.java โ Demo automated
- Polimorfisme: Skill interface dengan implementasi berbeda
- Encapsulation: Private attributes dengan public getters
- State Pattern: BattleState enum
- Observer Pattern: BattleLog records actions
- Strategy Pattern: Character skill strategies
- Error Handling: Validasi FP, skill index, etc
- Memory Efficient: Battle log capped di 100 actions
- Real-time Feedback: Display update setiap turn
โ
Dodge mechanic dengan speed calculation
โ
Critical hit system dengan speed factor
โ
Visual health bar dan FP bar
โ
Real-time status effect display
โ
Battle log untuk replay
โ
Coin flip untuk tie breaker
โ
FP regeneration per turn
โ
Color/emoji indicators untuk status
Fire: Aggressive early, tapi hancur vs Water special
Water: Defense heavy, Freeze untuk setup
Strategy: Fire perlu dodge/tank, Water bisa afford heal
Wind: Hit and run, speed advantage
Earth: Tank susah dikasih damage dari Wind
Strategy: Wind exploit speed, Earth guard heavy
Balanced matchup, depends on player skill
Mudah untuk menambah:
- Skill baru (create class extends Skill)
- Status effect baru (create class extends StatusEffect)
- Karakter baru (create class extends BaseCharacter)
- Game mode baru (modify BattleSimulator)
- Visual effects (extend displayStatus)
System ini mengajarkan:
- OOP principles (abstraction, inheritance, encapsulation, polymorphism)
- Design patterns (state, observer, strategy)
- Game loop implementation
- Resource management (FP system)
- Game balance concepts
- Combat mechanics
- BATTLE_SYSTEM.md โ Dokumentasi komprehensif (semua detail)
- QUICK_START.md โ Quick reference untuk bermain
- Code comments โ Inline documentation
Sistem battle sudah:
- โ Fully functional
- โ Tested (compile + run)
- โ Well documented
- โ Integrated dengan existing code
- โ Scalable & maintainable
- โ Performance optimized
cd C:\TurnBaseGameJava
mvn clean compile
java -cp target/classes com.game.gui.GameWindow