More progress

* Make it so that the initiative isn't actually saved to the database
* Add .25 for unknown disposition entities
* Add .5 for entities that lose the coinflip
This commit is contained in:
Oliver-Akins 2025-02-14 23:23:53 -07:00
parent e302b56a4e
commit c549a59c13
6 changed files with 146 additions and 23 deletions

View file

@ -2,17 +2,34 @@ import { distanceBetweenFates } from "../utils/distanceBetweenFates.mjs";
export class RipCryptCombatant extends Combatant {
async _preCreate(data, options, user) {
const allowed = await super._preCreate(data, options, user);
if (allowed === false) { return false };
get disposition() {
switch (this.token.disposition) {
case CONST.TOKEN_DISPOSITIONS.HOSTILE:
return `hostile`;
case CONST.TOKEN_DISPOSITIONS.FRIENDLY:
return `friendly`;
};
return `unknown`;
};
get dynamicInitiative() {
let total = 0;
const start = game.settings.get(`ripcrypt`, `currentFate`);
const end = this.actor?.system?.fate || this.baseActor?.system?.fate;
const fateDistance = distanceBetweenFates(start, end);
total += distanceBetweenFates(start, end);
this.updateSource({
initiative: fateDistance,
});
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
const disposition = this.disposition;
if (whoFirst) {
if (disposition === `unknown`) {
total += 0.25;
} else if (whoFirst !== disposition) {
total += 0.5;
};
}
return total;
};
get groupKey() {