diff --git a/gulpfile.js b/gulpfile.js index f4ef62b..0023a64 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -222,6 +222,7 @@ async function clean() { "lang", "templates", "assets", + "packs", "module", `${name}.js`, "module.json", diff --git a/src/lang/en.json b/src/lang/en.json index 08b3092..926d824 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -5,6 +5,8 @@ "OSE.Ok": "Ok", "OSE.Cancel": "Cancel", "OSE.Roll": "Roll", + "OSE.Success": "Success", + "OSE.Failure": "Failure", "OSE.Formula": "Formula", "OSE.SitMod": "Situational Modifier", @@ -20,6 +22,8 @@ "OSE.Experience": "Experience", "OSE.ExperienceBonus": "Bonus Experience", "OSE.Treasure": "Treasure type", + "OSE.TreasureTable": "Table", + "OSE.TreasureTableHint": "Drop a rollable table here to roll the monster treasure", "OSE.Size": "Size", "OSE.Morale": "Morale", "OSE.Retainer": "Retainer", diff --git a/src/module/actor/actor-sheet.js b/src/module/actor/actor-sheet.js index 102bd16..da2e953 100644 --- a/src/module/actor/actor-sheet.js +++ b/src/module/actor/actor-sheet.js @@ -125,6 +125,11 @@ export class OseActorSheet extends ActorSheet { actorObject.rollAttack({label: this.actor.name, type: attack}, { event: event }); }); + html.find(".hit-dice .attribute-name a").click((ev) => { + let actorObject = this.actor; + actorObject.rollHitDice({ event: event }); + }); + super.activateListeners(html); } diff --git a/src/module/actor/character-sheet.js b/src/module/actor/character-sheet.js index 4d04279..d755b6f 100644 --- a/src/module/actor/character-sheet.js +++ b/src/module/actor/character-sheet.js @@ -146,11 +146,6 @@ export class OseActorSheetCharacter extends OseActorSheet { actorObject.rollCheck(score, { event: event }); }); - html.find(".hit-dice .attribute-name a").click((ev) => { - let actorObject = this.actor; - actorObject.rollHitDice({ event: event }); - }); - html.find(".exploration .attribute-name a").click((ev) => { let actorObject = this.actor; let element = event.currentTarget; diff --git a/src/module/actor/entity.js b/src/module/actor/entity.js index 605bcaf..7b2d751 100644 --- a/src/module/actor/entity.js +++ b/src/module/actor/entity.js @@ -26,22 +26,42 @@ export class OseActor extends Actor { /* Socket Listeners and Handlers /* -------------------------------------------- */ getExperience(value, options = {}) { - console.log(this.data); - if (this.data.type != 'character') { + if (this.data.type != "character") { return; } - let modified = value + (this.data.data.details.xp.bonus * value) / 100; - console.log(modified); + let modified = Math.floor( + value + (this.data.data.details.xp.bonus * value) / 100 + ); return this.update({ - "data.details.xp.value": modified + this.data.data.details.xp.value + "data.details.xp.value": modified + this.data.data.details.xp.value, }).then(() => { - const speaker = ChatMessage.getSpeaker({actor: this}); - ChatMessage.create({content: game.i18n.format("OSE.messages.getExperience", {name: this.name, value: modified}), speaker}); + const speaker = ChatMessage.getSpeaker({ actor: this }); + ChatMessage.create({ + content: game.i18n.format("OSE.messages.getExperience", { + name: this.name, + value: modified, + }), + speaker, + }); }); } /* -------------------------------------------- */ /* Rolls */ /* -------------------------------------------- */ + + rollHP(options = {}) { + let roll = new Roll(this.data.data.hp.hd).roll(); + console.log(roll); + return this.update({ + data: { + hp: { + max: roll.total, + value: roll.total, + }, + }, + }); + } + rollSave(save, options = {}) { const label = game.i18n.localize(`OSE.saves.${save}.long`); const rollParts = ["1d20"]; @@ -57,7 +77,7 @@ export class OseActor extends Actor { }; let skip = options.event && options.event.ctrlKey; - + // Roll and return return OseDice.Roll({ event: options.event, @@ -132,7 +152,7 @@ export class OseActor extends Actor { ...this.data, ...{ rollData: { - type: "Hit Dice" + type: "Hit Dice", }, }, }; @@ -186,20 +206,20 @@ export class OseActor extends Actor { rollData: { type: "Damage", stat: attData.type, - scores: data.scores + scores: data.scores, }, }, }; let dmgParts = []; - if (!attData.dmg || !game.settings.get('ose', 'variableWeaponDamage')) { + if (!attData.dmg || !game.settings.get("ose", "variableWeaponDamage")) { dmgParts.push("1d6"); } else { dmgParts.push(attData.dmg); } // Add Str to damage - if (attData.type == 'melee') { + if (attData.type == "melee") { dmgParts.push(data.scores.str.mod); } @@ -212,7 +232,7 @@ export class OseActor extends Actor { speaker: ChatMessage.getSpeaker({ actor: this }), flavor: `${attData.label} - ${game.i18n.localize("OSE.Damage")}`, title: `${attData.label} - ${game.i18n.localize("OSE.Damage")}`, - }) + }); } rollAttack(attData, options = {}) { @@ -240,7 +260,7 @@ export class OseActor extends Actor { rollData: { type: "Attack", stat: attData.type, - scores: data.scores + scores: data.scores, }, }, }; diff --git a/src/module/actor/monster-sheet.js b/src/module/actor/monster-sheet.js index 2a2eed8..8f7c827 100644 --- a/src/module/actor/monster-sheet.js +++ b/src/module/actor/monster-sheet.js @@ -140,6 +140,11 @@ export class OseActorSheetMonster extends OseActorSheet { actorObject.rollMorale({ event: event }); }); + html.find(".hp-roll").click((ev) => { + let actorObject = this.actor; + actorObject.rollHP({ event: event }); + }); + // Handle default listeners last so system listeners are triggered first super.activateListeners(html); } diff --git a/src/module/dice.js b/src/module/dice.js index 5090c68..24851a9 100644 --- a/src/module/dice.js +++ b/src/module/dice.js @@ -1,6 +1,10 @@ export class OseDice { static digestResult(data, roll) { - let details = ""; + let result = { + isSuccess: false, + isFailure: false, + target: "", + }; // ATTACKS let die = roll.parts[0].total; if (data.rollData.type == "Attack") { @@ -11,12 +15,12 @@ export class OseDice { } else if (data.rollData.stat == "missile") { bba += data.data.thac0.mod.missile + data.rollData.scores.dex.mod; } - - details = `