|
|
@@ -12,6 +12,11 @@ declare let ItemCountSet: Array<ItemCount>; |
|
|
|
type EnumObject<T extends string> = { [K in T]?: number }; |
|
|
|
type outcomeCountObject = EnumObject<Outcomes>; |
|
|
|
|
|
|
|
interface RollStatsSetup { |
|
|
|
numDice?: number, |
|
|
|
diceOptions?: object |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Singleton-type class for all dice-statistic related needs |
|
|
|
*/ |
|
|
@@ -21,15 +26,21 @@ export class RollStats { |
|
|
|
balanceCounts: { [balance: string]: number } = {}; |
|
|
|
outcomeCounts: outcomeCountObject = {}; |
|
|
|
diceCounts: { [dice: string]: number} = {}; |
|
|
|
diceOptions = {}; |
|
|
|
|
|
|
|
numRolls = 100000; |
|
|
|
maxDice = 10; |
|
|
|
numDice = 4; |
|
|
|
|
|
|
|
constructor(numDice?:number) { |
|
|
|
constructor(rsSetup?: RollStatsSetup) { |
|
|
|
this.resetCounts(); |
|
|
|
if (numDice) { |
|
|
|
this.numDice = numDice; |
|
|
|
if (rsSetup) { |
|
|
|
if (rsSetup.numDice) { |
|
|
|
this.numDice = rsSetup.numDice; |
|
|
|
} |
|
|
|
if (rsSetup.diceOptions) { |
|
|
|
this.diceOptions = rsSetup.diceOptions; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -46,7 +57,7 @@ export class RollStats { |
|
|
|
} |
|
|
|
|
|
|
|
doRolls(): void { |
|
|
|
let asphodice = new Asphodice(); |
|
|
|
let asphodice = new Asphodice(this.diceOptions); |
|
|
|
// count rerolls, totals and outcome balances |
|
|
|
|
|
|
|
for (let i = 0; i < this.numRolls; i++) { |
|
|
|