Skip to content

Commit

Permalink
0.9.48 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisk123999 committed Jan 30, 2024
1 parent 84503ae commit 6198d92
Show file tree
Hide file tree
Showing 20 changed files with 308 additions and 53 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 0.9.48 Release:
## Bug Fixes:
- Wild Surge
- Aura of Life
- Effect Auras
## Update Notes:
- Initial Medkit support for Gambit's Premades and Midi Item Showcase - Community

# 0.9.47 Release:
## Bug Fixes:
- Manifest Echo
Expand Down
46 changes: 33 additions & 13 deletions scripts/compendium.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import {constants} from './constants.js';
import {chris} from './helperFunctions.js';
const ids = [
'chris-premades.CPR Spell Features',
'chris-premades.CPR Class Feature Items',
'chris-premades.CPR Monster Feature Items',
'chris-premades.CPR Summon Features',
'chris-premades.CPR Feat Features',
'chris-premades.CPR Homebrew Feature Items',
'chris-premades.CPR Race Feature Items',
'chris-premades.CPR Item Features'
];
export async function compendiumRender(doc, html, context) {
let ids = [
'chris-premades.CPR Spell Features',
'chris-premades.CPR Class Feature Items',
'chris-premades.CPR Monster Feature Items',
'chris-premades.CPR Summon Features',
'chris-premades.CPR Feat Features',
'chris-premades.CPR Homebrew Feature Items',
'chris-premades.CPR Race Feature Items',
'chris-premades.CPR Item Features'
];
if (!ids.includes(doc.metadata.id)) return;
await chris.dialog('Chris\'s Premades: Warning', [['OK', false]], 'This compendium is not intended to be accessed this way!<br>You do not need anything from here.');
}
export async function additionalCompendiums() {
let packs = game.packs.filter(i => !i.metadata.id.includes('chris-premades.') && i.metadata.type === 'Item');
let ignorePacks = [
'chris-premades',
'gambits-premades',
'midi-item-showcase-community'
];
let packs = game.packs.filter(i => !ignorePacks.some(j => i.metadata.id.includes(j)) && i.metadata.type === 'Item');
let oldSettings = game.settings.get('chris-premades', 'Additional Compendiums');
let inputs = packs.map(i => ({'label': i.metadata.label, 'type': 'checkbox', 'options': oldSettings.includes(i.metadata.id)}));
let selection = await chris.menu('Additional Compendiums', constants.okCancel, inputs, true);
Expand All @@ -29,20 +34,35 @@ export async function additionalCompendiums() {
}
export async function additionalCompendiumPriority() {
let packs = game.settings.get('chris-premades', 'Additional Compendiums');
if (!packs.length) {
let gambitItems = game.modules.get('gambits-premades')?.active ? !!game.settings.get('chris-premades', 'GPR Support') : false;
let miscItems = game.modules.get('midi-item-showcase-community')?.active ? !!game.settings.get('chris-premades', 'MISC Support') : false;
if (!packs.length && !gambitItems && !miscItems) {
ui.notifications.info('There are no compendiums selected in the "Additional Compendiums" setting!');
return;
}
let oldSettings = game.settings.get('chris-premades', 'Additional Compendium Priority');
let inputs = packs.map(i => ({'label': game.packs.get(i)?.metadata?.label ?? 'Unknown (' + i + ')', 'type': 'number', 'options': oldSettings[i] ?? 100}));
if (miscItems) inputs.unshift({'label': 'Midi Item Showcase', 'type': 'number', 'options': oldSettings['MISC'] ?? 2});
if (gambitItems) inputs.unshift({'label': 'Gambit\'s Premades', 'type': 'number', 'options': oldSettings['GPR'] ?? 1});
inputs.unshift({'label': 'Chris\'s Premades', 'type': 'number', 'options': oldSettings['CPR'] ?? 0});
let selection = await chris.menu('Additional Compendium Priority', constants.okCancel, inputs, true, 'Lower Number = Higher Priority');
if (!selection.buttons) return;
let newSettings = {};
for (let i = 1; inputs.length > i; i++) {
let startNumber = 1;
if (gambitItems) startNumber++;
if (miscItems) startNumber++;
for (let i = startNumber; inputs.length > i; i++) {
newSettings[packs[i - 1]] = isNaN(selection.inputs[i]) ? 100 : selection.inputs[i];
}
newSettings['CPR'] = selection.inputs[0];
if (gambitItems && !miscItems) {
newSettings['GPR'] = selection.inputs[1];
} else if (!gambitItems && miscItems) {
newSettings['MISC'] = selection.inputs[1];
} else if (gambitItems && miscItems) {
newSettings['GPR'] = selection.inputs[1];
newSettings['MISC'] = selection.inputs[2];
}
await game.settings.set('chris-premades', 'Additional Compendium Priority', newSettings);
}
export async function selectCompendium(setting) {
Expand Down
152 changes: 131 additions & 21 deletions scripts/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,77 @@ export function createHeaderButton(config, buttons) {
export function updateItemButton(app, [elem], options) {
let headerButton = elem.closest('.window-app').querySelector('a.header-button.chris-premades');
if (!headerButton) return;
let itemName = app.object?.name;
if (!itemName) return;
let automation = CONFIG.chrisPremades.automations[app.object.flags['chris-premades']?.info?.name ?? itemName];
if (!automation) return;
let itemVersion = app.object.flags['chris-premades']?.info?.version;
if (!itemVersion) {
headerButton.style.color = 'yellow';
return;
let item = app.object;
if (!item) return;
let source = item.flags['chris-premades']?.info?.source;
function cpr(item) {
let automation = CONFIG.chrisPremades.automations[item.flags['chris-premades']?.info?.name ?? getItemName(item.name)];
if (!automation) return false;
let itemVersion = item.flags['chris-premades']?.info?.version;
if (!itemVersion) {
headerButton.style.color = 'yellow';
return true;
}
if (automation.version != itemVersion) {
headerButton.style.color = 'red';
return true;
}
if (CONFIG.chrisPremades.itemConfiguration[automation.name]) {
headerButton.style.color = 'dodgerblue';
return true;
} else {
headerButton.style.color = 'green';
return true;
}
}
if (automation.version != itemVersion) {
headerButton.style.color = 'red';
return;
function gpr(item) {
let automation = CONFIG['gambits-premades']?.automations[item.name];
if (!automation) return;
let itemVersion = item.flags['chris-premades']?.info?.gambit?.version;
if (!itemVersion) {
headerButton.style.color = 'yellow';
return;
}
if (automation.version != itemVersion) {
headerButton.style.color = 'orange';
return;
}
headerButton.style.color = 'orchid';
}
if (CONFIG.chrisPremades.itemConfiguration[automation.name]) {
headerButton.style.color = 'dodgerblue';
function misc(item) {
let automation = CONFIG['midi-item-showcase-community']?.automations[item.name];
if (!automation) return;
let itemVersion = item.flags['chris-premades']?.info?.misc?.version;
if (!itemVersion) {
headerButton.style.color = 'yellow';
return;
}
if (automation.version != itemVersion) {
headerButton.style.color = 'orange';
return;
}
headerButton.style.color = 'orchid';
}
if (source) {
switch(source) {
case 'CPR':
cpr(item);
return;
case 'GPR':
gpr(item);
return;
case 'MISC':
misc(item);
return;
default:
headerButton.style.color = 'yellow';
return;
}
} else {
headerButton.style.color = 'green';
let found = cpr(item);
if (found) return;
let automation = CONFIG['gambits-premades']?.automations[item.name] ?? CONFIG['midi-item-showcase-community']?.automations[item.name];
if (automation) headerButton.style.color = 'yellow';
}
}
export function createActorHeaderButton(config, buttons) {
Expand All @@ -55,7 +109,7 @@ async function actorConfig(actor) {
list += '- ' + i + '<br>'
}
ChatMessage.create({
'speaker': {alias: name},
'speaker': {'alias': 'Chris\'s Premades'},
'whisper': [game.user.id],
'content': '<hr><b>Updated Items:</b><br><hr>' + list
});
Expand Down Expand Up @@ -117,7 +171,10 @@ async function updateItem(itemDocument) {
if (itemDocument.actor.type === 'npc') isNPC = true;
let compendiumItem;
let foundCompendiumName;
let gambitItems = game.modules.get('gambits-premades')?.active ? game.settings.get('chris-premades', 'GPR Support') : false;
let miscItems = game.modules.get('midi-item-showcase-community')?.active ? game.settings.get('chris-premades', 'MISC Support') : false;
itemName = getItemName(itemName);
let sourceModule;
if (!isNPC || itemType === 'spell') {
switch (itemType) {
case 'weapon':
Expand All @@ -127,15 +184,36 @@ async function updateItem(itemDocument) {
case 'backpack':
case 'loot':
searchCompendiums.push('chris-premades.CPR Items');
if (gambitItems) searchCompendiums.push('gambits-premades.gps-items');
if (gambitItems === 2) searchCompendiums.push('gambits-premades.gps-homebrew-items');
if (miscItems) searchCompendiums.push('midi-item-showcase-community.misc-items');
if (miscItems === 2 || miscItems === 4) searchCompendiums.push('midi-item-showcase-community.misc-homebrew');
if (miscItems === 1 || miscItems === 4) searchCompendiums.push('midi-item-showcase-community.misc-unearthed-arcana');
break;
case 'spell':
searchCompendiums.push('chris-premades.CPR Spells');
if (gambitItems) searchCompendiums.push('gambits-premades.gps-spells');
if (miscItems) searchCompendiums.push('midi-item-showcase-community.misc-spells');
if (miscItems === 2 || miscItems === 4) searchCompendiums.push('midi-item-showcase-community.misc-homebrew');
if (miscItems === 1 || miscItems === 4) searchCompendiums.push('midi-item-showcase-community.misc-unearthed-arcana');
break;
case 'feat':
searchCompendiums.push('chris-premades.CPR Race Features');
searchCompendiums.push('chris-premades.CPR Class Features');
searchCompendiums.push('chris-premades.CPR Feats');
searchCompendiums.push('chris-premades.CPR Actions');
if (gambitItems) {
searchCompendiums.push('gambits-premades.gps-class-features');
searchCompendiums.push('gambits-premades.gps-generic-features');
if (gambitItems === 2) searchCompendiums.push('gambits-premades.gps-homebrew-features');
}
if (miscItems) {
searchCompendiums.push('midi-item-showcase-community.misc-class-features');
searchCompendiums.push('midi-item-showcase-community.misc-feats');
searchCompendiums.push('midi-item-showcase-community.misc-race-features');
if (miscItems === 2 || miscItems === 4) searchCompendiums.push('midi-item-showcase-community.misc-homebrew');
if (miscItems === 1 || miscItems === 4) searchCompendiums.push('midi-item-showcase-community.misc-unearthed-arcana');
}
break;
}
for (let i of additionalCompendiums) searchCompendiums.push(i);
Expand All @@ -147,12 +225,28 @@ async function updateItem(itemDocument) {
'chris-premades.CPR Feats',
'chris-premades.CPR Actions'
];
searchCompendiums.sort((a, b) => (packs.includes(a) ? additionalCompendiumPriority['CPR'] : additionalCompendiumPriority[a] ?? 10) - (packs.includes(b) ? additionalCompendiumPriority['CPR'] : additionalCompendiumPriority[b] ?? additionalCompendiumPriority[b] ?? 10));
for (let compendium of searchCompendiums) {
if (!game.packs.get(compendium)) continue;
compendiumItem = await chris.getItemFromCompendium(compendium, itemName, true);
let gambitPacks = [];
if (gambitItems && game.modules.get('gambits-premades')?.active) gambitPacks = Array.from(game.modules.get('gambits-premades').packs).map(i => i.id)
let miscPacks = [];
if (miscItems && game.modules.get('midi-item-showcase-community')?.active) miscPacks = Array.from(game.modules.get('midi-item-showcase-community').packs).map(i => i.id);
searchCompendiums.sort((a, b) => {
let numA = additionalCompendiumPriority[a] ?? 10;
let numB = additionalCompendiumPriority[b] ?? 10;
if (packs.includes(a)) numA = additionalCompendiumPriority['CPR'];
if (packs.includes(b)) numB = additionalCompendiumPriority['CPR'];
if (gambitPacks.includes(a)) numA = additionalCompendiumPriority['GPR'];
if (gambitPacks.includes(b)) numB = additionalCompendiumPriority['GPR'];
if (miscPacks.includes(a)) numA = additionalCompendiumPriority['MISC'];
if (miscPacks.includes(b)) numB = additionalCompendiumPriority['MISC'];
return numA - numB;
});
for (let compendiumId of searchCompendiums) {
let compendium = game.packs.get(compendiumId);
if (!compendium) continue;
compendiumItem = await chris.getItemFromCompendium(compendiumId, itemName, true);
if (compendiumItem) {
foundCompendiumName = game.packs.get(compendium).metadata.label;
foundCompendiumName = compendium.metadata.label;
sourceModule = compendium.metadata.packageType === 'module' ? compendium.metadata.packageName : 'world';
break;
}
}
Expand All @@ -178,7 +272,7 @@ async function updateItem(itemDocument) {
let selection = await chris.dialog('Item Updater', constants.yesNo, 'Automation found, apply it? (' + foundCompendiumName + ')');
if (!selection) return;
ChatMessage.create({
'speaker': {'alias': name},
'speaker': {'alias': 'Chris\'s Premades'},
'whisper': [game.user.id],
'content': '<hr><b>' + compendiumItem.name + ':</b><br><hr>' + compendiumItem.system.description.value
});
Expand Down Expand Up @@ -209,6 +303,22 @@ async function updateItem(itemDocument) {
if (itemDocument.flags.ddbimporter) originalItem.flags.ddbimporter = itemDocument.flags.ddbimporter;
if (itemDocument.flags['chris-premades']) originalItem.flags['chris-premades'] = itemDocument.flags['chris-premades'];
if (info) setProperty(originalItem, 'flags.chris-premades.info', info);
switch (sourceModule) {
case 'midi-item-showcase-community':
setProperty(originalItem, 'flags.chris-premades.info.misc', CONFIG['midi-item-showcase-community']?.automations?.[itemName]);
setProperty(originalItem, 'flags.chris-premades.info.source', 'MISC');
break;
case 'gambits-premades':
setProperty(originalItem, 'flags.chris-premades.info.gambit', CONFIG['gambits-premades']?.automations?.[itemName]);
setProperty(originalItem, 'flags.chris-premades.info.source', 'GPR');
break;
case 'chris-premades':
setProperty(originalItem, 'flags.chris-premades.info.source', 'CPR');
break;
default:
setProperty(originalItem, 'flags.chris-premades.info.source', 'world');
break;
}
if (originalItem.img === 'icons/svg/item-bag.svg') originalItem.img = compendiumItem.img;
await itemDocument.actor.createEmbeddedDocuments('Item', [originalItem]);
await itemDocument.delete();
Expand Down
10 changes: 9 additions & 1 deletion scripts/macros/classFeatures/barbarian/wildMagic/wildSurge.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,15 @@ async function protectiveLightsAura(token, selectedAura) {
'value': '+1',
'priority': 20
}
]
],
'flags': {
'chris-premades': {
'aura': true,
'effect': {
'noAnimation': true
}
}
}
};
let effect = chris.findEffect(token.actor, effectData.name);
if (effect?.origin === effectData.origin) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,14 @@ async function attack({speaker, actor, token, character, item, args, scope, work
'value': '1',
'priority': 20
}
]
],
'flags': {
'chris-premades': {
'effect': {
'noAnimation': true
}
}
}
};
let effect = await chris.createEffect(workflow.actor, effectData);
let effect2 = await chris.createEffect(targetToken.actor, effectData);
Expand Down
5 changes: 4 additions & 1 deletion scripts/macros/classFeatures/paladin/auraOfCourage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export async function auraOfCourage(token, selectedAura) {
],
'flags': {
'chris-premades': {
'aura': true
'aura': true,
'effect': {
'noAnimation': true
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion scripts/macros/classFeatures/paladin/auraOfProtection.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export async function auraOfProtection(token, selectedAura) {
],
'flags': {
'chris-premades': {
'aura': true
'aura': true,
'effect': {
'noAnimation': true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export async function auraOfDevotion(token, selectedAura) {
],
'flags': {
'chris-premades': {
'aura': true
'aura': true,
'effect': {
'noAnimation': true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export async function auraOfAlacrity(token, origin) {
],
'flags': {
'chris-premades': {
'aura': true
'aura': true,
'effect': {
'noAnimation': true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export async function auraOfWarding(token, selectedAura) {
],
'flags': {
'chris-premades': {
'aura': true
'aura': true,
'effect': {
'noAnimation': true
}
}
}
}
Expand Down
Loading

0 comments on commit 6198d92

Please sign in to comment.