use hash of name to assign maintain icon
This commit is contained in:
parent
61e78936a7
commit
1207b9c1bd
@ -17,6 +17,19 @@ const MAINTAIN_ICONS = [
|
|||||||
'icons/magic/symbols/runes-triangle-orange.webp',
|
'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 {
|
export class PowerFormApplication extends FormApplication {
|
||||||
constructor(powerEffect) {
|
constructor(powerEffect) {
|
||||||
super();
|
super();
|
||||||
@ -522,7 +535,7 @@ export class PowerEffect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createMaintainEffect(maintId) {
|
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) {
|
if (!this.usePrimaryEffect) {
|
||||||
icon = this.icon;
|
icon = this.icon;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user