diff --git a/src/module/powers/basePowers.js b/src/module/powers/basePowers.js index e224a11..9ddb5d0 100644 --- a/src/module/powers/basePowers.js +++ b/src/module/powers/basePowers.js @@ -17,6 +17,19 @@ const MAINTAIN_ICONS = [ 'icons/magic/symbols/runes-triangle-orange.webp', ]; +function _hashCode(str) { + let hash = 0; + if (str.length === 0) { + return hash; + } + for (let i = 0; i < str.length; i++) { + const c = str.charCodeAt(i); + hash = (hash << 5) - hash + c; + hash |= 0; + } + return Math.abs(hash); +} + export class PowerFormApplication extends FormApplication { constructor(powerEffect) { super(); @@ -522,7 +535,7 @@ export class PowerEffect { } async createMaintainEffect(maintId) { - let icon = MAINTAIN_ICONS[Math.floor(Math.random() * MAINTAIN_ICONS.length)]; + let icon = MAINTAIN_ICONS[_hashCode(this.name) % MAINTAIN_ICONS.length]; if (!this.usePrimaryEffect) { icon = this.icon; }