Implement swapping edge case, restructure sources.
This commit is contained in:
parent
3f6f9f795f
commit
55beeb92c9
5 changed files with 173 additions and 76 deletions
24
spec/support/ds4rolls/utils.spec.ts
Normal file
24
spec/support/ds4rolls/utils.spec.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import "jasmine";
|
||||
import { isDiceSwapNecessary } from "../../../src/module/rolls/roll-utils";
|
||||
|
||||
describe("Utility function testing if dice swap is necessery", () => {
|
||||
it("Should not swap if all dice are crit successes.", () => {
|
||||
expect(isDiceSwapNecessary([1, 1, 1], [], 9)).toBeFalse();
|
||||
});
|
||||
|
||||
it("Should not swap if no die is crit success.", () => {
|
||||
expect(isDiceSwapNecessary([], [2, 2, 2], 9)).toBeFalse();
|
||||
});
|
||||
|
||||
it("Should not swap if all dice are already in use", () => {
|
||||
expect(isDiceSwapNecessary([1], [9, 8], 10)).toBeFalse();
|
||||
});
|
||||
|
||||
it("Should not swap if result does not get any better", () => {
|
||||
expect(isDiceSwapNecessary([1], [8], 4)).toBeFalse();
|
||||
});
|
||||
|
||||
it("Should swap if result does get better", () => {
|
||||
expect(isDiceSwapNecessary([1], [19], 18)).toBeTrue();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue