Skip to content

Commit

Permalink
Merge pull request #194 from SolarBear/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
SolarBear committed Jul 8, 2021
2 parents bd49e5a + 6e7022c commit 614752f
Show file tree
Hide file tree
Showing 33 changed files with 133 additions and 133 deletions.
20 changes: 10 additions & 10 deletions module/actor/NumeneraPCActor.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class NumeneraPCActor extends Actor {
//Default case: there is no specific ID
allFoci[Object.keys(allFoci)[0]] = value;

const data = {_id: this._id};
const data = {id: this.id};
data["data.focus"] = {"": value};

this.update(data);
Expand Down Expand Up @@ -369,7 +369,7 @@ export class NumeneraPCActor extends Actor {
}

this.update({
_id: this._id,
id: this.id,
"data.xp": xp,
});

Expand Down Expand Up @@ -499,7 +499,7 @@ export class NumeneraPCActor extends Actor {
const newPoolValue = stat.pool.value + stat.edge - cost.amount;
const poolProp = `data.stats.${cost.pool}.pool.value`;

const data = { _id: this._id };
const data = { id: this.id };
data[poolProp] = newPoolValue;

await this.update(data);
Expand Down Expand Up @@ -563,7 +563,7 @@ export class NumeneraPCActor extends Actor {
}

await this.updateEmbeddedDocuments("Item", [{
_id: newItem._id,
id: newItem.id,
"data.level": itemData.level,
"data.form": itemData.form,
}]);
Expand All @@ -588,8 +588,8 @@ export class NumeneraPCActor extends Actor {
//A skil already has the same name as the ability
//This is certainly the matching skill, no need to create a new one
const updated = {
_id: relatedSkill.data._id,
"data.relatedAbilityId": actorAbility._id,
id: relatedSkill.data.id,
"data.relatedAbilityId": actorAbility.id,
};
await this.updateEmbeddedDocuments("Item", [updated], {fromActorUpdateEmbeddedEntity: true});

Expand All @@ -599,7 +599,7 @@ export class NumeneraPCActor extends Actor {
//Create a related skill if one does not already exist
const skillData = {
stat: actorAbility.data.data.cost.pool,
relatedAbilityId: actorAbility._id,
relatedAbilityId: actorAbility.id,
};

const itemData = {
Expand Down Expand Up @@ -635,7 +635,7 @@ export class NumeneraPCActor extends Actor {
for (const updatedItem of updatedItems) {
switch (updatedItem.type) {
case NumeneraAbilityItem.type:
const relatedSkill = this.items.find(i => i.data.data.relatedAbilityId === updatedItem._id);
const relatedSkill = this.items.find(i => i.data.data.relatedAbilityId === updatedItem.id);
if (!relatedSkill)
break;

Expand All @@ -654,11 +654,11 @@ export class NumeneraPCActor extends Actor {
if (!updatedItem.data.data.relatedAbilityId)
break;

const skill = this.items.get(updatedItem._id);
const skill = this.items.get(updatedItem.id);
if (!skill)
break;

const relatedAbility = this.items.find(i => i.data._id === skill.data.data.relatedAbilityId);
const relatedAbility = this.items.find(i => i.data.id === skill.data.data.relatedAbilityId);
if (!relatedAbility)
break;

Expand Down
4 changes: 2 additions & 2 deletions module/actor/sheets/NumeneraNPCActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class NumeneraNPCActorSheet extends ActorSheet {

const updates = children.map((row, i) => {
return {
_id: row.dataset.itemId,
id: row.dataset.itemId,
};
});

Expand All @@ -161,7 +161,7 @@ export class NumeneraNPCActorSheet extends ActorSheet {
for (let i = 0; i < updates.length; i++) {
updates[i]["data.order"] = i;

const row = children.find(row => row.dataset.itemId == updates[i]._id);
const row = children.find(row => row.dataset.itemId == updates[i].id);
row.dataset.order = i;
}

Expand Down
16 changes: 8 additions & 8 deletions module/actor/sheets/NumeneraPCActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export class NumeneraPCActorSheet extends ActorSheet {

const updates = children.map((row, i) => {
return {
_id: row.dataset.itemId,
id: row.dataset.itemId,
};
});

Expand All @@ -710,7 +710,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
for (let i = 0; i < updates.length; i++) {
updates[i]["data.order"] = i;

const row = children.find(row => row.dataset.itemId == updates[i]._id);
const row = children.find(row => row.dataset.itemId == updates[i].id);
row.dataset.order = i;
}

Expand Down Expand Up @@ -848,12 +848,12 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (
ability &&
this.actor.data.items.find(i => i.type === "skill" &&
i.data.relatedAbilityId === ability._id)
i.data.relatedAbilityId === ability.id)
)
ui.notifications.warn(game.i18n.localize("NUMENERA.warnings.skillWithSameNameExists"));

//Check for any macro related to that ability
game.macros.filter(m => m.data.command.indexOf(ability._id) !== -1)
game.macros.filter(m => m.data.command.indexOf(ability.id) !== -1)
.forEach(m => m.delete());
}

Expand All @@ -862,20 +862,20 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (
skill &&
skill.data.relatedAbilityId &&
this.actor.data.items.find(i => i._id === skill.data.relatedAbilityId)
this.actor.data.items.find(i => i.id === skill.data.relatedAbilityId)
)
ui.notifications.warn(game.i18n.localize("NUMENERA.warnings.abilityWithSameNameExists"));

//Check for any macro related to that skill
game.macros.filter(m => m.data.command.indexOf(skill._id) !== -1)
game.macros.filter(m => m.data.command.indexOf(skill.id) !== -1)
.forEach(m => m.delete());
}

onWeaponDeleted(equipment) {
//TODO move to Weapon class
if (equipment.type === NumeneraWeaponItem.type) {
//Check for any macro related to that skill
game.macros.filter(m => m.data.command.indexOf(equipment._id) !== -1)
game.macros.filter(m => m.data.command.indexOf(equipment.id) !== -1)
.forEach(m => m.delete());
}
}
Expand Down Expand Up @@ -905,7 +905,7 @@ export class NumeneraPCActorSheet extends ActorSheet {
if (typeof(item) === "undefined")
return;

const id = item._id;
const id = item.id;

if (!id)
return;
Expand Down
8 changes: 4 additions & 4 deletions module/actor/sheets/sheetUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function onItemCreateGenerator(itemType, itemClass, callback = null) {
const newName = game.i18n.localize(`NUMENERA.item.${itemType}.new${itemType.capitalize()}`);

const itemData = {
_id: null,
id: null,
name: newName,
type: itemType,
};
Expand All @@ -48,10 +48,10 @@ export function onItemEditGenerator(editClass, callback = null) {
else if (!elem.dataset.itemId)
throw new Error(`No itemID on ${editClass} element`);

const updated = {_id: elem.dataset.itemId};
const updated = {id: elem.dataset.itemId};

const splitName = event.currentTarget.name.split(".");
const idIndex = splitName.indexOf(updated._id);
const idIndex = splitName.indexOf(updated.id);
const parts = splitName.splice(idIndex + 1);

//Add the newly added property to the object
Expand Down Expand Up @@ -91,7 +91,7 @@ export function onItemDeleteGenerator(deleteType, callback = null) {
if (await confirmDeletion(deleteType)) {
const elem = event.currentTarget.closest("." + deleteType);
const itemId = elem.dataset.itemId;
const toDelete = this.actor.data.items.find(i => i._id === itemId);
const toDelete = this.actor.data.items.find(i => i.id === itemId);

await this.actor.deleteEmbeddedDocuments("Item", [itemId]);

Expand Down
14 changes: 7 additions & 7 deletions module/apps/EffortDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ export class EffortDialog extends FormApplication {
let skill = this.object.skill;

//Fetch the skill, might be one of these weird kind-of-Item objects
if (skill._id)
skill = this.object.actor.items.get(this.object.skill._id);
if (skill.id)
skill = this.object.actor.items.get(this.object.skill.id);

actor.rollSkill(skill, rollData, this.object.ability);
}
Expand All @@ -449,7 +449,7 @@ export class EffortDialog extends FormApplication {

const poolProp = `data.stats.${shortStat}.pool.value`;

const data = { _id: actor._id };
const data = { id: actor.id };
data[poolProp] = poolValue - cost;

//TIME TO PAY THE PRICE MWAHAHAHAHAHAHAH
Expand All @@ -467,7 +467,7 @@ export class EffortDialog extends FormApplication {
const flavor = `${game.i18n.localize("NUMENERA.rolling")} ${this.object.skill ? this.object.skill.name : getShortStat(this.object.stat)}`;

await ChatMessage.create({
user: game.user._id,
user: game.user.id,
speaker: ChatMessage.getSpeaker({user: game.user}),
sound: CONFIG.sounds.dice,
content: await renderTemplate("systems/numenera/templates/chat/automaticResult.html", {
Expand All @@ -488,7 +488,7 @@ export class EffortDialog extends FormApplication {
const flavor = `${game.i18n.localize("NUMENERA.rolling")} ${this.object.skill ? this.object.skill.name : getShortStat(this.object.stat)}`;

await ChatMessage.create({
user: game.user._id,
user: game.user.id,
speaker: ChatMessage.getSpeaker({user: game.user}),
sound: CONFIG.sounds.dice,
content: await renderTemplate("systems/numenera/templates/chat/automaticResult.html", {
Expand All @@ -513,7 +513,7 @@ export class EffortDialog extends FormApplication {
formData.stat = getShortStat(formData.stat);

// Did the skill change?
if (formData.skill && (this.object.skill == null || formData.skill !== this.object.skill._id)) {
if (formData.skill && (this.object.skill == null || formData.skill !== this.object.skill.id)) {
//In that case, update the stat to be the skill's stat
this.object.skill = this.object.actor.items.get(formData.skill);

Expand Down Expand Up @@ -560,7 +560,7 @@ export class EffortDialog extends FormApplication {

if (formData.powerShift) {
const powerShift = actor.getEmbeddedCollection("Item")
.find(i => i._id === formData.powerShift);
.find(i => i.id === formData.powerShift);
this.object.powerShift = NumeneraPowerShiftItem.fromOwnedItem(powerShift);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion module/apps/RecoveryDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class RecoveryDialog extends FormApplication {
//Update the actor with its newly-found pool points to attribute and its new checked recoveries
const actor = this.object.actor;
actor.update({
_id: actor.data._id,
id: actor.data.id,
"data.recoveries": [...this.object.recoveriesLeft],
});

Expand Down
12 changes: 6 additions & 6 deletions module/combat.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function rollInitiative07(ids, {formula=null, updateTurn=true, messageOpti
if (!ids)
return this;

const currentId = this.combatant._id;
const currentId = this.combatant.id;

// Iterate over Combatants, performing an initiative roll for each
const [updates, messages] = ids.reduce(
Expand All @@ -37,7 +37,7 @@ async function rollInitiative07(ids, {formula=null, updateTurn=true, messageOpti

const cf = formula || this._getInitiativeFormula(c);
const roll = new Roll(cf, rollData).roll();
updates.push({ _id: id, initiative: roll.total });
updates.push({ id: id, initiative: roll.total });

// In Numenera, initiative is fixed for NPCs so don't spam the chat with constant values!
if (c.actor.data.type === "pc") {
Expand All @@ -51,9 +51,9 @@ async function rollInitiative07(ids, {formula=null, updateTurn=true, messageOpti
// Construct chat message data
let messageData = mergeObject({
speaker: {
scene: canvas.scene._id,
actor: c.actor ? c.actor._id : null,
token: c.token._id,
scene: canvas.scene.id,
actor: c.actor ? c.actor.id : null,
token: c.token.id,
alias: c.token.name,
},
flavor: `${c.token.name} ${game.i18n.localize("NUMENERA.pc.initiativeRoll")}`,
Expand Down Expand Up @@ -86,7 +86,7 @@ async function rollInitiative07(ids, {formula=null, updateTurn=true, messageOpti

// Ensure the turn order remains with the same combatant
if (updateTurn)
await this.update({ turn: this.turns.findIndex((t) => t._id === currentId) });
await this.update({ turn: this.turns.findIndex((t) => t.id === currentId) });

// Create multiple chat messages
await CONFIG.ChatMessage.entityClass.create(messages);
Expand Down
2 changes: 1 addition & 1 deletion module/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function registerHooks() {

game.socket.emit("system.numenera", {type: "gmIntrusion", data: {
userIds: ownerIds,
actorId: actor.data._id,
actorId: actor.data.id,
}});

ChatMessage.create({
Expand Down
6 changes: 3 additions & 3 deletions module/item/NumeneraAbilityItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ export class NumeneraAbilityItem extends Item {
return;

const updated = await skill.update({
_id: skill._id,
id: skill.id,
name: this.name,
"data.relatedAbilityId": this._id,
"data.relatedAbilityId": this.id,
"data.stat": this.data.data.cost.pool,
},
options);
Expand Down Expand Up @@ -189,7 +189,7 @@ export class NumeneraAbilityItem extends Item {

if (message !== null) {
ChatMessage.create({
user: game.user._id,
user: game.user.id,
speaker: this.actor,
content: message,
});
Expand Down
2 changes: 1 addition & 1 deletion module/item/NumeneraArmorItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class NumeneraArmorItem extends Item {
else
armorItem = await actor.createEmbeddedDocuments("Item", [this.object]);

armorItem._id = ownedItem._id;
armorItem.id = ownedItem.id;
armorItem.data.name = ownedItem.name;
armorItem.data.armor = ownedItem.data.armor;
armorItem.data.notes = ownedItem.data.notes;
Expand Down
2 changes: 1 addition & 1 deletion module/item/NumeneraArtifactItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class NumeneraArtifactItem extends Item {
else
artifactItem = await actor.createEmbeddedDocuments("Item", [this.object]);

artifactItem.data._id = ownedItem._id;
artifactItem.data.id = ownedItem.id;
artifactItem.data.name = ownedItem.name;
artifactItem.data.price = ownedItem.data.price;
artifactItem.data.notes = ownedItem.data.notes;
Expand Down
2 changes: 1 addition & 1 deletion module/item/NumeneraCypherItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class NumeneraCypherItem extends Item {
else
cypherItem = await actor.createEmbeddedDocuments("Item", [this.object]);

cypherItem.data._id = ownedItem._id;
cypherItem.data.id = ownedItem.id;
cypherItem.data.name = ownedItem.name;
cypherItem.data.price = ownedItem.data.price;
cypherItem.data.notes = ownedItem.data.notes;
Expand Down
2 changes: 1 addition & 1 deletion module/item/NumeneraPowerShiftItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class NumeneraPowerShiftItem extends Item {
else
powerShiftItem = await actor.createEmbeddedDocuments("Item", [this.object]);

powerShiftItem.data._id = ownedItem._id;
powerShiftItem.data.id = ownedItem.id;
powerShiftItem.data.name = ownedItem.name;
powerShiftItem.data.data.version = parseInt(ownedItem.data.version);
powerShiftItem.data.data.order = parseInt(ownedItem.data.order);
Expand Down
4 changes: 2 additions & 2 deletions module/item/NumeneraSkillItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class NumeneraSkillItem extends Item {
else
skillItem = await actor.createEmbeddedDocuments("Item", [this.object]);

skillItem.data._id = ownedItem._id;
skillItem.data.id = ownedItem.id;
skillItem.data.name = ownedItem.name;
skillItem.data.notes = ownedItem.data.notes;
skillItem.data.relatedAbilityId = ownedItem.data.relatedAbilityId;
Expand Down Expand Up @@ -68,7 +68,7 @@ export class NumeneraSkillItem extends Item {
return;

const updated = await ability.update({
_id: ability._id,
id: ability.id,
name: this.name,
"data.cost.pool": this.data.data.stat,
},
Expand Down
Loading

0 comments on commit 614752f

Please sign in to comment.