From 24ad72c029b4b0b5b7cff81792e2ad51a748c9d8 Mon Sep 17 00:00:00 2001 From: dan63047 Date: Fri, 27 Sep 2024 01:14:45 +0300 Subject: [PATCH] I guess i made it worse --- lib/views/main_view_tiles.dart | 94 +++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 36 deletions(-) diff --git a/lib/views/main_view_tiles.dart b/lib/views/main_view_tiles.dart index c82599b..a3658b3 100644 --- a/lib/views/main_view_tiles.dart +++ b/lib/views/main_view_tiles.dart @@ -229,26 +229,33 @@ enum CalcCards{ damage } -// class Damage{ -// final int clear; -// final int combo; -// final int b2b; -// final int surge; -// final int pc; +class Damage{ + final int clear; + final double combo; + final double b2b; + final int surge; + final int pc; + final double multiplier; + int get total => ((clear + combo + b2b + surge + pc) * multiplier).floor(); + const Damage(this.clear, this.combo, this.b2b, this.surge, this.pc, this.multiplier); -// const Damage(this.clear, this.combo, this.b2b, this.surge, this.pc); + @override + String toString(){ + return total.toString(); + } -// Damage operator+(Damage other){ -// return Damage( -// clear+other.clear, -// combo+other.combo, -// b2b+other.b2b, -// surge+other.b2b, -// pc+other.pc); -// } -// } + Damage operator+(Damage other){ + return Damage( + clear+other.clear, + combo+other.combo, + b2b+other.b2b, + surge+other.surge, + pc+other.pc, + multiplier); + } +} class ClearData{ final String title; @@ -276,18 +283,18 @@ class ClearData{ perfectClear = !perfectClear; } - int dealsDamage(int combo, int b2b, Rules rules){ - if (lines == 0) return 0; - double damage = 0; + Damage dealsDamage(int combo, int b2b, Rules rules){ + if (lines == 0) return Damage(0,0,0,0,0,rules.multiplier); + int clearDamage = 0; if (spin){ - if (lines <= 5) damage += garbage[lineclear]!; - else damage += garbage[Lineclears.TSPIN_PENTA]! + 2 * (lines - 5); + if (lines <= 5) clearDamage += garbage[lineclear]!; + else clearDamage += garbage[Lineclears.TSPIN_PENTA]! + 2 * (lines - 5); } else if (miniSpin){ - damage += garbage[lineclear]!; + clearDamage += garbage[lineclear]!; } else { - if (lines <= 5) damage += garbage[lineclear]!; - else damage += garbage[Lineclears.PENTA]! + (lines - 5); + if (lines <= 5) clearDamage += garbage[lineclear]!; + else clearDamage += garbage[Lineclears.PENTA]! + (lines - 5); } // Ok i can't figure out how b2b and combo works @@ -296,9 +303,17 @@ class ClearData{ // const n = e.cm.constants.garbage.BACKTOBACK_BONUS * (Math.floor(1 + Math.log1p((t.stats.btb - 1) * e.cm.constants.garbage.BACKTOBACK_BONUS_LOG)) + (t.stats.btb - 1 == 1 ? 0 : (1 + Math.log1p((t.stats.btb - 1) * e.cm.constants.garbage.BACKTOBACK_BONUS_LOG) % 1) / 3)); // if (h && (d += n), + double b2bDamage = 0; + if (difficultClear && b2b >= 1 && rules.b2b){ - if (rules.b2bChaining) damage += BACKTOBACK_BONUS * ((1 + log((b2b+1) * BACKTOBACK_BONUS_LOG)).floor() + (b2b+1 == 1 ? 0 : (1 + log((b2b+1) * BACKTOBACK_BONUS_LOG) % 1) / 3)); // but it should be b2b-1 ??? - else damage += 1; // if b2b chaining off + if (rules.b2bChaining) b2bDamage += BACKTOBACK_BONUS * ((1 + log((b2b+1) * BACKTOBACK_BONUS_LOG)).floor() + (b2b+1 == 1 ? 0 : (1 + log((b2b+1) * BACKTOBACK_BONUS_LOG) % 1) / 3)); // but it should be b2b-1 ??? + else b2bDamage += 1; // if b2b chaining off + } + + int surgeDamage = 0; + + if (!difficultClear && rules.surge){ + } // From tetrio.js: @@ -312,19 +327,23 @@ class ClearData{ // d += n[Math.max(0, Math.min(t.stats.combo - 2, n.length - 1))] // } + double comboDamage = 0; + if (rules.combo) { - if (combo >= 1){ - if (lines == 1) damage += combotable[rules.comboTable]![max(0, min(combo - 1, combotable[rules.comboTable]!.length - 1))]; - else damage *= 1 + COMBO_BONUS * (combo - 1); + if (combo > 1){ + if (lines == 1 && rules.comboTable != ComboTables.multiplier) comboDamage += combotable[rules.comboTable]![max(0, min(combo - 1, combotable[rules.comboTable]!.length - 1))]; + else comboDamage = (clearDamage + b2bDamage) * (1 + COMBO_BONUS * (combo-1)); } if (combo > 2) { - damage = max(log(COMBO_MINIFIER * (combo - 1) * COMBO_MINIFIER_LOG), damage); + comboDamage = max(log(COMBO_MINIFIER * (combo-1) * COMBO_MINIFIER_LOG), comboDamage); } } - if (perfectClear) damage += rules.pcDamage; + int pcDamage = 0; - return (damage * rules.multiplier).floor(); + if (perfectClear) pcDamage += rules.pcDamage; + + return Damage(clearDamage, comboDamage, b2bDamage, surgeDamage, pcDamage, rules.multiplier); } } @@ -534,12 +553,13 @@ class _DestinationCalculatorState extends State { int combo = -1; int b2b = -1; - int totalDamage = 0; + Damage totalDamage = Damage(0,0,0,0,0,rules.multiplier); + int totalDamageNumber = 0; for (ClearData lineclear in clears){ if (lineclear.difficultClear) b2b++; else if (lineclear.lines > 0) b2b = -1; if (lineclear.lines > 0) combo++; else combo = -1; - int dmg = lineclear.dealsDamage(combo, b2b, rules); + Damage dmg = lineclear.dealsDamage(combo, b2b, rules); lSideWidgets.add( ListTile( key: ValueKey(lineclear.id), @@ -551,7 +571,7 @@ class _DestinationCalculatorState extends State { ], ), title: Text("${lineclear.title}${lineclear.perfectClear ? " PC" : ""}${combo > 0 ? ", ${combo} combo" : ""}${b2b > 0 ? ", B2Bx${b2b}" : ""}"), - subtitle: lineclear.lines > 0 ? Text("${dmg} damage${lineclear.difficultClear ? ", difficult" : ""}", style: TextStyle(color: Colors.grey)) : null, + subtitle: lineclear.lines > 0 ? Text("${dmg.clear} from clear, ${dmg.combo} from combo, ${dmg.b2b} from B2B, ${dmg.surge} from Surge and ${dmg.pc} from PC", style: TextStyle(color: Colors.grey)) : null, trailing: lineclear.lines > 0 ? Padding( padding: const EdgeInsets.only(right: 10.0), child: Text(dmg.toString(), style: TextStyle(fontSize: 36, fontWeight: ui.FontWeight.w100)), @@ -559,6 +579,7 @@ class _DestinationCalculatorState extends State { ) ); totalDamage += dmg; + totalDamageNumber += dmg.total; } return Column( @@ -705,10 +726,11 @@ class _DestinationCalculatorState extends State { children: [ Text("Total damage:", style: TextStyle(fontSize: 36, fontWeight: ui.FontWeight.w100)), Spacer(), - Text(totalDamage.floor().toString(), style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 36, fontWeight: ui.FontWeight.w100)) + Text(totalDamageNumber.toString(), style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 36, fontWeight: ui.FontWeight.w100)) ], ), ), + Text(totalDamage.toString(), style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: 36, fontWeight: ui.FontWeight.w100)), ElevatedButton.icon(onPressed: (){setState((){clears.clear();});}, icon: const Icon(Icons.clear), label: Text("Clear all"), style: const ButtonStyle(shape: WidgetStatePropertyAll(RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12.0)))))) ], )