Fix rolls and various glitches

This commit is contained in:
sladecraven 2022-01-23 00:07:47 +01:00
parent 26a5cdcffb
commit da5b2bf785
8 changed files with 196 additions and 154 deletions

View File

@ -505,8 +505,10 @@ export class YggdrasillActor extends Actor {
rollMode: game.settings.get("core", "rollMode"),
title: title,
isBlesse: this.data.data.etat.etat == "blesse",
optionsBonusMalus: YggdrasillUtility.buildListOptions(-6, +6),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-15, +15),
bonusMalus: 0,
bonusdefense: 0,
optionsBD: YggdrasillUtility.buildListOptions(0, +15),
optionsSR: YggdrasillUtility.buildSROptions( ),
sr: 0
}
@ -535,11 +537,12 @@ export class YggdrasillActor extends Actor {
isEpuise: this.isEpuise(),
isBlesse: this.isBlesse(),
isMeurtri: this.isMeurtri(),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-6, +6),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-15, +15),
bonusMalus: 0,
optionsFuror: YggdrasillUtility.buildListOptions(0, this.getCurrentFuror() ),
furorUsage: 0,
optionsSR: YggdrasillUtility.buildSROptions( ),
optionsBD: YggdrasillUtility.buildListOptions(0, +15),
sr: 0
}
let rollDialog = await YggdrasillRoll.create( this, rollData);
@ -567,7 +570,7 @@ export class YggdrasillActor extends Actor {
isEpuise: this.isEpuise(),
isBlesse: this.isBlesse(),
isMeurtri: this.isMeurtri(),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-6, +6),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-15, +15),
bonusMalus: 0,
optionsFuror: YggdrasillUtility.buildListOptions(0, this.getCurrentFuror() ),
furorUsage: 0,
@ -645,6 +648,7 @@ export class YggdrasillActor extends Actor {
let rollData = {
mode: magie,
isMagie: true,
alias: this.name,
actorImg: this.img,
actorId: this.id,
@ -663,8 +667,8 @@ export class YggdrasillActor extends Actor {
isEpuise: this.isEpuise(),
isBlesse: this.isBlesse(),
isMeurtri: this.isMeurtri(),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-6, +6),
optionsBD: YggdrasillUtility.buildListOptions(0, +6),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-15, +15),
optionsBD: YggdrasillUtility.buildListOptions(0, +15),
bonusMalus: 0,
optionsFuror: YggdrasillUtility.buildListOptions(0, this.getCurrentFuror() ),
furorUsage: 0,
@ -714,8 +718,8 @@ export class YggdrasillActor extends Actor {
isEpuise: this.isEpuise(),
isBlesse: this.isBlesse(),
isMeurtri: this.isMeurtri(),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-6, +6),
optionsBD: YggdrasillUtility.buildListOptions(0, +6),
optionsBonusMalus: YggdrasillUtility.buildListOptions(-15, +15),
optionsBD: YggdrasillUtility.buildListOptions(0, +15),
bonusMalus: 0,
optionsFuror: YggdrasillUtility.buildListOptions(0, this.getCurrentFuror() ),
furorUsage: 0,

View File

@ -40,7 +40,7 @@ export class YggdrasillFigurantSheet extends ActorSheet {
effetsmagiques: this.actor.getEffetsMagiques(),
encTotal: this.actor.getEncTotal(),
monnaies: this.actor.getMonnaies(),
optionsAttr: new Array(21).fill('option'),
optionsAttr: new Array(41).fill('option'),
optionsBase: YggdrasillUtility.createDirectOptionList(0, 20),
options: this.options,
owner: this.document.isOwner,

View File

@ -91,27 +91,32 @@ export class YggdrasillRoll extends Dialog {
if ( this.rollData.supportRune == "peau") {
support = 3;
this.rollData.echelleDuree = "Actions";
this.rollData.echelleDureeVie = "Heures"
}
if ( this.rollData.supportRune == "tissu") {
support = 6;
this.rollData.echelleDuree = "Tours";
this.rollData.echelleDureeVie = "Jours"
}
if ( this.rollData.supportRune == "cuir") {
support = 9;
this.rollData.echelleDuree = "Minutes";
this.rollData.echelleDureeVie = "Semaines"
}
if ( this.rollData.supportRune == "bois") {
support = 12;
this.rollData.echelleDuree = "Heures";
this.rollData.echelleDureeVie = "Mois"
}
if ( this.rollData.supportRune == "pierremetal") {
support = 15;
this.rollData.echelleDuree = "Jours";
this.rollData.echelleDureeVie = "Années"
}
let SR = this.rollData.puissanceRune + (Number(this.rollData.sort.data.niveau)*3) + support;
$("#srTotal").text(SR);
$("#runeDuree").text( this.rollData.dureeRune + " " + this.rollData.echelleDuree);
$("#runeDureeVie").text( this.rollData.puissanceRune + " " + this.rollData.echelleDuree);
$("#runeDureeVie").text( this.rollData.competence.data.niveau + " " + this.rollData.echelleDureeVie);
this.rollData.sr = SR;
}

View File

@ -98,6 +98,38 @@ export class YggdrasillUtility {
return compendiumData.filter(filter);
}
/* -------------------------------------------- */
static async specificYggRoll( nbDice ) {
let rawDices = []
let rolls = []
let maxTab = []
maxTab[0] = {idx: 0, value: 0}
maxTab[1] = {idx: 0, value: 0}
for (let i=0; i<nbDice; i++) {
rolls[i] = new Roll("1d10x10").roll( {async: false}) //+sumDice+"+"+rollData.furorUsage+"d10+"+niveauCompetence+"+"+rollData.finalBM).roll( { async: false} );
if ( i == nbDice-1 ) {
await this.showDiceSoNice(rolls[i], game.settings.get("core", "rollMode") );
} else {
this.showDiceSoNice(rolls[i], game.settings.get("core", "rollMode") );
}
rawDices.push({ 'result': rolls[i].total});
if ( rolls[i].total > maxTab[0].value) {
if ( nbDice > 1 && maxTab[0].value > maxTab[1].value) {
maxTab[1].value = maxTab[0].value
}
maxTab[0].value = rolls[i].total
} else {
if ( nbDice > 1 && rolls[i].total > maxTab[1].value) {
maxTab[1].value = rolls[i].total
}
}
}
return { rawDices: rawDices, maxTab: maxTab, rolls: rolls}
}
/* -------------------------------------------- */
static async rollAttribute( rollData ) {
// Init stuff
@ -114,31 +146,27 @@ export class YggdrasillUtility {
rollData.finalBM -= 3;
}
let rolls = []
rollData.rawDices = []
for (let i=0; i < 2; i++) {
rolls[i] = new Roll("1d10x10").roll( { async: false} );
rollData.rawDices.push({ 'result': rolls[i].total});
}
this.showDiceSoNice(rolls[0], game.settings.get("core", "rollMode") );
await this.showDiceSoNice(rolls[1], game.settings.get("core", "rollMode") );
let results = await this.specificYggRoll( 2 )
rollData.rawDices = results.rawDices
rollData.maxTab = results.maxTab
rollData.rolls = results.rolls
rollData.bonus = niveau + rollData.finalBM
rollData.finalTotal = 0
for (let i=0; i< 2; i++) {
rollData.finalTotal = rolls[i].dice[0].results[0].result
}
rollData.finalTotal = rollData.maxTab[0].value + rollData.maxTab[1].value;
rollData.finalTotal += rollData.bonus
// Compute total SR
rollData.srFinal = rollData.sr;
if ( rollData.bonusdefense ) {
rollData.srFinal += rollData.bonusdefense;
}
if ( rollData.srFinal > 0 ) {
isCritical = rollData.finalTotal >= rollData.srFinal*2;
isSuccess = rollData.finalTotal >= rollData.srFinal;
marge = rollData.finalTotal - rollData.srFinal;
}
if (rolls[0].dice[0].results[0].result == 1 && rolls[1].dice[0].results[0].result == 1) {
if (rollData.rolls[0].dice[0].results[0].result == 1 && rollData.rolls[1].dice[0].results[0].result == 1) {
isFailure = true;
}
// Dégats
@ -154,7 +182,6 @@ export class YggdrasillUtility {
rollData.isSuccess = isSuccess;
rollData.isCritical = isCritical;
rollData.marge = marge;
rollData.rolls = rolls
console.log("ROLLLL ATTR!!!!", rollData);
@ -196,41 +223,30 @@ export class YggdrasillUtility {
rollData.finalBM -= 3;
}
rollData.rawDices = []
if (sumDice > nbDice) sumDice = nbDice;
let rolls = []
let maxTab = [ {idx: 0, value: 0}, {idx: 0, value:0}]
for (let i=0; i<nbDice; i++) {
rolls[i] = new Roll("1d10x10").roll( {async: false}) //+sumDice+"+"+rollData.furorUsage+"d10+"+niveauCompetence+"+"+rollData.finalBM).roll( { async: false} );
if ( i == nbDice-1 ) {
await this.showDiceSoNice(rolls[nbDice-1], game.settings.get("core", "rollMode") );
} else {
this.showDiceSoNice(rolls[i], game.settings.get("core", "rollMode") );
}
rollData.rawDices.push({ 'result': rolls[i].total});
let results = await this.specificYggRoll( nbDice )
rollData.rawDices = results.rawDices
rollData.maxTab = results.maxTab
rollData.rolls = results.rolls
console.log("RES", results, nbDice, sumDice)
if ( rolls[i].total > maxTab[0].value) {
if ( maxTab[0].value > maxTab[1].value) {
maxTab[1].value = maxTab[0].value
maxTab[1].idx = maxTab[0].idx
}
maxTab[0].value = rolls[i].total
maxTab[0].idx = i
} else {
if ( rolls[i].total > maxTab[1].value) {
maxTab[1].value = rolls[i].total
maxTab[1].idx = i
}
}
if ( rollData.furorUsage > 0 ) {
results = await this.specificYggRoll( rollData.furorUsage )
rollData.furorRawDices = results.rawDices
rollData.furorMaxTab = results.maxTab
rollData.furorRolls = results.rolls
let actor = game.actors.get(rollData.actorId);
actor.decrementFuror( rollData.furorUsage);
}
let bonusRoll = new Roll(rollData.furorUsage+"d10x10+"+niveauCompetence+"+"+rollData.finalBM).roll( {async: false})
if ( rollData.furorUsage > 0) {
this.showDiceSoNice(bonusRoll, game.settings.get("core", "rollMode") );
}
rollData.finalTotal = (sumDice ==1) ? maxTab[0].value : maxTab[0].value + maxTab[1].value;
rollData.finalTotal += bonusRoll.total;
rollData.furorResult = (rollData.furorUsage >0 ) ? bonusRoll.dice[0].results[0].result : 0;
rollData.maxTab = maxTab
rollData.bonusTotal = niveauCompetence + rollData.finalBM
rollData.finalTotal = (sumDice ==1) ? rollData.maxTab[0].value : rollData.maxTab[0].value + rollData.maxTab[1].value;
rollData.furorResult = 0
for (let i=0; i<rollData.furorUsage; i++) {
rollData.furorResult += rollData.furorMaxTab[i].value
}
rollData.finalTotal += rollData.furorResult + rollData.bonusTotal;
rollData.niveauCompetence = niveauCompetence
// Compute total SR
rollData.srFinal = rollData.sr;
@ -244,23 +260,19 @@ export class YggdrasillUtility {
marge = rollData.finalTotal - rollData.srFinal;
}
if (nbDice == 1 && rolls[0].dice[0].results[0].result == 1) {
if (nbDice == 1 && rollData.rolls[0].dice[0].results[0].result == 1) {
isFailure = true;
}
if (nbDice == 2 && rolls[0].dice[0].results[0].result == 1 && rolls[1].dice[0].results[0].result == 1) {
if (nbDice == 2 && rollData.rolls[0].dice[0].results[0].result == 1 && rollData.rolls[1].dice[0].results[0].result == 1) {
isFailure = true;
}
if (nbDice >= 3 ) {
let nbOnes = 0
for (let roll of rolls) {
for (let roll of rollData.rolls) {
if (roll.dice[0].results[0].result == 1 ) nbOnes++;
}
isFailure = nbOnes >= 3;
}
if ( rollData.furorUsage > 0 ) {
let actor = game.actors.get(rollData.actorId);
actor.decrementFuror( rollData.furorUsage);
}
// Dégats
if ( isSuccess && (rollData.mode == "armecc" || rollData.mode == "armedist") ) {
@ -269,7 +281,6 @@ export class YggdrasillUtility {
}
// Stockage resultats
rollData.rolls = rolls
rollData.sumDice = sumDice;
rollData.isFailure = isFailure;
rollData.isSuccess = isSuccess;

View File

@ -876,8 +876,7 @@ ul, li {
}
#sidebar.collapsed {
height: 430px !important;
position: absolute;
height: 470px !important;
}
#sidebar-tabs > .collapsed, #chat-controls .chat-control-icon {

View File

@ -2,7 +2,7 @@
"name": "fvtt-yggdrasill",
"title": "Yggdrasill",
"description": "Système non-officiel Yggdrasill (7ièm Cercle) pour FoundryVTT",
"version": "1.1.10",
"version": "1.1.11",
"manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "9",

View File

@ -4,104 +4,118 @@
</div>
<hr>
<div>
<img class="chat-icon" src="{{img}}" alt="{{alias}}" />
<h3>
{{#if (eq mode "attribut")}}
Jet de {{attr.label}} {{subAttr.label}} (2d10+{{subAttr.value}})
{{else}}
{{#if (eq mode "competence")}}
<div>
<img class="chat-icon" src="{{img}}" alt="{{alias}}" />
<h3>
{{#if (eq mode "attribut")}}
Jet de {{attr.label}} {{subAttr.label}} (2d10+{{subAttr.value}})
{{else}}
{{#if (eq mode "competence")}}
Jet de {{selectedCarac.label}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
{{#if (eq mode "armecc")}}
Attaque au corps à Corps {{attackDef.label}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
{{#if (eq mode "armedist")}}
Attaque à Distance {{attackDef.label}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
{{#if (eq mode "sejdr")}}
Lancer du Sort {{sort.name}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
{{#if (eq mode "rune")}}
Gravure de la Rune {{sort.name}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
{{#if (eq mode "galdr")}}
Lancer du Domaine {{sort.name}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
Jet de {{selectedCarac.label}} ({{selectedCarac.value}}d10)
{{/if}}
{{/if}}
{{/if}}
{{/if}}
{{/if}}
{{#if (eq mode "armecc")}}
Attaque au corps à Corps {{attackDef.label}} ({{selectedCarac.value}}d10) / {{competence.name}}
({{competence.data.niveau}})
{{else}}
{{#if (eq mode "armedist")}}
Attaque à Distance {{attackDef.label}} ({{selectedCarac.value}}d10) / {{competence.name}}
({{competence.data.niveau}})
{{else}}
{{#if (eq mode "sejdr")}}
Lancer du Sort {{sort.name}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
{{#if (eq mode "rune")}}
Gravure de la Rune {{sort.name}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
{{#if (eq mode "galdr")}}
Lancer du Domaine {{sort.name}} ({{selectedCarac.value}}d10) / {{competence.name}} ({{competence.data.niveau}})
{{else}}
Jet de {{selectedCarac.label}} ({{selectedCarac.value}}d10)
{{/if}}
{{/if}}
{{/if}}
{{/if}}
{{/if}}
{{/if}}
{{/if}}
</h3>
</div>
<div>
<ul>
<li>Dés :
{{#each rawDices as |roll key|}}
{{roll.result}}&nbsp;
{{/each}}
</li>
{{#if sumDice}}
<li>Nombre de dés additionnés : {{sumDice}}</li>
{{/if}}
<li>{{#if (eq mode "carac")}}Carac{{else}}Competence{{/if}} : {{niveauCompetence}}</li>
<li>Bonus/Malus Final : {{finalBM}}</li>
{{#if sr}}
<li>Seuil de Réussite final : {{srFinal}}</li>
{{/if}}
{{#if furorUsage}}
<li>Furor dépensée : {{furorUsage}}</li>
<li>Resultat de la Furor : {{furorResult}}</li>
{{/if}}
<li>
<h3>Total : {{finalTotal}}</h3>
</li>
</ul>
{{#if dureeGaldrText}}
<div>
Durée du Sort : {{dureeGaldrText}}
</div>
{{/if}}
</h3>
</div>
<div>
<ul>
<li>Dés :
{{#each rawDices as |roll key|}}
{{roll.result}}&nbsp;
{{/each}}
</li>
{{#if sumDice}}
<li>Nombre de dés additionnés : {{sumDice}}</li>
{{#if zoneGaldrText}}
<div>
Volume Max de l'Illusion : {{zoneGaldrText}}
</div>
{{/if}}
<li>{{#if (eq mode "carac")}}Carac{{else}}Competence{{/if}} : {{niveauCompetence}}</li>
<li>Bonus/Malus Final : {{finalBM}}</li>
{{#if sr}}
<li>Seuil de Réussite final : {{srFinal}}</li>
{{#if ciblesGaldrText}}
<div>
Nombre de Cibles : {{ciblesGaldrText}}
</div>
{{/if}}
{{#if furorUsage}}
<li>Furor dépensée : {{furorUsage}}</li>
<li>Resultat de la Furor : {{furorResult}}</li>
{{#if degats}}
<div>
Degats : {{degats}} ({{degatsExplain}})
</div>
{{/if}}
<li><h3>Total : {{finalTotal}}</h3></li>
</ul>
{{#if dureeGaldrText}}
<div>
Durée du Sort : {{dureeGaldrText}}
</div>
{{/if}}
{{#if zoneGaldrText}}
<div>
Volume Max de l'Illusion : {{zoneGaldrText}}
</div>
{{/if}}
{{#if attackDef.protection}}
<div>
Annuation de Protection du Défenseur : {{attackDef.protection}}
</div>
{{/if}}
{{#if ciblesGaldrText}}
<div>
Nombre de Cibles : {{ciblesGaldrText}}
</div>
{{/if}}
{{#if degats}}
<div>
Degats : {{degats}} ({{degatsExplain}})
</div>
{{/if}}
{{#if attackDef.protection}}
<div>
Annuation de Protection du Défenseur : {{attackDef.protection}}
</div>
{{/if}}
{{#if isCritical}}
<div class="chat-message-header">
<img class="chat-icon" src="systems/fvtt-yggdrasill/images/icons/icon_reussite_critique.png" alt="critique" />
Réussite Critique !
{{#if isCritical}}
<div class="chat-message-header">
<img class="chat-icon" src="systems/fvtt-yggdrasill/images/icons/icon_reussite_critique.png" alt="critique" />
Réussite Critique !
</div>
{{/if}}
{{#if isFailure}}
<img class="chat-icon" src="systems/fvtt-yggdrasill/images/icons/icon_echec_critique.png" alt="echec" />
Echec Critique !
</div>
{{/if}}
<div class="chat-message-header">
<img class="chat-icon" src="systems/fvtt-yggdrasill/images/icons/icon_echec_critique.png" alt="echec" />
Echec Critique !
</div>
{{/if}}
</div>
{{#if (and isSuccess isMagie)}}
<div>
<hr>
{{{sort.data.description}}}
</div>
{{/if}}
</div>
</div>

View File

@ -17,6 +17,15 @@
{{/select}}
</select>
</div>
<div class="flexrow">
<span class="competence-base flexrow" >Défense Physique du défenseur : </span>
<select class="competence-base flexrow" type="text" id="bonusdefense" name="bonusdefense" value="{{bonusdefense}}" data-dtype="Number">
{{#select bonusdefense}}
{{{optionsBD}}}
{{/select}}
</select>
</div>
<div class="flexrow">
<span class="competence-base flexrow" >Seuil de Réussite : </span>