Compare commits

...

3 Commits

Author SHA1 Message Date
d9d8151c74 add more future work for s4? 2023-05-21 22:20:11 +10:00
5f5603fff7 fix parsing of Thunder / Thunder Punch 2023-04-27 12:34:48 +10:00
ce70a9fb4d capture stderr on good calculations 2023-04-27 12:30:48 +10:00
3 changed files with 24 additions and 2 deletions

View File

@ -43,3 +43,13 @@ whatever SQL queries against the data file (default `data.db`) you want.
- calculate gametime based on active turns rather than moves used
- also solves the issue where paralyzed/confused turns are not counted
- use asyncio in bot
- allow for entering unplayed forfeits
- easy correction of game drift (e.g., two games played for a single team in a week)
- collect stats on teras and megas
- inline common queries into the base database as views
- channel filtering for replay collection
- move/damage tracking:
- delayed damage (Future Sight and co)
- self-damage misattribution (Belly Drum, possibly Explosion)
- indirect status (Toxic Spikes)
- weather?

5
bot.py
View File

@ -101,8 +101,11 @@ class BotClient(discord.Client):
proc = sp.run(
["node", "calc_main.js", "--"] + args, stdout=sp.PIPE, stderr=sp.PIPE
)
stderr = proc.stderr.decode().strip()
if proc.returncode != 0:
raise Exception(proc.stderr.decode())
raise Exception(stderr)
if stderr:
_log.warning(f"running calculation '{args}': {stderr}")
return proc.stdout.decode()
def is_replay(self, message: discord.Message) -> bool:

11
calc.js
View File

@ -63,7 +63,10 @@ function buildLexer() {
const Move = createToken({
name: "Move",
pattern: new RegExp(
[...gen.moves].map((m) => escapeRegExp(m.name)).join("|")
[...gen.moves]
.map((m) => escapeRegExp(m.name))
.sort((a, b) => b.length - a.length)
.join("|")
),
});
@ -350,6 +353,12 @@ function test() {
res = parseAndCalculate("Zoroark-Hisui Night Slash vs Golem");
assert(res.attacker.name === "Zoroark-Hisui", "should parse regional forme");
res = parseAndCalculate("Ditto Thunder Punch vs. Avalugg");
assert(
res.move.name === "Thunder Punch",
"should match entire move that is a superset of another move"
);
}
export { parseAndCalculate, test };