UNPKG

reldens

Version:
47 lines (40 loc) 1.16 kB
/** * * Reldens - TypeAttack * */ const { Attack } = require('@reldens/skills'); const { sc } = require('@reldens/utils'); class TypeAttack extends Attack { constructor(props) { super(props); // @TODO - BETA - Refactor and extract room reference. this.room = false; this.currentBattle = false; } async runSkillLogic() { if(this.room){ // @TODO - BETA - Replace all the defaults by constants. let skillAction = this.key+'_atk'; this.room.broadcast('*', { act: skillAction, owner: this.owner.broadcastKey, target: this.target.broadcastKey }); } await super.runSkillLogic(); if( sc.hasOwn(this.owner, 'player_id') && sc.hasOwn(this.target, 'objectBody') && this.currentBattle && 0 < this.getAffectedPropertyValue(this.target) ){ await this.currentBattle.startBattleWith(this.owner, this.room); } return true; } } module.exports = TypeAttack;