Test rencontres
This commit is contained in:
parent
3d34921072
commit
bdc8103f6b
@ -328,6 +328,7 @@ export class RdDActor extends Actor {
|
||||
return explications
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async dormir(heures=1) {
|
||||
let message = { title : "Récupération", content :"Vous dormez " + heures + " heure" + (heures > 1 ? "s": "") };
|
||||
this.recupereEndurance(message);
|
||||
@ -338,6 +339,7 @@ export class RdDActor extends Actor {
|
||||
ChatMessage.create( message );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
recupereEndurance(message) {
|
||||
const avant = this.data.data.sante.endurance.value;
|
||||
this.santeIncDec("endurance", this.data.data.sante.endurance.max - avant);
|
||||
@ -347,6 +349,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async recupererFatigueUneHeure(message) {
|
||||
let fatigue = duplicate(this.data.data.sante.fatigue)
|
||||
if (fatigue.value == 0) {
|
||||
@ -379,6 +382,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
recuperationReve(message) {
|
||||
const seuil = this.data.data.reve.seuil.value;
|
||||
const reve = this.getReveActuel();
|
||||
@ -401,6 +405,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
combattreReveDeDragon(force){
|
||||
let draconic = this.getBestDraconic();
|
||||
let niveau = Math.max(0, draconic.data.niveau);
|
||||
@ -413,6 +418,7 @@ export class RdDActor extends Actor {
|
||||
return this.appliquerReveDeDragon(rolled, force);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
appliquerReveDeDragon(roll, force) {
|
||||
let message = "";
|
||||
if (roll.isSuccess) {
|
||||
@ -629,6 +635,7 @@ export class RdDActor extends Actor {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
ajouterSouffle() {
|
||||
let souffle = RdDRollTables.getSouffle();
|
||||
// ChatMessage.create({
|
||||
@ -638,6 +645,7 @@ export class RdDActor extends Actor {
|
||||
// this.actor.createOwnedItem(souffle);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async ajouterQueue() {
|
||||
// TODO: Déterminer si Thanatos a été utilisé? => laisser le joueur ne pas choisir Thanatos => choisir sa voie?
|
||||
let utiliseThanatos = false;
|
||||
@ -696,6 +704,13 @@ export class RdDActor extends Actor {
|
||||
await this.update( {"data.reve.rencontre": rencontres } );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCoordTMR( coord ) {
|
||||
let tmrPos = duplicate(this.data.data.reve.tmrpos );
|
||||
tmrPos.coord = coord;
|
||||
await this.update( {"data.reve.tmrpos": tmrPos } );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updatePointsDeReve( value ) {
|
||||
@ -703,7 +718,8 @@ export class RdDActor extends Actor {
|
||||
reve.value = Math.max(reve.value + value, 0);
|
||||
await this.update( {"data.reve.reve": reve } );
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updatePointDeSeuil(value=1) {
|
||||
const seuil = Misc.toInt(this.data.data.reve.seuil.value);
|
||||
const reve = Misc.toInt(this.data.data.carac.reve.value);
|
||||
@ -712,6 +728,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setPointsDeSeuil( value ) {
|
||||
let seuil = duplicate(this.data.data.reve.seuil);
|
||||
seuil.value = value;
|
||||
@ -882,28 +899,28 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_stressRoll() {
|
||||
let result = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
|
||||
console.log("_stressRoll", result);
|
||||
switch (result.code) {
|
||||
case "sign": return { factor: 0.75, comment: " (75%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "norm": return { factor: 0.5, comment: " (50%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "echec": return { factor: 0.2, comment: " (20%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "epart": return { factor: 0.1, comment: " (10%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "etotal": return { factor: 0, comment: " (0%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "part":
|
||||
{
|
||||
let second = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
|
||||
console.log("_stressRoll", second);
|
||||
switch (second.code) {
|
||||
case "part": case "sign":
|
||||
return { factor: 1.5, comment: " (150%): Double Particulière - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
||||
default:
|
||||
return { factor: 1, comment: " (150%): " + result.quality + " - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
||||
_stressRoll() {
|
||||
let result = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
|
||||
console.log("_stressRoll", result);
|
||||
switch (result.code) {
|
||||
case "sign": return { factor: 0.75, comment: " (75%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "norm": return { factor: 0.5, comment: " (50%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "echec": return { factor: 0.2, comment: " (20%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "epart": return { factor: 0.1, comment: " (10%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "etotal": return { factor: 0, comment: " (0%): " + result.quality + " - " + result.roll + " sur " + result.score + "%" }
|
||||
case "part":
|
||||
{
|
||||
let second = RdDResolutionTable.roll(this.data.data.carac.reve.value, 0);
|
||||
console.log("_stressRoll", second);
|
||||
switch (second.code) {
|
||||
case "part": case "sign":
|
||||
return { factor: 1.5, comment: " (150%): Double Particulière - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
||||
default:
|
||||
return { factor: 1, comment: " (150%): " + result.quality + " - " + result.roll + " puis " + second.roll + " sur " + result.score + "%" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollUnSort(coord) {
|
||||
|
@ -15,6 +15,7 @@ import { RdDActorCreatureSheet } from "./actor-creature-sheet.js";
|
||||
import { RdDActorHumanoideSheet } from "./actor-humanoide-sheet.js";
|
||||
import { RdDActorEntiteSheet } from "./actor-entite-sheet.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
import { TMRUtility } from "./tmr-utility.js";
|
||||
import { RdDCalendrier } from "./rdd-calendrier.js";
|
||||
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
||||
|
||||
@ -100,7 +101,8 @@ Hooks.once("init", async function() {
|
||||
|
||||
// Create useful storage space
|
||||
game.system.rdd = {
|
||||
rollDataHandler: {}
|
||||
rollDataHandler: {},
|
||||
TMRUtility: TMRUtility
|
||||
}
|
||||
// Create specific settings
|
||||
// game.settings.register("foundryvtt-reve-de-dragon", "configuration", {
|
||||
|
@ -114,18 +114,19 @@ export class RdDTMRDialog extends Dialog {
|
||||
+ RdDResolutionTable.explain(rolled);
|
||||
|
||||
if (rolled.isEchec) {
|
||||
TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled);
|
||||
message += TMRUtility.processRencontreEchec(this.actor, this.currentRencontre, rolled);
|
||||
this._tellToUser("Vous avez <strong>échoué</strong> à maîtriser un " + this.currentRencontre.name + " de force " + this.currentRencontre.force
|
||||
+ "<br>Vous quittez brutalement les Terres Médianes !" + message);
|
||||
this.close();
|
||||
} else {
|
||||
TMRUtility.processRencontreReussite(this.actor, this.currentRencontre, rolled);
|
||||
message += TMRUtility.processRencontreReussite(this.actor, this.currentRencontre, rolled);
|
||||
this._tellToUser("Vous avez <strong>réussi</strong> à maîtriser un " + this.currentRencontre.name + " de force " + this.currentRencontre.force + message);
|
||||
}
|
||||
console.log("-> matriser", this.currentRencontre);
|
||||
this.updateValuesDisplay();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_tellToUser(message) {
|
||||
ChatMessage.create({ title: "TMR", content: message, user: game.user._id, whisper: ChatMessage.getWhisperRecipients("GM") });
|
||||
}
|
||||
@ -139,9 +140,9 @@ export class RdDTMRDialog extends Dialog {
|
||||
let rencontre = this.rencontresExistantes.find(prev => prev.coord == coordTMR);
|
||||
if (rencontre == undefined) {
|
||||
let deRencontre = new Roll("d7").roll();
|
||||
if (deRencontre.total == 7) {
|
||||
//if (deRencontre.total == 7) {
|
||||
rencontre = await TMRUtility.rencontreTMRRoll(coordTMR, cellDescr);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
if (rencontre) { // Manages it
|
||||
|
@ -581,6 +581,12 @@ export class RdDUtility {
|
||||
//console.log("Particulère !", rollData);
|
||||
attackerActor.continueRoll( rollData );
|
||||
});
|
||||
|
||||
html.on("click", '.tmr-passeur-coord a', event => {
|
||||
let coord = event.currentTarget.attributes['data-tmr-coord'].value;
|
||||
let actor = game.actors.get( game.user.character.id );
|
||||
actor.updateCoordTMR(coord);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ const rencontresTable = [
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class TMRUtility {
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static convertToTMRCoord( x, y )
|
||||
{
|
||||
@ -268,15 +268,17 @@ export class TMRUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async rencontreTMRRoll( coordTMR, cellDescr )
|
||||
{
|
||||
let rencontre = this.rencontreTMRTypeCase(cellDescr.type);
|
||||
//let rencontre = this.rencontreTMRTypeCase(cellDescr.type);
|
||||
let rencontre = rencontresTable[4];
|
||||
if (rencontre){
|
||||
rencontre = duplicate(rencontre);
|
||||
rencontre.force = this.evaluerForceRencontre(rencontre);
|
||||
rencontre.force = 1;//this.evaluerForceRencontre(rencontre);
|
||||
rencontre.coord = coordTMR;
|
||||
}
|
||||
return rencontre;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static rencontreTMRTypeCase(typeTMR, roll=undefined) {
|
||||
if (!roll)
|
||||
{
|
||||
@ -325,6 +327,19 @@ export class TMRUtility {
|
||||
// TODO random get same type
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getLocationTypeList( coordTMR ) {
|
||||
let descr = this.getTMRDescription( coordTMR );
|
||||
let typeList = [];
|
||||
for (let index in TMRMapping) {
|
||||
let caseTMR = TMRMapping[index];
|
||||
if (caseTMR.type == descr.type)
|
||||
typeList.push(index)
|
||||
}
|
||||
return typeList;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static evaluerForceRencontre(rencontre) {
|
||||
if (this.isReveDeDragon(rencontre)) {
|
||||
let ddr = RdDDice.deDraconique();
|
||||
@ -336,19 +351,20 @@ export class TMRUtility {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isReveDeDragon(rencontre) {
|
||||
return rencontre.name.toLowerCase() == "Rêve de Dragon".toLowerCase();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processRencontreReussite( actor, rencontre, rolled ) {
|
||||
let msg = "Vous avez réussi votre maîtrise ! ";
|
||||
let msg = "<br>";
|
||||
console.log("processRencontreReussite", actor, rencontre);
|
||||
if (rencontre.name == "Messagers des Rêves") {
|
||||
msg += "Le Messager des Rêves vous permet de lancer votre sort à XX cases !";
|
||||
|
||||
} else if (rencontre.name == "Passeur des Rêves") {
|
||||
msg += "Le Passeur des Rêves vous téléporte sur une case à distance XX !";
|
||||
msg += "Le Passeur des Rêves vous téléporte sur une case à XX !";
|
||||
|
||||
} else if (rencontre.name == "Fleur des Rêves") {
|
||||
await actor.updatePointsDeReve( rencontre.force );
|
||||
@ -358,7 +374,12 @@ export class TMRUtility {
|
||||
msg += "Ce Mangeur des Rêves disparait !"
|
||||
|
||||
} else if (rencontre.name == "Changeur de Rêve") {
|
||||
msg += "Ce Changeur des Rêves disparait !"
|
||||
msg += "Ce Changeur des Rêves vous propose de vous déplacer sur une autre case de même type."
|
||||
let locList = this.getLocationTypeList( actor.data.data.reve.tmrpos.coord );
|
||||
for ( let coord of locList) {
|
||||
let caseTMR = TMRMapping[coord];
|
||||
msg += "<li class='tmr-passeur-coord' data-tmr-coord='"+coord+"'><a>"+coord+" - " +caseTMR.label+"</a></li>";
|
||||
}
|
||||
|
||||
} else if (rencontre.name == "Briseur de Rêve") {
|
||||
msg += "Ce Briseur des Rêves disparait !"
|
||||
@ -377,11 +398,12 @@ export class TMRUtility {
|
||||
msg += "Vous maîtrisez le Rêve de Dragon !"
|
||||
msg += actor.appliquerReveDeDragon(rolled, rencontre.force);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async processRencontreEchec( actor, rencontre, rolled ) {
|
||||
let msg = "Vous avez échoué à votre maîtrise ! ";
|
||||
let msg = "<br>";
|
||||
|
||||
if (rencontre.name == "Messagers des Rêves") {
|
||||
msg += "Le Messager des Rêves s'éloigne de vous !";
|
||||
@ -395,10 +417,11 @@ export class TMRUtility {
|
||||
} else if (rencontre.name == "Mangeur de Rêve") {
|
||||
await actor.updatePointsDeReve( -rencontre.force );
|
||||
msg += "Ce Mangeur des Rêves croque votre Rêve ! Vous perdez " + rencontre.force + " points de rêve actuels, votre nouveau total est de " + actor.data.data.reve.reve.value;
|
||||
|
||||
} else if (rencontre.name == "Changeur de Rêve") {
|
||||
let coordTMR = actor.data.data.reve.tmrpos.coord;
|
||||
let newcoordTMR = this.getRandomLocationType(coordTMR);
|
||||
msg += "Vous avez été téléporté en "; // TODO
|
||||
msg += "Vous avez été téléporté en " + coordTMR + " - " + coordTMR.label;
|
||||
|
||||
} else if (rencontre.name == "Briseur de Rêve") {
|
||||
msg += "Votre Rêve est Brisé, vous quittez les Terres Médianes";
|
||||
@ -416,8 +439,9 @@ export class TMRUtility {
|
||||
msg += "Le Rêve de Dragon tourne au cauchemar !"
|
||||
msg += actor.appliquerReveDeDragon(rolled, rencontre.force);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async genericGetTableResult( tableName, toChat)
|
||||
{
|
||||
@ -431,9 +455,6 @@ export class TMRUtility {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static getTMRAleatoire()
|
||||
{
|
||||
let num = new Roll("1d15").roll().total;
|
||||
|
Loading…
Reference in New Issue
Block a user