|
@@ -44,6 +44,15 @@ interface DiceResult { |
|
|
balance?: number; |
|
|
balance?: number; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface ItemCount { |
|
|
|
|
|
item: string | number | Outcomes; |
|
|
|
|
|
count: number; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
declare let ItemCountSet: Array<ItemCount>; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Simple d10, implements `roll()` |
|
|
* Simple d10, implements `roll()` |
|
|
*/ |
|
|
*/ |
|
@@ -220,6 +229,26 @@ class Asphodice extends D10 { |
|
|
// PS also good practice to supply initialValue (0) |
|
|
// PS also good practice to supply initialValue (0) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Determine and return outcome of roll |
|
|
|
|
|
* |
|
|
|
|
|
* @remarks |
|
|
|
|
|
* |
|
|
|
|
|
* Determines outcome as in "Success", "Failure", etc. Assumes that `resultDice` is |
|
|
|
|
|
* the 'final' result after any rerolls. |
|
|
|
|
|
* |
|
|
|
|
|
* @see {@link:countOutcomeBalance} |
|
|
|
|
|
*/ |
|
|
|
|
|
checkOutcome (resultDice: Array<number>): Outcomes{ |
|
|
|
|
|
// Note: currently, one success = Success, regardless of number of failures |
|
|
|
|
|
// TODO: Critical failures, once decided with Mao |
|
|
|
|
|
if (this.allBelowCutOff(resultDice)) { |
|
|
|
|
|
return Outcomes.Fail; |
|
|
|
|
|
} else { |
|
|
|
|
|
return Outcomes.Success; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Roll an Asphodie or Asphodice |
|
|
* Roll an Asphodie or Asphodice |
|
|
* |
|
|
* |
|
@@ -283,6 +312,10 @@ class Asphodice extends D10 { |
|
|
|
|
|
|
|
|
results.balance = this.countOutcomeBalance(results.dice); |
|
|
results.balance = this.countOutcomeBalance(results.dice); |
|
|
results.total = results.dice.reduce((acc: number, curr: number) => acc + curr); |
|
|
results.total = results.dice.reduce((acc: number, curr: number) => acc + curr); |
|
|
|
|
|
|
|
|
|
|
|
// Finally, once we're done with rerolls etc, determine outcome |
|
|
|
|
|
results.outcome = this.checkOutcome(results.dice); |
|
|
|
|
|
|
|
|
return results; |
|
|
return results; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|