mr:buff_system
Table of Contents
Buff System - Code References
Core Classes
- BuffFactory.java - Central registry for all buff types, maps class names to buff classes
- Buff.java - Base class for all buffs
- Char.java - Actor base class with buff management (buff(), hasBuff(), buffLevel(), removeBuff())
- BuffIndicator.java - Icon constants for buff display in UI
Key Interfaces
- Doom.java - Interface for deadly buffs that trigger special death conditions
- ArtifactBuff.java - Base class for artifact-granted buffs
- TemporaryBuff.java - Base class for timed buffs
Buff Registration
BuffFactory maintains a static map of buff class names to Class objects:
private static final Map<String, Class<? extends Buff>> buffMap = new HashMap<>(); static { // Register all buff classes buffMap.put("Bleeding", Bleeding.class); buffMap.put("Poison", Poison.class); // ... etc }
Retrieving buff by name:
public static Buff getBuffByName(String className) { Class<? extends Buff> buffClass = buffMap.get(className); return buffClass != null ? buffClass.newInstance() : null; }
Char Buff Management
- buff(Class<? extends Buff> buffClass) - Apply buff with default duration
- buff(Class<? extends Buff> buffClass, float duration) - Apply buff with specific duration
- hasBuff(Class<? extends Buff> buffClass) - Check if buff is present
- buffLevel(Class<? extends Buff> buffClass) - Get number of buff stacks
- removeBuff(Class<? extends Buff> buffClass) - Remove specific buff
- clearBuffs() - Remove all buffs
Doom Buffs (Special Death)
Buffs implementing Doom interface:
- Necrotism - Spreads to nearby, kills on death
- StoneBlood - Wall walking, immurement on death
- CursedKing - Cursed King artifact buff
- LichEssence - Lich transformation buff
Artifact Buffs
Buffs granted by artifacts (implement ArtifactBuff):
- StoneBlood - Ring of Stone Walking
- LichEssence - Lich artifact
- CursedKing - Cursed King artifact
- AbyssalPresence - Abyssal artifact
String Resources
Standard string naming pattern for buffs:
- `{BuffName}_Name` - Display name
- `{BuffName}_Info` - Description
- `{BuffName}_Death` - Death message
- `ResultDescriptions_{BuffName}` - Death reason description
JSON Configuration
Most buffs are registered in BuffFactory, not configured via JSON. Some artifact buffs are configured in:
- `initHeroes.json` - Starting buffs for hero classes
- `levelsDesc/Bestiary.json` - Mob buff immunities
Related mr Pages
mr/buff_system.txt · Last modified: by 127.0.0.1
