Implementations diverses
This commit is contained in:
@@ -104,6 +104,18 @@ export class VadentisActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
calculerSommeStats( ) {
|
||||
for (const key in this.data.data.combat) {
|
||||
let combatData = this.data.data.combat[key];
|
||||
combatData.total = combatData.base + combatData.malus + combatData.bonus;
|
||||
}
|
||||
for (const key in this.data.data.magie) {
|
||||
let magieData = this.data.data.magie[key];
|
||||
magieData.total = magieData.base + magieData.malus + magieData.bonus;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async processSortDevotion( name, devotionSort ) {
|
||||
if ( this.data.data.stats.pointsenergie.value == 0) { // Vérification du ~ de points d'énergie
|
||||
@@ -113,51 +125,66 @@ export class VadentisActor extends Actor {
|
||||
|
||||
let scores = this.data.data.magie[(name =="devotion") ? 'devotion': 'matriseelementaire'];
|
||||
let statValue = scores.base + scores.malus + scores.bonus;
|
||||
let formulaFull = `1d20+${scores.base}+${scores.malus}+${scores.bonus}`;
|
||||
let myRoll = new Roll("1d20+"+statValue);
|
||||
myRoll.evaluate();
|
||||
myRoll.toMessage( { flavor: `Lancer de ${name} : ${devotionSort.name} (${formulaFull})` } );
|
||||
|
||||
let formulaFull = this.buildTexteFormula( scores );
|
||||
let myRoll = await VadentisUtility.processRoll("1d20+"+statValue );
|
||||
let msgData = {
|
||||
alias: this.name,
|
||||
title: `Sort ${devotionSort.name}`,
|
||||
isSort: true
|
||||
}
|
||||
|
||||
if (myRoll.results[0] > 1 && myRoll.total >= devotionSort.data.difficulty) {
|
||||
let content = `${this.name} a réussi son ${name} et perd ${devotionSort.data.pe} Points d'Energie. L'effet suivant se produit: <br>${devotionSort.data.effect}`;
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_sort_réussi.webp';
|
||||
msgData.msg = `${this.name} a réussi son ${name} et perd ${devotionSort.data.pe} Points d'Energie (lancer : ${formulaFull}). L'effet suivant se produit: <br>${devotionSort.data.effect}`;
|
||||
let newEnergie = this.data.data.stats.pointsenergie.value - devotionSort.data.pe;
|
||||
await this.update( {'data.stats.pointsenergie.value': newEnergie });
|
||||
if (myRoll.results[0] == 20 ) { // Critique ?
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_réussite_critique.webp';
|
||||
msgData.ms += "<br>C'est une <strong>réussite critique</strong> !";
|
||||
}
|
||||
|
||||
if ( devotionSort.data.damage != "") {
|
||||
let degatsText = `<br>Et provoque les dégats suivants : `;
|
||||
let formula = devotionSort.data.damage;
|
||||
if (myRoll.results[0] == 20 ) { // Critique ?
|
||||
degatsText += `<br>Et provoque les dégats critiques suivants : `;
|
||||
msgData.msg += `<br>Et provoque les dégats critiques suivants : `;
|
||||
formula = devotionSort.data.damagecritical;
|
||||
}
|
||||
content += degatsText;
|
||||
/*let myRoll = new Roll(formula);
|
||||
myRoll.evaluate();
|
||||
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
||||
await game.dice3d.showForRoll(degatsRoll, game.user, true);
|
||||
} else {
|
||||
msgData.msg += `<br>Et provoque les dégats suivants : `;
|
||||
}
|
||||
content += myRoll.total + `(${devotionSort.data.damagecritical})`; */
|
||||
content += `${devotionSort.data.damagecritical}`;
|
||||
content += `${formula}`;
|
||||
}
|
||||
if ( newEnergie < 0) {
|
||||
content += `<br><strong>Attention</strong> : Les Points d'Energie de ${this.name} sont négatifs ! Il convient d'éditer ses Points de Vie en conséquence.`;
|
||||
msgData.msg += `<br><strong>Attention</strong> : Les Points d'Energie de ${this.name} sont négatifs ! Il convient d'éditer ses Points de Vie en conséquence.`;
|
||||
}
|
||||
ChatMessage.create( { content: content} );
|
||||
} else {
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_sort_échoué.webp';
|
||||
if (myRoll.results[0] == 1 ) { // Critique ?
|
||||
ChatMessage.create( { content: `${this.name} a fait un <strong>échec critique</strong> à son lancer de ${name}` } );
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_échec_critique.webp';
|
||||
msgData.msg = `${this.name} a fait un <strong>échec critique</strong> à son lancer de ${name}`;
|
||||
} else {
|
||||
ChatMessage.create( { content: `${this.name} a échoué son lancer de ${name}` } );
|
||||
msgData.msg = `${this.name} a échoué son lancer de ${name}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
ChatMessage.create({
|
||||
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollDamage( weapon, damageType ) {
|
||||
let formula = VadentisUtility.processDamageString( weapon.data.data[damageType], this );
|
||||
let degatsRoll = await VadentisUtility.processRoll( formula );
|
||||
|
||||
ChatMessage.create( { content: `${this.name} frappe avec ${weapon.name} et produit ${degatsRoll.total} Points de Dégâts (${formula}).` } );
|
||||
let msgData = {
|
||||
alias: this.name,
|
||||
img: "systems/foundryvtt-vadentis/images/icons/tchat_dégâts_infligés.webp",
|
||||
title: `Dégâts de ${weapon.name}`,
|
||||
msg: `${this.name} frappe avec ${weapon.name} et produit <strong>${degatsRoll.total} Points de Dégâts</strong> (${formula}).`
|
||||
}
|
||||
ChatMessage.create({
|
||||
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -165,12 +192,22 @@ export class VadentisActor extends Actor {
|
||||
let pvData = this.data.data.stats.pointsvie;
|
||||
let newValue = Math.max( pvData.value - damageValue, MIN_PV);
|
||||
await this.update( {'data.stats.pointsvie.value': newValue });
|
||||
ChatMessage.create( { content: `${this.name} vient de perdre ${damageValue} Points de Vie. Ses Points de Vie actuels sont désormais de ${newValue}.` } );
|
||||
|
||||
let msgData = {
|
||||
alias: this.name,
|
||||
img: "systems/foundryvtt-vadentis/images/icons/tchat_dégâts_infligés.webp",
|
||||
title: `${this.name} encaisse des dégâts !`,
|
||||
msg: `${this.name} vient de perdre ${damageValue} Points de Vie. Ses Points de Vie actuels sont désormais de ${newValue}.`
|
||||
}
|
||||
ChatMessage.create({
|
||||
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_getCombatValue(mydata) {
|
||||
if ( Number(mydata.base)) {
|
||||
if ( typeof mydata.base == 'number' ) {
|
||||
return mydata.base + mydata.malus + mydata.bonus;
|
||||
}else {
|
||||
return Number(mydata.base[0]) + Number(mydata.malus[0]) + Number(mydata.bonus[0]);
|
||||
@@ -198,6 +235,12 @@ export class VadentisActor extends Actor {
|
||||
return this._getCombatValue( attaqueData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildTexteFormula( stat) {
|
||||
let signMalus = (stat.malus < 0) ? "" : "+";
|
||||
return `1d20+ ${stat.base} ${signMalus} ${stat.malus} + ${stat.bonus}`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollSort( sortId ) {
|
||||
let sort = this.data.items.find( item => item.type == 'sort' && item._id == sortId );
|
||||
@@ -218,38 +261,99 @@ export class VadentisActor extends Actor {
|
||||
async rollTechnique( techniqueId ) {
|
||||
let technique = this.data.items.find( item => item.type == 'technique' && item._id == techniqueId );
|
||||
if (technique) {
|
||||
if ( this.data.data.stats.pointsadrenaline.value < technique.data.pacost) { // Vérification du ~ de points d'adrénaline
|
||||
ChatMessage.create({ content: `${this.name} n'a pas assez de Points d'Adrénaline pour éxecuter sa technique ${technique.name}` } );
|
||||
return;
|
||||
let msgData = {
|
||||
alias: this.name,
|
||||
img: technique.img,
|
||||
title: `Technique ${technique.name}`
|
||||
}
|
||||
let newAdrenaline = this.data.data.stats.pointsadrenaline.value - technique.data.pacost;
|
||||
await this.update( {'data.stats.pointsadrenaline.value': newAdrenaline });
|
||||
|
||||
ChatMessage.create( { content: `${this.name} execute sa technique ${technique.name}, pour un côut de ${technique.data.pacost} Points d'Adrénaline<br>
|
||||
Les effets sont : ${technique.data.effect}`} );
|
||||
if ( this.data.data.stats.pointsadrenaline.value < technique.data.pacost) { // Vérification du ~ de points d'adrénaline
|
||||
msgData.msg = `${this.name} n'a pas assez de Points d'Adrénaline pour éxecuter sa technique ${technique.name}`;
|
||||
} else {
|
||||
let newAdrenaline = this.data.data.stats.pointsadrenaline.value - technique.data.pacost;
|
||||
await this.update( {'data.stats.pointsadrenaline.value': newAdrenaline });
|
||||
msgData.msg = `${this.name} execute sa technique ${technique.name}, pour un côut de ${technique.data.pacost} Points d'Adrénaline<br>
|
||||
Les effets sont : ${technique.data.effect}`;
|
||||
}
|
||||
ChatMessage.create({
|
||||
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
|
||||
});
|
||||
} else {
|
||||
ui.notifications.warn("Technique non trouvée");
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollCompetence( competenceId ) {
|
||||
async rollCompetence( competenceId ) {
|
||||
let competence = this.data.items.find( item => item.type == 'competence' && item._id == competenceId);
|
||||
if ( competence) {
|
||||
let msgData = {
|
||||
alias: this.name,
|
||||
img: competence.img,
|
||||
title: `Compétence ${competence.name}`
|
||||
}
|
||||
|
||||
let statValue = competence.data.base + competence.data.malus + competence.data.bonus;
|
||||
let formulaFull = `1d20+${competence.data.base}+${competence.data.malus}+${competence.data.bonus}`;
|
||||
let myRoll = new Roll("1d20+"+statValue);
|
||||
myRoll.evaluate();
|
||||
myRoll.toMessage( { flavor: `Jet de compétence : ${competence.name} (${formulaFull})` } );
|
||||
let formulaFull = this.buildTexteFormula( competence.data );
|
||||
let myRoll = await VadentisUtility.processRoll("1d20+"+statValue );
|
||||
msgData.msg = `${formulaFull} => <strong>${myRoll.total}</strong>`;
|
||||
|
||||
if (myRoll.results[0] == 1 ) { // Critique ?
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_échec_critique.webp';
|
||||
msgData.msg += `<br>C'est un <strong>échec critique</strong> !`;
|
||||
}
|
||||
if (myRoll.results[0] == 20 ) { // Critique ?
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_réussite_critique.webp';
|
||||
msgData.msg += `<br>C'est une <strong>réussite critique</strong> !`;
|
||||
}
|
||||
|
||||
ChatMessage.create({
|
||||
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
|
||||
});
|
||||
} else {
|
||||
ui.notifications.warn("Compétence non trouvée");
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollCombat( combatName ) {
|
||||
let stat = this.data.data.combat[combatName];
|
||||
async genericRoll( stat ) {
|
||||
let statValue = this._getCombatValue( stat );
|
||||
let formulaFull = `1d20+${stat.base}+${stat.malus}+${stat.bonus}`;
|
||||
let myRoll = new Roll("1d20+"+statValue);
|
||||
myRoll.evaluate();
|
||||
myRoll.toMessage( { title: "Test !",flavor: `Jet de ${stat.label} (${formulaFull})` } );
|
||||
let formulaFull = this.buildTexteFormula( stat );
|
||||
|
||||
let myRoll = await VadentisUtility.processRoll("1d20+"+statValue );
|
||||
let msgData = {
|
||||
alias: this.name,
|
||||
img: "",
|
||||
title: `Jet de ${stat.label}`,
|
||||
msg: `${formulaFull} => <strong>${myRoll.total}</strong>`
|
||||
}
|
||||
|
||||
if (myRoll.results[0] == 1 ) { // Critique ?
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_échec_critique.webp';
|
||||
msgData.msg += `<br>C'est un <strong>échec critique</strong> !`;
|
||||
}
|
||||
if (myRoll.results[0] == 20 ) { // Critique ?
|
||||
msgData.img = 'systems/foundryvtt-vadentis/images/icons/tchat_réussite_critique.webp';
|
||||
msgData.msg += `<br>C'est une <strong>réussite critique</strong> !`;
|
||||
}
|
||||
|
||||
ChatMessage.create({
|
||||
//whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
|
||||
content: await renderTemplate(`systems/foundryvtt-vadentis/templates/chat-generic-result.html`, msgData)
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCombat( combatName ) {
|
||||
let stat = this.data.data.combat[combatName];
|
||||
this.genericRoll( stat );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollMagie( magieName ) {
|
||||
let stat = this.data.data.magie[magieName];
|
||||
this.genericRoll( stat );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user