v10 Migration
This commit is contained in:
@@ -25,9 +25,8 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = PegasusUtility.data(this.object);
|
||||
|
||||
let actorData = duplicate(PegasusUtility.templateData(this.object));
|
||||
const objectData = this.object
|
||||
let actorData = duplicate(this.object)
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
@@ -37,7 +36,7 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
name: objectData.name,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
data: actorData,
|
||||
data: actorData.system,
|
||||
traumaState: this.actor.getTraumaState(),
|
||||
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
|
||||
limited: this.object.limited,
|
||||
@@ -87,7 +86,7 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollIDR( itemId, diceValue) {
|
||||
let item = this.actor.data.items.get( itemId) ?? {name: "Unknown"}
|
||||
let item = this.actor.items.get( itemId) ?? {name: "Unknown"}
|
||||
let myRoll = new Roll(diceValue+"x").roll({ async: false })
|
||||
await PegasusUtility.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
let chatData = {
|
||||
@@ -362,10 +361,9 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onDropItem(event, dragData) {
|
||||
console.log(">>>>>> DROPPED!!!!")
|
||||
let item = await PegasusUtility.searchItem( dragData)
|
||||
const item = fromUuidSync(dragData.uuid)
|
||||
if (item == undefined) {
|
||||
item = this.actor.items.get( dragData.data._id )
|
||||
item = this.actor.items.get( dragData.uuid )
|
||||
}
|
||||
let ret = await this.actor.preprocessItem( event, item, true )
|
||||
if ( ret ) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -48,9 +48,9 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = PegasusUtility.data(this.object);
|
||||
const objectData = this.object
|
||||
|
||||
let itemData = foundry.utils.deepClone(PegasusUtility.templateData(this.object));
|
||||
let itemData = foundry.utils.deepClone(objectData)
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: this.id,
|
||||
@@ -61,7 +61,7 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
optionsDiceList: PegasusUtility.getOptionsDiceList(),
|
||||
optionsStatusList: PegasusUtility.getOptionsStatusList(),
|
||||
data: itemData,
|
||||
data: itemData.system,
|
||||
limited: this.object.limited,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
@@ -69,7 +69,7 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
isGM: game.user.isGM
|
||||
}
|
||||
|
||||
this.options.editable = !(this.object.data.origin == "embeddedItem");
|
||||
this.options.editable = true //!(this.object.isEmbedded)
|
||||
console.log("ITEM DATA", formData, this);
|
||||
return formData;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
postItem() {
|
||||
let chatData = duplicate(PegasusUtility.data(this.item));
|
||||
let chatData = this.item.system
|
||||
if (this.actor) {
|
||||
chatData.actor = { id: this.actor.id };
|
||||
}
|
||||
@@ -113,10 +113,10 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
async viewSubitem(ev) {
|
||||
let field = $(ev.currentTarget).data('type');
|
||||
let idx = Number($(ev.currentTarget).data('index'));
|
||||
let itemData = this.object.data.data[field][idx];
|
||||
let itemData = this.object.system[field][idx];
|
||||
if (itemData.name != 'None') {
|
||||
let spec = await Item.create(itemData, { temporary: true });
|
||||
spec.data.origin = "embeddedItem";
|
||||
spec.system.origin = "embeddedItem";
|
||||
new PegasusItemSheet(spec).render(true);
|
||||
}
|
||||
}
|
||||
@@ -125,8 +125,8 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
async deleteSubitem(ev) {
|
||||
let field = $(ev.currentTarget).data('type');
|
||||
let idx = Number($(ev.currentTarget).data('index'));
|
||||
let oldArray = this.object.data.data[field];
|
||||
let itemData = this.object.data.data[field][idx];
|
||||
let oldArray = this.object.system[field];
|
||||
let itemData = this.object.system[field][idx];
|
||||
if (itemData.name != 'None') {
|
||||
let newArray = [];
|
||||
for (var i = 0; i < oldArray.length; i++) {
|
||||
@@ -134,16 +134,16 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
newArray.push(oldArray[i]);
|
||||
}
|
||||
}
|
||||
this.object.update({ [`data.${field}`]: newArray });
|
||||
this.object.update({ [`system.${field}`]: newArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async manageSpec() {
|
||||
let itemData = this.object.data.data.specialisation[0];
|
||||
let itemData = this.object.system.specialisation[0];
|
||||
if (itemData.name != 'None') {
|
||||
let spec = await Item.create(itemData, { temporary: true });
|
||||
spec.data.origin = "embeddedItem";
|
||||
spec.system.origin = "embeddedItem";
|
||||
new PegasusItemSheet(spec).render(true);
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
});
|
||||
|
||||
html.find('.delete-spec').click(ev => {
|
||||
this.object.update({ "data.specialisation": [{ name: 'None' }] });
|
||||
this.object.update({ "system.specialisation": [{ name: 'None' }] });
|
||||
});
|
||||
|
||||
html.find('.delete-subitem').click(ev => {
|
||||
@@ -174,9 +174,9 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
|
||||
html.find('.stat-choice-flag').click(ev => {
|
||||
let idx = $(ev.currentTarget).data("stat-idx");
|
||||
let array = duplicate(this.object.data.data.statincreasechoice);
|
||||
let array = duplicate(this.object.system.statincreasechoice);
|
||||
array[Number(idx)].flag = !array[Number(idx)].flag;
|
||||
this.object.update({ "data.statincreasechoice": array });
|
||||
this.object.update({ "system.statincreasechoice": array });
|
||||
});
|
||||
|
||||
// Update Inventory Item
|
||||
@@ -197,225 +197,225 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addAbility(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
console.log("ABB", event, item, dataItem)
|
||||
async addAbility(event, item) {
|
||||
let newItem = duplicate(item)
|
||||
newItem._id = randomID(item.id.length);
|
||||
console.log("ABB", event, item)
|
||||
if (event.toElement.className == 'drop-abilities') {
|
||||
let abilityArray = duplicate(this.object.data.data.abilities);
|
||||
let abilityArray = duplicate(this.object.system.abilities);
|
||||
abilityArray.push(newItem);
|
||||
await this.object.update({ 'data.abilities': abilityArray });
|
||||
await this.object.update({ 'system.abilities': abilityArray });
|
||||
}
|
||||
if (event.toElement.className == 'drop-optionnal-abilities') {
|
||||
let abilityArray = duplicate(this.object.data.data.optionnalabilities);
|
||||
let abilityArray = duplicate(this.object.system.optionnalabilities);
|
||||
abilityArray.push(newItem);
|
||||
await this.object.update({ 'data.optionnalabilities': abilityArray });
|
||||
await this.object.update({ 'system.optionnalabilities': abilityArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addRacePerk(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addRacePerk(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id);
|
||||
if (event.toElement.className == 'drop-race-perk') {
|
||||
let perkArray = duplicate(this.object.data.data.perks);
|
||||
let perkArray = duplicate(this.object.system.perks);
|
||||
perkArray.push(newItem);
|
||||
await this.object.update({ 'data.perks': perkArray });
|
||||
await this.object.update({ 'system.perks': perkArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addSpecialisation(item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addSpecialisation(item) {
|
||||
let newItem = duplicate(item)
|
||||
newItem._id = randomID(item.id.length)
|
||||
let specArray = [newItem];
|
||||
await this.object.update({ 'data.specialisation': specArray });
|
||||
await this.object.update({ 'system.specialisation': specArray });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addRoleSpecialisation(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addRoleSpecialisation(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id.length);
|
||||
console.log("Add spec", event, newItem);
|
||||
if (event.toElement.className == 'drop-spec1') {
|
||||
let specArray = duplicate(this.object.data.data.specialisationsplus1);
|
||||
let specArray = duplicate(this.object.system.specialisationsplus1);
|
||||
specArray.push(newItem);
|
||||
await this.object.update({ 'data.specialisationsplus1': specArray });
|
||||
await this.object.update({ 'system.specialisationsplus1': specArray });
|
||||
}
|
||||
if (event.toElement.className == 'drop-spec2') {
|
||||
let specArray = duplicate(this.object.data.data.specincrease);
|
||||
let specArray = duplicate(this.object.system.specincrease);
|
||||
specArray.push(newItem);
|
||||
await this.object.update({ 'data.specincrease': specArray });
|
||||
await this.object.update({ 'system.specincrease': specArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addRolePerk(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addRolePerk(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id.length);
|
||||
if (event.toElement.className == 'drop-perk2') {
|
||||
let perkArray = duplicate(this.object.data.data.perks);
|
||||
let perkArray = duplicate(this.object.system.perks);
|
||||
perkArray.push(newItem);
|
||||
await this.object.update({ 'data.perks': perkArray });
|
||||
await this.object.update({ 'system.perks': perkArray });
|
||||
}
|
||||
if (event.toElement.className == 'drop-specialperk1') {
|
||||
let perkArray = duplicate(this.object.data.data.specialperk);
|
||||
let perkArray = duplicate(this.object.system.specialperk);
|
||||
perkArray.push(newItem);
|
||||
await this.object.update({ 'data.specialperk': perkArray });
|
||||
await this.object.update({ 'system.specialperk': perkArray });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addRoleAbility(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data)
|
||||
newItem._id = randomID(dataItem.id.length)
|
||||
async addRoleAbility(event, item) {
|
||||
let newItem = duplicate(item)
|
||||
newItem._id = randomID(item.id.length)
|
||||
if (event.toElement.className == 'drop-specialability') {
|
||||
let abiArray = duplicate(this.object.data.data.specialability)
|
||||
let abiArray = duplicate(this.object.system.specialability)
|
||||
abiArray.push(newItem)
|
||||
await this.object.update({ 'data.specialability': abiArray })
|
||||
await this.object.update({ 'system.specialability': abiArray })
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addPower(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addPower(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id.length);
|
||||
if (event.toElement.className == 'drop-spec-power') {
|
||||
let powArray = duplicate(this.object.data.data.powers);
|
||||
let powArray = duplicate(this.object.system.powers);
|
||||
powArray.push(newItem);
|
||||
await this.object.update({ 'data.powers': powArray });
|
||||
await this.object.update({ 'system.powers': powArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addAbilityPower(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addAbilityPower(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id.length);
|
||||
if (event.toElement.className == 'drop-ability-power') {
|
||||
let powArray = duplicate(this.object.data.data.powersgained);
|
||||
let powArray = duplicate(this.object.system.powersgained);
|
||||
powArray.push(newItem);
|
||||
await this.object.update({ 'data.powersgained': powArray });
|
||||
await this.object.update({ 'system.powersgained': powArray });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addAbilityEffect(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addAbilityEffect(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id.length);
|
||||
if (event.toElement.className == 'drop-ability-effect') {
|
||||
let powArray = duplicate(this.object.data.data.effectsgained);
|
||||
let powArray = duplicate(this.object.system.effectsgained);
|
||||
powArray.push(newItem);
|
||||
await this.object.update({ 'data.effectsgained': powArray });
|
||||
await this.object.update({ 'system.effectsgained': powArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addAbilitySpec(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addAbilitySpec(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id.length);
|
||||
if (event.toElement.className == 'drop-ability-spec') {
|
||||
let powArray = duplicate(this.object.data.data.specialisations);
|
||||
let powArray = duplicate(this.object.system.specialisations);
|
||||
powArray.push(newItem);
|
||||
await this.object.update({ 'data.specialisations': powArray });
|
||||
await this.object.update({ 'system.specialisations': powArray });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addAbilityWeaponArmor(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID(dataItem.id.length);
|
||||
async addAbilityWeaponArmor(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
newItem._id = randomID(item.id.length);
|
||||
if (event.toElement.className == 'drop-ability-weapon') {
|
||||
let weaponArray = duplicate(this.object.data.data.attackgained);
|
||||
let weaponArray = duplicate(this.object.system.attackgained);
|
||||
weaponArray.push(newItem);
|
||||
await this.object.update({ 'data.attackgained': weaponArray });
|
||||
await this.object.update({ 'system.attackgained': weaponArray });
|
||||
}
|
||||
if (event.toElement.className == 'drop-ability-armor') {
|
||||
let armorArray = duplicate(this.object.data.data.armorgained);
|
||||
let armorArray = duplicate(this.object.system.armorgained);
|
||||
armorArray.push(newItem);
|
||||
await this.object.update({ 'data.armorgained': armorArray });
|
||||
await this.object.update({ 'system.armorgained': armorArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addPerkSpecialisation(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
async addPerkSpecialisation(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
if (event.toElement.className == 'drop-spec-perk') {
|
||||
//console.log("PER SPEC", event)
|
||||
let key = event.toElement.dataset["key"];
|
||||
if (key == 'affectedspec') {
|
||||
await this.object.update({ 'data.features.affectedspec.value': newItem.name });
|
||||
await this.object.update({ 'system.features.affectedspec.value': newItem.name });
|
||||
} else {
|
||||
await this.object.update({ 'data.features.gainspecdice.value': newItem.name });
|
||||
await this.object.update({ 'system.features.gainspecdice.value': newItem.name });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addPerkEffect(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data)
|
||||
async addPerkEffect(event, item) {
|
||||
let newItem = duplicate(item)
|
||||
if (event.toElement.className == 'drop-perk-effect') {
|
||||
let effectArray = duplicate(this.object.data.data.effectsgained)
|
||||
let effectArray = duplicate(this.object.system.effectsgained)
|
||||
effectArray.push(newItem)
|
||||
await this.object.update({ 'data.effectsgained': effectArray })
|
||||
await this.object.update({ 'system.effectsgained': effectArray })
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addEffectPower(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data)
|
||||
async addEffectPower(event, item) {
|
||||
let newItem = duplicate(item)
|
||||
if (event.toElement.className == 'drop-power-effect') {
|
||||
let effectArray = duplicate(this.object.data.data.effectsgained)
|
||||
let effectArray = duplicate(this.object.system.effectsgained)
|
||||
effectArray.push(newItem);
|
||||
await this.object.update({ 'data.effectsgained': effectArray })
|
||||
await this.object.update({ 'system.effectsgained': effectArray })
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addEffectSpec(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
async addEffectSpec(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
if (event.toElement.className == 'drop-effect-spec') {
|
||||
let specArray = duplicate(this.object.data.data.recoveryrollspec);
|
||||
let specArray = duplicate(this.object.system.recoveryrollspec);
|
||||
specArray.push(newItem);
|
||||
await this.object.update({ 'data.recoveryrollspec': specArray });
|
||||
await this.object.update({ 'system.recoveryrollspec': specArray });
|
||||
}
|
||||
if (event.toElement.className == 'drop-effect-specaffected') {
|
||||
let specArray = duplicate(this.object.data.data.specaffected);
|
||||
let specArray = duplicate(this.object.system.specaffected);
|
||||
specArray.push(newItem);
|
||||
await this.object.update({ 'data.specaffected': specArray });
|
||||
await this.object.update({ 'system.specaffected': specArray });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addEffectItem(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
async addEffectItem(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
if (event.toElement.className == 'drop-equipment-effect') {
|
||||
let effectArray = duplicate(this.object.data.data.effects);
|
||||
let effectArray = duplicate(this.object.system.effects);
|
||||
effectArray.push(newItem);
|
||||
await this.object.update({ 'data.effects': effectArray });
|
||||
await this.object.update({ 'system.effects': effectArray });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addEffectVirtueVice(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
async addEffectVirtueVice(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
if (event.toElement.className == 'drop-virtue-vice-effect') {
|
||||
let effectArray = duplicate(this.object.data.data.effectsgained);
|
||||
let effectArray = duplicate(this.object.system.effectsgained);
|
||||
effectArray.push(newItem);
|
||||
await this.object.update({ 'data.effectsgained': effectArray });
|
||||
await this.object.update({ 'system.effectsgained': effectArray });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addViceToVirtue(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
async addViceToVirtue(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
if (event.toElement.className == 'drop-virtue-vice') {
|
||||
let viceArray = duplicate(this.object.data.data.unavailablevice);
|
||||
let viceArray = duplicate(this.object.system.unavailablevice);
|
||||
viceArray.push(newItem);
|
||||
await this.object.update({ 'data.unavailablevice': viceArray });
|
||||
await this.object.update({ 'system.unavailablevice': viceArray });
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addVirtueToVice(event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
async addVirtueToVice(event, item) {
|
||||
let newItem = duplicate(item);
|
||||
if (event.toElement.className == 'drop-vice-virtue') {
|
||||
let virtueArray = duplicate(this.object.data.data.unavailablevirtue);
|
||||
let virtueArray = duplicate(this.object.system.unavailablevirtue);
|
||||
virtueArray.push(newItem);
|
||||
await this.object.update({ 'data.unavailablevirtue': virtueArray });
|
||||
await this.object.update({ 'system.unavailablevirtue': virtueArray });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,140 +423,101 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
/* -------------------------------------------- */
|
||||
async _onDrop(event) {
|
||||
|
||||
let data = event.dataTransfer.getData('text/plain')
|
||||
let dataItem = JSON.parse( data)
|
||||
console.log("DROP", event, dataItem )
|
||||
const item = fromUuidSync(dataItem.uuid)
|
||||
if (!item) {
|
||||
ui.notifications.warn("Unable to find relevant item - Aborting drag&drop " + data.uuid)
|
||||
return
|
||||
}
|
||||
|
||||
if (this.object.type == 'virtue' ) {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'effect') {
|
||||
return this.addEffectVirtueVice(event, item, dataItem);
|
||||
}
|
||||
if (item.data.type == 'vice') {
|
||||
return this.addViceToVirtue(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'effect') {
|
||||
return this.addEffectVirtueVice(event, item);
|
||||
}
|
||||
if (item.type == 'vice') {
|
||||
return this.addViceToVirtue(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'vice' ) {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'effect') {
|
||||
return this.addEffectVirtueVice(event, item, dataItem);
|
||||
}
|
||||
if (item.data.type == 'virtue') {
|
||||
return this.addVirtueToVice(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'effect') {
|
||||
return this.addEffectVirtueVice(event, item);
|
||||
}
|
||||
if (item.type == 'virtue') {
|
||||
return this.addVirtueToVice(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'weapon' || this.object.type == 'armor' || this.object.type == 'shield'
|
||||
|| this.object.type == 'equipment' || this.object.type == 'vehiclemodule'
|
||||
|| this.object.type == 'vehicleweaponmodule') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'effect') {
|
||||
return this.addEffectItem(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'effect') {
|
||||
return this.addEffectItem(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'power') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'effect') {
|
||||
return this.addEffectPower(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'effect') {
|
||||
return this.addEffectPower(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'effect') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'specialisation') {
|
||||
return this.addEffectSpec(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'specialisation') {
|
||||
return this.addEffectSpec(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'race') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'ability') {
|
||||
return this.addAbility(event, item, dataItem);
|
||||
}
|
||||
if (item.data.type == 'perk') {
|
||||
return this.addRacePerk(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'ability') {
|
||||
return this.addAbility(event, item);
|
||||
}
|
||||
if (item.type == 'perk') {
|
||||
return this.addRacePerk(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'perk') {
|
||||
let data = event.dataTransfer.getData('text/plain')
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem)
|
||||
if (item.data.type == 'specialisation') {
|
||||
return this.addPerkSpecialisation(event, item, dataItem)
|
||||
}
|
||||
if (item.data.type == 'effect') {
|
||||
return this.addPerkEffect(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'specialisation') {
|
||||
return this.addPerkSpecialisation(event, item)
|
||||
}
|
||||
if (item.type == 'effect') {
|
||||
return this.addPerkEffect(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'specialisation') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'power') {
|
||||
return this.addPower(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'power') {
|
||||
return this.addPower(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'ability') {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data);
|
||||
let item = await PegasusUtility.searchItem(dataItem);
|
||||
if (item.data.type == 'effect') {
|
||||
return this.addAbilityEffect(event, item, dataItem);
|
||||
}
|
||||
if (item.data.type == 'power') {
|
||||
return this.addAbilityPower(event, item, dataItem);
|
||||
}
|
||||
if (item.data.type == 'specialisation') {
|
||||
return this.addAbilitySpec(event, item, dataItem);
|
||||
}
|
||||
if (item.data.type == 'weapon' || item.data.type == 'armor') {
|
||||
return this.addAbilityWeaponArmor(event, item, dataItem);
|
||||
}
|
||||
if (item.type == 'effect') {
|
||||
return this.addAbilityEffect(event, item);
|
||||
}
|
||||
if (item.type == 'power') {
|
||||
return this.addAbilityPower(event, item);
|
||||
}
|
||||
if (item.type == 'specialisation') {
|
||||
return this.addAbilitySpec(event, item);
|
||||
}
|
||||
if (item.type == 'weapon' || item.type == 'armor') {
|
||||
return this.addAbilityWeaponArmor(event, item);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.object.type == 'role') {
|
||||
let data = event.dataTransfer.getData('text/plain')
|
||||
if (data) {
|
||||
let dataItem = JSON.parse(data)
|
||||
let item = await PegasusUtility.searchItem(dataItem)
|
||||
if (item.data.type == 'specialisation') {
|
||||
return this.addRoleSpecialisation(event, item, dataItem)
|
||||
}
|
||||
if (item.data.type == 'perk') {
|
||||
return this.addRolePerk(event, item, dataItem)
|
||||
}
|
||||
if (item.data.type == 'ability') {
|
||||
return this.addRoleAbility(event, item, dataItem)
|
||||
}
|
||||
if (item.type == 'specialisation') {
|
||||
return this.addRoleSpecialisation(event, item)
|
||||
}
|
||||
if (item.type == 'perk') {
|
||||
return this.addRolePerk(event, item)
|
||||
}
|
||||
if (item.type == 'ability') {
|
||||
return this.addRoleAbility(event, item)
|
||||
}
|
||||
}
|
||||
ui.notifications.warn("This item can not be dropped over another item")
|
||||
|
@@ -51,10 +51,10 @@ export class PegasusRollDialog extends Dialog {
|
||||
let level, genre, idVal, key
|
||||
if (effect.type == 'effect') {
|
||||
let effectData = effect.effect
|
||||
level = effectData.data.effectlevel
|
||||
genre = effectData.data.genre
|
||||
effectData.data.isUsed = toggled
|
||||
if (effectData.data.reducedicevalue || effectData.data.statdice) {
|
||||
level = effectData.system.effectlevel
|
||||
genre = effectData.system.genre
|
||||
effectData.system.isUsed = toggled
|
||||
if (effectData.system.reducedicevalue || effectData.system.statdice) {
|
||||
idVal = "#statDicesLevel"
|
||||
key = "statLevelBonus"
|
||||
}
|
||||
@@ -124,13 +124,13 @@ export class PegasusRollDialog extends Dialog {
|
||||
if (equip) {
|
||||
equip.applied = toggled
|
||||
let idVal = "#damageDiceLevel" // Default
|
||||
if (equip.equip.data.bonusdice) {
|
||||
if (equip.equip.system.bonusdice) {
|
||||
idVal = "#bonusDicesLevel"
|
||||
}
|
||||
if (equip.equip.data.statdice) {
|
||||
if (equip.equip.system.statdice) {
|
||||
idVal = "#statDicesLevel"
|
||||
}
|
||||
if (equip.equip.data.otherdice) {
|
||||
if (equip.equip.system.otherdice) {
|
||||
idVal = "#damageDiceLevel"
|
||||
}
|
||||
let newLevel = Number($(idVal).val())
|
||||
@@ -170,7 +170,7 @@ export class PegasusRollDialog extends Dialog {
|
||||
this.rollData.selectedSpec = event.currentTarget.value
|
||||
let spec = this.rollData.specList.find(item => item._id == this.rollData.selectedSpec)
|
||||
if (spec) {
|
||||
this.rollData.specDicesLevel = spec.data.level
|
||||
this.rollData.specDicesLevel = spec.system.level
|
||||
this.rollData.specName = spec.name
|
||||
$('#specDicesLevel').val(this.rollData.specDicesLevel)
|
||||
} else {
|
||||
|
@@ -109,12 +109,12 @@ export class PegasusUtility {
|
||||
static updateEffectsBonusDice(rollData) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-bonus-dice")
|
||||
for (let effect of rollData.effectsList) {
|
||||
if (effect && effect.applied && effect.type == "effect" && effect.effect.data.bonusdice) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(effect.effect.data.effectlevel)
|
||||
if (effect && effect.applied && effect.type == "effect" && effect.effect.system.bonusdice) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel(effect.effect.system.effectlevel)
|
||||
let diceList = diceKey.split(" ")
|
||||
for (let myDice of diceList) {
|
||||
let newDice = {
|
||||
name: "effect-bonus-dice", key: myDice, level: effect.effect.data.effectlevel, effect: effect.effect.name,
|
||||
name: "effect-bonus-dice", key: myDice, level: effect.effect.system.effectlevel, effect: effect.effect.name,
|
||||
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
|
||||
}
|
||||
newDicePool.push(newDice)
|
||||
@@ -128,8 +128,8 @@ export class PegasusUtility {
|
||||
static updateHindranceBonusDice(rollData) {
|
||||
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-hindrance")
|
||||
for (let hindrance of rollData.effectsList) {
|
||||
if (hindrance && hindrance.applied && (hindrance.type == "hindrance" || (hindrance.type == "effect" && hindrance.effect?.data?.hindrance) ) ) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel( (hindrance.value) ? hindrance.value : hindrance.effect.data.effectlevel)
|
||||
if (hindrance && hindrance.applied && (hindrance.type == "hindrance" || (hindrance.type == "effect" && hindrance.effect?.system?.hindrance) ) ) {
|
||||
let diceKey = PegasusUtility.getDiceFromLevel( (hindrance.value) ? hindrance.value : hindrance.effect.system.effectlevel)
|
||||
let diceList = diceKey.split(" ")
|
||||
for (let myDice of diceList) {
|
||||
let newDice = {
|
||||
@@ -500,19 +500,6 @@ export class PegasusUtility {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static templateData(it) {
|
||||
return PegasusUtility.data(it)?.data ?? {}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static data(it) {
|
||||
if (it instanceof Actor || it instanceof Item || it instanceof Combatant) {
|
||||
return it.data;
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getDiceValue(level = 0) {
|
||||
let diceString = this.diceList[level]
|
||||
@@ -716,7 +703,7 @@ export class PegasusUtility {
|
||||
// De-actived used effects from perks
|
||||
let toRem = []
|
||||
for (let effect of rollData.effectsList) {
|
||||
if (effect.effect.data.perkId && effect.effect.data.isUsed) {
|
||||
if (effect.effect.system.perkId && effect.effect.system.isUsed) {
|
||||
toRem.push(effect.effect._id)
|
||||
}
|
||||
}
|
||||
@@ -731,7 +718,7 @@ export class PegasusUtility {
|
||||
// De-actived used effects from perks
|
||||
let toRem = []
|
||||
for (let effect of rollData.effectsList) {
|
||||
if (effect.effect && effect.effect.data.isUsed && effect.effect.data.oneuse) {
|
||||
if (effect.effect && effect.effect.system.isUsed && effect.effect.system.oneuse) {
|
||||
effect.defenderTokenId = rollData.defenderTokenId
|
||||
if (effect.foreign) {
|
||||
if (game.user.isGM) {
|
||||
@@ -896,7 +883,7 @@ export class PegasusUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getUsers(filter) {
|
||||
return game.users.filter(filter).map(user => user.data._id);
|
||||
return game.users.filter(filter).map(user => user.id);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static getWhisperRecipients(rollMode, name) {
|
||||
|
Reference in New Issue
Block a user