I'm planning to make a Class for RPG game's character skill. But the problem is that the skills need to be classified by multiple criteria. Below are the criteria for skills.
- Independent / dependent
Some skills are usuable by itself. Howver some skills are only used (automatically) in situations where certain skills are used. For example 'Additinal FireBall' skill are only used after 'FireBall' skill.
- Attack / Buff
Attack skills deal damage to enemy. On the contrary buff skills do some useful effects like increasing character's movement speed.
abstract class Skill {
String skillId;
abstract void use(Character character, Enemy enemy);
}
abstract class IndepentdentSkill {
}
abstract class DependentSkill {
List<String> conditionSkills; //DependentSkill are automatically used after one of conditionSkills are used
}
interface AttackSkill {
void doDamage(Enemy enemy);
}
interface BuffSkill {
void applyBuff(Character character);
}
class IndependentAttackSkill extends IndepentdentSkill implements AttackSkill {
@Override
void use(Character character, Enemy enemy) {
doDamage(enemey);
}
@Override
void doDamage(Enemy enemy) {
enemy.takeDamage(this.damage);
}
}
class IndependentBuffSkill extends IndepentdentSkill implements BuffSkill {
List<BuffEffects> BuffEffects;
@Override
void use(Character character, Enemy enemy) {
doDamage(enemey);
}
@Override
void applyBuff(Character character) {
character.applyBuff(this.BuffEffects);
}
}
//class DependentAttackSkill { ... }
//class DependentBuffSkill { ... }
I tried to make class like below but there were several problems.
In this example, there will be four(2 * 2) class in total(IndependentAttackSkill, ..., DependentBuffSkill). If I need one more criteria and it would be 2 * 2 * 2 = 8. Moreover, if I have to add 'Defense' classification there would be a lot of work.
method Skill.use(Character, Enemy) are taking parameter more than necessary. As you can see in the concrete Class, Skill.use() only use one of them.
If you know a class design that can complement these two issues, I would really appreciate it if you could let me know