Gestion auto de l'état sonné en combat
This commit is contained in:
parent
98c6133938
commit
1cdadbd9d6
@ -345,7 +345,14 @@ export class RdDActor extends Actor {
|
|||||||
await this.update({ "data.blessures": blessures });
|
await this.update({ "data.blessures": blessures });
|
||||||
await this._recupererVie(message);
|
await this._recupererVie(message);
|
||||||
await this.jetDeMoral('neutre');
|
await this.jetDeMoral('neutre');
|
||||||
|
|
||||||
|
// On ne récupère un point de chance que si aucun appel à la chance dans la journée
|
||||||
|
let utilisationChance = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'utilisationChance') ?? false);
|
||||||
|
if ( !utilisationChance ) {
|
||||||
await this.chanceActuelleIncDec(1);
|
await this.chanceActuelleIncDec(1);
|
||||||
|
}
|
||||||
|
await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance'); // Nouveau jour, suppression du flag
|
||||||
|
|
||||||
this.transformerStress();
|
this.transformerStress();
|
||||||
await this.retourSeuilDeReve(message);
|
await this.retourSeuilDeReve(message);
|
||||||
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
message.content = `A la fin Chateau Dormant, ${message.content}<br>Un nouveau jour se lève`;
|
||||||
@ -1250,18 +1257,41 @@ export class RdDActor extends Actor {
|
|||||||
getSonne() {
|
getSonne() {
|
||||||
return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.value ?? false);
|
return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.value ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
getSonneRound() {
|
||||||
|
return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.round ?? false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async verifierSonneRound( round ) {
|
||||||
|
if ( this.getSonne() ) {
|
||||||
|
if ( round >= this.getSonneRound() + 1) {
|
||||||
|
await this.setSonne( false, -1 ); // Nettoyer l'état sonné
|
||||||
|
ChatMessage.create( { content: `${this.name} n'est plus sonné ce round !`} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
async setSonne(sonne = true) {
|
async setSonne(sonne = true) {
|
||||||
if (this.isEntiteCauchemar()) {
|
if (this.isEntiteCauchemar()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let round = (sonne && game.combat) ? game.combat.current.round : -1; // Sauvegarde du round de sonné en cas de combat
|
||||||
await this.setStatusSonne(sonne);
|
await this.setStatusSonne(sonne);
|
||||||
await this.setStateSonne(sonne);
|
await this.setStateSonne(sonne, round);
|
||||||
}
|
}
|
||||||
async setStateSonne(sonne) {
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async setStateSonne(sonne, round = -1) {
|
||||||
if (this.isEntiteCauchemar()) {
|
if (this.isEntiteCauchemar()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.update({ "data.sante.sonne.value": sonne });
|
let sonneData = duplicate(this.data.data.sante.sonne);
|
||||||
|
sonneData.value = sonne;
|
||||||
|
sonneData.round = round;
|
||||||
|
await this.update({ "data.sante.sonne": sonneData });
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -1279,15 +1309,15 @@ export class RdDActor extends Actor {
|
|||||||
RdDDice.show(roll);
|
RdDDice.show(roll);
|
||||||
let result = {
|
let result = {
|
||||||
roll: roll,
|
roll: roll,
|
||||||
sonne: roll.total > endurance || roll.total == 20
|
sonne: roll.total > endurance || roll.total == 20 // 20 is always a failure
|
||||||
}
|
}
|
||||||
if (roll.total == 1) {
|
if (roll.total == 1) {
|
||||||
let xp = Misc.toInt(this.data.data.carac.constitution.xp) + 1;
|
let xp = Misc.toInt(this.data.data.carac.constitution.xp) + 1;
|
||||||
this.update({ "data.carac.constitution.xp": xp }); // +1 XP !
|
this.update({ "data.carac.constitution.xp": xp }); // +1 XP !
|
||||||
// TODO : Output to chat
|
ChatMessage.create( { content: `${this.name} a obenu 1 sur son Jet d'Endurance et a gagné 1 point d'Expérience en Constitution. Ce point d'XP a été ajouté automatiquement).`});
|
||||||
}
|
}
|
||||||
if (result.sonne) {
|
if (result.sonne) {
|
||||||
// 20 is always a failure
|
|
||||||
await this.setSonne();
|
await this.setSonne();
|
||||||
sante.sonne.value = true;
|
sante.sonne.value = true;
|
||||||
}
|
}
|
||||||
@ -2249,6 +2279,10 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
|
async rollAppelChance(onSuccess = () => { }, onEchec = () => { }) {
|
||||||
|
// Stocke si utilisation de la chance
|
||||||
|
await this.unsetFlag('foundryvtt-reve-de-dragon', 'utilisationChance');
|
||||||
|
await this.setFlag('foundryvtt-reve-de-dragon', 'utilisationChance', true );
|
||||||
|
|
||||||
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
|
let rollData = { selectedCarac: this.getCaracByName('chance-actuelle'), surprise: '' };
|
||||||
const dialog = await RdDRoll.create(this, rollData,
|
const dialog = await RdDRoll.create(this, rollData,
|
||||||
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
|
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' },
|
||||||
@ -2407,6 +2441,7 @@ export class RdDActor extends Actor {
|
|||||||
return RdDActor._findCaracByName(this.data.data.carac, caracName);
|
return RdDActor._findCaracByName(this.data.data.carac, caracName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
static _findCaracByName(carac, name) {
|
static _findCaracByName(carac, name) {
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
switch (name) {
|
switch (name) {
|
||||||
|
@ -19,10 +19,18 @@ export class RdDCombatManager extends Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
cleanSonne( ) {
|
||||||
|
for (let combatant of this.data.combatants) {
|
||||||
|
combatant.actor.verifierSonneRound( this.current.round );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async nextRound() {
|
async nextRound() {
|
||||||
//console.log('New round !');
|
//console.log('New round !');s
|
||||||
this.cleanItemUse();
|
this.cleanItemUse();
|
||||||
|
this.cleanSonne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,10 +85,12 @@ export class RdDCommands {
|
|||||||
this.commandsTable = {};
|
this.commandsTable = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
registerCommand(command) {
|
registerCommand(command) {
|
||||||
this._addCommand(this.commandsTable, command.path, '', command);
|
this._addCommand(this.commandsTable, command.path, '', command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
_addCommand(targetTable, path, fullPath, command) {
|
_addCommand(targetTable, path, fullPath, command) {
|
||||||
if (!this._validateCommand(targetTable, path, command)) {
|
if (!this._validateCommand(targetTable, path, command)) {
|
||||||
return;
|
return;
|
||||||
@ -107,6 +109,7 @@ export class RdDCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
_validateCommand(targetTable, path, command) {
|
_validateCommand(targetTable, path, command) {
|
||||||
if (path.length > 0 && path[0] && command.descr && (path.length != 1 || targetTable[path[0]] == undefined)) {
|
if (path.length > 0 && path[0] && command.descr && (path.length != 1 || targetTable[path[0]] == undefined)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
"name": "foundryvtt-reve-de-dragon",
|
"name": "foundryvtt-reve-de-dragon",
|
||||||
"title": "Rêve de Dragon",
|
"title": "Rêve de Dragon",
|
||||||
"description": "Rêve de Dragon RPG for FoundryVTT",
|
"description": "Rêve de Dragon RPG for FoundryVTT",
|
||||||
"version": "1.3.21",
|
"version": "1.3.22",
|
||||||
"manifestPlusVersion": "1.0.0",
|
"manifestPlusVersion": "1.0.0",
|
||||||
"minimumCoreVersion": "0.7.5",
|
"minimumCoreVersion": "0.7.5",
|
||||||
"compatibleCoreVersion": "0.7.9",
|
"compatibleCoreVersion": "0.7.9",
|
||||||
"templateVersion": 94,
|
"templateVersion": 95,
|
||||||
"author": "LeRatierBretonnien",
|
"author": "LeRatierBretonnien",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -165,6 +165,7 @@
|
|||||||
},
|
},
|
||||||
"sonne": {
|
"sonne": {
|
||||||
"value": false,
|
"value": false,
|
||||||
|
"round": -1,
|
||||||
"label": "Sonné"
|
"label": "Sonné"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user