Skip to content

Commit

Permalink
Merge pull request #13608 from Zakarik/Knight
Browse files Browse the repository at this point in the history
[Knight] Fix visual bug & roll bug
  • Loading branch information
BronsonHall authored Dec 17, 2024
2 parents 88989e5 + 2f12ad3 commit 0a82e7b
Show file tree
Hide file tree
Showing 21 changed files with 392 additions and 1,109 deletions.
193 changes: 0 additions & 193 deletions Knight/knight.css

Large diffs are not rendered by default.

663 changes: 201 additions & 462 deletions Knight/knight.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Knight/pug/js/_functionsWeapons.js
Original file line number Diff line number Diff line change
Expand Up @@ -4240,7 +4240,7 @@ function updateRoll(roll, diceJet, bonusJet, totalDegats, diceDegats, bonusDegat

let vTCheneSculpte = 0;

if (conditions.bourreau || conditions.equilibre) {
if (conditions.bourreau) {
tDegats = diceDegats.reduce((accumulateur, valeurCourante) => {
let newV = +valeurCourante;
if (newV <= 3) { newV = 4; }
Expand Down Expand Up @@ -4436,7 +4436,7 @@ function updateRoll(roll, diceJet, bonusJet, totalDegats, diceDegats, bonusDegat
}
}

if (conditions.devaste || conditions.equilibre) {
if (conditions.devaste) {
tViolence = diceViolence.reduce((accumulateur, valeurCourante) => {
let newV = valeurCourante;
if (newV <= 3) { newV = 4; }
Expand Down
87 changes: 87 additions & 0 deletions Knight/pug/js/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ const i18n_deplacement = getTranslationByKey("deplacement"),
i18n_devasterAnatheme = getTranslationByKey("devaster-anatheme"),
i18n_bourreauTenebres = getTranslationByKey("bourreau-tenebres"),
i18n_equilibrerBalance = getTranslationByKey("equilibrer-balance"),
i18n_equilibrerBalanceShort = getTranslationByKey("equilibrer-balance-short"),
i18n_bourreau = getTranslationByKey("bourreau"),
i18n_conviction = getTranslationByKey("conviction"),
i18n_devastation = getTranslationByKey("devastation"),
Expand Down Expand Up @@ -1061,6 +1062,92 @@ function isApplied(e) {
return result;
}

async function postRoll(computed, gmroll, stringRoll, mainRoll, conditions={}, startString=`&{template:simple} {{Nom=@{name}}}`) {
const isGuidage = conditions.isGuidage || false;
const results = mainRoll.results;
const pairOrImpair = isGuidage === true ? 'cs1cs3cs5cf2cf4cf6s' : 'cs2cs4cs6cf1cf3cf5s';
const dices = results.jet.dice;
let success = 0;

success += computed.basejet;

if(conditions.equilibre && dices.length !== success) {
const notSuccess = parseInt(dices.length)-parseInt(success);

const relance = await startRoll(`${gmroll} ${startString} {{special1=${i18n_equilibrerBalanceShort}}} {{jet=[[ ${notSuccess}d6${pairOrImpair}]]}}`);
const rRelance = relance.results.jet.dice;
const relancePairOrImpair = isGuidage === true ? 1 : 0;

const jetRelance = rRelance.reduce((accumulateur, valeurCourante) => {
const vC = valeurCourante;
let nV = 0;

if (vC % 2 === relancePairOrImpair) {
nV = 1;
}

return accumulateur + nV;
}, 0);

const relanceComputed = {
jet: jetRelance,
};

finishRoll(relance.rollId, relanceComputed);

success += relanceComputed.jet;
}

if (success !== 0 && success === dices.length) {
const isGuidage = conditions.isGuidage || false;

const exploitRoll = await startRoll(`${gmroll} ${startString} {{special1=${i18n_exploit}}}${stringRoll}`);
const rExploit = exploitRoll.results.jet.dice;
const exploitPairOrImpair = isGuidage === true ? 1 : 0;

const jetExploit = rExploit.reduce((accumulateur, valeurCourante) => {
const vC = valeurCourante;
let nV = 0;

if (vC % 2 === exploitPairOrImpair) {
nV = 1;
}

return accumulateur + nV;
}, 0);

const exploitComputed = {
jet: jetExploit,
};

finishRoll(exploitRoll.rollId, exploitComputed);
}
}

function computeSimpleRoll(mainRoll, bonus = 0, pairOrImpair = 0) {
const results = mainRoll.results;
console.warn(results);
let jet = 0;
let dices = results.jet.dice.reduce((accumulateur, valeurCourante) => {
const vC = valeurCourante;
let nV = 0;

if (vC % 2 === pairOrImpair) {
nV = 1;
}

return accumulateur + nV;
}, 0);

jet += dices;
jet += bonus;

return {
jet:jet,
basejet:dices,
}
}

var PI = {
"msgSlot":0,
"msgEnergie":0
Expand Down
49 changes: 17 additions & 32 deletions Knight/pug/js/rolls/pj/art.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable linebreak-style */
/* eslint-disable max-len */
/* eslint-disable linebreak-style */
/* eslint-disable camelcase */
/* eslint-disable no-undef */
on('clicked:domaineArtistique', (info) => {
Expand All @@ -10,9 +13,10 @@ on('clicked:domaineArtistique', (info) => {
'caracteristique2Art',
'caracteristique3Art',
'caracteristique4Art',
'equilibreBalance',
];

getAttrs(attributs, (value) => {
getAttrs(attributs, async (value) => {
const exec = [];

const mod = Number(value.jetModifDes);
Expand All @@ -22,6 +26,7 @@ on('clicked:domaineArtistique', (info) => {
const C2 = value.caracteristique2Art;
const C3 = value.caracteristique3Art;
const C4 = value.caracteristique4Art;
const equilibre = +value.equilibreBalance;

const C1Nom = C1.slice(2, -1);
const C2Nom = C2.slice(2, -1);
Expand Down Expand Up @@ -70,37 +75,17 @@ on('clicked:domaineArtistique', (info) => {
}

if (cRoll.length === 0) { cRoll.push(0); }

exec.push(`{{jet=[[ {[[{${cRoll.join('+')}, 0}kh1]]d6cs2cs4cs6cf1cf3cf5s%2}=0]]}}`);
exec.push(`{{tBonus=[[${bonus.join('+')}+0]]}}`);
exec.push(`{{Exploit=[[${cRoll.join('+')}]]}}`);

startRoll(exec.join(' '), (results) => {
const tJet = results.results.jet.result;
const tBonus = results.results.tBonus.result;
const tExploit = results.results.Exploit.result;

const total = tJet + tBonus;

finishRoll(
results.rollId,
{
jet: total,
},
);

if (tJet !== 0 && tJet === tExploit) {
startRoll(`${roll}@{jetGM} &{template:simple} {{Nom=@{name}}} {{special1=${i18n_exploit}}}{{jet=[[ {[[{${cRoll.join('+')}, 0}kh1]]d6cs2cs4cs6cf1cf3cf5s%2}=0]]}}`, (exploit) => {
const tExploit2 = exploit.results.jet.result;

finishRoll(
exploit.rollId,
{
jet: tExploit2,
},
);
});
}
const bonusTotal = bonus.reduce((accumulateur, valeurCourante) => parseInt(accumulateur, 10) + parseInt(valeurCourante, 10), 0);
const stringRoll = `{{jet=[[ [[{${cRoll.join('+')}, 0}kh1]]d6cs2cs4cs6cf1cf3cf5s]]}}`;
exec.push(stringRoll);
exec.push('{{basejet=[[0]]}}');
exec.push(`{{tBonus=[[${bonusTotal}]]}}`);
const finalRoll = await startRoll(exec.join(' '));
const computed = computeSimpleRoll(finalRoll, bonusTotal);

finishRoll(finalRoll.rollId, computed);
await postRoll(computed, roll, stringRoll, finalRoll, {
equilibre,
});
});
});
1 change: 1 addition & 0 deletions Knight/pug/js/rolls/pj/bard.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable linebreak-style */
/* eslint-disable camelcase */
/* eslint-disable no-undef */
on('clicked:distanceBard', async (info) => {
Expand Down
1 change: 1 addition & 0 deletions Knight/pug/js/rolls/pj/berserk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable linebreak-style */
/* eslint-disable camelcase */
/* eslint-disable no-undef */
const berserkIlluminationRoll = ['berserkIlluminationBlaze', 'berserkIlluminationLantern'];
Expand Down
26 changes: 2 additions & 24 deletions Knight/pug/js/rolls/pj/combatAutre.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable linebreak-style */
/* eslint-disable prefer-destructuring */
/* eslint-disable camelcase */
/* eslint-disable max-len */
Expand Down Expand Up @@ -413,11 +414,9 @@ rollCombatAutre.forEach((button) => {

if (pasEnergie === false) {
finalRoll = await startRoll(exec.join(' '));
const tJet = finalRoll.results.jet.result;
const rJet = finalRoll.results.jet.dice;

const tBonus = finalRoll.results.bonus.result;
const tExploit = finalRoll.results.Exploit.result;

const rDegats = finalRoll.results.degats.dice;
const rViolence = finalRoll.results.violence.dice;
Expand Down Expand Up @@ -447,28 +446,7 @@ rollCombatAutre.forEach((button) => {

finishRoll(finalRoll.rollId, computed);

if (tJet !== 0 && computed.basejet === tExploit) {
const exploitRoll = await startRoll(`${roll}@{jetGM} &{template:simple} {{Nom=@{name}}} {{special1=${i18n_exploit}}}${jet}`);
const rExploit = exploitRoll.results.jet.dice;
const exploitPairOrImpair = isGuidage === true ? 1 : 0;

const jetExploit = rExploit.reduce((accumulateur, valeurCourante) => {
const vC = valeurCourante;
let nV = 0;

if (vC % 2 === exploitPairOrImpair) {
nV = 1;
}

return accumulateur + nV;
}, 0);

const exploitComputed = {
jet: jetExploit,
};

finishRoll(exploitRoll.rollId, exploitComputed);
}
await postRoll(computed, roll, jet, finalRoll, conditions);

if (hasEnergieRetiree && button === 'repeating_armeautre:armeautrepjvehicule') {
setAttrs({ energieVehicule: newEnergie });
Expand Down
25 changes: 1 addition & 24 deletions Knight/pug/js/rolls/pj/combatContact.js
Original file line number Diff line number Diff line change
Expand Up @@ -974,14 +974,12 @@ rollCombatContact.forEach((button) => {

finalRoll = await startRoll(exec.join(' '));

const tJet = finalRoll.results.jet.result;
const rJet = finalRoll.results.jet.dice;

const rDegats = finalRoll.results.degats.dice;
const rViolence = finalRoll.results.violence.dice;

const tBonus = finalRoll.results.bonus.result;
const tExploit = finalRoll.results.Exploit.result;

const tDegats = finalRoll.results.degats.result;
const tViolence = finalRoll.results.violence.result;
Expand Down Expand Up @@ -1017,28 +1015,7 @@ rollCombatContact.forEach((button) => {

finishRoll(finalRoll.rollId, computed);

if (tJet !== 0 && computed.basejet === tExploit) {
const exploitRoll = await startRoll(`${roll}@{jetGM} &{template:simple} {{Nom=@{name}}} {{special1=${i18n_exploit}}}${jet}`);
const rExploit = exploitRoll.results.jet.dice;
const exploitPairOrImpair = isGuidage === true ? 1 : 0;

const jetExploit = rExploit.reduce((accumulateur, valeurCourante) => {
const vC = valeurCourante;
let nV = 0;

if (vC % 2 === exploitPairOrImpair) {
nV = 1;
}

return accumulateur + nV;
}, 0);

const exploitComputed = {
jet: jetExploit,
};

finishRoll(exploitRoll.rollId, exploitComputed);
}
await postRoll(computed, roll, jet, finalRoll, conditions);

if (hasEnergieRetiree) {
if (energieIsEspoir) {
Expand Down
26 changes: 2 additions & 24 deletions Knight/pug/js/rolls/pj/combatDistance.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable linebreak-style */
/* eslint-disable max-len */
/* eslint-disable prefer-destructuring */
/* eslint-disable camelcase */
Expand Down Expand Up @@ -806,11 +807,9 @@ rollCombatDistance.forEach((button) => {
if (isDevastation && !devaste && !equilibre) { exec.push(`{{vDevastation=${i18n_devastation} ${eDevastationValue} ${i18n_inclus}}}`); }

finalRoll = await startRoll(exec.join(' '));
const tJet = finalRoll.results.jet.result;
const rJet = finalRoll.results.jet.dice;

const tBonus = finalRoll.results.bonus.result;
const tExploit = finalRoll.results.Exploit.result;

const rDegats = finalRoll.results.degats.dice;
const rViolence = finalRoll.results.violence.dice;
Expand Down Expand Up @@ -843,28 +842,7 @@ rollCombatDistance.forEach((button) => {

finishRoll(finalRoll.rollId, computed);

if (tJet !== 0 && computed.basejet === tExploit) {
const exploitRoll = await startRoll(`${roll}@{jetGM} &{template:simple} {{Nom=@{name}}} {{special1=${i18n_exploit}}}${jet}`);
const rExploit = exploitRoll.results.jet.dice;
const exploitPairOrImpair = isGuidage === true ? 1 : 0;

const jetExploit = rExploit.reduce((accumulateur, valeurCourante) => {
const vC = valeurCourante;
let nV = 0;

if (vC % 2 === exploitPairOrImpair) {
nV = 1;
}

return accumulateur + nV;
}, 0);

const exploitComputed = {
jet: jetExploit,
};

finishRoll(exploitRoll.rollId, exploitComputed);
}
await postRoll(computed, roll, jet, finalRoll, conditions);

if (hasEnergieRetiree) {
if (energieIsEspoir) {
Expand Down
27 changes: 2 additions & 25 deletions Knight/pug/js/rolls/pj/combatGrenade.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable linebreak-style */
/* eslint-disable max-len */
/* eslint-disable camelcase */
/* eslint-disable prefer-destructuring */
Expand Down Expand Up @@ -402,10 +403,8 @@ rollCombatGrenade.forEach((button) => {
exec = firstExec.concat(exec);

const finalRoll = await startRoll(exec.join(' '));
const tJet = finalRoll.results.jet.result;
const rJet = finalRoll.results.jet.dice;
const tBonus = finalRoll.results.bonus.result;
const tExploit = finalRoll.results.Exploit.result;

let rDegats = [];
let rViolence = [];
Expand Down Expand Up @@ -437,28 +436,6 @@ rollCombatGrenade.forEach((button) => {
const computed = updateRoll(finalRoll, rJet, tBonus, tDegats, rDegats, bDegats, tViolence, rViolence, bViolence, conditions);

finishRoll(finalRoll.rollId, computed);

if (tJet !== 0 && computed.basejet === tExploit) {
const exploitRoll = await startRoll(`${roll}@{jetGM} &{template:simple} {{Nom=@{name}}} {{special1=${i18n_exploit}}}${jet}`);
const rExploit = exploitRoll.results.jet.dice;
const exploitPairOrImpair = 0;

const jetExploit = rExploit.reduce((accumulateur, valeurCourante) => {
const vC = valeurCourante;
let nV = 0;

if (vC % 2 === exploitPairOrImpair) {
nV = 1;
}

return accumulateur + nV;
}, 0);

const exploitComputed = {
jet: jetExploit,
};

finishRoll(exploitRoll.rollId, exploitComputed);
}
await postRoll(computed, roll, jet, finalRoll, conditions);
});
});
Loading

0 comments on commit 0a82e7b

Please sign in to comment.