Merge pull request 'Fix possession' (#540) from VincentVk/foundryvtt-reve-de-dragon:v1.5 into v1.5
Reviewed-on: public/foundryvtt-reve-de-dragon#540
This commit is contained in:
commit
782c6a8fe2
@ -372,12 +372,27 @@ export class RdDActor extends Actor {
|
||||
const list = this.getDraconicList();
|
||||
return duplicate(list[0]);
|
||||
}
|
||||
getDraconicOrZero() {
|
||||
const list = this.getDraconicList().filter(it => Misc.data(it).data.niveau >= 0);
|
||||
if (list.length == 0) {
|
||||
return { name: "Aucun", data: { niveau: 0 } };
|
||||
getDraconicOuPossession() {
|
||||
const possessions = this.items.filter(it => Misc.data(it).type == 'competencecreature' && Misc.templateData(it).ispossession)
|
||||
.sort(Misc.descending(it => Misc.templateData(it).niveau));
|
||||
if (possessions.length>0) {
|
||||
return duplicate(possessions[0]);
|
||||
}
|
||||
return duplicate(list[0]);
|
||||
const draconics = this.getDraconicList().filter(it => Misc.data(it).data.niveau >= 0);
|
||||
if (draconics.length> 0) {
|
||||
return duplicate(draconics[0]);
|
||||
}
|
||||
return {
|
||||
img: 'systems/foundryvtt-reve-de-dragon/icons/entites/possession.webp',
|
||||
name: 'Sans draconic',
|
||||
data: {
|
||||
niveau: 0,
|
||||
defaut_carac: "reve",
|
||||
}
|
||||
};
|
||||
}
|
||||
getPossession(possessionId) {
|
||||
return this.items.find(it => it.type == 'possession' && it.data.data.possessionid == possessionId);
|
||||
}
|
||||
|
||||
getDemiReve() {
|
||||
@ -783,7 +798,7 @@ export class RdDActor extends Actor {
|
||||
async combattreReveDeDragon(force) {
|
||||
let rollData = {
|
||||
actor: this,
|
||||
competence: duplicate(this.getDraconicOrZero()),
|
||||
competence: duplicate(this.getDraconicOuPossession()),
|
||||
canClose: false,
|
||||
rencontre: duplicate(TMRRencontres.getRencontre('rdd')),
|
||||
tmr: true,
|
||||
@ -2538,7 +2553,7 @@ export class RdDActor extends Actor {
|
||||
if (rollData.competence.type == 'competencecreature') {
|
||||
if (rollData.competence.data.iscombat) {
|
||||
if (rollData.competence.data.ispossession) {
|
||||
RdDPossession.managePossession(this, rollData.competence)
|
||||
RdDPossession.onAttaquePossession(this, rollData.competence)
|
||||
} else {
|
||||
const arme = RdDItemCompetenceCreature.toArme(rollData.competence)
|
||||
RdDCombat.createUsingTarget(this)?.attaque(competence, arme)
|
||||
@ -2566,8 +2581,8 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
conjurerPossession(possession) {
|
||||
let draconic = this.getBestDraconic();
|
||||
RdDPossession.managePossession(this, draconic, possession)
|
||||
let draconic = this.getDraconicOuPossession();
|
||||
RdDPossession.onAttaquePossession(this, draconic, possession)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -3206,7 +3221,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.managePossession(this, competence);
|
||||
RdDPossession.onAttaquePossession(this, competence);
|
||||
} else {
|
||||
RdDCombat.createUsingTarget(this)?.attaque(competence, arme);
|
||||
}
|
||||
|
@ -71,43 +71,34 @@ export class RdDPossession {
|
||||
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)
|
||||
let possession = attacker.getPossession(possessionId) ?? defender.getPossession(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
|
||||
mode: "conjuration",
|
||||
isECNIDefender: defender.type == "entite",
|
||||
possession: duplicate(possession),
|
||||
attacker: attacker,
|
||||
defender: defender,
|
||||
competence: defender.getDraconicOuPossession(),
|
||||
selectedCarac: defender.data.data.carac.reve,
|
||||
}
|
||||
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: defender.getReveActuel() } }
|
||||
rollData.selectedCarac = defender.data.data.carac.reve
|
||||
rollData.isECNIDefender = false
|
||||
} else {
|
||||
rollData.competence = duplicate(defender.getCompetence("Possession"))
|
||||
|
||||
if (rollData.isECNIDefender) {
|
||||
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 )
|
||||
} else {
|
||||
rollData.competence.data.defaut_carac = 'reve-actuel'
|
||||
rollData.forceCarac = { 'reve-actuel': { label: "Rêve Actuel", value: defender.getReveActuel() } }
|
||||
}
|
||||
rollData.mode = "conjuration"
|
||||
rollData.possesseur = attacker.name
|
||||
|
||||
const dialog = await RdDRoll.create(defender, rollData,
|
||||
{
|
||||
html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-defense-possession.html',
|
||||
options: { height: 400 }
|
||||
options: { height: 450 }
|
||||
},
|
||||
{
|
||||
name: 'conjurer',
|
||||
@ -121,16 +112,7 @@ export class RdDPossession {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async _onRollPossession( rollData, isSuccess ) {
|
||||
let possession = rollData.possession
|
||||
possession.isSuccess = isSuccess
|
||||
this.updateEtatPossession( possession)
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async managePossession(attacker, competence, possession=undefined) {
|
||||
|
||||
static async onAttaquePossession(attacker, competence, possession = undefined) {
|
||||
const target = RdDCombat.getTarget()
|
||||
if (target == undefined) {
|
||||
ui.notifications.warn((game.user.targets?.size ?? 0) > 1
|
||||
@ -140,23 +122,16 @@ export class RdDPossession {
|
||||
}
|
||||
|
||||
const defender = target.actor;
|
||||
if ( !possession) {
|
||||
possession = this.searchPossessionFromEntite( attacker, defender)
|
||||
if ( !possession) {
|
||||
possession = await this.createPossession(attacker, defender)
|
||||
}
|
||||
}
|
||||
possession = duplicate(possession);
|
||||
possession = duplicate(possession ?? this.searchPossessionFromEntite(attacker, defender) ??(await this.createPossession(attacker, defender)));
|
||||
|
||||
this.updateEtatPossession(possession)
|
||||
let rollData = {
|
||||
competence: competence.data.data.niveau >=0 ? competence : RdDPossession.competenceNonHautRevant(),
|
||||
mode: "possession",
|
||||
isECNIDefender: defender.type == "entite",
|
||||
competence: competence,
|
||||
possession: possession,
|
||||
possede: defender.name,
|
||||
possesseur: attacker.name,
|
||||
attackerId: attacker.data._id,
|
||||
defenderId: defender.data._id,
|
||||
mode: "possession"
|
||||
attacker: attacker,
|
||||
defender: defender
|
||||
};
|
||||
if (attacker.isCreature()) {
|
||||
RdDItemCompetenceCreature.setRollDataCreature(rollData)
|
||||
@ -168,7 +143,7 @@ export class RdDPossession {
|
||||
options: { height: 540 }
|
||||
}, {
|
||||
name: 'jet-possession',
|
||||
label: 'Possession: ',
|
||||
label: rollData.isECNIDefender ? 'Conjurer la possession' : 'Possession',
|
||||
callbacks: [
|
||||
{ condition: r => (r.rolled.isSuccess), action: async r => await this._onRollPossession(r, true) },
|
||||
{ condition: r => (r.rolled.isEchec), action: async r => await this._onRollPossession(r, false) },
|
||||
@ -177,17 +152,11 @@ export class RdDPossession {
|
||||
dialog.render(true)
|
||||
}
|
||||
|
||||
static competenceNonHautRevant() {
|
||||
return {
|
||||
img: 'systems/foundryvtt-reve-de-dragon/icons/competence_vigilance.webp',
|
||||
name: 'non Haut-rêvant',
|
||||
data: {
|
||||
data: {
|
||||
niveau: 0,
|
||||
defaut_carac: "reve",
|
||||
}
|
||||
}
|
||||
};
|
||||
/* -------------------------------------------- */
|
||||
static async _onRollPossession(rollData, isSuccess) {
|
||||
rollData.possession.isSuccess = isSuccess;
|
||||
this.updateEtatPossession(rollData.possession);
|
||||
await RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-possession.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -694,7 +694,7 @@ export class RdDUtility {
|
||||
actor.tmrApp.lancerSortEnReserve(coord, sortId);
|
||||
});
|
||||
|
||||
// gestion bouton tchat Acheter
|
||||
// gestion bouton tchat Possession
|
||||
html.on("click", '.defense-possession', event => {
|
||||
let attackerId = event.currentTarget.attributes['data-attackerId'].value
|
||||
let defenderId = event.currentTarget.attributes['data-defenderId'].value
|
||||
|
@ -321,6 +321,7 @@
|
||||
{{!-- Liste de blessures --}}
|
||||
{{> "systems/foundryvtt-reve-de-dragon/templates/actor-liste-blessures-partial.html" this}}
|
||||
|
||||
{{#if maladiesPoisons.length}}
|
||||
{{!-- Maladies & Poison --}}
|
||||
<h3 class="blessures-title">Maladies & Poisons:</h3>
|
||||
<ul class="item-list alterne-list">
|
||||
@ -354,7 +355,9 @@
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
{{#if possessions.length}}
|
||||
{{!-- Possession --}}
|
||||
<h3 class="blessures-title">Possession:</h3>
|
||||
<ul class="item-list alterne-list">
|
||||
@ -375,7 +378,7 @@
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
{{!-- Connaissances Tab --}}
|
||||
|
@ -1,29 +1,30 @@
|
||||
<img class="chat-icon" src="{{competence.img}}" />
|
||||
<h4>
|
||||
{{#if (eq mode "possession")}}
|
||||
{{alias}} tente de posséder {{possede}}
|
||||
{{attacker.name}} tente de {{#if isECNIDefender}}conjurer la possession de{{else}}posséder{{/if}} {{defender.name}}
|
||||
{{else}}
|
||||
{{alias}} tente de conjurer la possession de {{possesseur}}
|
||||
{{defender.name}} tente de {{#if isECNIDefender}}résister à{{else}}conjurer la possession de{{/if}} {{attacker.name}}
|
||||
{{/if}}
|
||||
</h4>
|
||||
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}}
|
||||
|
||||
<hr>
|
||||
|
||||
<div>
|
||||
<span class='chat-card-button-area'>
|
||||
<br>
|
||||
{{#if (eq mode "possession")}}
|
||||
{{#if possession.isSuccess}}
|
||||
<a class='defense-possession chat-card-button' data-attackerId='{{attackerId}}'
|
||||
data-defenderId='{{defenderId}}' data-possessionId='{{possession.data.possessionid}}'>Résister à la possession</a>
|
||||
<a class='defense-possession chat-card-button'
|
||||
data-attackerId='{{attacker.id}}'
|
||||
data-defenderId='{{defender.id}}'
|
||||
data-possessionId='{{possession.data.possessionid}}'>Résister à la possession</a>
|
||||
</a>
|
||||
{{else}}
|
||||
La Tentative de Possession a échouée !
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if rolled.isSuccess}}
|
||||
La Tentative de Possession a été conjurée ! {{alias}} résiste à la tentative de possession.
|
||||
La Tentative de Possession a été conjurée ! {{defender.name}} résiste à la tentative de possession.
|
||||
{{else}}
|
||||
La Tentative de Possession n'a pas pu être conjurée !
|
||||
{{/if}}
|
||||
|
@ -1,5 +1,9 @@
|
||||
<form class="skill-roll-dialog">
|
||||
<h2>Conjuration d'une Possession {{possession.name}}!</h2>
|
||||
<h2>
|
||||
{{defender.name}} tente de
|
||||
{{#if isECNIDefender}}maintenir{{else}}résister à{{/if}}
|
||||
la possession de {{attacker.name}}
|
||||
</h2>
|
||||
<div class="grid grid-2col">
|
||||
<div class="flex-group-left">
|
||||
<img class="chat-icon" src="{{competence.img}}" alt="{{competence.name}}"/>
|
||||
|
Loading…
Reference in New Issue
Block a user