Calcul du poids
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
## [0.1.3] (2024-05-25)
|
## [0.1.4] (2024-05-25)
|
||||||
|
|
||||||
|
### Correctifs
|
||||||
|
* Erreur lors du calcul du poids lors de différent événement (Drop, Delete)
|
||||||
|
|
||||||
|
## [0.1.3] (2024-05-24)
|
||||||
|
|
||||||
### Correctifs
|
### Correctifs
|
||||||
* Localisation
|
* Localisation
|
||||||
|
|||||||
@@ -537,7 +537,7 @@ class ActorCharacter {
|
|||||||
await $this.deleteEmbeddedDocuments("Item", toDeleteIds);
|
await $this.deleteEmbeddedDocuments("Item", toDeleteIds);
|
||||||
if (itemToUpdates.length > 0)
|
if (itemToUpdates.length > 0)
|
||||||
await $this.updateEmbeddedDocuments("Item", itemToUpdates);
|
await $this.updateEmbeddedDocuments("Item", itemToUpdates);
|
||||||
await this.recalculateWeight();
|
await this.recalculateWeight($this);
|
||||||
}
|
}
|
||||||
static async onUpdateDescendantDocuments($this, parent, collection, documents, changes, options, userId) {
|
static async onUpdateDescendantDocuments($this, parent, collection, documents, changes, options, userId) {
|
||||||
await this.calculEncumbranceAndWeight($this, parent, collection, documents, changes, options, userId);
|
await this.calculEncumbranceAndWeight($this, parent, collection, documents, changes, options, userId);
|
||||||
@@ -615,8 +615,10 @@ class ActorCharacter {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (recalculEncumbrance || recalculWeight) {
|
if (recalculEncumbrance || recalculWeight) {
|
||||||
const cloneActor = duplicate($this);
|
const cloneActorSystem = duplicate($this.system);
|
||||||
await this.recalculateArmor($this, cloneActor);
|
await this.recalculateArmor($this, cloneActorSystem);
|
||||||
|
if (!recalculEncumbrance && !recalculWeight)
|
||||||
|
await $this.update({ system: cloneActorSystem });
|
||||||
if (recalculEncumbrance) {
|
if (recalculEncumbrance) {
|
||||||
const str = Number($this.system.characteristics.strength.value);
|
const str = Number($this.system.characteristics.strength.value);
|
||||||
const end = Number($this.system.characteristics.endurance.value);
|
const end = Number($this.system.characteristics.endurance.value);
|
||||||
@@ -624,17 +626,19 @@ class ActorCharacter {
|
|||||||
$this.items.filter((x) => x.type === "talent" && x.system.subType === "skill" && x.system.skill.reduceEncumbrance === true).forEach((x) => sumSkill += Number(x.system.level));
|
$this.items.filter((x) => x.type === "talent" && x.system.subType === "skill" && x.system.skill.reduceEncumbrance === true).forEach((x) => sumSkill += Number(x.system.level));
|
||||||
let normal = str + end + sumSkill;
|
let normal = str + end + sumSkill;
|
||||||
let heavy = normal * 2;
|
let heavy = normal * 2;
|
||||||
cloneActor.system.states.encumbrance = $this.system.inventory.weight > normal;
|
cloneActorSystem.states.encumbrance = $this.system.inventory.weight > normal;
|
||||||
cloneActor.system.encumbrance.normal = normal;
|
cloneActorSystem.encumbrance.normal = normal;
|
||||||
cloneActor.system.encumbrance.heavy = heavy;
|
cloneActorSystem.encumbrance.heavy = heavy;
|
||||||
|
if (!recalculWeight)
|
||||||
|
await $this.update({ system: cloneActorSystem });
|
||||||
}
|
}
|
||||||
if (recalculWeight)
|
if (recalculWeight)
|
||||||
await this.recalculateWeight($this, cloneActor);
|
await this.recalculateWeight($this, cloneActorSystem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async recalculateArmor($this, cloneActor) {
|
static async recalculateArmor($this, cloneActorSystem) {
|
||||||
if (cloneActor === null || cloneActor === void 0)
|
if (cloneActorSystem === null || cloneActorSystem === void 0)
|
||||||
cloneActor = duplicate($this);
|
cloneActorSystem = foundry.utils.duplicate($this.system);
|
||||||
let armor = 0;
|
let armor = 0;
|
||||||
for (let item of $this.items) {
|
for (let item of $this.items) {
|
||||||
if (item.type === "armor") {
|
if (item.type === "armor") {
|
||||||
@@ -643,11 +647,11 @@ class ActorCharacter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cloneActor.system.inventory.armor = armor;
|
cloneActorSystem.inventory.armor = armor;
|
||||||
}
|
}
|
||||||
static async recalculateWeight($this, cloneActor) {
|
static async recalculateWeight($this, cloneActorSystem) {
|
||||||
if (cloneActor === null || cloneActor === void 0)
|
if (cloneActorSystem === null || cloneActorSystem === void 0)
|
||||||
cloneActor = duplicate($this);
|
cloneActorSystem = foundry.utils.duplicate($this.system);
|
||||||
let updatedContainers = [];
|
let updatedContainers = [];
|
||||||
let containerChanges = {};
|
let containerChanges = {};
|
||||||
let containers = [];
|
let containers = [];
|
||||||
@@ -705,9 +709,9 @@ class ActorCharacter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cloneActor.system.inventory.weight = onHandWeight;
|
cloneActorSystem.inventory.weight = onHandWeight;
|
||||||
cloneActor.system.states.encumbrance = onHandWeight > $this.system.inventory.encumbrance.normal;
|
cloneActorSystem.states.encumbrance = onHandWeight > $this.system.inventory.encumbrance.normal;
|
||||||
await $this.update(cloneActor);
|
await $this.update({ system: cloneActorSystem });
|
||||||
if (updatedContainers.length > 0) {
|
if (updatedContainers.length > 0) {
|
||||||
await $this.updateEmbeddedDocuments("Item", updatedContainers);
|
await $this.updateEmbeddedDocuments("Item", updatedContainers);
|
||||||
}
|
}
|
||||||
@@ -950,6 +954,16 @@ class TravellerActor extends Actor {
|
|||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
async recalculateWeight() {
|
||||||
|
if (this.type === "character") {
|
||||||
|
return ActorCharacter.recalculateWeight(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async recalculateArmor() {
|
||||||
|
if (this.type === "character") {
|
||||||
|
return ActorCharacter.recalculateArmor(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TravellerItem extends Item {
|
class TravellerItem extends Item {
|
||||||
@@ -1189,7 +1203,7 @@ const _MGT2Helper = class _MGT2Helper {
|
|||||||
const pack = game.packs.get(item.pack);
|
const pack = game.packs.get(item.pack);
|
||||||
item = await (pack == null ? void 0 : pack.getDocument(item._id));
|
item = await (pack == null ? void 0 : pack.getDocument(item._id));
|
||||||
}
|
}
|
||||||
return deepClone(item);
|
return foundry.utils.deepClone(item);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
__publicField(_MGT2Helper, "POUNDS_CONVERT", 2.20462262185);
|
__publicField(_MGT2Helper, "POUNDS_CONVERT", 2.20462262185);
|
||||||
@@ -2485,14 +2499,17 @@ class TravellerActorSheet extends ActorSheet {
|
|||||||
transferData.system.container.id = targetId;
|
transferData.system.container.id = targetId;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
transferData.system.container.id = targetItem.system.container.id;
|
if (MGT2Helper.hasValue(targetItem.system.container, "id"))
|
||||||
|
transferData.system.container.id = targetItem.system.container.id;
|
||||||
|
else
|
||||||
|
transferData.system.container.id = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(await this.actor.createEmbeddedDocuments("Item", [transferData]))[0];
|
(await this.actor.createEmbeddedDocuments("Item", [transferData]))[0];
|
||||||
if (transferData.actor) ;
|
if (transferData.actor) ;
|
||||||
if (recalcWeight) {
|
if (recalcWeight) {
|
||||||
await this.actor.recalculateWeight();
|
await this.actor.recalculateWeight(this.actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"id": "mgt2",
|
"id": "mgt2",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"title": "MGT2 - Mongoose Traveller (Unofficial)",
|
"title": "MGT2 - Mongoose Traveller (Unofficial)",
|
||||||
"description": "An unofficial implementation of Mongoose Publishing Traveller (VO/VF). Traveller is the property of Mongoose Publishing, and can be purchased at https://www.mongoosepublishing.com",
|
"description": "An unofficial implementation of Mongoose Publishing Traveller (VO/VF). Traveller is the property of Mongoose Publishing, and can be purchased at https://www.mongoosepublishing.com",
|
||||||
"background": "systems/mgt2/assets/screens/rosette-nebula-ngc2239-hoo.webp",
|
"background": "systems/mgt2/assets/screens/rosette-nebula-ngc2239-hoo.webp",
|
||||||
"url": "https://github.com/JDR-Ninja/foundryvtt-mgt2",
|
"url": "https://github.com/JDR-Ninja/foundryvtt-mgt2",
|
||||||
"manifest": "https://github.com/JDR-Ninja/foundryvtt-mgt2/releases/latest/download/system.json",
|
"manifest": "https://github.com/JDR-Ninja/foundryvtt-mgt2/releases/latest/download/system.json",
|
||||||
"readme": "https://raw.githubusercontent.com/JDR-Ninja/foundryvtt-mgt2/main/README.md",
|
"readme": "https://raw.githubusercontent.com/JDR-Ninja/foundryvtt-mgt2/main/README.md",
|
||||||
"download": "https://github.com/JDR-Ninja/foundryvtt-mgt2/releases/download/v0.1.3/mgt2.zip",
|
"download": "https://github.com/JDR-Ninja/foundryvtt-mgt2/releases/download/v0.1.4/mgt2.zip",
|
||||||
"changelog": "https://raw.githubusercontent.com/JDR-Ninja/foundryvtt-mgt2/main/CHANGELOG.md",
|
"changelog": "https://raw.githubusercontent.com/JDR-Ninja/foundryvtt-mgt2/main/CHANGELOG.md",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user