Skip to content

Commit fa017be

Browse files
committed
add: --target flag for ap-calc + rewrite README for ap-calc
1 parent 3526cfb commit fa017be

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ Script that lists event welfare Servants that have not yet been released on the
3939
### AP Calc
4040

4141
```
42-
pnpm ap-calc [-m,--max <num>] [-n,--node <num>] <current-ap> [<current-timer>]
42+
pnpm ap-calc [-m,--max <num>] [-n,--node <num>] [-t,--target <num>] <current-ap> [<current-timer>]
4343
```
4444

45-
Simple AP Calculator that calculates time to Max AP and, if given a node cost via `-n` (or `--node`) time until each possible run can be done. Output is given as a table with time (24h notation) and delta until that point. Max AP is assumed to be `144`, but can be overriden with `-m` (or `--max`). Values for current ap and time until next AP are positional, with current timer being optional.
45+
Simple AP Calculator that calculates time to Max AP and targets based on node cost or target AP. Output is given as a table with time (24h notation) and delta until that point.
46+
47+
- `-m`,`--max`: Override for Max AP (Default: `144`)
48+
- `-n`,`--node`: Node Cost (shows all possible future runs; optional)
49+
- `-t`,`--target`: Sets target AP (optional)
50+
- Positional: Values for current ap (num; required) and time until next AP (either as `M:SS` or `MSS`; optional)
4651

4752
## Cache
4853

src/ap-calc/script.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const args = parseArgs({
88
options: {
99
verbose: { type: "boolean", short: "v", default: false },
1010
max: { type: "string", short: "m", default: "144" },
11+
target: { type: "string", short: "t" },
1112
node: { type: "string", short: "n" }
1213
},
1314
allowPositionals: true
@@ -37,6 +38,8 @@ async function main() {
3738
// parse args
3839
let apMax = parseInt(args.values.max);
3940
let nodeCost = args.values.node ? parseInt(args.values.node) : undefined;
41+
let targetAP = args.values.target ? parseInt(args.values.target) : undefined;
42+
4043
if (isNaN(apMax) || apMax < 20) {
4144
log.error(
4245
`Could not parse argument for --max '${args.values.max}'. Argument must integer >= 20`
@@ -50,6 +53,12 @@ async function main() {
5053
);
5154
nodeCost = undefined;
5255
}
56+
if (typeof targetAP == "number" && (isNaN(targetAP) || targetAP < 1)) {
57+
log.error(
58+
`Could not parse argument for --target '${args.values.target}'. Argument must be integer > 0`
59+
);
60+
targetAP = undefined;
61+
}
5362

5463
// parse positionals
5564
const apCurr = parseInt(args.positionals[0] || "");
@@ -88,6 +97,17 @@ async function main() {
8897
}
8998
}
9099

100+
if (targetAP) {
101+
const deltaTargetAP = targetAP - apCurr;
102+
const deltaTargetSeconds = (deltaTargetAP - 1) * 300 + timerSeconds;
103+
table.push(
104+
Object.assign(
105+
{ ap: targetAP, title: "Target" },
106+
timeDiffer(deltaTargetSeconds)
107+
)
108+
);
109+
}
110+
91111
// handle max AP
92112
const deltaMaxAP = apMax - apCurr;
93113
const deltaMaxSeconds = (deltaMaxAP - 1) * 300 + timerSeconds;
@@ -99,6 +119,7 @@ async function main() {
99119
console.table(
100120
table
101121
.filter(run => run.ap >= apCurr)
122+
.sort((a, b) => a.ap - b.ap)
102123
.reduce(
103124
(obj, { title, ...row }) => {
104125
obj[title] = row;

0 commit comments

Comments
 (0)