tweaks to reporting

This commit is contained in:
dtookey 2023-09-05 09:22:15 -04:00
parent 07f76b2e1d
commit 5c7d72ea86
3 changed files with 9 additions and 6 deletions

View File

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">

View File

@ -59,10 +59,12 @@ fun crunchBarbarian(defense: Int = 16){
val gwmAttack = MeleeAttackBuilder(attackDice, weaponDice, defense)
//attack modifiers
.withAtkBonus(2)// weapon bonus
.withAtkBonus(4)// proficiency bonus
.withAtkBonus(5)// str mod
.withAtkBonus(-5)// gwm penalty
//damage modifiers
.withDmgBonus(2) // weapon bonus
.withDmgBonus(5) // str mod
.withDmgBonus(10) // gwm bonus
@ -125,7 +127,7 @@ fun generateCombatSuggestions(
fun defaultReport(): ReportBuilder{
return ReportBuilder.getInstance()
.addRateMetric("Accuracy") { it.rollSucceeded }
.addRateMetric("Crit Rate") { it.rollSucceeded }
.addRateMetric("Crit Rate") { it.rollWasCritical }
.addStdDevMetric("Dmg std") { it.resultingDamage.toLong() }
.addAverageMetric(avgDamage) { it.resultingDamage.toLong() }
}
@ -134,7 +136,7 @@ fun defaultReport(): ReportBuilder{
fun List<MetricResult>.getDamage(): MetricResult? {
forEach {
if (it.label == avgDamage) {
if (it.name == avgDamage) {
return it
}
}

View File

@ -4,7 +4,7 @@ import simulation.fifthEd.AttackResult
import kotlin.math.pow
data class MetricReport(val name: String, val results: List<MetricResult>)
data class MetricResult(val label: String, val metricValue: Double)
data class MetricResult(val name: String, val label: String, val metricValue: Double)
interface Report {
val name: String
@ -14,7 +14,7 @@ interface Report {
fun formatReport(name: String, results: List<MetricResult>): String {
val builder = StringBuilder()
results.forEach {
builder.append("${it.label}: %.2f".format(it.metricValue))
builder.append(it.label)
.append('\t')
}
@ -27,7 +27,7 @@ interface Report {
val m = ArrayList<MetricResult>(metrics.size)
metrics.forEach {
val value = it.mapToMetric(results)
m.add(MetricResult(it.metricName, value))
m.add(MetricResult(it.metricName, it.formatResults(value), value))
}
return MetricReport(name, m)
}
@ -96,7 +96,7 @@ class RateMetric(override val metricName: String, private val fieldMapFn: (Attac
}
override fun formatResults(result: Double): String {
return "$metricName: %.2f".format(result)
return "$metricName: %.2f".format(result) +"%"
}
}