This commit is contained in:
sladecraven 2022-01-14 18:20:15 +01:00
parent c2c335181b
commit 3874495bcf
6 changed files with 111 additions and 46 deletions

View File

@ -44,7 +44,7 @@ export class PegasusActorSheet extends ActorSheet {
optionsDiceList: PegasusUtility.getOptionsDiceList(),
optionsLevel: PegasusUtility.getOptionsLevel(),
weapons: this.actor.checkAndPrepareWeapons( duplicate(this.actor.getWeapons()) ),
armors: duplicate(this.actor.getArmors()),
armors: this.actor.checkAndPrepareArmors( duplicate(this.actor.getArmors())),
shields: duplicate(this.actor.getShields()),
equipments: duplicate(this.actor.getEquipments()),
perks: duplicate(this.actor.getPerks()),
@ -150,12 +150,22 @@ export class PegasusActorSheet extends ActorSheet {
const specId = li.data("item-id");
this.actor.rollSpec(specId);
});
html.find('.power-roll').click((event) => {
const li = $(event.currentTarget).parents(".item");
const powerId = li.data("item-id");
this.actor.rollPower(powerId);
});
html.find('.weapon-roll').click((event) => {
const li = $(event.currentTarget).parents(".item");
const weaponId = li.data("item-id");
this.actor.rollWeapon(weaponId);
});
html.find('.armor-roll').click((event) => {
const li = $(event.currentTarget).parents(".item");
const armorId = li.data("item-id");
this.actor.rollArmor(armorId);
});
html.find('.weapon-damage-roll').click((event) => {
const li = $(event.currentTarget).parents(".item");
const weaponId = li.data("item-id");

View File

@ -111,7 +111,7 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
getArmors() {
let comp = this.data.items.filter(item => item.type == 'armor');
let comp = duplicate(this.data.items.filter(item => item.type == 'armor') || []);
return comp;
}
/* -------------------------------------------- */
@ -127,12 +127,22 @@ export class PegasusActor extends Actor {
let role = this.data.items.filter(item => item.type == 'role');
return role[0] ?? [];
}
/* -------------------------------------------- */
checkAndPrepareArmor(armor) {
armor.data.resistanceDice = PegasusUtility.getDiceFromLevel(armor.data.resistance);
}
/* -------------------------------------------- */
checkAndPrepareArmors(armors) {
for (let item of armors) {
this.checkAndPrepareArmor(item);
}
return armors;
}
/* -------------------------------------------- */
checkAndPrepareWeapon(weapon) {
weapon.data.damageDice = PegasusUtility.getDiceFromLevel(weapon.data.damage);
}
/* -------------------------------------------- */
checkAndPrepareWeapons(weapons) {
for (let item of weapons) {
@ -436,37 +446,6 @@ export class PegasusActor extends Actor {
}
}
/* -------------------------------------------- */
async rollMR() {
let mr = duplicate(this.data.data.mr);
if (mr) {
mr.dice = PegasusUtility.getDiceFromLevel(mr.value);
let rollData = {
rollId: randomID(16),
mode: "MR",
alias: this.name,
actorImg: this.img,
actorId: this.id,
img: this.img,
rollMode: game.settings.get("core", "rollMode"),
title: `${mr.label} `,
stat: mr,
activePerks: duplicate(this.getActivePerks()),
optionsDiceList: PegasusUtility.getOptionsDiceList(),
bonusDicesLevel: 0,
hindranceDicesLevel: 0,
otherDicesLevel: 0,
}
this.syncRoll(rollData);
let rollDialog = await PegasusRollDialog.create(this, rollData);
console.log(rollDialog);
rollDialog.render(true);
} else {
ui.notifications.warn("MR not found !");
}
}
/* -------------------------------------------- */
getCommonRollData() {
let rollData = {
@ -530,6 +509,7 @@ export class PegasusActor extends Actor {
let stat = this.getStat(statKey);
if (stat) {
let rollData = this.getCommonRollData()
rollData.specList = this.getRelevantSpec(armor.data.statistic)
rollData.mode = "stat"
rollData.title = `Stat ${stat.label}`;
rollData.stat = stat;
@ -556,6 +536,24 @@ export class PegasusActor extends Actor {
}
}
/* -------------------------------------------- */
async rollMR() {
let mr = duplicate(this.data.data.mr);
if (mr) {
mr.dice = PegasusUtility.getDiceFromLevel(mr.value);
let rollData = this.getCommonRollData()
rollData.mode = "MR"
rollData.stat = mr
rollData.activePerks = duplicate(this.getActivePerks()),
rollData.specList = this.getRelevantSpec(armor.data.statistic),
this.startRoll(rollData);
} else {
ui.notifications.warn("MR not found !");
}
}
/* -------------------------------------------- */
async deleteAllItemsByType(itemType) {
let items = this.data.items.filter(item => item.type == itemType);
@ -755,9 +753,35 @@ export class PegasusActor extends Actor {
//console.log("ROLLDATA DEFENDER !!!", rollData);
}
}
/* -------------------------------------------- */
async rollArmor(armorId) {
let armor = this.data.items.get(armorId)
if (armor) {
let rollData = this.getCommonRollData()
armor = duplicate(armor);
this.checkAndPrepareArmor(armor);
rollData.mode = "armor"
rollData.img = armor.img
rollData.armor = armor
rollData.title = `Armor : ${armor.name}`
rollData.stat = this.getStat(armor.data.statistic)
rollData.specList = this.getRelevantSpec(armor.data.statistic)
rollData.activePerks = duplicate(this.getActivePerks())
rollData.isResistance = true;
rollData.otherDicesLevel = armor.data.resistance
//this.updateWithTarget(rollData);
this.startRoll(rollData);
} else {
ui.notifications.warn("Armor not found !", weaponId);
}
}
/* -------------------------------------------- */
async rollWeapon(weaponId, damage=false) {
async rollWeapon(weaponId, damage = false) {
let weapon = this.data.items.get(weaponId)
if (weapon) {
@ -785,4 +809,25 @@ export class PegasusActor extends Actor {
}
}
/* -------------------------------------------- */
async rollPower(powerId) {
let power = this.data.items.get(powerId)
if (power) {
let rollData = this.getCommonRollData()
power = duplicate(power);
rollData.mode = "power"
rollData.img = power.img
rollData.power = power
rollData.title = `Power : ${power.name}`
rollData.stat = this.getStat(power.data.statistic)
rollData.specList = this.getRelevantSpec(power.data.statistic)
rollData.activePerks = duplicate(this.getActivePerks())
this.startRoll(rollData);
} else {
ui.notifications.warn("Power not found !", powerId);
}
}
}

View File

@ -16,7 +16,7 @@ export class PegasusRollDialog extends Dialog {
} else if (rollData.mode == "spec") {
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-spec.html', rollData);
options.height = 360;
} else if (rollData.mode == "weapon") {
} else if (rollData.mode == "weapon" || rollData.mode == "armor" || rollData.mode == "power") {
html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-weapon.html', rollData);
options.height = 320;
} else {

View File

@ -163,6 +163,6 @@
"templateVersion": 57,
"title": "Pegasus RPG",
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
"version": "0.1.1",
"version": "0.1.2",
"background" : "./images/ui/pegasus_welcome_page.webp"
}

View File

@ -259,8 +259,6 @@
<li class="item stat flexrow list-item" data-item-id="{{weapon._id}}">
<img class="sheet-competence-img" src="{{weapon.img}}" />
<span class="generic-label"><a class="weapon-roll">{{weapon.name}}</a></span>
<span class="generic-label">{{weapon.data.typeText}}</span>
<span class="generic-label">Speed {{weapon.data.speed}}</span>
<span class="generic-label"><a class="weapon-damage-roll">Damage {{weapon.data.damageDice}}</a></span>
<div class="item-controls">
<a class="item-control item-equip" title="Equip">{{#if weapon.data.equipped}}<i
@ -279,7 +277,8 @@
{{#each armors as |armor key|}}
<li class="item stat flexrow list-item" data-item-id="{{armor._id}}">
<img class="sheet-competence-img" src="{{armor.img}}" />
<span class="stat-label outfit-label">{{armor.name}}</span>
<span class="stat-label outfit-label"><a class="armor-roll">{{armor.name}}</a></span>
<span class="stat-label outfit-label">Res. {{armor.data.resistanceDice}}</span>
<div class="item-controls">
<a class="item-control item-equip" title="Worn">{{#if armor.data.equipped}}<i
class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>

View File

@ -21,19 +21,30 @@
{{#if weapon}}
<li>Weapon : {{weapon.name}}</li>
{{/if}}
{{#if power}}
<li>Power : {{power.name}}</li>
{{/if}}
{{#if isDamage}}
<li>Weapon Damage Dice : {{weapon.data.damageDice}}</li>
{{/if}}
{{#if isResistance}}
<li>Armor Resistance Dice : {{armor.data.resistanceDice}}</li>
{{/if}}
{{#if stat}}
<li>Statistic : {{stat.label}}</li>
{{/if}}
{{#if spec}}
<li>Specialisation : {{spec.name}}</li>
{{/if}}
{{#if isDamage}}
<li><strong>Damages : {{finalScore}}</strong>
{{#if isResistance}}
<li><strong>Defense Result : {{finalScore}}</strong>
{{else}}
<li><strong>Final Result : {{finalScore}}</strong>
{{#if isDamage}}
<li><strong>Damages : {{finalScore}}</strong>
{{else}}
<li><strong>Final Result : {{finalScore}}</strong>
{{/if}}
{{/if}}
{{#if linkedRollId}}