Skip to content

Commit

Permalink
Merge pull request #348 from pwatson100/RT9
Browse files Browse the repository at this point in the history
Fixed a number of minor issues
  • Loading branch information
pwatson100 authored Oct 13, 2021
2 parents 74f87c9 + d124da8 commit 5a382f1
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 86 deletions.
5 changes: 4 additions & 1 deletion Release_Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,7 @@ Version 3.1.1
- Code simplification and debuging

Version 3.1.2
- updated readmen compendium as the user guide had vanished.
- updated readmen compendium as the user guide had vanished.

Version 3.1.3
- Fixed a number of minor issues
2 changes: 1 addition & 1 deletion script/common/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class SymbaroumActor extends Actor {
// console.log("Init data - complete");
this.data.numRituals = 0;
// console.log("Compute items");
console.log("original items",this.data.items);
game.symbaroum.log("original items",this.data.items);
let items = this.data.items.contents.sort( (a, b) => {
if(a.data.type == b.data.type) {
return a.data.name == b.data.name ? 0 : a.data.name < b.data.name ? -1:1;
Expand Down
2 changes: 1 addition & 1 deletion script/common/devmsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function sendDevMessage()
}
latestVersion = Math.max(latestVersion, msgenvelope.version);
}
console.info("latestVersion after "+latestVersion);
game.symbaroum.info("latestVersion after "+latestVersion);
game.settings.set('symbaroum', 'symbaroumDevMessageVersionNumber', latestVersion);
})
.fail(function(data) {
Expand Down
58 changes: 31 additions & 27 deletions script/common/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export async function prepareRollAttribute(actor, attributeName, armor, weapon)
weaponModifier.attribute = [];
weaponModifier.attributeModifiers = [];
weaponModifier.damageChoices = [];
weaponModifier.damageBonus = [];

if(weapon !== null)
{
Expand Down Expand Up @@ -61,21 +60,21 @@ export async function prepareRollAttribute(actor, attributeName, armor, weapon)
}
attri_defaults.additionalModifier = damModifier;

for(let bonus of weaponModifier.damageBonus) {
damModifier += `${bonus.damageModifier}[${bonus.label}]`;
}
for(let optionalBonus of weaponModifier.damageChoices) {
if(optionalBonus.type === "check") {
if(optionalBonus.type === "fixed") {
damModifier += `${optionalBonus.alternatives.damMod}[${optionalBonus.label}]`
} else if(optionalBonus.type === "check") {
// Find if the box is checked
let ticked = html.find(`#${optionalBonus.label}`);
let ticked = html.find(`#${optionalBonus.id}`);
console.log("Hfm", ticked, optionalBonus);
if( ticked.length > 0 && ticked[0].checked )
damModifier += ticked[0].value;
damModifier += `${optionalBonus.alternatives.damMod}[${optionalBonus.label}]`;
} else if( optionalBonus.type === "radio") {
// Find the selected radio button
let radioSelection = html.find("input[name='"+optionalBonus.identifier+"']");
let radioSelection = html.find(`input[name='${optionalBonus.id}']`);
for( let f of radioSelection) {
if( f.checked )
damModifier += f.value;
damModifier += `${f.value}[${optionalBonus.label}]`;
}
}
}
Expand All @@ -101,7 +100,7 @@ export async function prepareRollAttribute(actor, attributeName, armor, weapon)
}
attri_defaults.impeding = html.find("#impeding")[0].checked ? "checked":"";
}
// console.log("Damage bonus",damModifier);
console.log("Damage bonus",damModifier);
await rollAttribute(actor, attributeName, getTarget(), targetAttributeName, favour, modifier, armor, weapon, advantage, damModifier);
},
},
Expand Down Expand Up @@ -174,12 +173,11 @@ function calculateWeaponModifiers(actor, weapon, weaponModifier)
let choice = {};
choice["label"] = robust[0].name;
choice["type"] = "check";
choice["id"] = robust[0].id;
let damMod = `+1d${(dice+1)*2}`;
let damlabel = `(${damMod})`;
damMod = `${damMod}[${robust[0].name}]`;
choice["alternatives"] = {
"label":damlabel,
"damMod":damMod
"damMod":damMod,
};
choice["restrition"] = "1st-attack"; // Only apply damage bonus to first attack
weaponModifier.damageChoices.push(choice);
Expand All @@ -192,24 +190,30 @@ function calculateWeaponModifiers(actor, weapon, weaponModifier)
if( power.level > 0) {
weaponModifier.attribute.push( {
attribute:"strong",
label: ironFist[0].name
label: ironFist[0].name,
id: ironFist[0].id
});
}
if( power.level === 2) {
let bonus = {};
bonus.label = ironFist[0].name;
bonus.damageModifier = "+1d4";
// No choice
weaponModifier.damageBonus.push(bonus);
let choice = {};
choice.label = ironFist[0].name;
choice["type"] = "fixed";
choice["alternatives"] = {
"damMod":"+1d4"
};
// No choice
weaponModifier.damageChoices.push(choice);
} else if( power.level === 3) {
let choice = {};
choice["type"] = "radio";
choice["label"] = ironFist[0].name;
choice["identifier"] = "weapMod_"+ironFist[0].name;
choice["defaultSelect"] = `+1d4[${ironFist[0].name}]`;
choice["id"] = ironFist[0].id;
choice["defaultSelect"] = `+1d4`;
choice["alternatives"] = {};
choice["alternatives"][`+1d4[${ironFist[0].name}]`] = `${ironFist[0].name} - ${power.lvlName} (1d4)`;
choice["alternatives"][`+1d8[${ironFist[0].name}]`] = `${ironFist[0].name} - ${power.lvlName} (1d8)`;
// Change this to fixed values
// Add in alternatives.damageModifier
choice["alternatives"][`+1d4`] = `${ironFist[0].name} - ${power.lvlName} (1d4)`;
choice["alternatives"][`+1d8`] = `${ironFist[0].name} - ${power.lvlName} (1d8)`;
weaponModifier.damageChoices.push(choice);
}
}
Expand All @@ -232,13 +236,12 @@ function calculateWeaponModifiers(actor, weapon, weaponModifier)
if( weapon.isDistance && hunterInstinct.length > 0 && hunterInstinct[0].getLevel().level > 1) {
let choice = {};
choice["label"] = hunterInstinct[0].name;
choice["id"] = hunterInstinct[0].id;
choice["type"] = "check";
let damMod = `+1d4`;
let damlabel = `(${damMod})`;
damMod = `${damMod}[${hunterInstinct[0].name}]`;
let damlabel = `(${damMod})`;
choice["alternatives"] = {
"label":damlabel,
"damMod":damMod
"damMod":damMod,
};
weaponModifier.damageChoices.push(choice);
}
Expand All @@ -247,6 +250,7 @@ function calculateWeaponModifiers(actor, weapon, weaponModifier)
if(weapon.qualities.precise) {
let attributeModifier = {
label: game.i18n.localize("QUALITY.PRECISE"),
id: weapon.id,
modifier: "+1"
}
weaponModifier.attributeModifiers.push(attributeModifier);
Expand Down
44 changes: 26 additions & 18 deletions script/common/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ Hooks.once('init', () => {
config: SYMBAROUM,
SymbaroumConfig,
};
game.symbaroum.debug = (...args) => {
console.debug("Symbaroum |", ...args);
};
game.symbaroum.error = (...args) => {
console.error("Symbaroum |", ...args);
};
game.symbaroum.info = (...args) => {
console.info("Symbaroum |", ...args);
};
game.symbaroum.log = (...args) => {
console.log("Symbaroum |", ...args);
};

game.settings.register('symbaroum', 'worldTemplateVersion', {
// worldTemplateVersion is deprecated - not to use anymore
Expand Down Expand Up @@ -417,7 +429,7 @@ Hooks.on('renderChatMessage', async (chatItem, html, data) => {
functionStuff.actor = tok.actor;
functionStuff.targetData.token = targetToken;
functionStuff.targetData.actor = targetToken.actor;
console.log("from hook: ", functionStuff);
// game.symbaroum.log("from hook: ", functionStuff);
buildRolls(functionStuff);
await chatItem.unsetFlag(game.system.id, 'resistRoll');
return;
Expand Down Expand Up @@ -470,17 +482,25 @@ async function showReleaseNotes() {

let newReleasePack = game.packs.find((p) => p.metadata.label === releasePackLabel);
if (newReleasePack === null || newReleasePack === undefined) {
console.error('No pack found');
let err = "No pack found for the system guide in this release";
game.symbaroum.error(err);
ui.notifications.error(err);
// This is bad - the symbaroum pack does not exist in the system packages
return;
}
await newReleasePack.getIndex();

let newReleaseNotes = newReleasePack.index.find((j) => j.name === releaseNoteName);
// console.log("Found new release notes in the compendium pack");
// game.symbaroum.log("Found new release notes in the compendium pack");
if( newReleaseNotes === undefined || newReleaseNotes === null ) {
let err = "No system guide found in this release";
game.symbaroum.error(err);
ui.notifications.error(err);
return;
}

// Don't delete until we have new release Pack
if (newReleaseNotes !== undefined && newReleaseNotes !== null && oldReleaseNotes !== null && oldReleaseNotes !== undefined) {
if (oldReleaseNotes !== null && oldReleaseNotes !== undefined) {
await oldReleaseNotes.delete();
}

Expand All @@ -489,28 +509,16 @@ async function showReleaseNotes() {

await newReleaseJournal.setFlag('symbaroum', 'ver', newVer);

// Before we show final - tidy up release prior to this
tidyReleaseNotes11();

// Show journal
await newReleaseJournal.sheet.render(true, { sheetMode: 'text' });
} catch (error) {
console.error(error);
game.symbaroum.error(error);
} // end of try
} // end of if(isgm)
} // end of function

async function tidyReleaseNotes11() {
const releaseNoteName = 'Symbaroum System guide EN (1.1)';
let old11ReleaseNotes = game.journal.getName(releaseNoteName);
// Delete Delete Delete
if (old11ReleaseNotes !== undefined && old11ReleaseNotes !== null) {
await old11ReleaseNotes.delete();
}
}

async function setupEmit() {
console.info('Setting up Symbaroum emit system');
game.symbaroum.info('Setting up Symbaroum emit system');
SymbaroumCommsListener.ready();
}

Expand Down
4 changes: 2 additions & 2 deletions script/common/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class SymbaroumItem extends Item {
data.data.isDistance = false;
}
let baseDamage = data.data.baseDamage;
// console.log("baseDamage["+baseDamage+"]");
// game.symbaroum.log("baseDamage["+baseDamage+"]");
if( baseDamage === null || baseDamage === undefined || baseDamage === "" ) {
baseDamage = "1d8";
}
Expand Down Expand Up @@ -2051,7 +2051,7 @@ async function standardPowerResult(rollData, functionStuff){
}

if(healResult){
// console.log(healResult)
// game.symbaroum.log(healResult)
templateData.hasDamage = healResult.hasDamage;
templateData.damageText = healResult.damageText;
templateData.dmgFormula = healResult.dmgFormula;
Expand Down
Loading

0 comments on commit 5a382f1

Please sign in to comment.