refactor: yarn runner man

This commit is contained in:
2026-03-03 15:09:25 +08:00
parent 8d5b15ad51
commit e13ead2309
5 changed files with 46 additions and 30 deletions
+15 -12
View File
@@ -38,7 +38,7 @@ export function getTtrpgFunctions(runner: IRunner){
}
/* stat related */
function ensure_stat(stat: string){
if(!runner.getVariable(stat)){
if(runner.getVariable(stat) === undefined){
const statBase = `${stat}_base`;
const statMod = `${stat}_mod`;
const statDamage = `${stat}_damage`;
@@ -74,6 +74,7 @@ export function getTtrpgFunctions(runner: IRunner){
const progress = runner.getVariable(key) as number || 0;
const newProgress = progress + Math.ceil(Math.random() * 4);
runner.setVariable(key, newProgress);
console.log(`check ${stat}(${statVal}) ${pass ? 'pass' : 'fail'}, now ${newProgress}`);
return pass ? newProgress : -newProgress;
}
function rollStat(){
@@ -94,15 +95,17 @@ export function getTtrpgFunctions(runner: IRunner){
heal(stat, 1);
}
return {
add_minutes: add_minute,
add_hours: add_hour,
add_days: add_day,
damage,
heal,
check,
fatigue,
regen,
};
commands: {
add_minute,
add_hour,
add_day,
damage,
heal,
fatigue,
regen
} as Record<string, (...args: any[]) =>any>,
functions: {
check
} as Record<string, (...args: any[]) =>any>
}
}