-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
188 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { roll as baseRoll } from '~src/roll' | ||
import { RollResult } from './types' | ||
|
||
function judgeResult(sortedRolls: number[]): RollResult { | ||
const sixes = sortedRolls.filter((r) => r === 6).length | ||
if (sixes >= 2) { | ||
return RollResult.CRITICAL | ||
} | ||
|
||
switch (sortedRolls[0]) { | ||
case 6: | ||
return RollResult.SUCCESS | ||
case 5: | ||
case 4: | ||
return RollResult.PARTIAL | ||
default: | ||
return RollResult.FAILURE | ||
} | ||
} | ||
|
||
function roll(count: number): [RollResult, number[]] { | ||
const rollResult = baseRoll({ | ||
sides: 6, | ||
quantity: count | ||
}) | ||
const rolls = rollResult.rawResult.flat().sort((a, b) => a - b) | ||
|
||
return [judgeResult(rolls), rolls] | ||
} | ||
|
||
import * as types from './types' | ||
|
||
export default { roll, judgeResult, ...types } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export enum RollMods5E { | ||
export enum RollMods { | ||
Advantage = 'advantage', | ||
Disadvantage = 'disadvantage' | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { RollTables } from './tables' | ||
import { CoreMechanic, Entry, Table } from './types' | ||
import { roll as baseRoll } from '~src/roll' | ||
|
||
function interpretRelt(relt: number): CoreMechanic { | ||
switch (true) { | ||
case relt === 20: | ||
return CoreMechanic.nailedIt | ||
case relt >= 11 && relt <= 19: | ||
return CoreMechanic.ccess | ||
case relt >= 6 && relt <= 10: | ||
return CoreMechanic.toughChoice | ||
case relt >= 2 && relt <= 5: | ||
return CoreMechanic.failure | ||
default: | ||
return CoreMechanic.cascadeFailure | ||
} | ||
} | ||
|
||
function roll(tableKey: Table = Table.coreMechanic): [Entry, number] { | ||
const { total } = baseRoll(20) | ||
return [RollTables[tableKey][interpretRelt(total)], total] | ||
} | ||
|
||
import * as types from './types' | ||
import * as tables from './tables' | ||
|
||
export default { interpretRelt, roll, ...tables, ...types } |
Oops, something went wrong.