I'm developing a RPG-game. After searching about various ways to save item information in RPG-game, I determined to save information in JSON files. The problem is that in my game, some equipment's stat depends on the character condition.
class Equipment {
String name;
double strength;
double agility;
Equipment(String name) {
this.name = name;
}
checkCondition(Character character) {
switch (this.name) {
case "itemA" -> {
strength = 20;
//This is what I mean by "condition dependent item"
agility = character.strength > 30 ? 20 : 10;
}
case "itemB" -> strength = 40;
}
}
}
As you can see, "itemA"'s stat is dependent to characters' strength.
{
"name": "itemB",
"strength": 40,
"agility": 0
}
This is how I planned to save the items, but "itemA" doesn't seem to fit in this form. Please let me know you have an idea to solve this problem.