@@ -22,6 +22,8 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
2222 this .explosion = false ,
2323 this .compoundedFinal = false ,
2424 this .compounded = false ,
25+ this .penetrated = false ,
26+ this .penetrator = false ,
2527 this .reroll = false ,
2628 this .rerolled = false ,
2729 this .clampCeiling = false ,
@@ -65,21 +67,23 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
6567
6668 factory RolledDie .singleVal ({
6769 required int result,
68- Iterable <RolledDie >? from,
70+ bool discarded = false ,
71+ bool penetrator = false ,
72+ Iterable <RolledDie >? from = const IList .empty (),
6973 }) => RolledDie (
7074 result: result,
7175 nsides: 1 ,
76+ discarded: discarded,
77+ penetrator: penetrator,
7278 dieType: DieType .singleVal,
7379 potentialValues: [result],
74- from: IList . orNull (from) ?? const IList . empty ( ),
80+ from: IList (from),
7581 );
7682
77- factory RolledDie .d66 ({required int result, Iterable <RolledDie >? from}) =>
78- RolledDie (
79- result: result,
80- dieType: DieType .d66,
81- from: IList .orNull (from) ?? const IList .empty (),
82- );
83+ factory RolledDie .d66 ({
84+ required int result,
85+ Iterable <RolledDie >? from = const IList .empty (),
86+ }) => RolledDie (result: result, dieType: DieType .d66, from: IList (from));
8387
8488 factory RolledDie .copyWith (
8589 RolledDie other, {
@@ -93,6 +97,8 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
9397 bool ? explosion,
9498 bool ? compounded,
9599 bool ? compoundedFinal,
100+ bool ? penetrator,
101+ bool ? penetrated,
96102 bool ? reroll,
97103 bool ? rerolled,
98104 bool ? clampHigh,
@@ -106,6 +112,8 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
106112 discarded: discarded ?? other.discarded,
107113 success: success ?? other.success,
108114 failure: failure ?? other.failure,
115+ penetrated: penetrated ?? other.penetrated,
116+ penetrator: penetrator ?? other.penetrator,
109117 critSuccess: critSuccess ?? other.critSuccess,
110118 critFailure: critFailure ?? other.critFailure,
111119 exploded: exploded ?? other.exploded,
@@ -182,6 +190,12 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
182190 /// true if the die is the sum a multiple die due to compounding
183191 final bool compoundedFinal;
184192
193+ /// true if the die was a discarded result during penetration
194+ final bool penetrator;
195+
196+ /// true if the die was the result of penetration
197+ final bool penetrated;
198+
185199 /// true if the (discarded) result is from a reroll
186200 final bool rerolled;
187201
@@ -194,6 +208,8 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
194208 /// true if the result has been clamped via `C<`
195209 final bool clampFloor;
196210
211+ bool get isMaxResult => result == maxPotentialValue;
212+
197213 @override
198214 List <Object ?> get props => [
199215 result,
@@ -215,6 +231,8 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
215231 rerolled,
216232 clampCeiling,
217233 clampFloor,
234+ penetrated,
235+ penetrator,
218236 ];
219237
220238 Map <String , dynamic > toJson () =>
@@ -236,6 +254,8 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
236254 'rerolled' : rerolled,
237255 'clampHigh' : clampCeiling,
238256 'clampLow' : clampFloor,
257+ 'penetrated' : penetrated,
258+ 'penetrator' : penetrator,
239259 }..removeWhere (
240260 (k, v) =>
241261 v == null ||
@@ -278,11 +298,17 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
278298 if (explosion) {
279299 buffer.write ('🔥' ); //'⇪');
280300 }
301+ if (penetrated) {
302+ buffer.write ('➶' );
303+ }
304+ if (penetrator) {
305+ buffer.write ('⥅' );
306+ }
281307 if (compoundedFinal) {
282308 buffer.write ('∑' );
283309 }
284310 if (compounded) {
285- buffer.write ('+ ' );
311+ buffer.write ('⥅ ' );
286312 }
287313 if (clampCeiling) {
288314 buffer.write ('⌈⌉' );
@@ -316,14 +342,23 @@ class RolledDie extends Equatable implements Comparable<RolledDie> {
316342 return buffer.toString ();
317343 }
318344
319- //TODO: should this compare other fields too?
320345 @override
321346 int compareTo (RolledDie other) => result
322347 .compareTo (other.result)
323348 .if0 (dieType.compareTo (other.dieType))
324- .if0 (
325- dieType == DieType .polyhedral && other.dieType == DieType .polyhedral
326- ? nsides.compareTo (other.nsides)
327- : 0 ,
328- );
349+ .if0 (nsides.compareTo (other.nsides))
350+ .if0 (discarded.compareTo (other.discarded))
351+ .if0 (success.compareTo (other.success))
352+ .if0 (failure.compareTo (other.failure))
353+ .if0 (failure.compareTo (other.failure))
354+ .if0 (critSuccess.compareTo (other.critSuccess))
355+ .if0 (critFailure.compareTo (other.critFailure))
356+ .if0 (exploded.compareTo (other.exploded))
357+ .if0 (explosion.compareTo (other.explosion))
358+ .if0 (compoundedFinal.compareTo (other.compoundedFinal))
359+ .if0 (compounded.compareTo (other.compounded))
360+ .if0 (reroll.compareTo (other.reroll))
361+ .if0 (rerolled.compareTo (other.rerolled))
362+ .if0 (clampCeiling.compareTo (other.clampCeiling))
363+ .if0 (clampFloor.compareTo (other.clampFloor));
329364}
0 commit comments