v0.5 fixes

This commit is contained in:
sladecraven 2022-07-19 00:18:46 +02:00
parent bf52b61a0d
commit 2ab1cbe24c
12 changed files with 255 additions and 52 deletions

View File

@ -57,6 +57,8 @@ export class PegasusActorSheet extends ActorSheet {
role: duplicate(this.actor.getRole()),
effects: duplicate(this.actor.getEffects()),
moneys: duplicate(this.actor.getMoneys()),
virtues: duplicate(this.actor.getVirtues()),
vices: duplicate(this.actor.getVices()),
encCapacity: this.actor.getEncumbranceCapacity(),
levelRemainingList: this.actor.getLevelRemainingList(),
containersTree: this.actor.containersTree,
@ -321,7 +323,12 @@ export class PegasusActorSheet extends ActorSheet {
this.actor.activatePower( li.data("item-id") );
this.render(true);
});
html.find('.vice-virtue-activate').click(ev => {
const li = $(ev.currentTarget).parents(".item")
this.actor.activateViceOrVirtue( li.data("item-id") )
this.render(true);
})
html.find('.change-worstfear').change(ev => {
this.actor.manageWorstFear( ev.currentTarget.checked )
});

View File

@ -110,6 +110,16 @@ export class PegasusActor extends Actor {
return comp;
}
/* -------------------------------------------- */
getVirtues() {
let comp = this.data.items.filter(item => item.type == 'virtue');
return comp;
}
/* -------------------------------------------- */
getVices() {
let comp = this.data.items.filter(item => item.type == 'vice');
return comp;
}
/* -------------------------------------------- */
getArmors() {
let comp = duplicate(this.data.items.filter(item => item.type == 'armor') || []);
return comp;
@ -222,6 +232,37 @@ export class PegasusActor extends Actor {
}
}
/* -------------------------------------------- */
async activateViceOrVirtue(itemId) {
let item = this.data.items.find(item => item.id == itemId)
if (item && item.data.data) {
let nrg = duplicate(this.data.data.nrg)
if (!item.data.data.activated) { // Current value
let effects = []
for (let effect of item.data.data.effectsgained) {
effect.data.powerId = itemId // Link to the perk, in order to dynamically remove them
effects.push(effect)
}
if (effects.length) {
await this.createEmbeddedDocuments('Item', effects)
}
} else {
let toRem = []
for (let item of this.data.items) {
if (item.type == 'effect' && item.data.data.powerId == itemId) {
toRem.push(item.id)
}
}
if (toRem.length) {
await this.deleteEmbeddedDocuments('Item', toRem)
}
}
let update = { _id: item.id, "data.activated": !item.data.data.activated }
await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
async activatePower(itemId) {
let item = this.data.items.find(item => item.id == itemId)
@ -444,6 +485,9 @@ export class PegasusActor extends Actor {
chatData.content = `<div>${this.name} has used a Momentum</div`
}
ChatMessage.create(chatData)
if (incDec < 0) {
PegasusUtility.showMomentumDialog(this.id)
}
} else {
ui.notifications.warn("Momentum cannot go below 0")
}
@ -862,10 +906,10 @@ export class PegasusActor extends Actor {
return this.data.data.biodata.currentlevelremaining
}
/* -------------------------------------------- */
modifyHeroLevelRemaining( incDec) {
modifyHeroLevelRemaining(incDec) {
let biodata = duplicate(this.data.data.biodata)
biodata.currentlevelremaining = Math.max(biodata.currentlevelremaining+incDec, 0)
this.update( {"data.biodata": biodata} )
biodata.currentlevelremaining = Math.max(biodata.currentlevelremaining + incDec, 0)
this.update({ "data.biodata": biodata })
return biodata.currentlevelremaining
}
@ -1236,7 +1280,7 @@ export class PegasusActor extends Actor {
}
let diceKey = PegasusUtility.getDiceFromLevel(rollData.stat.value)
rollData.dicePool.push({
name: "stat", key: diceKey, mod: rollData.stat.mod,
name: "stat", key: diceKey, level: rollData.stat.value, mod: rollData.stat.mod,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
})
}
@ -1245,15 +1289,16 @@ export class PegasusActor extends Actor {
this.addArmorsShields(rollData, statKey, useShield)
this.addWeapons(rollData, statKey, useShield)
this.addEquipments(rollData, statKey)
console.log("ROLLDATA", rollData)
return rollData
}
/* -------------------------------------------- */
getLevelRemainingList( ) {
getLevelRemainingList() {
let options = []
for (let i=0; i<=this.data.data.biodata.maxlevelremaining; i++) {
options.push( `<option value="${i}">${i}</option>`)
for (let i = 0; i <= this.data.data.biodata.maxlevelremaining; i++) {
options.push(`<option value="${i}">${i}</option>`)
}
return options.join("\n")
}
@ -1262,10 +1307,9 @@ export class PegasusActor extends Actor {
async startRoll(rollData) {
this.syncRoll(rollData);
//console.log("ROLL DATA", rollData)
let rollDialog = await PegasusRollDialog.create(this, rollData);
console.log(rollDialog);
let rollDialog = await PegasusRollDialog.create(this, rollData)
console.log(rollDialog)
rollDialog.render(true);
}
/* -------------------------------------------- */

View File

@ -48,7 +48,7 @@ export class PegasusRollDialog extends Dialog {
if (effect) {
effect.applied = toggled
let level, genre, idVal
let level, genre, idVal, key
if (effect.type == 'hindrance') {
level = effect.value
genre = 'positive'
@ -61,30 +61,36 @@ export class PegasusRollDialog extends Dialog {
effectData.data.isUsed = toggled
if (effectData.data.reducedicevalue || effectData.data.statdice) {
idVal = "#statDicesLevel"
key = "statLevelBonus"
}
if (effectData.data.otherdice) {
idVal = "#damageDiceLevel"
key = "damageLevelBonus"
}
if (effectData.data.hindrance) {
idVal = "#hindranceDicesLevel"
genre = 'positive' // Dynamic fix
key = "hindranceLevelBonus"
}
}
// Now process the dice level update
if (idVal) {
let newLevel = Number($(idVal).val())
if (toggled) {
let newLevel = Number($(idVal).val())
console.log("Ongoing", newLevel, toggled, idVal)
if (genre == 'positive') {
if (genre == 'positive') {
newLevel += Number(level)
this.rollData[key] += Number(level)
} else {
newLevel -= Number(level)
this.rollData[key] -= Number(level)
}
} else {
if (genre == 'positive') {
newLevel -= Number(level)
this.rollData[key] -= Number(level)
} else {
newLevel += Number(level)
this.rollData[key] += Number(level)
}
}
newLevel = (newLevel < 0) ? 0 : newLevel
@ -210,7 +216,7 @@ export class PegasusRollDialog extends Dialog {
html.find('#statDicesLevel').change((event) => {
this.rollData.statDicesLevel = Number(event.currentTarget.value)
});
html.find('#specDicesLevel').change( async (event) => {
html.find('#specDicesLevel').change(async (event) => {
this.rollData.specDicesLevel = Number(event.currentTarget.value)
PegasusUtility.updateSpecDicePool(this.rollData)
this.refreshDialog()
@ -244,15 +250,16 @@ export class PegasusRollDialog extends Dialog {
html.find('.pool-add-dice').click(async (event) => {
let diceKey = $(event.currentTarget).data("dice-key")
PegasusUtility.addDicePool( this.rollData, diceKey)
let diceLevel = $(event.currentTarget).data("dice-level")
PegasusUtility.addDicePool(this.rollData, diceKey, diceLevel)
this.refreshDialog()
})
html.find('.pool-remove-dice').click(async (event) => {
let idx = $(event.currentTarget).data("dice-idx")
PegasusUtility.removeFromDicePool( this.rollData, idx)
PegasusUtility.removeFromDicePool(this.rollData, idx)
this.refreshDialog()
})
}
}

View File

@ -60,9 +60,9 @@ export class PegasusUtility {
/* -------------------------------------------- */
static getDiceList() {
return [{ key: "d4", img: "systems/fvtt-pegasus-rpg/images/dice/d4.webp" }, { key: "d6", img: "systems/fvtt-pegasus-rpg/images/dice/d6.webp" },
{ key: "d8", img: "systems/fvtt-pegasus-rpg/images/dice/d8.webp" }, { key: "d10", img: "systems/fvtt-pegasus-rpg/images/dice/d10.webp" },
{ key: "d12", img: "systems/fvtt-pegasus-rpg/images/dice/d12.webp" }]
return [{ key: "d4", level: 1, img: "systems/fvtt-pegasus-rpg/images/dice/d4.webp" }, { key: "d6", level: 2, img: "systems/fvtt-pegasus-rpg/images/dice/d6.webp" },
{ key: "d8", level: 3, img: "systems/fvtt-pegasus-rpg/images/dice/d8.webp" }, { key: "d10", level: 4, img: "systems/fvtt-pegasus-rpg/images/dice/d10.webp" },
{ key: "d12", level: 5, img: "systems/fvtt-pegasus-rpg/images/dice/d12.webp" }]
}
/* -------------------------------------------- */
@ -72,7 +72,7 @@ export class PegasusUtility {
if (effect && effect.applied && effect.effect.data.bonusdice) {
let diceKey = PegasusUtility.getDiceFromLevel(effect.effect.data.effectlevel)
let newDice = {
name: "effect-bonus-dice", key: diceKey, effect: effect.effect.name,
name: "effect-bonus-dice", key: diceKey, level: effect.effect.data.effectlevel, effect: effect.effect.name,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
}
newDicePool.push(newDice)
@ -90,7 +90,7 @@ export class PegasusUtility {
let diceList = diceKey.split(" ")
for(let myDice of diceList) {
let newDice = {
name: "damage", key: myDice,
name: "damage", key: myDice, level: rollData.damageDiceLevel,
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
}
newDicePool.push(newDice)
@ -108,7 +108,7 @@ export class PegasusUtility {
let diceList = diceKey.split(" ")
for(let myDice of diceList) {
let newDice = {
name: "spec", key: myDice,
name: "spec", key: myDice, level: rollData.specDicesLevel,
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
}
newDicePool.push(newDice)
@ -118,9 +118,9 @@ export class PegasusUtility {
}
/* -------------------------------------------- */
static addDicePool(rollData, diceKey) {
static addDicePool(rollData, diceKey, level) {
let newDice = {
name: "dice-click", key: diceKey,
name: "dice-click", key: diceKey, level: level,
img: `systems/fvtt-pegasus-rpg/images/dice/${diceKey}.webp`
}
rollData.dicePool.push(newDice)
@ -451,22 +451,22 @@ export class PegasusUtility {
/* -------------------------------------------- */
static updateRollData(rollData) {
let id = rollData.rollId;
let oldRollData = this.rollDataStore[id] || {};
let newRollData = mergeObject(oldRollData, rollData);
this.rollDataStore[id] = newRollData;
let id = rollData.rollId
let oldRollData = this.rollDataStore[id] || {}
let newRollData = mergeObject(oldRollData, rollData)
this.rollDataStore[id] = newRollData
}
/* -------------------------------------------- */
static saveRollData(rollData) {
game.socket.emit("system.pegasus-rpg", {
name: "msg_update_roll", data: rollData
}); // Notify all other clients of the roll
this.updateRollData(rollData);
this.updateRollData(rollData)
}
/* -------------------------------------------- */
static getRollData(id) {
return this.rollDataStore[id];
return this.rollDataStore[id]
}
/* -------------------------------------------- */
@ -570,15 +570,51 @@ export class PegasusUtility {
for (let effect of rollData.effectsList) {
if (effect.effect.data.isUsed && effect.effect.data.oneuse) {
toRem.push(effect.effect._id)
ChatMessage.create({content: `One used effect ${effect.effect.name} has been auto-deleted.`})
}
}
if (toRem.length > 0) {
console.log("Going to remove one use effects", toRem)
//console.log("Going to remove one use effects", toRem)
let actor = game.actors.get(rollData.actorId)
actor.deleteEmbeddedDocuments('Item', toRem)
}
}
/* -------------------------------------------- */
static async momentumReroll(actorId) {
let actor = game.actors.get(actorId)
let rollData = actor.lastRoll
if (rollData) {
rollData.rerollMomentum = true
PegasusUtility.rollPegasus(rollData)
this.actor.lastRoll = undefined
} else {
ui.notifications.warn("No last roll registered....")
}
}
/* -------------------------------------------- */
static async showMomentumDialog( actorId) {
let d = new Dialog({
title: "Momentum reroll",
content: "<p>Do you want to re-roll your last roll ?</p>",
buttons: {
one: {
icon: '<i class="fas fa-check"></i>',
label: "Cancel",
callback: () => this.close()
},
two: {
icon: '<i class="fas fa-times"></i>',
label: "Reroll",
callback: () => PegasusUtility.momentumReroll(actorId)
}
},
default: "Reroll",
})
d.render(true)
}
/* -------------------------------------------- */
static async rollPegasus(rollData) {
@ -626,13 +662,17 @@ export class PegasusUtility {
let diceFormulaTab = []
for (let dice of rollData.dicePool) {
diceFormulaTab.push(dice.key)
let level = dice.level
if (dice.name == "stat" ) {
level += rollData.statLevelBonus
}
diceFormulaTab.push( this.getFoundryDiceFromLevel(level) )
}
let diceFormula = '{' + diceFormulaTab.join(', ') + '}kh + ' + (rollData.stat?.mod || 0)
// Performs roll
let myRoll = rollData.roll
if (!myRoll || rollData.reroll) { // New rolls only of no rerolls
if (!myRoll || rollData.reroll || rollData.rerollMomentum) { // New rolls only of no rerolls
myRoll = new Roll(diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = myRoll
@ -669,7 +709,8 @@ export class PegasusUtility {
this.removeOneUseEffects(rollData) // Unused for now
// And save the roll
this.saveRollData(rollData);
this.saveRollData(rollData)
actor.lastRoll = rollData
}
/* -------------------------------------------- */
@ -812,6 +853,10 @@ export class PegasusUtility {
rollId: randomID(16),
rollMode: game.settings.get("core", "rollMode"),
bonusDicesLevel: 0,
statLevelBonus: 0,
damageLevelBonus: 0,
specLevelBonus: 0,
hindranceLevelBonus: 0,
hindranceDicesLevel: 0,
otherDicesLevel: 0,
statDicesLevel: 0,

View File

@ -1412,6 +1412,11 @@ Focus FOC: #ff0084
max-width: 14rem;
min-width: 14rem;
}
.item-name-label-header-long2 {
flex-grow:2;
max-width: 24rem;
min-width: 24rem;
}
.item-name-label {
flex-grow:2;
max-width: 10rem;
@ -1422,6 +1427,11 @@ Focus FOC: #ff0084
max-width: 12rem;
min-width: 12rem;
}
.item-name-label-long2 {
flex-grow:2;
max-width: 22rem;
min-width: 22rem;
}
.item-name-label-level2 {
flex-grow:2;
max-width: 9rem;

View File

@ -180,9 +180,9 @@
"styles": [
"styles/simple.css"
],
"templateVersion": 94,
"templateVersion": 95,
"title": "Pegasus RPG",
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
"version": "0.5.15",
"version": "0.6.0",
"background" : "./images/ui/pegasus_welcome_page.webp"
}

View File

@ -271,12 +271,14 @@
"unavailablevice": [],
"effectsgained": [],
"threatlevel": 0,
"activated": false,
"description": ""
},
"vice": {
"unavailablevirtue": [],
"effectsgained": [],
"threatlevel": 0,
"activated": false,
"description": ""
},
"specialisation": {

View File

@ -175,14 +175,14 @@
<h3><label class="items-title-text">Perks</label></h3>
</span>
<span class="item-field-label-short">
<label class="short-label">#Targets</label>
</span>
<span class="item-field-label-long">
<label class="short-label">Level</label>
</span>
<span class="item-field-label-medium">
<label class="short-label">Range</label>
</span>
<span class="item-field-label-short">
<label class="short-label">#Targets</label>
</span>
<span class="item-field-label-long">
<label class="short-label">Status</label>
</span>
@ -208,9 +208,9 @@
<span class="item-field-label-short">{{perk.data.level}}</span>
{{#if perk.data.features.range.flag}}
<span class="item-field-label-long">{{perk.data.features.range.value}}</span>
<span class="item-field-label-medium">{{perk.data.features.range.value}}</span>
{{else}}
<span class="item-field-label-long">&nbsp;-&nbsp;</span>
<span class="item-field-label-medium">&nbsp;-&nbsp;</span>
{{/if}}
{{#if perk.data.features.nbtargets.flag}}
@ -219,6 +219,7 @@
<span class="item-field-label-short">&nbsp;-&nbsp;</span>
{{/if}}
<span class="item-field-label-long">
<select class="perk-status" type="text" value="{{perk.data.status}}" data-dtype="String">
{{#select perk.data.status}}
@ -279,7 +280,7 @@
<ul class="stat-list alternate-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<span class="item-name-label-header-long2">
<h3><label class="items-title-text">Effects</label></h3>
</span>
<span class="item-field-label-short">
@ -301,7 +302,7 @@
data-item-id="{{effect._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{effect.img}}" /></a>
<span class="item-name-label">{{effect.name}}</span>
<span class="item-name-label-long2">{{effect.name}}</span>
<span class="item-field-label-short">{{effect.data.effectlevel}}</span>
<span class="item-field-label-short">{{upperFirst effect.data.type}}</span>
<span class="item-field-label-short">{{upperFirst effect.data.genre}}</span>
@ -840,7 +841,7 @@
</li>
</ul>
</div>
<div>
<div>
<ul>
<li class="flexrow item">
<label class="generic-label">Weight</label>
@ -878,8 +879,79 @@
</div>
</div>
<h3 class="items-title-bg">Psychology : </h3>
<div>
<ul class="stat-list alternate-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<h3><label class="items-title-text">Virtues</label></h3>
</span>
<span class="item-field-label-short">Status</label></span>
</li>
{{#each virtues as |virtue key|}}
<li class="item stat flexrow list-item list-item-shadow" data-arme-id="{{virtue.id}}"
data-item-id="{{virtue._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{virtue.img}}" /></a>
<span class="item-name-label">{{virtue.name}}</span>
<span class="item-field-label-short"><label class="short-label">
{{#if virtue.data.activated}}
Activated
{{else}}
&nbsp;-&nbsp;
{{/if}}
</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control vice-virtue-activate" title="Activated">{{#if virtue.data.activated}}<i
class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</div>
<div>
<ul class="stat-list alternate-list">
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<h3><label class="items-title-text">Vices</label></h3>
</span>
<span class="item-field-label-short">Status</label></span>
</li>
{{#each vices as |vice key|}}
<li class="item stat flexrow list-item list-item-shadow" data-arme-id="{{vice.id}}"
data-item-id="{{vice._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{vice.img}}" /></a>
<span class="item-name-label">{{vice.name}}</span>
<span class="item-field-label-short"><label class="short-label">
{{#if vice.data.activated}}
Activated
{{else}}
&nbsp;-&nbsp;
{{/if}}
</label>
</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
<a class="item-control vice-virtue-activate" title="Activated">{{#if vice.data.activated}}<i
class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
</div>
</li>
{{/each}}
</ul>
</div>
<ul>
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<h3><label class="items-title-text">Psychology</label></h3>
</span>
</li>
<li class="flexrow">
<label class="short-label">Worst Fear </label>
<input type="text" class="" name="data.biodata.worstfear" value="{{data.biodata.worstfear}}"
@ -915,8 +987,12 @@
</li>
</ul>
<h3 class="items-title-bg">Development : </h3>
<ul>
<li class="item flexrow list-item items-title-bg">
<span class="item-name-label-header">
<h3><label class="items-title-text">Development</label></h3>
</span>
</li>
<li class="flexrow">
<label class="short-label">Character Value : </label>
<input type="text" class="" name="data.biodata.charactervalue" value="{{data.biodata.charactervalue}}"

View File

@ -31,6 +31,12 @@
</ul>
</li>
<li class="flexrow">
<label class="generic-label">Activated ? </label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.activated" {{checked
data.activated}} /></label>
</li>
<li class="flexrow"><label class="generic-label">Effects Gained</label>
</li>
<li>

View File

@ -31,6 +31,12 @@
</ul>
</li>
<li class="flexrow">
<label class="generic-label">Activated ? </label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.activated" {{checked
data.activated}} /></label>
</li>
<li class="flexrow"><label class="generic-label">Effects Gained</label>
</li>
<li>

View File

@ -17,7 +17,7 @@
</li>
{{else}}
{{#if (count effect.effect.data.specaffected)}}
{{#each effect.effect.data.specaffected as |spec idx|}}
{{#each effect.effect.data.specaffected as |spec idx2|}}
{{#if (eq @root.specName spec.name)}}
<li class="flex-group-left">
<label class="attribute-value checkbox"><input type="checkbox" class="effect-clicked" id="effect-{{idx}}" data-effect-idx="{{idx}}" {{checked effect.applied}}/></label>

View File

@ -71,7 +71,7 @@
</span>
<div class="flexrow dice-pool-stack">
{{#each dicePool as |dice idx|}}
<span><a class="pool-remove-dice" data-dice-idx="{{idx}}" data-dice-key="{{dice.key}}"><img class="dice-pool-image"
<span><a class="pool-remove-dice" data-dice-idx="{{idx}}" data-dice-level="{{dice.level}}" data-dice-key="{{dice.key}}"><img class="dice-pool-image"
src="{{dice.img}}"></a></span>
{{/each}}
</div>
@ -79,7 +79,7 @@
<div class="flexrow">
{{#each diceList as |dice idx|}}
<span><a class="pool-add-dice" data-dice-key="{{dice.key}}"><img class="dice-pool-image"
<span><a class="pool-add-dice" data-dice-key="{{dice.key}}" data-dice-level="{{dice.level}}"><img class="dice-pool-image"
src="{{dice.img}}"></a></span>
{{/each}}
</div>