Actor sheet

This commit is contained in:
LeRatierBretonnien 2023-01-29 18:32:30 +01:00
parent f5e03886d5
commit bc7910a50d
11 changed files with 166 additions and 75 deletions

View File

@ -37,9 +37,11 @@
"WH.ui.weapons": "Weapons",
"WH.ui.armors": "Armors",
"WH.ui.shields": "Shields",
"WH.ui.weapon": "Weapon",
"WH.ui.Strength": "Strength",
"WH.ui.Instinct": "Instinct",
"WH.ui.Dexterity": "Dexterity",
"WH.ui.Mind": "Mind",
"WH.ui.Type": "Type",
"WH.ui.HitPoints": "Hit Points",
@ -48,6 +50,7 @@
"WH.ui.Mana": "Mana",
"WH.ui.Initiative": "Initiative",
"WH.ui.Movement": "Movement",
"WH.ui.power": "Power",
"WH.ui.Qty": "Qty",
"WH.ui.maxslots": "Max slots",

View File

@ -137,11 +137,20 @@ export class WarheroActorSheet extends ActorSheet {
this.actor.rollFromType(rollType, statKey)
});
html.find('.roll-weapon').click((event) => {
const li = $(event.currentTarget).parents(".item");
const skillId = li.data("item-id")
this.actor.rollWeapon(skillId)
const li = $(event.currentTarget).parents(".item")
const weaponId = li.data("item-id")
this.actor.rollWeapon(weaponId)
});
html.find('.power-roll').click((event) => {
const li = $(event.currentTarget).parents(".item")
const powerId = li.data("item-id")
this.actor.rollPower(powerId)
});
html.find('.roll-damage').click((event) => {
const li = $(event.currentTarget).parents(".item")
const weaponId = li.data("item-id")
this.actor.rollDamage(weaponId)
});
html.find('.lock-unlock-sheet').click((event) => {
this.options.editScore = !this.options.editScore;

View File

@ -183,8 +183,22 @@ export class WarheroActor extends Actor {
return comp;
}
/* -------------------------------------------- */
prepareWeapon(weapon) {
let formula = weapon.system.damage
if (weapon.system.weapontype == "long") {
formula += "+" + this.system.statistics.str.value
}
if (weapon.system.weapontype == "twohanded") {
formula += "+" + Math.floor(this.system.statistics.str.value*1.5)
}
weapon.damageFormula = formula
}
/* -------------------------------------------- */
getWeapons() {
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || []);
for (let weapon of comp) {
this.prepareWeapon(weapon)
}
WarheroUtility.sortArrayObjectsByName(comp)
return comp;
}
@ -521,6 +535,15 @@ export class WarheroActor extends Actor {
return this.items.find(cond => cond.type == "condition" && cond.system.targetadvantage)
}
/* -------------------------------------------- */
spentMana( mana) {
if ( Number(mana) > this.system.attributes.mana.value) {
ui.notifications.warn("Not enough Mana points !")
return false
}
this.update({'system.attributes.mana.value': this.system.attributes.mana.value-mana})
return true
}
/* -------------------------------------------- */
getCommonRollData() {
let rollData = WarheroUtility.getBasicRollData()
@ -547,30 +570,40 @@ export class WarheroActor extends Actor {
let weapon = this.items.get(weaponId)
if (weapon) {
weapon = duplicate(weapon)
let skill = this.items.find(item => item.name.toLowerCase() == weapon.system.skill.toLowerCase())
if (skill) {
skill = duplicate(skill)
WarheroUtility.updateSkill(skill)
let abilityKey = skill.system.ability
let rollData = this.getCommonRollData(abilityKey)
rollData.mode = "weapon"
rollData.skill = skill
rollData.weapon = weapon
rollData.img = weapon.img
if (!rollData.forceDisadvantage) { // This is an attack, check if disadvantaged
rollData.forceDisadvantage = this.isAttackDisadvantage()
}
/*if (rollData.weapon.system.isranged && rollData.tokensDistance > WarheroUtility.getWeaponMaxRange(rollData.weapon) ) {
ui.notifications.warn(`Your target is out of range of your weapon (max: ${WarheroUtility.getWeaponMaxRange(rollData.weapon)} - current : ${rollData.tokensDistance})` )
return
}*/
this.startRoll(rollData)
} else {
ui.notifications.warn("Unable to find the relevant skill for weapon " + weapon.name)
}
let rollData = this.getCommonRollData()
rollData.mode = "weapon"
rollData.stat = duplicate(this.system.statistics.dex)
rollData.weapon = weapon
rollData.img = weapon.img
this.startRoll(rollData)
}
}
/* -------------------------------------------- */
rollDamage(weaponId) {
let weapon = this.items.get(weaponId)
if (weapon) {
weapon = duplicate(weapon)
this.prepareWeapon(weapon)
let rollData = this.getCommonRollData()
rollData.mode = "damage"
rollData.weapon = weapon
rollData.img = weapon.img
this.startRoll(rollData)
}
}
/* -------------------------------------------- */
rollPower(powerId) {
let power = this.items.get(powerId)
if (power) {
power = duplicate(power)
let rollData = this.getCommonRollData()
rollData.mode = "power"
rollData.power = power
rollData.img = power.img
rollData.hasBM = false
this.startRoll(rollData)
}
}
/* -------------------------------------------- */
async startRoll(rollData) {

View File

@ -58,23 +58,8 @@ export class WarheroRollDialog extends Dialog {
}
$(function () { onLoad(); });
html.find('#advantage').change((event) => {
this.rollData.advantage = event.currentTarget.value
})
html.find('#disadvantage').change((event) => {
this.rollData.disadvantage = event.currentTarget.value
})
html.find('#rollAdvantage').change((event) => {
this.rollData.rollAdvantage = event.currentTarget.value
})
html.find('#useshield').change((event) => {
this.rollData.useshield = event.currentTarget.checked
})
html.find('#hasCover').change((event) => {
this.rollData.hasCover = event.currentTarget.value
})
html.find('#situational').change((event) => {
this.rollData.situational = event.currentTarget.value
html.find('#powerLevel').change((event) => {
this.rollData.powerLevel = event.currentTarget.value
})
html.find('#bonusMalus').change((event) => {
this.rollData.bonusMalus = Number(event.currentTarget.value)

View File

@ -540,6 +540,30 @@ export class WarheroUtility {
let actor = game.actors.get(rollData.actorId)
if ( rollData.mode == "power") {
let manaCost = Array.from(rollData.powerLevel)[0]
if( actor.spentMana(manaCost)) {
let powerKey = "level"+rollData.powerLevel
rollData.powerText = rollData.power.system[powerKey]
let msg = await this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
})
msg.setFlag("world", "rolldata", rollData)
}
return
}
if ( rollData.mode == "damage") {
let myRoll = new Roll(rollData.weapon.damageFormula + "+" + rollData.bonusMalus).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = myRoll
let msg = await this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
})
msg.setFlag("world", "rolldata", rollData)
return
}
// ability/save/size => 0
let diceFormula = "1d20"
if ( rollData.stat) {
@ -667,7 +691,9 @@ export class WarheroUtility {
rollId: randomID(16),
rollMode: game.settings.get("core", "rollMode"),
advantage: "none",
bonusMalus: 0
bonusMalus: 0,
powerLevel: "1",
hasBM: true
}
WarheroUtility.updateWithTarget(rollData)
return rollData

View File

@ -100,7 +100,7 @@
"styles": [
"styles/simple.css"
],
"version": "10.0.6",
"version": "10.0.7",
"compatibility": {
"minimum": "10",
"verified": "10",
@ -108,7 +108,7 @@
},
"title": "Warhero RPG",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-warhero/raw/branch/master/system.json",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-warhero/archive/fvtt-warhero-10.0.6.zip",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-warhero/archive/fvtt-warhero-10.0.7.zip",
"url": "https://www.uberwald.me/gitea/public/fvtt-warhero",
"background": "images/ui/warhero_welcome_page.webp",
"id": "fvtt-warhero"

View File

@ -28,9 +28,9 @@
"style": "dropdown",
"value": 0
},
"ist": {
"label": "WH.ui.Instinct",
"abbrev": "ist",
"dex": {
"label": "WH.ui.Dexterity",
"abbrev": "dex",
"style": "dropdown",
"value": 0
},

View File

@ -82,7 +82,7 @@
<span class="item-name-label-header-long">
<h3><label class="items-title-text">Weapons</label></h3>
</span>
<span class="item-field-label-short">
<span class="item-field-label-medium">
<label class="short-label">{{localize "WH.ui.Type"}}</label>
</span>
<span class="item-field-label-medium">
@ -93,11 +93,11 @@
<li class="item flexrow list-item list-item-shadow" data-item-id="{{weapon._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{weapon.img}}" /></a>
<span class="item-name-label-long"><a class ="roll-weapon">{{weapon.name}}</a></span>
<span class="item-name-label-long"><a class="roll-weapon"><i class="fa-solid fa-dice-d20"></i>{{weapon.name}}</a></span>
<span class="item-field-label-short">{{weapon.system.weapontype}}</span>
<span class="item-field-label-medium">{{weapon.system.weapontype}}</span>
<span class="item-field-label-medium">{{perk.system.damage}}</span>
<span class="item-field-label-medium"><a class="roll-damage"><i class="fa-solid fa-dice-d20"></i>{{weapon.damageFormula}}</a></span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
@ -125,7 +125,7 @@
<li class="item flexrow list-item list-item-shadow" data-item-id="{{shield._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{shield.img}}" /></a>
<span class="item-name-label-long"><a class ="roll-weapon">{{shield.name}}</a></span>
<span class="item-name-label-long">{{shield.name}}</span>
<span class="item-field-label-short">{{shield.system.shieldtype}}</span>
@ -157,7 +157,7 @@
<li class="item flexrow list-item list-item-shadow" data-item-id="{{armor._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{armor.img}}" /></a>
<span class="item-name-label-long"><a class ="roll-weapon">{{armor.name}}</a></span>
<span class="item-name-label-long">{{armor.name}}</span>
<span class="item-field-label-short">{{armor.system.armortype}}</span>
@ -193,7 +193,7 @@
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{power.img}}" /></a>
<span class="item-name-label">
<a class="power-roll">{{power.name}}</a>
<a class="power-roll"><i class="fa-solid fa-dice-d20"></i>{{power.name}}</a>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">

View File

@ -13,19 +13,26 @@
</div>
{{/if}}
<div class="flexcol">
</div>
<div>
<ul>
{{#if stat}}
<li>{{localize stat.label}} : {{stat.value}}</li>
{{/if}}
{{#if weapon}}
<li>{{localize "WH.ui.weapon"}} : {{weapon.name}}</li>
{{/if}}
{{#if hasBM}}
<li>Bonus/Malus : {{bonusMalus}}</li>
{{/if}}
<div>
<ul>
{{#if stat}}
<li>{{localize stat.label}} : {{stat.value}}</li>
{{/if}}
<li>Bonus/Malus : {{bonusMalus}}</li>
{{#if power}}
<li>{{localize "WH.ui.power"}} : {{power.name}}</li>
<li>{{{powerText}}}</li>
{{else}}
<li><strong>Result : {{roll.total}} </strong></li>
{{/if}}
<li><strong>Result : {{roll.total}} </strong></li>
</ul>
</div>
</ul>
</div>
</div>

View File

@ -2,7 +2,7 @@
<span class="item-field-label-medium" name="{{key}}">
<h4 class="item-field-label-medium">
{{#if roll}}
<a class="roll-this stat-margin" data-type="{{path}}" data-key="{{key}}">{{localize stat.label}}</a>
<i class="fa-solid fa-dice-d20"></i><a class="roll-this stat-margin" data-type="{{path}}" data-key="{{key}}">{{localize stat.label}}</a>
{{else}}
{{localize stat.label}}
{{/if}}

View File

@ -17,8 +17,14 @@
{{#if weapon}}
<div class="flexrow">
<span class="roll-dialog-label">Weapon : </span>
<span class="roll-dialog-label">{{weapon.name}}</span>
<span class="item-field-label-medium">Weapon : </span>
<span class="item-field-label-medium">{{weapon.name}}</span>
{{#if (eq mode "damage")}}
<div class="flexrow">
<span class="item-field-label-medium">Damage : </span>
<span class="item-field-label-medium">{{weapon.damageFormula}}</span>
</div>
{{/if}}
</div>
{{/if}}
@ -33,6 +39,26 @@
</div>
{{/if}}
{{#if power}}
<div class="flexrow">
<span class="item-field-label-medium">Power : </span>
<span class="item-field-label-medium">{{power.name}}</span>
</div>
<div class="flexrow">
<span class="item-field-label-medium">Power Level : </span>
<select class="item-field-label-medium" type="text" id="powerLevel" value="{{powerLevel}}">
{{#select powerLevel}}
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4_1">4 - 1</option>
<option value="4_2">4 - 2</option>
{{/select}}
</select>
</div>
{{/if}}
{{#if hasBM}}
<div class="flexrow">
<span class="item-field-label-medium">Bonus/Malus : </span>
<select class="item-field-label-medium" type="text" id="bonusMalus" value="{{bonusMalus}}">
@ -53,6 +79,8 @@
{{/select}}
</select>
</div>
</div>
{{/if}}
</div>
</form>