Skip to main content

How do you structure a Item class?

I've been thinking about the structure of a Item class. There are many item which may or may not have effects in games.

For example, an item "Herb" has effect "Heal HP by 5". but an item "Stone" has no effect.

As per a title, when you design a game, how do you structure the Item class?

The following is the structure I've come up with.

class Item{
    String id;
    // Status where s = HP, MP, ATK .. etc
    // Integer -> value which affects on the Status
    Map<Status, Integer> effect;
    SignType st; // +, -, *, /
}

class Player{
    Map<Status, Integer> status; // Status where s = HP, MP, ATK .. etc
}
neko
  • 107
  • 8