|
5 | 5 | targetPatterns,
|
6 | 6 | damageTypes,
|
7 | 7 | moveTiers,
|
| 8 | + statusConditions, |
8 | 9 | } = require("../../config/battleConfig");
|
9 | 10 | const { getMove } = require("./moveRegistry");
|
10 | 11 | const { moveIdEnum } = require("../../enums/battleEnums");
|
@@ -67,9 +68,9 @@ class Move {
|
67 | 68 | offTargetDamageMultiplier = 0.8,
|
68 | 69 | calculateDamageFunction = undefined,
|
69 | 70 | }) {
|
70 |
| - const damageToDeal = ( |
71 |
| - calculateDamageFunction || source.calculateMoveDamage |
72 |
| - )({ |
| 71 | + const damageFunc = |
| 72 | + calculateDamageFunction || ((args) => source.calculateMoveDamage(args)); |
| 73 | + const damageToDeal = damageFunc({ |
73 | 74 | move: getMove(this.id),
|
74 | 75 | target,
|
75 | 76 | primaryTarget,
|
@@ -112,9 +113,91 @@ class Move {
|
112 | 113 | });
|
113 | 114 | }
|
114 | 115 | }
|
| 116 | + |
| 117 | + // eslint-disable-next-line class-methods-use-this |
| 118 | + genericApplySingleStatus({ |
| 119 | + source, |
| 120 | + target, |
| 121 | + // eslint-disable-next-line no-unused-vars |
| 122 | + primaryTarget, |
| 123 | + // eslint-disable-next-line no-unused-vars |
| 124 | + allTargets, |
| 125 | + missedTargets = [], |
| 126 | + statusId, |
| 127 | + options, |
| 128 | + probablity = 1, |
| 129 | + }) { |
| 130 | + if (!missedTargets.includes(target) && Math.random() < probablity) { |
| 131 | + return target.applyStatus(statusId, source, options); |
| 132 | + } |
| 133 | + return false; |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * @param {object} param0 |
| 138 | + * @param {BattlePokemon} param0.source |
| 139 | + * @param {BattlePokemon} param0.primaryTarget |
| 140 | + * @param {Array<BattlePokemon>} param0.allTargets |
| 141 | + * @param {Array<BattlePokemon>=} param0.missedTargets |
| 142 | + * @param {StatusConditionEnum} param0.statusId |
| 143 | + * @param {object=} param0.options |
| 144 | + * @param {number=} param0.probablity |
| 145 | + */ |
| 146 | + genericApplyAllStatus({ |
| 147 | + source, |
| 148 | + primaryTarget, |
| 149 | + allTargets, |
| 150 | + missedTargets = [], |
| 151 | + statusId, |
| 152 | + options, |
| 153 | + probablity = 1, |
| 154 | + }) { |
| 155 | + for (const target of allTargets) { |
| 156 | + this.genericApplySingleStatus({ |
| 157 | + source, |
| 158 | + target, |
| 159 | + primaryTarget, |
| 160 | + allTargets, |
| 161 | + missedTargets, |
| 162 | + statusId, |
| 163 | + options, |
| 164 | + probablity, |
| 165 | + }); |
| 166 | + } |
| 167 | + } |
115 | 168 | }
|
116 | 169 |
|
117 | 170 | const movesToRegister = Object.freeze({
|
| 171 | + [moveIdEnum.FIRE_PUNCH]: new Move({ |
| 172 | + id: moveIdEnum.FIRE_PUNCH, |
| 173 | + name: "Fire Punch", |
| 174 | + type: pokemonTypes.FIRE, |
| 175 | + power: 75, |
| 176 | + accuracy: 100, |
| 177 | + cooldown: 2, |
| 178 | + targetType: targetTypes.ENEMY, |
| 179 | + targetPosition: targetPositions.FRONT, |
| 180 | + targetPattern: targetPatterns.SINGLE, |
| 181 | + tier: moveTiers.POWER, |
| 182 | + damageType: damageTypes.PHYSICAL, |
| 183 | + description: |
| 184 | + "The target is punched with a fiery fist. It may also leave the target with a burn with a 50% chance.", |
| 185 | + execute({ source, primaryTarget, allTargets, missedTargets }) { |
| 186 | + this.genericDealAllDamage({ |
| 187 | + source, |
| 188 | + primaryTarget, |
| 189 | + allTargets, |
| 190 | + missedTargets, |
| 191 | + }); |
| 192 | + this.genericApplyAllStatus({ |
| 193 | + source, |
| 194 | + primaryTarget, |
| 195 | + allTargets, |
| 196 | + statusId: statusConditions.BURN, |
| 197 | + probablity: 0.5, |
| 198 | + }); |
| 199 | + }, |
| 200 | + }), |
118 | 201 | [moveIdEnum.VINE_WHIP]: new Move({
|
119 | 202 | id: moveIdEnum.VINE_WHIP,
|
120 | 203 | name: "Vine Whip",
|
@@ -193,6 +276,37 @@ const movesToRegister = Object.freeze({
|
193 | 276 | });
|
194 | 277 | },
|
195 | 278 | }),
|
| 279 | + [moveIdEnum.MAGMA_IMPACT]: new Move({ |
| 280 | + id: moveIdEnum.MAGMA_IMPACT, |
| 281 | + name: "Magma Impact", |
| 282 | + type: pokemonTypes.FIRE, |
| 283 | + power: 45, |
| 284 | + accuracy: 90, |
| 285 | + cooldown: 5, |
| 286 | + targetType: targetTypes.ENEMY, |
| 287 | + targetPosition: targetPositions.FRONT, |
| 288 | + targetPattern: targetPatterns.ALL, |
| 289 | + tier: moveTiers.ULTIMATE, |
| 290 | + damageType: damageTypes.PHYSICAL, |
| 291 | + description: |
| 292 | + "The targets are struck with blades of magma. If hit and the target is not a full HP, deals 1.5x damage.", |
| 293 | + execute({ source, primaryTarget, allTargets, missedTargets }) { |
| 294 | + this.genericDealAllDamage({ |
| 295 | + source, |
| 296 | + primaryTarget, |
| 297 | + allTargets, |
| 298 | + missedTargets, |
| 299 | + calculateDamageFunction: (args) => { |
| 300 | + const { target } = args; |
| 301 | + const baseDamage = source.calculateMoveDamage(args); |
| 302 | + if (!missedTargets.includes(target) && target.hp < target.maxHp) { |
| 303 | + return Math.floor(baseDamage * 1.5); |
| 304 | + } |
| 305 | + return baseDamage; |
| 306 | + }, |
| 307 | + }); |
| 308 | + }, |
| 309 | + }), |
196 | 310 | });
|
197 | 311 |
|
198 | 312 | module.exports = {
|
|
0 commit comments