Skip to content

Commit

Permalink
Fix prettier/eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorhansen committed Nov 27, 2023
1 parent 673fb72 commit bee7d08
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 98 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ dependencies:
- python=3.9
- pip>=23.0
- pip:
- -r requirements.txt
- -r requirements.txt
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@
"prettier": "^3.1.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^5.3.2"
"typescript": "5.2.2"
}
}
80 changes: 40 additions & 40 deletions src/ts/battle/agent/maxDamage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ function calcDamge(
benchMon === undefined
? "<empty>"
: benchMon === null
? "<unknown>"
: benchMon.species,
? "<unknown>"
: benchMon.species,
];
}

Expand Down Expand Up @@ -692,16 +692,16 @@ function calcDamge(
critRatio === true
? 1
: critRatio === false
? 0
: critRatio < 1
? 1 / 16
: critRatio < 2
? 1 / 8
: critRatio < 3
? 1 / 4
: critRatio < 4
? 1 / 3
: 1 / 2;
? 0
: critRatio < 1
? 1 / 16
: critRatio < 2
? 1 / 8
: critRatio < 3
? 1 / 4
: critRatio < 4
? 1 / 3
: 1 / 2;

let critModifier = psMove.critModifier ?? 2;
if (ourActive.ability === "sniper") {
Expand Down Expand Up @@ -730,12 +730,12 @@ function calcDamge(
ratio < 1
? 40
: ratio < 2
? 60
: ratio < 3
? 80
: ratio < 4
? 120
: 150;
? 60
: ratio < 3
? 80
: ratio < 4
? 120
: 150;
break;
}
case "eruption":
Expand All @@ -755,14 +755,14 @@ function calcDamge(
ratio < 2
? 200
: ratio < 6
? 150
: ratio < 13
? 100
: ratio < 22
? 80
: ratio < 43
? 40
: 20;
? 150
: ratio < 13
? 100
: ratio < 22
? 80
: ratio < 43
? 40
: 20;
break;
}
case "fling":
Expand All @@ -782,14 +782,14 @@ function calcDamge(
theirSpecies.weightkg < 10
? 20
: theirSpecies.weightkg < 25
? 40
: theirSpecies.weightkg < 50
? 60
: theirSpecies.weightkg < 100
? 80
: theirSpecies.weightkg < 200
? 100
: 120;
? 40
: theirSpecies.weightkg < 50
? 60
: theirSpecies.weightkg < 100
? 80
: theirSpecies.weightkg < 200
? 100
: 120;
break;
case "gyroball":
basePower = 1 + Math.floor((25 * theirSpe) / ourSpe);
Expand Down Expand Up @@ -855,12 +855,12 @@ function calcDamge(
move.pp > 3
? 40
: move.pp > 2
? 50
: move.pp > 1
? 60
: move.pp > 0
? 80
: 200;
? 50
: move.pp > 1
? 60
: move.pp > 0
? 80
: 200;
break;
case "wringout":
basePower =
Expand Down
28 changes: 14 additions & 14 deletions src/ts/battle/parser/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@ handlersImpl["|-fail|"] = async function (ctx) {
const side = event.kwArgs.of
? Protocol.parsePokemonIdent(event.kwArgs.of).player
: ident.player === "p1"
? "p2"
: "p1";
? "p2"
: "p1";
const mon = ctx.state.getTeam(side).active;
if (from.type === "ability") {
mon.revealAbility(from.name);
Expand Down Expand Up @@ -1567,8 +1567,8 @@ handlersImpl["|-activate|"] = async function (ctx) {
const targetSide = event.kwArgs.of
? Protocol.parsePokemonIdent(event.kwArgs.of).player
: ident.player === "p1"
? "p2"
: "p1";
? "p2"
: "p1";
const opp = ctx.state.getTeam(targetSide).active;
opp.moveset.reveal(warnMoveId);

Expand Down Expand Up @@ -1605,8 +1605,8 @@ handlersImpl["|-activate|"] = async function (ctx) {
const targetSide = event.kwArgs.of
? Protocol.parsePokemonIdent(event.kwArgs.of).player
: ident.player === "p1"
? "p2"
: "p1";
? "p2"
: "p1";
v.lockOn(ctx.state.getTeam(targetSide).active.volatile);
break;
}
Expand Down Expand Up @@ -1783,14 +1783,14 @@ export const handlers =
},
}
: handlersImpl[key] === "unsupported"
? {
// Unsupported parser throws an error.
async [key](ctx: BattleParserContext) {
await unsupportedParser(ctx, key);
},
}
: // Handler already implemented, don't override it.
undefined,
? {
// Unsupported parser throws an error.
async [key](ctx: BattleParserContext) {
await unsupportedParser(ctx, key);
},
}
: // Handler already implemented, don't override it.
undefined,
),
) as Required<HandlerMap>;

Expand Down
28 changes: 16 additions & 12 deletions src/ts/battle/state/encoder/encoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ export const definedMajorStatusCounterEncoder: Encoder<ReadonlyMajorStatusCounte
// Note: Damage is actually turns * max(1, floor(hp/16)).
Math.min(15 / 16, msc.turns / 16)
: msc.current === "slp"
? // Chance of staying asleep.
limitedStatusTurns(msc.turns, msc.duration!)
: // Irrelevant.
1,
? // Chance of staying asleep.
limitedStatusTurns(msc.turns, msc.duration!)
: // Irrelevant.
1,
}),
oneHotEncoder(dex.majorStatusKeys.length),
);
Expand Down Expand Up @@ -524,17 +524,17 @@ export const definedItemEncoder: Encoder<ItemArgs> = concat(
item
? [item]
: usage && usage.size > 0
? constraintWithUsage(dex.itemKeys, usage, smoothing)
: itemSet,
? constraintWithUsage(dex.itemKeys, usage, smoothing)
: itemSet,
itemKeyEncoder,
),
augment(
({lastItem, usage, smoothing}) =>
lastItem
? [lastItem]
: usage && usage.size > 0
? constraintWithUsage(dex.itemKeys, usage, smoothing)
: itemSet,
? constraintWithUsage(dex.itemKeys, usage, smoothing)
: itemSet,
itemKeyEncoder,
),
);
Expand Down Expand Up @@ -610,10 +610,14 @@ export const definedMoveEncoder: Encoder<KnownMoveArgs> = concat(
move.name !== "hiddenpower"
? [move.name]
: typeof hpType === "string"
? [`hiddenpower${hpType}`]
: hpType instanceof Map && hpType.size > 0
? constraintWithUsage(hiddenPowerMoveKeys, hpType, smoothing)
: hiddenPowerMoveKeysSet,
? [`hiddenpower${hpType}`]
: hpType instanceof Map && hpType.size > 0
? constraintWithUsage(
hiddenPowerMoveKeys,
hpType,
smoothing,
)
: hiddenPowerMoveKeysSet,
moveKeyEncoder,
),
// Ratio of pp to maxpp.
Expand Down
52 changes: 26 additions & 26 deletions src/ts/battle/state/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import "mocha";
import * as Hp from "./Hp.test";
import * as MajorStatusCounter from "./MajorStatusCounter.test";
import * as Move from "./Move.test";
import * as Moveset from "./Moveset.test";
import * as MultiTempStatus from "./MultiTempStatus.test";
import * as Pokemon from "./Pokemon.test";
import * as RoomStatus from "./RoomStatus.test";
import * as StatRange from "./StatRange.test";
import * as StatTable from "./StatTable.test";
import * as Team from "./Team.test";
import * as TeamStatus from "./TeamStatus.test";
import * as TempStatus from "./TempStatus.test";
import * as VolatileStatus from "./VolatileStatus.test";
import * as hp from "./Hp.test";
import * as majorStatusCounter from "./MajorStatusCounter.test";
import * as move from "./Move.test";
import * as moveset from "./Moveset.test";
import * as multiTempStatus from "./MultiTempStatus.test";
import * as pokemon from "./Pokemon.test";
import * as roomStatus from "./RoomStatus.test";
import * as statRange from "./StatRange.test";
import * as statTable from "./StatTable.test";
import * as team from "./Team.test";
import * as teamStatus from "./TeamStatus.test";
import * as tempStatus from "./TempStatus.test";
import * as volatileStatus from "./VolatileStatus.test";
import * as encoder from "./encoder/index.test";
import * as utility from "./utility.test";

export const test = () =>
describe("state", function () {
Hp.test();
MajorStatusCounter.test();
Move.test();
Moveset.test();
MultiTempStatus.test();
Pokemon.test();
RoomStatus.test();
StatRange.test();
StatTable.test();
Team.test();
TeamStatus.test();
TempStatus.test();
VolatileStatus.test();
hp.test();
majorStatusCounter.test();
move.test();
moveset.test();
multiTempStatus.test();
pokemon.test();
roomStatus.test();
statRange.test();
statTable.test();
team.test();
teamStatus.test();
tempStatus.test();
volatileStatus.test();
utility.test();
encoder.test();
});

0 comments on commit bee7d08

Please sign in to comment.