1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00
tobspr_shapez.io/src/ts/core/explained_result.ts

33 lines
914 B
TypeScript
Raw Normal View History

2022-11-18 01:33:12 +00:00
export class ExplainedResult {
public result: boolean = result;
public reason: string = reason;
constructor(result = true, reason = null, additionalProps = {}) {
// Copy additional props
for (const key: any in additionalProps) {
this[key] = additionalProps[key];
}
}
isGood(): any {
return !!this.result;
}
isBad(): any {
return !this.result;
}
static good(): any {
return new ExplainedResult(true);
}
static bad(reason: any, additionalProps: any): any {
return new ExplainedResult(false, reason, additionalProps);
}
static requireAll(...args: any): any {
for (let i: any = 0; i < args.length; ++i) {
const subResult: any = args[i].call();
if (!subResult.isGood()) {
return subResult;
}
}
return this.good();
}
}