Get most of the custom Initiative sorting stuff through the door
This commit is contained in:
parent
ed93e9f927
commit
e302b56a4e
10 changed files with 142 additions and 14 deletions
27
module/utils/distanceBetweenFates.mjs
Normal file
27
module/utils/distanceBetweenFates.mjs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { gameTerms } from "../gameTerms.mjs";
|
||||
import { Logger } from "./Logger.mjs";
|
||||
|
||||
const { FatePath } = gameTerms;
|
||||
|
||||
export function isOppositeFates(a, b) {
|
||||
return a === FatePath.NORTH && b === FatePath.SOUTH
|
||||
|| a === FatePath.EAST && FatePath.WEST;
|
||||
};
|
||||
|
||||
export function distanceBetweenFates(start, end) {
|
||||
if (!start || !end) {
|
||||
Logger.error(`Start and End must both have a defined value, given`, {start, end});
|
||||
return undefined;
|
||||
};
|
||||
|
||||
if (isOppositeFates(start, end)) {
|
||||
return 2;
|
||||
};
|
||||
|
||||
let isForward = start === FatePath.SOUTH && end === FatePath.WEST;
|
||||
isForward ||= start === FatePath.NORTH && end === FatePath.EAST;
|
||||
if (isForward) {
|
||||
return 1;
|
||||
};
|
||||
return 3;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue