Various fixes

This commit is contained in:
sladecraven 2022-05-14 17:28:27 +02:00
parent 0a65f767dd
commit fd32c21297
16 changed files with 164 additions and 82 deletions

View File

@ -40,7 +40,8 @@
"TypeQueue": "Queue de Dragon",
"TypeOmbre": "Ombre de Thanatos",
"TypeSouffle": "Souffle de Dragon",
"TypeTete": "Tête de Dragon"
"TypeTete": "Tête de Dragon",
"TypePossession": "Possession"
},
"EFFECT": {
"StatusStunned": "Sonné",

View File

@ -171,9 +171,10 @@ export class RdDActorSheet extends ActorSheet {
RdDSheetUtility.splitItem(item, this.actor);
});
html.find('.item-edit').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
item.sheet.render(true);
});
const item = RdDSheetUtility.getItem(event, this.actor)
console.log("ITEM :", item)
item.sheet.render(true)
})
html.find('.display-label a').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
item.sheet.render(true);
@ -195,7 +196,7 @@ export class RdDActorSheet extends ActorSheet {
});
html.find('.item-action').click(async event => {
const item = RdDSheetUtility.getItem(event, this.actor);
const item = RdDSheetUtility.getItem(event, this.actor)
this.actor.actionItem(item);
});
html.find('.subacteur-delete').click(async event => {
@ -205,8 +206,11 @@ export class RdDActorSheet extends ActorSheet {
html.find('.encaisser-direct').click(async event => {
this.actor.encaisser();
});
})
html.find('.sheet-possession-attack').click(async event => {
const poss = RdDSheetUtility.getItem(event, this.actor)
this.actor.conjurerPossession(poss)
})
html.find('.remise-a-neuf').click(async event => {
if (game.user.isGM) {
this.actor.remiseANeuf();

View File

@ -2537,18 +2537,19 @@ export class RdDActor extends Actor {
async rollCompetence(idOrName) {
let rollData = { competence: Misc.data(this.getCompetence(idOrName)) }
//console.log("COMP CREATURE", name, rollData, name);
if (rollData.competence.type == 'competencecreature') {
if (rollData.competence.data.iscombat) {
const arme = RdDItemCompetenceCreature.toArme(rollData.competence);
RdDCombat.createUsingTarget(this).attaque(rollData.competence, arme);
return;
if (rollData.competence.data.ispossession) {
RdDPossession.managePossession(this, rollData.competence)
} else {
const arme = RdDItemCompetenceCreature.toArme(rollData.competence)
RdDCombat.createUsingTarget(this)?.attaque(competence, arme)
}
return
}
//console.log("COMP CREATURE2");
// Fake competence pour créature
RdDItemCompetenceCreature.setRollDataCreature(rollData);
}
else {
RdDItemCompetenceCreature.setRollDataCreature(rollData)
} else {
rollData.carac = Misc.templateData(this).carac;
}
console.log("rollCompetence !!!", rollData);
@ -2565,6 +2566,12 @@ export class RdDActor extends Actor {
dialog.render(true);
}
/* -------------------------------------------- */
conjurerPossession(possession) {
let draconic = this.getBestDraconic()
RdDPossession.managePossession(this, draconic, possession)
}
/* -------------------------------------------- */
async _competenceResult(rollData) {
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-competence.html')
@ -2599,8 +2606,8 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async rollTache(id) {
const actorData = Misc.data(this);
const tacheData = Misc.data(this.getTache(id));
const compData = Misc.data(this.getCompetence(tacheData.data.competence));
const tacheData = Misc.data(this.getTache(id))
const compData = Misc.data(this.getCompetence(tacheData.data.competence))
compData.data.defaut_carac = tacheData.data.carac; // Patch !
let rollData = {
@ -3202,7 +3209,7 @@ export class RdDActor extends Actor {
let competence = Misc.data(this.getCompetence(arme.data.competence));
if (arme || (competence.type == 'competencecreature' && competence.data.iscombat)) {
if (competence.data.ispossession) {
RdDPossession.managePosession(this, competence);
RdDPossession.managePossession(this, competence);
} else {
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
}

View File

@ -7,9 +7,9 @@ export class RdDItemCompetenceCreature extends Item {
static setRollDataCreature(rollData) {
rollData.competence = Misc.data(rollData.competence);
rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
rollData.competence.data.defaut_carac = "carac_creature";
rollData.competence.data.categorie = "creature";
rollData.selectedCarac = rollData.carac.carac_creature;
rollData.competence.data.defaut_carac = "carac_creature"
rollData.competence.data.categorie = "creature"
rollData.selectedCarac = rollData.carac.carac_creature
if (rollData.competence.data.iscombat) {
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence);
}

View File

@ -60,7 +60,7 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */
async getData() {
const objectData = Misc.data(this.object);
const objectData = Misc.data(this.object)
let formData = {
id: this.object.id,
title: objectData.name,
@ -82,14 +82,15 @@ export class RdDItemSheet extends ItemSheet {
}
}
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences();
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences()
if (formData.type == 'tache' || formData.type == 'livre' || formData.type == 'meditation' || formData.type == 'oeuvre') {
formData.caracList = duplicate(game.system.model.Actor.personnage.carac);
formData.competences = await RdDUtility.loadCompendium('foundryvtt-reve-de-dragon.competences');
formData.caracList = duplicate(game.system.model.Actor.personnage.carac)
formData.caracList["reve-actuel"] = duplicate(game.system.model.Actor.personnage.reve.reve)
formData.competences = await RdDUtility.loadCompendium('foundryvtt-reve-de-dragon.competences')
}
if (formData.type == 'arme') {
formData.competences = await RdDUtility.loadCompendium('foundryvtt-reve-de-dragon.competences', it => RdDItemCompetence.isCompetenceArme(it));
console.log(formData.competences);
console.log(formData.competences)
}
if (formData.type == 'recettealchimique') {
RdDAlchimie.processManipulation(objectData, this.actor && this.actor.id);
@ -113,6 +114,7 @@ export class RdDItemSheet extends ItemSheet {
return formData;
}
/* -------------------------------------------- */
prepareConteneurData(formData) {
formData.itemsByType = Misc.classify(this.actor.items.map(i => foundry.utils.deepClone(i.data)));
RdDUtility.filterEquipementParType(formData);

View File

@ -3,8 +3,8 @@ import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js";
import { RdDUtility } from "./rdd-utility.js";
const typesObjetsEquipement = ["objet", "arme", "armure", "gemme", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "nourritureboisson", "monnaie"];
const typesObjetsOeuvres = ["oeuvre", "recettecuisine", "musique", "chant", "danse", "jeu"];
const typesObjetsEquipement = ["objet", "arme", "armure", "gemme", "conteneur", "herbe", "ingredient", "livre", "potion", "munition", "nourritureboisson", "monnaie"]
const typesObjetsOeuvres = ["oeuvre", "recettecuisine", "musique", "chant", "danse", "jeu"]
const encBrin = 0.00005;// un brin = 1 décigramme = 1/10g = 1/10000kg = 1/20000 enc
export const defaultItemImg = {
@ -34,7 +34,8 @@ export const defaultItemImg = {
oeuvre: "systems/foundryvtt-reve-de-dragon/icons/competence_comedie.webp",
nourritureboisson: "systems/foundryvtt-reve-de-dragon/icons/objets/provision_crue.webp",
signedraconique: "systems/foundryvtt-reve-de-dragon/icons/tmr/signe_draconique.webp",
gemme: "systems/foundryvtt-reve-de-dragon/icons/gemmes/almaze.webp"
gemme: "systems/foundryvtt-reve-de-dragon/icons/gemmes/almaze.webp",
possession: "systems/foundryvtt-reve-de-dragon/icons/entites/possession2.webp"
}
/* -------------------------------------------- */
@ -48,11 +49,11 @@ export class RdDItem extends Item {
}
static getTypeObjetsEquipement() {
return typesObjetsEquipement;
return typesObjetsEquipement
}
static getTypesOeuvres() {
return typesObjetsOeuvres;
return typesObjetsOeuvres
}
isCompetence() {

View File

@ -183,7 +183,7 @@ Hooks.once("init", async function () {
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
types: ["arme", "armure", "objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique", "gemme",
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson"], makeDefault: true
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson", "possession"], makeDefault: true
});
CONFIG.Combat.documentClass = RdDCombatManager;

View File

@ -5,7 +5,6 @@ import { RdDUtility } from "./rdd-utility.js";
import { RdDCombat } from "./rdd-combat.js";
import { RdDResolutionTable } from "./rdd-resolution-table.js";
import { RdDRoll } from "./rdd-roll.js";
import { RdDRollTables } from "./rdd-rolltables.js";
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
/* -------------------------------------------- */
@ -35,10 +34,10 @@ export class RdDPossession {
possession.ptsConjuration = 0;
possession.ptsPossession = 0;
if ( possession.data.compteur > 0) {
possession.ptsPossession = possession.data.compteur;
possession.ptsPossession = possession.data.compteur
}
if ( possession.data.compteur < 0) {
possession.ptsConjuration = Math.abs(possession.data.compteur);
possession.ptsConjuration = Math.abs(possession.data.compteur)
}
if (possession.ptsPossession >= 2 ) {
// Possede
@ -51,33 +50,61 @@ export class RdDPossession {
/* -------------------------------------------- */
static async resultConjuration( rollData) {
console.log("RollData!!!", rollData);
console.log("RollData!!!", rollData)
if ( !rollData.rolled.isSuccess ) {
rollData.possession.data.compteur++;
if( rollData.isECNIDefender) {
rollData.possession.data.compteur--
} else {
rollData.possession.data.compteur++
}
this.updateEtatPossession(rollData.possession);
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html');
let actor = game.actors.get(rollData.possession.data.possedeid)
let update = { _id: rollData.possession._id, "data.compteur": rollData.possession.data.compteur }
await this.updateEmbeddedDocuments('Item', [update])
}
this.updateEtatPossession(rollData.possession)
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html')
}
/* -------------------------------------------- */
static async onDefensePossession( actorId, possessionId) {
let actor = game.actors.get(actorId);
console.log("onDefensePossession", actor, possessionId);
let possession = duplicate(actor.items.find( item => item.type =='possession' && item.data.data.possessionid == possessionId));
let attacker = game.actors.get(possession.data.possesseurid);
static async onDefensePossession( attackerId, defenderId, possessionId) {
let attacker = game.actors.get(attackerId)
let defender = game.actors.get(defenderId)
let possession = attacker.items.find( item => item.type =='possession' && item.data.data.possessionid == possessionId)
if ( !possession ) {
possession = defender.items.find( item => item.type =='possession' && item.data.data.possessionid == possessionId)
if ( !possession) {
ui.notifications.warn("Une erreur s'est produite : Aucune possession trouvée !!")
return
}
}
possession = duplicate(possession)
// Update for draconic roll
let rollData = {
possession: possession
}
rollData.actor = actor;
rollData.competence = duplicate(actor.getDraconicOrZero());
rollData.competence.data.defaut_carac = 'reve-actuel';
rollData.actor = defender
if ( defender.type == "personnage") {
rollData.competence = duplicate(defender.getDraconicOrZero())
rollData.competence.data.defaut_carac = 'reve-actuel'
rollData.forceCarac = { 'reve-actuel': { label: "Rêve Actuel", value: actor.getReveActuel() } }
rollData.mode = "conjuration";
rollData.possesseur = attacker.name;
rollData.selectedCarac = defender.data.data.carac.reve
rollData.isECNIDefender = false
} else {
rollData.competence = duplicate(defender.getCompetence("Possession"))
rollData.competence.data.defaut_carac = "reve"
rollData.forceCarac = { 'reve': { label: "Rêve", value: defender.data.data.carac.reve.value } }
rollData.selectedCarac = defender.data.data.carac.reve
rollData.isECNIDefender = true
//RdDItemCompetenceCreature.setRollDataCreature( rollData )
}
rollData.mode = "conjuration"
rollData.possesseur = attacker.name
console.log("onDefensePossession", rollData)
const dialog = await RdDRoll.create(actor, rollData,
const dialog = await RdDRoll.create(defender, rollData,
{
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-defense-possession.html',
options: { height: 400 }
@ -90,21 +117,21 @@ export class RdDPossession {
]
}
);
dialog.render(true);
dialog.render(true)
}
/* -------------------------------------------- */
static async _onRollPossession( rollData, isSuccess ) {
let possession = rollData.possession;
possession.isSuccess = isSuccess;
this.updateEtatPossession( possession);
let possession = rollData.possession
possession.isSuccess = isSuccess
this.updateEtatPossession( possession)
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html');
}
/* -------------------------------------------- */
static async managePosession(attacker, competence ) {
static async managePossession(attacker, competence, possession=undefined) {
const target = RdDCombat.getTarget();
const target = RdDCombat.getTarget()
if (target == undefined) {
ui.notifications.warn((game.user.targets?.size ?? 0) > 1
? "Vous devez choisir <strong>une seule</strong> cible à posséder!"
@ -112,13 +139,16 @@ export class RdDPossession {
return;
}
const defender = target.actor;
let possession = this.searchPossessionFromEntite( attacker, defender);
const defender = target.actor
if ( !possession) {
possession = this.createPossession(attacker, defender);
possession = this.searchPossessionFromEntite( attacker, defender)
if ( !possession) {
possession = this.createPossession(attacker, defender)
}
}
possession = duplicate(possession)
this.updateEtatPossession(possession);
this.updateEtatPossession(possession)
let rollData = {
competence: competence,
possession: possession,
@ -129,9 +159,9 @@ export class RdDPossession {
mode: "possession"
};
if ( attacker.isCreature()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData);
RdDItemCompetenceCreature.setRollDataCreature(rollData)
}
console.log("Creation de possession2", attacker, rollData);
console.log("Creation de possession2", attacker, rollData)
const dialog = await RdDRoll.create( attacker, rollData,
{
@ -145,19 +175,19 @@ export class RdDPossession {
{ condition: r => (r.rolled.isEchec), action: async r => await this._onRollPossession(r, false) },
]
});
dialog.render(true);
dialog.render(true)
}
/* -------------------------------------------- */
static async createPossession( attacker, defender ) {
let posessionData = {
name: "Possession en cours", type: 'possession',
let possessionData = {
name: "Possession en cours de " + attacker.name, type: 'possession',
img: "systems/foundryvtt-reve-de-dragon/icons/entites/possession2.webp",
data: { description: "", possede: false, possessionid: randomID(16), possesseurid: attacker.data._id, possedeid: defender.data._id, date: 0 }
data: { description: "", typepossession: attacker.name, possede: false, possessionid: randomID(16), possesseurid: attacker.data._id, possedeid: defender.data._id, date: 0, compteur: 0 }
}
await attacker.createEmbeddedDocuments('Item', [posessionData])
let poss = await defender.createEmbeddedDocuments('Item', [posessionData])
return duplicate(poss[0]);
// Creates only the possession on the personnage side
let poss = await defender.createEmbeddedDocuments('Item', [possessionData])
return duplicate(poss[0])
}
}

View File

@ -64,7 +64,11 @@ export class RdDRoll extends Dialog {
canClose: true,
isGM: game.user.isGM,
forceDiceResult: -1
};
}
// Mini patch :Ajout du rêve actuel
if ( actorData.type == "personnage") {
defaultRollData.carac["reve-actuel"] = actorData.data.reve.reve
}
mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false });
if (rollData.forceCarac) {
@ -298,8 +302,8 @@ export class RdDRoll extends Dialog {
async updateRollResult() {
let rollData = this.rollData;
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat());
rollData.caracValue = parseInt(rollData.selectedCarac.value);
rollData.dmg = rollData.attackerRoll?.dmg ?? RdDBonus.dmg(rollData, this.actor.getBonusDegat())
rollData.caracValue = parseInt(rollData.selectedCarac.value)
rollData.mortalite = rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite ?? 'mortel';
rollData.coupsNonMortels = (rollData.attackerRoll?.dmg.mortalite ?? rollData.dmg.mortalite) == 'non-mortel';
rollData.use.appelAuMoral = this.actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac);

View File

@ -4,7 +4,7 @@ import { Misc } from "./misc.js";
export class RdDSheetUtility {
static getItem(event, actor) {
return actor.items.get(RdDSheetUtility.getItemId(event));
return actor.items.get(RdDSheetUtility.getItemId(event))
}
static getItemId(event) {

View File

@ -147,6 +147,7 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/item-meditation-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-nourritureboisson-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/item-possession-sheet.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html',
'systems/foundryvtt-reve-de-dragon/templates/competence-base.html',
'systems/foundryvtt-reve-de-dragon/templates/enum-aspect-tarot.html',
@ -473,6 +474,7 @@ export class RdDUtility {
return str;
}
/* -------------------------------------------- */
static buildContenu(objet, niveau, afficherContenu) {
if (!niveau) niveau = 1;
objet.niveau = niveau;
@ -692,9 +694,10 @@ export class RdDUtility {
// gestion bouton tchat Acheter
html.on("click", '.defense-possession', event => {
let actorId = event.currentTarget.attributes['data-defenderId'].value;
let possessionId = event.currentTarget.attributes['data-possessionId'].value;
RdDPossession.onDefensePossession(actorId, possessionId);
let attackerId = event.currentTarget.attributes['data-attackerId'].value
let defenderId = event.currentTarget.attributes['data-defenderId'].value
let possessionId = event.currentTarget.attributes['data-possessionId'].value
RdDPossession.onDefensePossession(attackerId, defenderId, possessionId)
});
// gestion bouton tchat Acheter

View File

@ -29,7 +29,7 @@
"url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-reve-de-dragon/",
"license": "LICENSE.txt",
"flags": {},
"version": "1.5.69",
"version": "1.5.71",
"minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "9",
"scripts": [],

View File

@ -578,7 +578,7 @@
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson", "signedraconique", "gemme",
"possession" ],
"possession": {
"type": "",
"typepossession": "",
"possede": false,
"possessionid": "",
"possesseurid": "",

View File

@ -366,7 +366,7 @@
{{#each possessions as |possession key|}}
<li class="item flexrow list-item" data-item-id="{{possession._id}}">
<span class="competence-label">
{{possession.name}}
<a class="sheet-possession-attack">{{possession.name}} (Conjurer)</a>
</span>
<span class="competence-label">{{possession.data.type}}</span>
<div class="item-controls">

View File

@ -15,3 +15,4 @@
<option value="tir">Tir</option>
<option value="lancer">Lancer</option>
<option value="derobee">Dérobée</option>
<option value="reve-actuel">Rêve Actuel</option>

View File

@ -0,0 +1,29 @@
<form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header">
<img class="profile-img" src="{{img}}" data-edit="img" title="{{name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
</div>
</header>
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="form-group">
<label for="xp">Type de possession </label>
<input class="attribute-value" type="text" name="data.typepossession" value="{{data.typepossession}}" data-dtype="String"/>
</div>
<div class="form-group">
<label for="xp">Possédé ? </label>
<input class="attribute-value" type="checkbox" name="data.istrue" {{#if data.istrue}}checked{{/if}}/>
</div>
<div class="form-group">
<label for="xp">Compteur </label>
<input class="attribute-value" type="text" name="data.compteur" value="{{data.compteur}}" data-dtype="Number"/>
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html"}}
</section>
</form>