From b15ccf90c4d683194788b9ba022d0c2c02c7e428 Mon Sep 17 00:00:00 2001 From: bertieb Date: Sat, 20 Feb 2021 15:27:41 +0000 Subject: [PATCH] Add quick-and-dirty FE Emphasis on the dirty, not so much 'quick' ! This shows select outputs from the default Asphodice class: - rerolls - outcome balance - outcomes This information is presented in a Bootstrap card: https://getbootstrap.com/docs/5.0/components/card/ --- src/html/index.html | 2 +- src/ts/frontend.ts | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/html/index.html b/src/html/index.html index fd9db1f..e684836 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -20,7 +20,7 @@
Roll - + times
diff --git a/src/ts/frontend.ts b/src/ts/frontend.ts index a4b34c2..23a0513 100644 --- a/src/ts/frontend.ts +++ b/src/ts/frontend.ts @@ -8,20 +8,31 @@ function getResults():void { $("#results").empty(); rollstats.doRolls(); $("#results").append(`
`); - $("#results").append(`
`); - $("#results").append(`

- Rerolled: ${rollstats.rerollCounts.true}
- Not rerolled: ${rollstats.rerollCounts.false} -

`); - $("#results").append(` + let resultsCard = $("#results").find("div.card"); + resultsCard.append(`
`); + let resultsCardBody = $("#results").find("div.card-body"); + resultsCardBody.append(`

Asphodice Results

`); + resultsCardBody.append(`

Rerolls

`); + resultsCardBody.append(`
+
Rerolled: ${rollstats.rerollCounts.true} (${(rollstats.rerollCounts.true / rollstats.numRolls * 100).toFixed(2)} %)
+
Not rerolled: ${rollstats.rerollCounts.false} (${(rollstats.rerollCounts.false / rollstats.numRolls * 100).toFixed(2)} %)
+
`); + + resultsCardBody.append(`

Outcome Balances

`); + resultsCardBody.append(`
Balance Count Percentage
`); - // + + resultsCardBody.append(`

Outcomes

`); + resultsCardBody.append(` + + +
Outcome Count Percentage
`); + let bc = rollstats.balanceCounts; let keys = Object.keys(bc); keys.sort(function(a: string, b: string){return Number(a) - Number(b)}); - //for (let balance in rollstats.balanceCounts) { for (var i = 0; i < keys.length; i++) { let tb = $("#balanceTable").find("tbody"); tb.append(` ${keys[i]} @@ -29,8 +40,19 @@ function getResults():void { ${(rollstats.balanceCounts[keys[i]] / rollstats.numRolls * 100).toFixed(2)} `); } - $("#results").append(`
`); - $("#results").append(`
`); + + let oc = rollstats.outcomeCounts; + let okeys = Object.keys(oc); + for (var i = 0; i < okeys.length; i++) { + let tb = $("#outcomeTable").find("tbody"); + let outcome: Outcomes = okeys[i]; + let outcomeCount = rollstats.outcomeCounts[outcome]; + let outcomePercent = (outcomeCount / rollstats.numRolls * 100).toFixed(2); + tb.append(` ${outcome} + ${outcomeCount} + ${outcomePercent} + `); + } }