Skip to content

Commit c7b57c2

Browse files
committed
Fix Dragon Darts bugs
- should not stop after one faint - should not show miss message for first miss
1 parent 5cb8c6e commit c7b57c2

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

data/scripts.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ let BattleScripts = {
481481
}
482482
if (accuracy !== true && !this.randomChance(accuracy, 100)) {
483483
if (!move.spreadHit) this.attrLastMove('[miss]');
484-
this.add('-miss', pokemon, target);
484+
const hideFailure = move.smartTarget && (i < targets.length - 1 || hitResults.some(Boolean));
485+
if (!hideFailure) this.add('-miss', pokemon, target);
485486
if (pokemon.hasItem('blunderpolicy') && pokemon.useItem()) this.boost({spe: 2}, pokemon);
486487
hitResults[i] = false;
487488
continue;
@@ -614,11 +615,11 @@ let BattleScripts = {
614615
for (hit = 1; hit <= targetHits; hit++) {
615616
if (damage.includes(false)) break;
616617
if (hit > 1 && pokemon.status === 'slp' && !isSleepUsable) break;
617-
if (targets.some(target => target && !target.hp)) break;
618+
if (targets.every(target => !target || !target.hp)) break;
618619
move.hit = hit;
619-
if (move.smartTarget && targets.length > hit - 1) {
620+
if (move.smartTarget && targets.length > 1) {
620621
targetsCopy = targets.slice(hit - 1, hit);
621-
if (targetsCopy[0]) this.addMove('-anim', pokemon, move.name, targetsCopy[0]);
622+
if (targetsCopy[0] && hit > 1) this.addMove('-anim', pokemon, move.name, targetsCopy[0]);
622623
} else {
623624
targetsCopy = targets.slice(0);
624625
}
@@ -677,15 +678,17 @@ let BattleScripts = {
677678
move.mindBlownRecoil = false;
678679
}
679680
this.eachEvent('Update');
680-
if (!pokemon.hp) {
681+
if (!pokemon.hp && targets.length === 1) {
681682
hit++; // report the correct number of hits for multihit moves
682683
break;
683684
}
684685
}
685686
// hit is 1 higher than the actual hit count
686687
if (hit === 1) return damage.fill(false);
687688
if (nullDamage) damage.fill(false);
688-
if (move.multihit && !move.smartTarget) this.add('-hitcount', targets[0], hit - 1);
689+
if (move.multihit && typeof move.smartTarget === 'boolean') {
690+
this.add('-hitcount', targets[0], hit - 1);
691+
}
689692

690693
if (move.recoil && move.totalDamage) {
691694
this.damage(this.calcRecoilDamage(move.totalDamage, move), pokemon, pokemon, 'recoil');

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"pretest": "npm run lint && npm run build",
2929
"test": "mocha",
3030
"posttest": "npm run tsc",
31-
"fulltest": "npm run pretest && npm run tsc && mocha -R spec -g \".*\""
31+
"fulltest": "npm run pretest && npm run tsc && mocha --forbid-only -R spec -g \".*\""
3232
},
3333
"husky": {
3434
"hooks": {

test/sim/moves/dragondarts.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,20 @@ describe('Dragon Darts', function () {
3636

3737
it(`should hit the other foe twice if it misses against one`, function () {
3838
battle = common.createBattle({gameType: 'doubles'}, [[
39-
{species: "Ninjask", moves: ['dragondarts']},
39+
{species: "Ninjask", item: 'blunderpolicy', moves: ['dragondarts']},
4040
{species: "Mew", ability: 'stamina', moves: ['splash']},
4141
], [
4242
{species: "Mew", ability: 'stamina', moves: ['splash']},
4343
{species: "Shaymin", ability: 'stamina', moves: ['splash']},
4444
]]);
45+
46+
// default seed will make Dragon Darts miss at +6 evasion
47+
// remember to manually set the seed if an engine change means it doesn't
4548
battle.p2.active[0].boostBy({evasion: 6});
49+
4650
battle.makeChoices();
51+
assert(!battle.log.includes('|-miss|p1a: Ninjask|p2a: Mew'));
52+
assert.statStage(battle.p1.active[0], 'spe', 2);
4753
assert.statStage(battle.p1.active[1], 'def', 0);
4854
assert.statStage(battle.p2.active[0], 'def', 0);
4955
assert.statStage(battle.p2.active[1], 'def', 2);
@@ -64,6 +70,20 @@ describe('Dragon Darts', function () {
6470
assert.statStage(battle.p2.active[1], 'def', 0);
6571
});
6672

73+
it(`should hit both targets even if one faints`, function () {
74+
battle = common.createBattle({gameType: 'doubles'}, [[
75+
{species: "Ninjask", moves: ['dragondarts']},
76+
{species: "Mew", moves: ['splash']},
77+
], [
78+
{species: "Shedinja", moves: ['splash']},
79+
{species: "Shedinja", moves: ['splash']},
80+
]]);
81+
battle.makeChoices();
82+
battle.getDebugLog();
83+
assert.equal(battle.p2.active[0].hp, 0);
84+
assert.equal(battle.p2.active[1].hp, 0);
85+
});
86+
6787
it(`should hit the ally twice in doubles`, function () {
6888
battle = common.createBattle({gameType: 'doubles'}, [[
6989
{species: "Ninjask", moves: ['dragondarts']},

0 commit comments

Comments
 (0)