Fix numbering
This commit is contained in:
parent
9974c5365a
commit
f590e1fe6a
@ -224,17 +224,9 @@ export class PegasusActorSheet extends ActorSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onDrop(event) {
|
async _onDropItem(event, dragData) {
|
||||||
let data = event.dataTransfer.getData('text/plain');
|
let item = await PegasusUtility.searchItem( dragData)
|
||||||
if (data) {
|
this.actor.preprocessItem( event, item, true )
|
||||||
let dataItem = JSON.parse( data);
|
|
||||||
let npc = game.actors.get( dataItem.id);
|
|
||||||
if ( npc ) {
|
|
||||||
this.actor.addSubActor( dataItem.id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super._onDrop(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -255,8 +255,24 @@ export class PegasusActor extends Actor {
|
|||||||
getAttribute(attrKey) {
|
getAttribute(attrKey) {
|
||||||
return this.data.data.attributes[attrKey];
|
return this.data.data.attributes[attrKey];
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async preprocessItem( event, item, onDrop = false) {
|
||||||
|
if ( item.data.type == 'race') {
|
||||||
|
this.applyRace(item.data)
|
||||||
|
} else if ( item.data.type == 'ability') {
|
||||||
|
this.applyAbility(item.data, [], true)
|
||||||
|
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||||
|
} else {
|
||||||
|
if ( onDrop) {
|
||||||
|
await super._onDropItem(event, dragData)
|
||||||
|
} else {
|
||||||
|
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
async equipGear(equipmentId) {
|
async equipGear(equipmentId) {
|
||||||
let item = this.data.items.find(item => item.id == equipmentId);
|
let item = this.data.items.find(item => item.id == equipmentId);
|
||||||
if (item && item.data.data) {
|
if (item && item.data.data) {
|
||||||
@ -354,7 +370,7 @@ export class PegasusActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async computeNRGHealth() {
|
async computeNRGHealth() {
|
||||||
if ( this.isToken) return
|
if ( this.isToken ) return
|
||||||
if (this.isOwner || game.user.isGM) {
|
if (this.isOwner || game.user.isGM) {
|
||||||
let updates = {}
|
let updates = {}
|
||||||
let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod;
|
let phyDiceValue = PegasusUtility.getDiceValue(this.data.data.statistics.phy.value) + this.data.data.secondary.health.bonus + this.data.data.statistics.phy.mod;
|
||||||
@ -454,12 +470,15 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
applyAbility(ability, updates = []) {
|
applyAbility(ability, updates = [], directUpdate = false) {
|
||||||
if (ability.data.affectedstat != "notapplicable") {
|
if (ability.data.affectedstat != "notapplicable") {
|
||||||
let stat = duplicate(this.data.data.statistics[ability.data.affectedstat])
|
let stat = duplicate(this.data.data.statistics[ability.data.affectedstat])
|
||||||
stat.value += parseInt(ability.data.statlevelincrease)
|
stat.value += parseInt(ability.data.statlevelincrease)
|
||||||
stat.mod += parseInt(ability.data.statmodifier)
|
stat.mod += parseInt(ability.data.statmodifier)
|
||||||
updates[`data.statistics.${ability.data.affectedstat}`] = stat
|
updates[`data.statistics.${ability.data.affectedstat}`] = stat
|
||||||
|
if(directUpdate) {
|
||||||
|
this.update(updates)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -470,7 +489,7 @@ export class PegasusActor extends Actor {
|
|||||||
newItems.push(race);
|
newItems.push(race);
|
||||||
|
|
||||||
for (let ability of race.data.abilities) {
|
for (let ability of race.data.abilities) {
|
||||||
newItems.push(ability);
|
newItems.push(ability)
|
||||||
this.applyAbility(ability, updates)
|
this.applyAbility(ability, updates)
|
||||||
}
|
}
|
||||||
if (race.data.powersgained) {
|
if (race.data.powersgained) {
|
||||||
|
@ -197,16 +197,6 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
async searchItem( dataItem) {
|
|
||||||
let item;
|
|
||||||
if (dataItem.pack) {
|
|
||||||
item = await fromUuid("Compendium."+dataItem.pack+"."+dataItem.id);
|
|
||||||
} else {
|
|
||||||
item = game.items.get(dataItem.id )
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async addAbility(event, item, dataItem) {
|
async addAbility(event, item, dataItem) {
|
||||||
let newItem = duplicate(item.data);
|
let newItem = duplicate(item.data);
|
||||||
@ -362,7 +352,7 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
let data = event.dataTransfer.getData('text/plain');
|
let data = event.dataTransfer.getData('text/plain');
|
||||||
if (data) {
|
if (data) {
|
||||||
let dataItem = JSON.parse( data );
|
let dataItem = JSON.parse( data );
|
||||||
let item = await this.searchItem( dataItem);
|
let item = await PegasusUtility.searchItem( dataItem);
|
||||||
if ( item.data.type == 'specialisation') {
|
if ( item.data.type == 'specialisation') {
|
||||||
return this.addEffectSpec( event, item, dataItem);
|
return this.addEffectSpec( event, item, dataItem);
|
||||||
}
|
}
|
||||||
@ -373,7 +363,7 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
let data = event.dataTransfer.getData('text/plain');
|
let data = event.dataTransfer.getData('text/plain');
|
||||||
if (data) {
|
if (data) {
|
||||||
let dataItem = JSON.parse( data );
|
let dataItem = JSON.parse( data );
|
||||||
let item = await this.searchItem( dataItem);
|
let item = await PegasusUtility.searchItem( dataItem);
|
||||||
if ( item.data.type == 'ability') {
|
if ( item.data.type == 'ability') {
|
||||||
return this.addAbility( event, item, dataItem);
|
return this.addAbility( event, item, dataItem);
|
||||||
}
|
}
|
||||||
@ -387,7 +377,7 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
let data = event.dataTransfer.getData('text/plain');
|
let data = event.dataTransfer.getData('text/plain');
|
||||||
if (data) {
|
if (data) {
|
||||||
let dataItem = JSON.parse( data );
|
let dataItem = JSON.parse( data );
|
||||||
let item = await this.searchItem( dataItem);
|
let item = await PegasusUtility.searchItem( dataItem);
|
||||||
if ( item.data.type == 'specialisation') {
|
if ( item.data.type == 'specialisation') {
|
||||||
return this.addPerkSpecialisation( event, item, dataItem);
|
return this.addPerkSpecialisation( event, item, dataItem);
|
||||||
}
|
}
|
||||||
@ -398,7 +388,7 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
let data = event.dataTransfer.getData('text/plain');
|
let data = event.dataTransfer.getData('text/plain');
|
||||||
if (data) {
|
if (data) {
|
||||||
let dataItem = JSON.parse( data );
|
let dataItem = JSON.parse( data );
|
||||||
let item = await this.searchItem( dataItem);
|
let item = await PegasusUtility.searchItem( dataItem);
|
||||||
if ( item.data.type == 'power') {
|
if ( item.data.type == 'power') {
|
||||||
return this.addPower( event, item, dataItem);
|
return this.addPower( event, item, dataItem);
|
||||||
}
|
}
|
||||||
@ -408,7 +398,7 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
let data = event.dataTransfer.getData('text/plain');
|
let data = event.dataTransfer.getData('text/plain');
|
||||||
if (data) {
|
if (data) {
|
||||||
let dataItem = JSON.parse( data );
|
let dataItem = JSON.parse( data );
|
||||||
let item = await this.searchItem( dataItem);
|
let item = await PegasusUtility.searchItem( dataItem);
|
||||||
if ( item.data.type == 'power') {
|
if ( item.data.type == 'power') {
|
||||||
return this.addAbilityPower( event, item, dataItem);
|
return this.addAbilityPower( event, item, dataItem);
|
||||||
}
|
}
|
||||||
@ -425,7 +415,7 @@ export class PegasusItemSheet extends ItemSheet {
|
|||||||
let data = event.dataTransfer.getData('text/plain');
|
let data = event.dataTransfer.getData('text/plain');
|
||||||
if (data) {
|
if (data) {
|
||||||
let dataItem = JSON.parse( data );
|
let dataItem = JSON.parse( data );
|
||||||
let item = await this.searchItem( dataItem);
|
let item = await PegasusUtility.searchItem( dataItem);
|
||||||
if ( item.data.type == 'specialisation') {
|
if ( item.data.type == 'specialisation') {
|
||||||
return this.addRoleSpecialisation( event, item, dataItem);
|
return this.addRoleSpecialisation( event, item, dataItem);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import { PegasusNPCSheet } from "./pegasus-npc-sheet.js";
|
|||||||
import { PegasusUtility } from "./pegasus-utility.js";
|
import { PegasusUtility } from "./pegasus-utility.js";
|
||||||
import { PegasusCombat } from "./pegasus-combat.js";
|
import { PegasusCombat } from "./pegasus-combat.js";
|
||||||
import { PegasusItem } from "./pegasus-item.js";
|
import { PegasusItem } from "./pegasus-item.js";
|
||||||
|
import { PegasusToken } from "./pegasus-token.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Foundry VTT Initialization */
|
/* Foundry VTT Initialization */
|
||||||
@ -52,9 +53,10 @@ Hooks.once("init", async function () {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
// Define custom Entity classes
|
// Define custom Entity classes
|
||||||
CONFIG.Combat.documentClass = PegasusCombat;
|
CONFIG.Combat.documentClass = PegasusCombat
|
||||||
CONFIG.Actor.documentClass = PegasusActor;
|
CONFIG.Actor.documentClass = PegasusActor
|
||||||
CONFIG.Item.documentClass = PegasusItem;
|
CONFIG.Item.documentClass = PegasusItem
|
||||||
|
//CONFIG.Token.objectClass = PegasusToken
|
||||||
game.system.pegasus = { };
|
game.system.pegasus = { };
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
6
modules/pegasus-token.js
Normal file
6
modules/pegasus-token.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { PegasusUtility } from "./pegasus-utility.js";
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
export class PegasusToken extends Token {
|
||||||
|
|
||||||
|
}
|
@ -17,6 +17,10 @@ export class PegasusUtility {
|
|||||||
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
||||||
PegasusUtility.pushInitiativeOptions(html, options);
|
PegasusUtility.pushInitiativeOptions(html, options);
|
||||||
});
|
});
|
||||||
|
Hooks.on("dropCanvasData", (canvas, data) => {
|
||||||
|
PegasusUtility.dropItemOnToken(canvas, data)
|
||||||
|
});
|
||||||
|
|
||||||
this.rollDataStore = {}
|
this.rollDataStore = {}
|
||||||
this.defenderStore = {}
|
this.defenderStore = {}
|
||||||
this.diceList = [];
|
this.diceList = [];
|
||||||
@ -34,14 +38,14 @@ export class PegasusUtility {
|
|||||||
});
|
});
|
||||||
Handlebars.registerHelper('notEmpty', function (list) {
|
Handlebars.registerHelper('notEmpty', function (list) {
|
||||||
return list.length > 0;
|
return list.length > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static pushInitiativeOptions(html, options) {
|
static pushInitiativeOptions(html, options) {
|
||||||
console.log('Option pushed....')
|
console.log('Option pushed....')
|
||||||
options.push( { name: "Apply -10", condition: true, icon: '<i class="fas fa-plus"></i>', callback: target => { PegasusCombat.decInitBy10(target.data('combatant-id'), -10); } } )
|
options.push({ name: "Apply -10", condition: true, icon: '<i class="fas fa-plus"></i>', callback: target => { PegasusCombat.decInitBy10(target.data('combatant-id'), -10); } })
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -55,6 +59,27 @@ export class PegasusUtility {
|
|||||||
this.specs = specs.map(i => i.toObject());
|
this.specs = specs.map(i => i.toObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static async dropItemOnToken(canvas, data) {
|
||||||
|
if (data.type != "Item") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const position = canvas.grid.getTopLeft(data.x, data.y)
|
||||||
|
let x = position[0]
|
||||||
|
let y = position[1]
|
||||||
|
const tokensList = [...canvas.tokens.placeables]
|
||||||
|
for(let token of tokensList) {
|
||||||
|
if ( x >= token.x && x <= (token.x + token.width)
|
||||||
|
&& y >= token.y && y <= (token.y + token.height) ) {
|
||||||
|
let item = await this.searchItem(data)
|
||||||
|
token.actor.preprocessItem("none", item, false )
|
||||||
|
console.log("Dropped !!!", item, token)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async loadCompendiumData(compendium) {
|
static async loadCompendiumData(compendium) {
|
||||||
const pack = game.packs.get(compendium);
|
const pack = game.packs.get(compendium);
|
||||||
@ -152,7 +177,6 @@ export class PegasusUtility {
|
|||||||
|
|
||||||
const templatePaths = [
|
const templatePaths = [
|
||||||
'systems/fvtt-pegasus-rpg/templates/editor-notes-gm.html',
|
'systems/fvtt-pegasus-rpg/templates/editor-notes-gm.html',
|
||||||
'systems/fvtt-pegasus-rpg/templates/partial-roll-common-dices.html',
|
|
||||||
'systems/fvtt-pegasus-rpg/templates/partial-roll-select-effects.html',
|
'systems/fvtt-pegasus-rpg/templates/partial-roll-select-effects.html',
|
||||||
'systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html',
|
'systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html',
|
||||||
'systems/fvtt-pegasus-rpg/templates/partial-options-level.html',
|
'systems/fvtt-pegasus-rpg/templates/partial-options-level.html',
|
||||||
@ -449,8 +473,8 @@ export class PegasusUtility {
|
|||||||
}
|
}
|
||||||
// Init stuf
|
// Init stuf
|
||||||
if (rollData.isInit) {
|
if (rollData.isInit) {
|
||||||
let combat = game.combats.get( rollData.combatId)
|
let combat = game.combats.get(rollData.combatId)
|
||||||
combat.updateEmbeddedDocuments("Combatant", [ { _id: rollData.combatantId, initiative: rollData.finalScore } ]);
|
combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]);
|
||||||
}
|
}
|
||||||
// And save the roll
|
// And save the roll
|
||||||
this.saveRollData(rollData);
|
this.saveRollData(rollData);
|
||||||
@ -539,6 +563,17 @@ export class PegasusUtility {
|
|||||||
game.socket.emit("system.fvtt-weapons-of-the-gods", { msg: "msg_gm_chat_message", data: chatGM });
|
game.socket.emit("system.fvtt-weapons-of-the-gods", { msg: "msg_gm_chat_message", data: chatGM });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
static async searchItem(dataItem) {
|
||||||
|
let item;
|
||||||
|
if (dataItem.pack) {
|
||||||
|
item = await fromUuid("Compendium." + dataItem.pack + "." + dataItem.id);
|
||||||
|
} else {
|
||||||
|
item = game.items.get(dataItem.id)
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static split3Columns(data) {
|
static split3Columns(data) {
|
||||||
|
|
||||||
|
@ -183,6 +183,6 @@
|
|||||||
"templateVersion": 64,
|
"templateVersion": 64,
|
||||||
"title": "Pegasus RPG",
|
"title": "Pegasus RPG",
|
||||||
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
|
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
|
||||||
"version": "0.2.7",
|
"version": "0.3.0",
|
||||||
"background" : "./images/ui/pegasus_welcome_page.webp"
|
"background" : "./images/ui/pegasus_welcome_page.webp"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user