The following diagram illustrates the core class hierarchy of Pixel Dungeon, including game structure, actors, items, and level generation systems.
classDiagram
%% 플레이어 기본 이동 (G1)
class Char {
+int pos
+int HP
+int HT
+CharSprite sprite
+boolean act()
+void spend(float time)
+void move(int step)
+boolean canMove(int step)
+void onMotionComplete()
}
class Hero {
+HeroClass heroClass
+HeroSubClass subClass
+int STR
+int lvl
+int exp
+boolean ready
+HeroAction curAction
+boolean act()
+void rest(boolean fullRest)
+void interrupt()
+void onMotionComplete()
+void earnExp(int exp)
}
class Level {
+int width()
+int height()
+int length()
+int[] map
+boolean[] passable
+boolean[] losBlocking
+int entrance()
+int exit()
+boolean adjacent(int a, int b)
+int pointToCell(int x, int y)
}
%% 전투 시스템 (G2)
class Damage {
+int value
+Object source
+Element element
+boolean isFeatured
+static Damage normalDamage(int value, Object source)
+static Damage elementalDamage(int value, Element element)
+int adjustForDefense(int defense)
}
class Mob {
+int EXP
+int defenseSkill
+boolean hostile
+boolean ally
+AI aiState
+boolean act()
+int attackSkill(Char target)
+int damageRoll()
+int defenseProc(Char enemy, int damage)
+void aggro(Char ch)
+void die(Object cause)
}
%% 적 AI 기본 (G3)
class AI {
+Mob mob
+boolean canAttack(Char enemy)
+boolean canSee(Char ch)
+boolean act(boolean enemyInFOV, boolean justAlerted)
+String status()
}
class Hunting {
+boolean act(boolean enemyInFOV, boolean justAlerted)
+String status()
}
class Wandering {
+boolean act(boolean enemyInFOV, boolean justAlerted)
+String status()
}
%% 사망 및 리셋 (G4)
class GameOver {
+static void show(int cause)
+static void showBadge(Rankings.Record rec)
}
class Rankings {
+ArrayList~Record~ records
+int lastRecord
+void submit(boolean win)
+class Record
}
%% 몬스터 스폰 로직 (G5)
class MobSpawner {
+float spawnCooldown
+void respawnCooldown()
+boolean act()
+Mob createMob()
+void spawnAt(Mob mob, int pos)
}
class RegularLevel {
#ArrayList~Room~ rooms
+void create()
#void createMobs()
#Mob createMob()
#void placeRandomMob()
}
%% 자원 관리 시스템 (G6)
class Hunger {
+float level
+float STARVING
+float HUNGRY
+boolean act()
+void satisfy(float energy)
+void reduceHunger(float energy)
}
class Energy {
+float value
+float max
+void use(float amount)
+void charge(float amount)
+boolean isFull()
+boolean isEmpty()
}
%% 캐릭터 성장 시스템 (G7)
class HeroClass {
+String title()
+String desc()
+ArrayList~HeroSubClass~ subClasses()
+void initHero(Hero hero)
+int armor()
+int hp()
}
class Talent {
+int maxPoints
+int points
+String title()
+String desc()
+void onUpgrade(Hero hero)
+void activate(Hero hero)
}
%% 아이템 시스템 (G8)
class Item {
+String name
+String desc
+int image
+int quantity
+boolean unique
+void execute(Hero hero, String action)
+ArrayList~String~ actions(Hero hero)
+String info()
}
class Weapon {
+int tier
+int min()
+int max()
+int damageRoll(Char owner)
+float accuracyFactor(Char owner)
+float speedFactor(Char owner)
}
class Armor {
+int tier
+int DRMin()
+int DRMax()
+int DRRoll()
+int defenseProc(Char attacker, Char defender, int damage)
}
%% 인벤토리 시스템 (G9)
class Belongings {
+Hero owner
+Backpack backpack
+Item weapon
+Item armor
+Item artifact
+Item misc
+Item ring
+Item getItem(Class~? extends Item~ itemClass)
+void identify()
}
class Backpack {
+int capacity
+ArrayList~Item~ items
+boolean add(Item item)
+boolean remove(Item item)
+Item findItem(Class~? extends Item~ itemClass)
}
%% 아이템 식별 시스템 (G10)
class Catalog {
+HashSet~Class~ seen
+static boolean isSeen(Class itemClass)
+static void setSeen(Class itemClass)
}
%% 아이템 장착/소모 시스템 (G11)
class EquipableItem {
+boolean isEquipped(Hero hero)
+boolean doEquip(Hero hero)
+boolean doUnequip(Hero hero, boolean collect, boolean single)
}
%% 상태이상 시스템 (G12)
class Buff {
+Char target
+int icon()
+String toString()
+String desc()
+boolean attachTo(Char target)
+void detach()
+boolean act()
}
class FlavourBuff {
+int duration
+void spend(float time)
+boolean act()
}
class Burning {
+float DURATION
+void start(Char ch)
+boolean act()
+void detach()
}
class Poison {
+float durationFactor
+void set(float duration)
+boolean act()
}
%% 상호작용 시스템 (G13)
class Heap {
+int pos
+Type type
+Item item
+void drop(Item item)
+void destroy()
+void burn()
+void freeze()
+enum Type
}
class NPC {
+boolean act()
+void interact(Hero hero)
+String[] actions()
}
%% 보스 AI 및 패턴 (G14)
class Boss {
+int defenseSkill
+int damageRoll()
+void damage(int dmg, Object src)
+void die(Object cause)
+void notice()
}
class BossAI {
+Boss boss
+int phase
+boolean canAttack(Char enemy)
+boolean act(boolean enemyInFOV, boolean justAlerted)
+void nextPhase()
}
class BossAttack {
+String name
+float cooldown
+void execute(Boss boss, Char target)
+boolean canUse(Boss boss)
}
%% 클래스 간 관계
Char <|-- Hero
Char <|-- Mob
Mob <|-- Boss
AI <|-- Hunting
AI <|-- Wandering
Mob --> AI : uses
Item <|-- EquipableItem
EquipableItem <|-- Weapon
EquipableItem <|-- Armor
Buff <|-- FlavourBuff
FlavourBuff <|-- Burning
FlavourBuff <|-- Poison
Hero --> HeroClass : has
Hero --> Belongings : has
Hero --> Hunger : has
Belongings --> Backpack : contains
Boss --> BossAI : uses
BossAI --> BossAttack : uses
Level --> Heap : contains
Level --> MobSpawner : uses
RegularLevel --|> Level