我有格斗游戏,想增加一点互动,一些能力。这是一个好方法吗?构造函数和所有能力的列表,还是我错过了一些更简单的方法?
var abilityConstructor = function(name, desc, icon, target, param, rate, duration) {
this.name = name; // Name of ability
this.desc = desc; // Ability's description
this.icon = icon; // Ability's icon
this.target = target; // If for self usage - 0, if for enemy - 1
this.param = param; // Which parameter is influenced (health - 0, damage - 1, speed - 2, missing rate - 3)
this.rate = rate; // Factor for dealing (ability's strength)
this.duration = duration; // Spells' duration (current round - 1, two rounds - 2, three rounds - 3)
}
// List of available rates for abilities
var lowRate = 0.1;
var midRate = 0.25;
var highRate = 0.5;
var testAbility = new abilityConstructor('Health reduction', 'Reduces health of the opponent for 2 rounds', 'icon_path_here', 1, 0, midRate, 2);