forked from public/foundryvtt-reve-de-dragon
Séparation de l'Actor Vehicule
This commit is contained in:
@ -145,8 +145,11 @@ export class RdDBaseActor extends Actor {
|
||||
}
|
||||
|
||||
getMonnaie(id) { return this.findItemLike(id, 'monnaie'); }
|
||||
|
||||
getReveActuel() { return 0 }
|
||||
computeMalusSurEncombrement() { return 0 }
|
||||
getEncombrementMax() { return 0 }
|
||||
recompute() { }
|
||||
async setEffect(statusId, status) { }
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -388,14 +391,6 @@ export class RdDBaseActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computeMalusSurEncombrement() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getEncombrementMax() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
async computeEncTotal() {
|
||||
if (!this.pack) {
|
||||
this.encTotal = this.items.map(it => it.getEncTotal()).reduce(Misc.sum(), 0);
|
||||
|
@ -15,10 +15,7 @@ export class RdDCommerce extends RdDBaseActor {
|
||||
}
|
||||
|
||||
canReceive(item) {
|
||||
if (item.isInventaire('all')) {
|
||||
return true;
|
||||
}
|
||||
return super.canReceive(item);
|
||||
return item.isInventaire('all');
|
||||
}
|
||||
|
||||
getQuantiteDisponible(item) {
|
||||
|
55
module/actor/vehicule-sheet.js
Normal file
55
module/actor/vehicule-sheet.js
Normal file
@ -0,0 +1,55 @@
|
||||
import { RdDUtility } from "../rdd-utility.js";
|
||||
import { RdDBaseActorSheet } from "./base-actor-sheet.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDActorVehiculeSheet extends RdDBaseActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
RdDUtility.initAfficheContenu();
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["rdd", "sheet", "actor"],
|
||||
template: "systems/foundryvtt-reve-de-dragon/templates/actor-vehicule-sheet.html",
|
||||
width: 640,
|
||||
height: 720,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: undefined }]
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
let formData = await super.getData();
|
||||
mergeObject(formData,
|
||||
{
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
effects: this.actor.effects.map(e => foundry.utils.deepClone(e)),
|
||||
limited: this.actor.limited,
|
||||
owner: this.actor.isOwner,
|
||||
});
|
||||
|
||||
this.timerRecherche = undefined;
|
||||
return formData;
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
if (!this.options.editable) return;
|
||||
|
||||
this.html.find('.resistance-moins').click(async event => {
|
||||
this.actor.vehicleIncDec("resistance", -1);
|
||||
});
|
||||
this.html.find('.resistance-plus').click(async event => {
|
||||
this.actor.vehicleIncDec("resistance", 1);
|
||||
});
|
||||
this.html.find('.structure-moins').click(async event => {
|
||||
this.actor.vehicleIncDec("structure", -1);
|
||||
});
|
||||
this.html.find('.structure-plus').click(async event => {
|
||||
this.actor.vehicleIncDec("structure", 1);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
28
module/actor/vehicule.js
Normal file
28
module/actor/vehicule.js
Normal file
@ -0,0 +1,28 @@
|
||||
import { RdDBaseActor } from "./base-actor.js";
|
||||
|
||||
export class RdDVehicule extends RdDBaseActor {
|
||||
|
||||
static get defaultIcon() {
|
||||
return "systems/foundryvtt-reve-de-dragon/icons/vehicules/charette.webp";
|
||||
}
|
||||
isVehicule() { return true }
|
||||
|
||||
canReceive(item) {
|
||||
return item.isInventaire();
|
||||
}
|
||||
|
||||
getEncombrementMax() {
|
||||
return this.system.capacite_encombrement;
|
||||
}
|
||||
|
||||
async vehicleIncDec(name, inc) {
|
||||
if (!['resistance', 'structure'].includes(name)) {
|
||||
return
|
||||
}
|
||||
const newValue = this.system.etat[name].value + inc;
|
||||
if (0 <= newValue && newValue <= this.system.etat[name].max) {
|
||||
await this.update({ [`system.etat.${name}.value`]: newValue })
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user