Gestion de la Faune #587
@ -132,12 +132,14 @@ export class RdDActorSheet extends ActorSheet {
|
||||
/* -------------------------------------------- */
|
||||
async _onDropItem(event, dragData) {
|
||||
const destItemId = $(event.target)?.closest('.item').attr('data-item-id')
|
||||
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor.id, dragData, this.objetVersConteneur)
|
||||
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
|
||||
if (dropParams){
|
||||
const callSuper = await this.actor.processDropItem(dropParams)
|
||||
if (callSuper) {
|
||||
await super._onDropItem(event, dragData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async createItem(name, type) {
|
||||
|
@ -145,7 +145,7 @@ export class RdDActor extends Actor {
|
||||
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
||||
// things organized.
|
||||
if (this.isPersonnage()) this._prepareCharacterData(this)
|
||||
if (this.isCreature()) this._prepareCreatureData(this)
|
||||
if (this.isCreatureEntite()) this._prepareCreatureData(this)
|
||||
if (this.isVehicule()) this._prepareVehiculeData(this)
|
||||
this.computeEtatGeneral();
|
||||
}
|
||||
@ -193,10 +193,36 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
canReceive(item) {
|
||||
if (this.isCreature()) {
|
||||
return item.type == 'competencecreature' || RdDItem.isItemInventaire(item);
|
||||
}
|
||||
if (this.isEntite()) {
|
||||
return item.type == 'competencecreature';
|
||||
}
|
||||
if (this.isVehicule()) {
|
||||
return RdDItem.isItemInventaire(item);
|
||||
}
|
||||
if (this.isPersonnage()) {
|
||||
switch (item.type) {
|
||||
case 'competencecreature': case 'tarot':
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
isCreature() {
|
||||
isCreatureEntite() {
|
||||
return this.type == 'creature' || this.type == 'entite';
|
||||
}
|
||||
isCreature() {
|
||||
return this.type == 'creature';
|
||||
}
|
||||
isEntite() {
|
||||
return this.type == 'entite';
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
isPersonnage() {
|
||||
return this.type == 'personnage';
|
||||
@ -1175,13 +1201,13 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
let result = true;
|
||||
const item = this.getObjet(itemId);
|
||||
if (item?.isEquipement() && sourceActorId == targetActorId) {
|
||||
if (item?.isInventaire() && sourceActorId == targetActorId) {
|
||||
// rangement
|
||||
if (srcId != destId && itemId != destId) { // déplacement de l'objet
|
||||
const src = this.getObjet(srcId);
|
||||
const dest = this.getObjet(destId);
|
||||
const cible = this.getContenantOrParent(dest);
|
||||
const [empilable, message] = item.isEquipementEmpilable(dest);
|
||||
const [empilable, message] = item.isInventaireEmpilable(dest);
|
||||
if (empilable) {
|
||||
await this.regrouperEquipementsSimilaires(item, dest);
|
||||
result = false;
|
||||
@ -1359,7 +1385,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
computePrixTotalEquipement() {
|
||||
const valeur = this.items.filter(it => it.isEquipement())
|
||||
const valeur = this.items.filter(it => it.isInventaire())
|
||||
.map(it => it.valeurTotale())
|
||||
.reduce(Misc.sum(), 0);
|
||||
return valeur;
|
||||
@ -2995,7 +3021,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getHeureNaissance() {
|
||||
if (this.isCreature()) {
|
||||
if (this.isCreatureEntite()) {
|
||||
return 0;
|
||||
}
|
||||
return this.system.heure;
|
||||
@ -3003,7 +3029,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
ajustementAstrologique() {
|
||||
if (this.isCreature()) {
|
||||
if (this.isCreatureEntite()) {
|
||||
return 0;
|
||||
}
|
||||
// selon l'heure de naissance...
|
||||
|
@ -30,9 +30,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
/* -------------------------------------------- */
|
||||
_getHeaderButtons() {
|
||||
let buttons = super._getHeaderButtons();
|
||||
// Add "Post to chat" button
|
||||
// We previously restricted this to GM and editable items only. If you ever find this comment because it broke something: eh, sorry!
|
||||
if ("cout" in this.item.system && this.item.isVideOuNonConteneur()) {
|
||||
if (this.item.isInventaire() && this.item.isVideOuNonConteneur()) {
|
||||
buttons.unshift({
|
||||
class: "vendre",
|
||||
icon: "fas fa-comments-dollar",
|
||||
@ -256,8 +254,10 @@ export class RdDItemSheet extends ItemSheet {
|
||||
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
if (this.item.type == 'sort') {
|
||||
// Données de bonus de cases ?
|
||||
formData['system.bonuscase'] = RdDItemSort.buildBonusCaseStringFromFormData(formData.bonusValue, formData.caseValue);
|
||||
}
|
||||
|
||||
return this.item.update(formData);
|
||||
}
|
||||
@ -301,7 +301,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
/* -------------------------------------------- */
|
||||
async _onDropItem(event, dragData) {
|
||||
if (this.actor) {
|
||||
const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor.id, dragData, this.objetVersConteneur);
|
||||
const dropParams = RdDSheetUtility.prepareItemDropParameters(this.item.id, this.actor, dragData, this.objetVersConteneur);
|
||||
await this.actor.processDropItem(dropParams);
|
||||
await this.render(true);
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
import { DialogItemVente } from "./dialog-item-vente.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { Monnaie } from "./item-monnaie.js";
|
||||
import { RdDHerbes } from "./rdd-herbes.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
const typesObjetsEquipement = [
|
||||
const typesObjetsInventaire = [
|
||||
"arme",
|
||||
"armure",
|
||||
"conteneur",
|
||||
@ -70,7 +69,11 @@ export class RdDItem extends Item {
|
||||
return defaultItemImg[itemType];
|
||||
}
|
||||
|
||||
static isEquipementFieldEditable(type, field) {
|
||||
static isItemInventaire(newLocal) {
|
||||
return typesObjetsInventaire.includes(newLocal.type);
|
||||
}
|
||||
|
||||
static isFieldInventaireModifiable(type, field) {
|
||||
switch (field) {
|
||||
case 'quantite':
|
||||
if (['conteneur'].includes(type)) {
|
||||
@ -102,8 +105,8 @@ export class RdDItem extends Item {
|
||||
super(itemData, context);
|
||||
}
|
||||
|
||||
static getTypesObjetsEquipement() {
|
||||
return typesObjetsEquipement
|
||||
static getItemTypesInventaire() {
|
||||
return typesObjetsInventaire
|
||||
}
|
||||
|
||||
static getTypesOeuvres() {
|
||||
@ -113,11 +116,14 @@ export class RdDItem extends Item {
|
||||
isCompetencePersonnage() {
|
||||
return this.type == 'competence'
|
||||
}
|
||||
isCompetenceCreature() {
|
||||
return this.type == 'competencecreature'
|
||||
}
|
||||
isCompetence() {
|
||||
return typesObjetsCompetence.includes(this.type)
|
||||
}
|
||||
isEquipement() {
|
||||
return typesObjetsEquipement.includes(this.type)
|
||||
isInventaire() {
|
||||
return RdDItem.isItemInventaire(this)
|
||||
}
|
||||
isOeuvre() {
|
||||
return typesObjetsOeuvres.includes(this.type)
|
||||
@ -136,7 +142,7 @@ export class RdDItem extends Item {
|
||||
}
|
||||
|
||||
getItemGroup() {
|
||||
if (this.isEquipement()) return "equipement";
|
||||
if (this.isInventaire()) return "equipement";
|
||||
if (this.isOeuvre()) return "oeuvre";
|
||||
if (this.isDraconique()) return "draconique";
|
||||
if (this.isConnaissance()) return "connaissance";
|
||||
@ -202,7 +208,7 @@ export class RdDItem extends Item {
|
||||
|
||||
prepareDerivedData() {
|
||||
super.prepareDerivedData();
|
||||
if (this.isEquipement()) {
|
||||
if (this.isInventaire()) {
|
||||
this.system.encTotal = this.getEncTotal();
|
||||
if (this.isPotion()) {
|
||||
this.prepareDataPotion()
|
||||
@ -275,8 +281,8 @@ export class RdDItem extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// détermine si deux équipements sont similaires: de même type, et avec les même champs hormis la quantité
|
||||
isEquipementEmpilable(other) {
|
||||
if (!other || !this.isEquipement()) {
|
||||
isInventaireEmpilable(other) {
|
||||
if (!other || !this.isInventaire()) {
|
||||
return [false, undefined];
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,8 @@ export class Misc {
|
||||
}
|
||||
|
||||
static typeName(type, subType) {
|
||||
return game.i18n.localize(`${type.toUpperCase()}.Type${Misc.upperFirst(subType)}`);
|
||||
return subType ? game.i18n.localize(`${type.toUpperCase()}.Type${Misc.upperFirst(subType)}`)
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,7 +246,7 @@ export class RdDCombatManager extends Combat {
|
||||
if (actions.length > 0) {
|
||||
return actions;
|
||||
}
|
||||
if (actor.isCreature()) {
|
||||
if (actor.isCreatureEntite()) {
|
||||
actions = actions.concat(RdDCombatManager.listActionsCreature(actor.itemTypes['competencecreature']));
|
||||
} else {
|
||||
// Recupération des items 'arme'
|
||||
@ -821,7 +821,7 @@ export class RdDCombat {
|
||||
essais: {}
|
||||
};
|
||||
|
||||
if (this.attacker.isCreature()) {
|
||||
if (this.attacker.isCreatureEntite()) {
|
||||
RdDItemCompetenceCreature.setRollDataCreature(rollData);
|
||||
}
|
||||
else if (arme) {
|
||||
@ -1079,7 +1079,7 @@ export class RdDCombat {
|
||||
show: {}
|
||||
};
|
||||
|
||||
if (this.defender.isCreature()) {
|
||||
if (this.defender.isCreatureEntite()) {
|
||||
RdDItemCompetenceCreature.setRollDataCreature(defenderRoll);
|
||||
}
|
||||
|
||||
@ -1158,7 +1158,7 @@ export class RdDCombat {
|
||||
show: {}
|
||||
};
|
||||
|
||||
if (this.defender.isCreature()) {
|
||||
if (this.defender.isCreatureEntite()) {
|
||||
RdDItemCompetenceCreature.setRollDataCreature(rollData);
|
||||
}
|
||||
return rollData;
|
||||
|
@ -45,7 +45,7 @@ export class RdDPossession {
|
||||
defender: defender,
|
||||
targetToken: Targets.extractTokenData(target)
|
||||
};
|
||||
if (attacker.isCreature()) {
|
||||
if (attacker.isCreatureEntite()) {
|
||||
RdDItemCompetenceCreature.setRollDataCreature(rollData)
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,12 @@ export class RdDSheetUtility {
|
||||
return $(event.currentTarget)?.parents(".item");
|
||||
}
|
||||
|
||||
static prepareItemDropParameters(destItemId, actorId, dragData, objetVersConteneur) {
|
||||
static prepareItemDropParameters(destItemId, actor, dragData, objetVersConteneur) {
|
||||
const item = fromUuidSync(dragData.uuid)
|
||||
if (actor.canReceive(item)) {
|
||||
return {
|
||||
destId: destItemId,
|
||||
targetActorId: actorId,
|
||||
targetActorId: actor.id,
|
||||
itemId: item.id,
|
||||
sourceActorId: item.actor?.id,
|
||||
srcId: objetVersConteneur[item.id],
|
||||
@ -31,6 +32,11 @@ export class RdDSheetUtility {
|
||||
onAjouterDansConteneur: (itemId, conteneurId) => { objetVersConteneur[itemId] = conteneurId; }
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui.notifications.warn(`Impossible de donner ${item.name} à ${actor.name}: ${item.type} / ${actor.type}`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
static async splitItem(item, actor, onSplit = () => { }) {
|
||||
const dialog = await DialogSplitItem.create(item, async (item, split) => {
|
||||
|
@ -330,7 +330,7 @@ export class RdDUtility {
|
||||
);
|
||||
Handlebars.registerHelper('linkCompendium', (compendium, id, name) => `@Compendium[${compendium}.${id}]{${name}}`);
|
||||
Handlebars.registerHelper('uniteQuantite', (type) => RdDItem.getUniteQuantite(type));
|
||||
Handlebars.registerHelper('isEquipementFieldEditable', (type, field) => RdDItem.isEquipementFieldEditable(type, field));
|
||||
Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field));
|
||||
Handlebars.registerHelper('getFrequenceRarete', (rarete, field) => Environnement.getFrequenceRarete(rarete, field));
|
||||
Handlebars.registerHelper('either', (a, b) => a ?? b);
|
||||
return loadTemplates(templatePaths);
|
||||
@ -344,7 +344,7 @@ export class RdDUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async selectObjetType(actorSheet) {
|
||||
let typeObjets = RdDItem.getTypesObjetsEquipement();
|
||||
let typeObjets = RdDItem.getItemTypesInventaire();
|
||||
let options = `<span class="competence-label">Selectionnez le type d'équipement</span><select class="item-type">`;
|
||||
for (let typeName of typeObjets) {
|
||||
options += `<option value="${typeName}">${typeName}</option>`
|
||||
@ -467,8 +467,7 @@ export class RdDUtility {
|
||||
formData.potions = this.arrayOrEmpty(itemTypes['potion']);
|
||||
formData.ingredients = this.arrayOrEmpty(itemTypes['ingredient']);
|
||||
formData.herbes = this.arrayOrEmpty(itemTypes['herbe']);
|
||||
formData.monnaie = this.arrayOrEmpty(itemTypes['monnaie']);
|
||||
formData.monnaie.sort(Monnaie.triValeurEntiere());
|
||||
formData.monnaie = this.arrayOrEmpty(itemTypes['monnaie']).sort(Monnaie.triValeurEntiere());
|
||||
formData.nourritureboissons = this.arrayOrEmpty(itemTypes['nourritureboisson']);
|
||||
formData.gemmes = this.arrayOrEmpty(itemTypes['gemme']);
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
<div class="form-group">
|
||||
<label for="system.qualite">Qualité</label>
|
||||
<input class="attribute-value" type="text" name="system.qualite" value="{{system.qualite}}" data-dtype="Number"
|
||||
{{#unless (isEquipementFieldEditable type 'qualite')}}disabled{{/unless}}/>
|
||||
{{#unless (isFieldInventaireModifiable type 'qualite')}}disabled{{/unless}}/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="system.encombrement">Encombrement</label>
|
||||
<input class="attribute-value" type="text" name="system.encombrement" value="{{system.encombrement}}" data-dtype="Number"
|
||||
{{#unless (isEquipementFieldEditable type 'encombrement')}}disabled{{/unless}}/>
|
||||
{{#unless (isFieldInventaireModifiable type 'encombrement')}}disabled{{/unless}}/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="system.quantite">Quantité {{uniteQuantite type}}</label>
|
||||
<input class="attribute-value" type="text" name="system.quantite" value="{{system.quantite}}" data-dtype="Number"
|
||||
{{#unless (isEquipementFieldEditable type 'quantite')}}disabled{{/unless}}/>
|
||||
{{#unless (isFieldInventaireModifiable type 'quantite')}}disabled{{/unless}}/>
|
||||
</div>
|
||||
<div class="form-group item-cout">
|
||||
<label for="system.cout">Prix (sols) </label>
|
||||
<input class="attribute-value" type="text" name="system.cout" value="{{system.cout}}" data-dtype="Number"
|
||||
{{#unless (isEquipementFieldEditable type 'cout')}}disabled{{/unless}}/>
|
||||
{{#unless (isFieldInventaireModifiable type 'cout')}}disabled{{/unless}}/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user