organize artigen's types
This commit is contained in:
parent
c9aff85452
commit
69f95bf701
|
@ -0,0 +1,23 @@
|
||||||
|
import { CountDetails } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
|
// ReturnData is the temporary internal type used before getting turned into SolvedRoll
|
||||||
|
export interface ReturnData {
|
||||||
|
rollTotal: number;
|
||||||
|
rollPreFormat: string;
|
||||||
|
rollPostFormat: string;
|
||||||
|
rollDetails: string;
|
||||||
|
containsCrit: boolean;
|
||||||
|
containsFail: boolean;
|
||||||
|
initConfig: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SolvedRoll is the complete solved and formatted roll, or the error said roll created
|
||||||
|
export interface SolvedRoll {
|
||||||
|
error: boolean;
|
||||||
|
errorMsg: string;
|
||||||
|
errorCode: string;
|
||||||
|
line1: string;
|
||||||
|
line2: string;
|
||||||
|
line3: string;
|
||||||
|
counts: CountDetails;
|
||||||
|
}
|
|
@ -2,9 +2,9 @@ import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import config from '~config';
|
import config from '~config';
|
||||||
|
|
||||||
import { CountDetails, ReturnData } from 'artigen/solver.d.ts';
|
import { ReturnData } from 'artigen/artigen.d.ts';
|
||||||
|
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
import { CountDetails, RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
import { tokenizeMath } from 'artigen/math/mathTokenizer.ts';
|
import { tokenizeMath } from 'artigen/math/mathTokenizer.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,38 @@
|
||||||
|
import { SolvedStep } from 'artigen/math/math.d.ts';
|
||||||
|
|
||||||
|
// Available Roll Types
|
||||||
|
export type RollType = '' | 'roll20' | 'fate' | 'cwod' | 'ova';
|
||||||
|
|
||||||
|
// RollSet is used to preserve all information about a calculated roll
|
||||||
|
export interface RollSet {
|
||||||
|
type: RollType;
|
||||||
|
origIdx: number;
|
||||||
|
roll: number;
|
||||||
|
dropped: boolean;
|
||||||
|
rerolled: boolean;
|
||||||
|
exploding: boolean;
|
||||||
|
critHit: boolean;
|
||||||
|
critFail: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountDetails is the object holding the count data for creating the Count Embed
|
||||||
|
export interface CountDetails {
|
||||||
|
total: number;
|
||||||
|
successful: number;
|
||||||
|
failed: number;
|
||||||
|
rerolled: number;
|
||||||
|
dropped: number;
|
||||||
|
exploded: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollFormat is the return structure for the rollFormatter
|
||||||
|
export interface RollFormat {
|
||||||
|
solvedStep: SolvedStep;
|
||||||
|
countDetails: CountDetails;
|
||||||
|
}
|
||||||
|
|
||||||
// RollModifiers is the structure to keep track of the decorators applied to a roll command
|
// RollModifiers is the structure to keep track of the decorators applied to a roll command
|
||||||
export type RollModifiers = {
|
export interface RollModifiers {
|
||||||
noDetails: boolean;
|
noDetails: boolean;
|
||||||
superNoDetails: boolean;
|
superNoDetails: boolean;
|
||||||
spoiler: string;
|
spoiler: string;
|
||||||
|
@ -13,4 +46,46 @@ export type RollModifiers = {
|
||||||
commaTotals: boolean;
|
commaTotals: boolean;
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
apiWarn: string;
|
apiWarn: string;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
// Basic conf interfaces
|
||||||
|
interface CountConf {
|
||||||
|
on: boolean;
|
||||||
|
count: number;
|
||||||
|
}
|
||||||
|
interface RangeConf {
|
||||||
|
on: boolean;
|
||||||
|
range: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// D% configuration
|
||||||
|
export interface DPercentConf {
|
||||||
|
on: boolean;
|
||||||
|
sizeAdjustment: number;
|
||||||
|
critVal: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RollConf is used by the roll20 setup
|
||||||
|
export interface RollConf {
|
||||||
|
dieCount: number;
|
||||||
|
dieSize: number;
|
||||||
|
dPercent: DPercentConf;
|
||||||
|
drop: CountConf;
|
||||||
|
keep: CountConf;
|
||||||
|
dropHigh: CountConf;
|
||||||
|
keepLow: CountConf;
|
||||||
|
reroll: {
|
||||||
|
on: boolean;
|
||||||
|
once: boolean;
|
||||||
|
nums: number[];
|
||||||
|
};
|
||||||
|
critScore: RangeConf;
|
||||||
|
critFail: RangeConf;
|
||||||
|
exploding: {
|
||||||
|
on: boolean;
|
||||||
|
once: boolean;
|
||||||
|
compounding: boolean;
|
||||||
|
penetrating: boolean;
|
||||||
|
nums: number[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@ import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import config from '~config';
|
import config from '~config';
|
||||||
|
|
||||||
import { RollConf, RollSet, RollType } from 'artigen/solver.d.ts';
|
import { RollConf, RollModifiers, RollSet, RollType } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
|
||||||
|
|
||||||
import { genFateRoll, genRoll } from 'artigen/utils/generateRoll.ts';
|
import { genFateRoll, genRoll } from 'artigen/utils/generateRoll.ts';
|
||||||
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import { log, LogTypes as LT } from '@Log4Deno';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import { RollFormat } from 'artigen/solver.d.ts';
|
import { RollFormat, RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
|
||||||
import { executeRoll } from 'artigen/dice/executeRoll.ts';
|
import { executeRoll } from 'artigen/dice/executeRoll.ts';
|
||||||
|
|
||||||
import { rollCounter } from 'artigen/utils/counter.ts';
|
import { rollCounter } from 'artigen/utils/counter.ts';
|
||||||
|
|
|
@ -4,14 +4,14 @@ import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import config from '~config';
|
import config from '~config';
|
||||||
import { DEVMODE } from '~flags';
|
import { DEVMODE } from '~flags';
|
||||||
|
|
||||||
import { SolvedRoll } from 'artigen/solver.d.ts';
|
import { SolvedRoll } from 'artigen/artigen.d.ts';
|
||||||
|
|
||||||
import { removeWorker } from 'artigen/managers/countManager.ts';
|
import { removeWorker } from 'artigen/managers/countManager.ts';
|
||||||
import { QueuedRoll } from 'artigen/managers/manager.d.ts';
|
import { QueuedRoll } from 'artigen/managers/manager.d.ts';
|
||||||
|
|
||||||
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
||||||
import dbClient from 'db/client.ts';
|
|
||||||
|
|
||||||
|
import dbClient from 'db/client.ts';
|
||||||
import { queries } from 'db/common.ts';
|
import { queries } from 'db/common.ts';
|
||||||
|
|
||||||
import stdResp from 'endpoints/stdResponses.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { SolvedRoll } from 'artigen/solver.d.ts';
|
import { SolvedRoll } from 'artigen/artigen.d.ts';
|
||||||
|
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
// SolvedStep is used to preserve information while math is being performed on the roll
|
||||||
|
export interface SolvedStep {
|
||||||
|
total: number;
|
||||||
|
details: string;
|
||||||
|
containsCrit: boolean;
|
||||||
|
containsFail: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Joined type for mathConf as its a "WIP" variable and moved everything from string->number->SolvedStep
|
||||||
|
export type MathConf = string | number | SolvedStep;
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import { log, LogTypes as LT } from '@Log4Deno';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import { MathConf, SolvedStep } from 'artigen/solver.d.ts';
|
import { MathConf, SolvedStep } from 'artigen/math/math.d.ts';
|
||||||
|
|
||||||
import { legalMath, legalMathOperators } from 'artigen/utils/legalMath.ts';
|
import { legalMath, legalMathOperators } from 'artigen/utils/legalMath.ts';
|
||||||
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import { log, LogTypes as LT } from '@Log4Deno';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import { CountDetails, MathConf, ReturnData, SolvedStep } from 'artigen/solver.d.ts';
|
import { ReturnData } from 'artigen/artigen.d.ts';
|
||||||
|
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
import { MathConf, SolvedStep } from 'artigen/math/math.d.ts';
|
||||||
|
|
||||||
|
import { CountDetails, RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||||
import { generateFormattedRoll } from 'artigen/dice/generateFormattedRoll.ts';
|
import { generateFormattedRoll } from 'artigen/dice/generateFormattedRoll.ts';
|
||||||
|
|
||||||
import { mathSolver } from 'artigen/math/mathSolver.ts';
|
import { mathSolver } from 'artigen/math/mathSolver.ts';
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { log, LogTypes as LT } from '@Log4Deno';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
|
import { SolvedRoll } from 'artigen/artigen.d.ts';
|
||||||
import { tokenizeCmd } from 'artigen/cmdTokenizer.ts';
|
import { tokenizeCmd } from 'artigen/cmdTokenizer.ts';
|
||||||
import { SolvedRoll } from 'artigen/solver.d.ts';
|
|
||||||
|
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
import { cmdSplitRegex, escapeCharacters } from 'artigen/utils/escape.ts';
|
import { cmdSplitRegex, escapeCharacters } from 'artigen/utils/escape.ts';
|
||||||
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
||||||
import { assertPrePostBalance } from 'src/artigen/utils/parenBalance.ts';
|
import { assertPrePostBalance } from 'artigen/utils/parenBalance.ts';
|
||||||
import { compareTotalRolls, compareTotalRollsReverse } from 'artigen/utils/sortFuncs.ts';
|
import { compareTotalRolls, compareTotalRollsReverse } from 'artigen/utils/sortFuncs.ts';
|
||||||
import { translateError } from 'artigen/utils/translateError.ts';
|
import { translateError } from 'artigen/utils/translateError.ts';
|
||||||
|
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
// Available Roll Types
|
|
||||||
export type RollType = '' | 'roll20' | 'fate' | 'cwod' | 'ova';
|
|
||||||
|
|
||||||
export type MathConf = string | number | SolvedStep;
|
|
||||||
|
|
||||||
// RollSet is used to preserve all information about a calculated roll
|
|
||||||
export type RollSet = {
|
|
||||||
type: RollType;
|
|
||||||
origIdx: number;
|
|
||||||
roll: number;
|
|
||||||
dropped: boolean;
|
|
||||||
rerolled: boolean;
|
|
||||||
exploding: boolean;
|
|
||||||
critHit: boolean;
|
|
||||||
critFail: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
// SolvedStep is used to preserve information while math is being performed on the roll
|
|
||||||
export type SolvedStep = {
|
|
||||||
total: number;
|
|
||||||
details: string;
|
|
||||||
containsCrit: boolean;
|
|
||||||
containsFail: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ReturnData is the temporary internal type used before getting turned into SolvedRoll
|
|
||||||
export type ReturnData = {
|
|
||||||
rollTotal: number;
|
|
||||||
rollPreFormat: string;
|
|
||||||
rollPostFormat: string;
|
|
||||||
rollDetails: string;
|
|
||||||
containsCrit: boolean;
|
|
||||||
containsFail: boolean;
|
|
||||||
initConfig: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
// CountDetails is the object holding the count data for creating the Count Embed
|
|
||||||
export type CountDetails = {
|
|
||||||
total: number;
|
|
||||||
successful: number;
|
|
||||||
failed: number;
|
|
||||||
rerolled: number;
|
|
||||||
dropped: number;
|
|
||||||
exploded: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
// RollFormat is the return structure for the rollFormatter
|
|
||||||
export type RollFormat = {
|
|
||||||
solvedStep: SolvedStep;
|
|
||||||
countDetails: CountDetails;
|
|
||||||
};
|
|
||||||
|
|
||||||
// SolvedRoll is the complete solved and formatted roll, or the error said roll created
|
|
||||||
export type SolvedRoll = {
|
|
||||||
error: boolean;
|
|
||||||
errorMsg: string;
|
|
||||||
errorCode: string;
|
|
||||||
line1: string;
|
|
||||||
line2: string;
|
|
||||||
line3: string;
|
|
||||||
counts: CountDetails;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DPercentConf = {
|
|
||||||
on: boolean;
|
|
||||||
sizeAdjustment: number;
|
|
||||||
critVal: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
// RollConf is used by the roll20 setup
|
|
||||||
export type RollConf = {
|
|
||||||
dieCount: number;
|
|
||||||
dieSize: number;
|
|
||||||
dPercent: DPercentConf;
|
|
||||||
drop: {
|
|
||||||
on: boolean;
|
|
||||||
count: number;
|
|
||||||
};
|
|
||||||
keep: {
|
|
||||||
on: boolean;
|
|
||||||
count: number;
|
|
||||||
};
|
|
||||||
dropHigh: {
|
|
||||||
on: boolean;
|
|
||||||
count: number;
|
|
||||||
};
|
|
||||||
keepLow: {
|
|
||||||
on: boolean;
|
|
||||||
count: number;
|
|
||||||
};
|
|
||||||
reroll: {
|
|
||||||
on: boolean;
|
|
||||||
once: boolean;
|
|
||||||
nums: number[];
|
|
||||||
};
|
|
||||||
critScore: {
|
|
||||||
on: boolean;
|
|
||||||
range: number[];
|
|
||||||
};
|
|
||||||
critFail: {
|
|
||||||
on: boolean;
|
|
||||||
range: number[];
|
|
||||||
};
|
|
||||||
exploding: {
|
|
||||||
on: boolean;
|
|
||||||
once: boolean;
|
|
||||||
compounding: boolean;
|
|
||||||
penetrating: boolean;
|
|
||||||
nums: number[];
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { CountDetails, RollSet } from 'artigen/solver.d.ts';
|
import { CountDetails, RollSet } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
||||||
const countDetails = {
|
const countDetails = {
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
import { DPercentConf, RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
import { DPercentConf } from 'artigen/solver.d.ts';
|
|
||||||
|
|
||||||
// genRoll(size) returns number
|
// genRoll(size) returns number
|
||||||
// genRoll rolls a die of size size and returns the result
|
// genRoll rolls a die of size size and returns the result
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import config from '~config';
|
import config from '~config';
|
||||||
|
|
||||||
import { MathConf } from 'artigen/solver.d.ts';
|
import { MathConf } from 'artigen/math/math.d.ts';
|
||||||
|
|
||||||
import { closeInternal, openInternal } from 'artigen/utils/escape.ts';
|
import { closeInternal, openInternal } from 'artigen/utils/escape.ts';
|
||||||
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { ReturnData, RollSet } from 'src/artigen/solver.d.ts';
|
import { ReturnData } from 'artigen/artigen.d.ts';
|
||||||
|
|
||||||
|
import { RollSet } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
// compareRolls(a, b) returns -1|0|1
|
// compareRolls(a, b) returns -1|0|1
|
||||||
// compareRolls is used to order an array of RollSets by RollSet.roll
|
// compareRolls is used to order an array of RollSets by RollSet.roll
|
||||||
|
|
|
@ -2,9 +2,9 @@ import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import config from '~config';
|
import config from '~config';
|
||||||
|
|
||||||
import { RollModifiers } from 'artigen/dice/dice.d.ts';
|
import { SolvedRoll } from 'artigen/artigen.d.ts';
|
||||||
|
|
||||||
import { CountDetails, SolvedRoll } from 'artigen/solver.d.ts';
|
import { CountDetails, RollModifiers } from 'artigen/dice/dice.d.ts';
|
||||||
|
|
||||||
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
import { loggingEnabled } from 'artigen/utils/logFlag.ts';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue