Minor changes

This commit is contained in:
2023-02-20 10:16:17 +01:00
parent 46b129cf81
commit 7137de0983
16 changed files with 123 additions and 60 deletions

View File

@@ -134,6 +134,15 @@ export class WarheroActorSheet extends ActorSheet {
const li = $(event.currentTarget).parents(".item");
this.actor.incDecQuantity( li.data("item-id"), +1 );
} );
html.find('.skill-use-minus').click(event => {
const li = $(event.currentTarget).parents(".item");
this.actor.incDecSkillUse( li.data("item-id"), -1 );
} );
html.find('.skill-use-plus').click(event => {
const li = $(event.currentTarget).parents(".item");
this.actor.incDecSkillUse( li.data("item-id"), +1 );
} );
html.find('.ammo-minus').click(event => {
const li = $(event.currentTarget).parents(".item")

View File

@@ -461,12 +461,10 @@ export class WarheroActor extends Actor {
}
}
/* -------------------------------------------- */
getInitiativeScore(combatId, combatantId) {
if (this.type == 'character') {
this.rollMR(true, combatId, combatantId)
}
console.log("Init required !!!!")
return -1;
async getInitiativeScore(combatId, combatantId) {
let roll = new Roll("1d20+"+this.system.attributes.ini.value).roll({async: false})
await WarheroUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"))
return roll.total
}
/* -------------------------------------------- */
@@ -547,7 +545,19 @@ export class WarheroActor extends Actor {
}
}
}
/* -------------------------------------------- */
async incDecSkillUse(skillId, value) {
let skill = this.items.get(skillId)
if (skill) {
let newUse = skill.system.currentuse + value
if (newUse > skill.system.maxuse) {
ui.notifications.warn(game.i18n.localize("WH.notif.skillmaxuse"))
return
}
newUse = Math.max(newUse, 0)
this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'system.currentuse': newUse }])
}
}
/* -------------------------------------------- */
async incDecQuantity(objetId, incDec = 0) {
let objetQ = this.items.get(objetId)
@@ -625,12 +635,14 @@ export class WarheroActor extends Actor {
this.system.secondary.nblanguage.value = Math.floor(this.system.statistics.min.value / 2)
}
/* -------------------------------------------- */
spentMana(mana) {
if (Number(mana) > this.system.attributes.mana.value) {
spentMana(spentValue) {
let mana = duplicate(this.system.attributes.mana)
if (Number(spentValue) > mana.value) {
ui.notifications.warn("Not enough Mana points !")
return false
}
this.update({ 'system.attributes.mana.value': this.system.attributes.mana.value - mana })
mana.value -= Number(spentValue)
this.update({ 'system.attributes.mana': mana })
return true
}
/* -------------------------------------------- */
@@ -651,6 +663,10 @@ export class WarheroActor extends Actor {
let rollData = this.getCommonRollData()
rollData.mode = rollType
rollData.stat = stat
if (stat && stat.stat)
{
rollData.statBonus = duplicate(this.system.statistics[stat.stat])
}
if (rollKey == "parrybonustotal") {
WarheroUtility.rollParry(rollData)
return
@@ -678,8 +694,8 @@ export class WarheroActor extends Actor {
} else {
rollData.stat = duplicate(this.system.attributes.txcm)
}
rollData.usemWeaponMalus =
rollData.mWeaponMalus = this.system.secondary.malusmultiweapon.value
rollData.usemWeaponMalus = false
rollData.mWeaponMalus = this.system.secondary.malusmultiweapon.value
rollData.weapon = weapon
rollData.img = weapon.img
this.startRoll(rollData)
@@ -707,7 +723,7 @@ export class WarheroActor extends Actor {
let rollData = this.getCommonRollData()
rollData.mode = "power"
rollData.power = power
rollData.powerLevel = power.system.level
rollData.powerLevel = Number(power.system.level)
rollData.img = power.img
rollData.hasBM = false
this.startRoll(rollData)

View File

@@ -9,7 +9,7 @@ export class WarheroCombat extends Combat {
for (let cId = 0; cId < ids.length; cId++) {
const c = this.combatants.get(ids[cId]);
let id = c._id || c.id;
let initBonus = c.actor ? c.actor.getInitiativeScore( this.id, id ) : -1;
let initBonus = c.actor ? await c.actor.getInitiativeScore( this.id, id ) : -1;
await this.updateEmbeddedDocuments("Combatant", [ { _id: id, initiative: initBonus } ]);
}

View File

@@ -71,16 +71,6 @@ Hooks.once("init", async function () {
WarheroUtility.init()
});
/* -------------------------------------------- */
function welcomeMessage() {
/*ChatMessage.create({
user: game.user.id,
whisper: [game.user.id],
content: `<div id="welcome-message-crucible"><span class="rdd-roll-part">
<strong>Welcome to the Warhero RPG.</strong>
` });*/
}
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
@@ -96,15 +86,14 @@ Hooks.once("ready", function () {
}
// CSS patch for v9
if (game.version) {
/*if (game.version) {
let sidebar = document.getElementById("sidebar");
sidebar.style.width = "min-content";
}
}*/
welcomeMessage();
//welcomeMessage();
WarheroUtility.ready()
WarheroCommands.init()
WarheroHotbar.initDropbar()
//WarheroHotbar.initDropbar()
})

View File

@@ -552,7 +552,7 @@ export class WarheroUtility {
let actor = game.actors.get(rollData.actorId)
if (rollData.mode == "power") {
let manaCost = Array.from(rollData.powerLevel)[0]
let manaCost = rollData.powerLevel
if (actor.spentMana(manaCost)) {
let powerKey = "level" + rollData.powerLevel
rollData.powerText = rollData.power.system[powerKey]
@@ -592,6 +592,9 @@ export class WarheroUtility {
if (rollData.stat) {
diceFormula += "+" + rollData.stat.value
}
if (rollData.statBonus) {
diceFormula += "+" + rollData.statBonus.value
}
}
if (rollData.usemWeaponMalus) {
diceFormula += "+" + rollData.mWeaponMalus