Start adv generator

This commit is contained in:
sladecraven 2022-05-20 21:50:18 +02:00
parent 9b8762300e
commit 2637f698ad
3 changed files with 80 additions and 12 deletions

View File

@ -14,6 +14,7 @@ import { BoLCombatManager } from "./system/bol-combat.js"
import { BoLTokenHud } from "./system/bol-action-hud.js" import { BoLTokenHud } from "./system/bol-action-hud.js"
import { BoLHotbar } from "./system/bol-hotbar.js" import { BoLHotbar } from "./system/bol-hotbar.js"
import { BoLAdventureGenerator } from "./system/bol-adventure-generator.js" import { BoLAdventureGenerator } from "./system/bol-adventure-generator.js"
import { BoLCommands} from "./system/bol-commands.js"
/* -------------------------------------------- */ /* -------------------------------------------- */
Hooks.once('init', async function () { Hooks.once('init', async function () {
@ -29,7 +30,7 @@ Hooks.once('init', async function () {
// Game socket // Game socket
game.socket.on("system.bol", sockmsg => { game.socket.on("system.bol", sockmsg => {
BoLUtility.onSocketMessage(sockmsg); BoLUtility.onSocketMessage(sockmsg);
}); })
/** /**
@ -56,6 +57,8 @@ Hooks.once('init', async function () {
BoLUtility.init() BoLUtility.init()
BoLTokenHud.init() BoLTokenHud.init()
BoLHotbar.init() BoLHotbar.init()
BoLCommands.init()
BoLAdventureGenerator.init()
// Preload Handlebars Templates // Preload Handlebars Templates
await preloadHandlebarsTemplates(); await preloadHandlebarsTemplates();
@ -109,8 +112,6 @@ Hooks.once('ready', async function () {
registerUsageCount('bol') registerUsageCount('bol')
welcomeMessage() welcomeMessage()
})
BoLAdventureGenerator.init()
});

View File

@ -1,19 +1,86 @@
/* -------------------------------------------- */ /* -------------------------------------------- */
import { BoLRoll } from "../controllers/bol-rolls.js"; import { BoLUtility } from "./bol-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class BoLAdventureGenerator { export class BoLAdventureGenerator {
/* -------------------------------------------- */
static async init() { static async init() {
this.adventureData = await fetchJsonWithTimeout("systems/bol/module/system/adventure_data.json") this.adventureData = await fetchJsonWithTimeout("systems/bol/module/system/adventure_data.json")
}
let roll1 = new Roll("1d"+this.adventureData.titre1.length).evaluate( {async: false}) /* -------------------------------------------- */
let roll2 = new Roll("1d"+this.adventureData.titre2.length).evaluate( {async: false}) static async createAdventure() {
let roll1 = new Roll("1d" + this.adventureData.titre1.length).evaluate({ async: false })
let roll2 = new Roll("1d" + this.adventureData.titre2.length).evaluate({ async: false })
let p1 = this.adventureData.titre1[roll1.result-1] let p1 = this.adventureData.titre1[roll1.result - 1]
let p2 = this.adventureData.titre2[roll2.result-1] let p2 = this.adventureData.titre2[roll2.result - 1]
let story = {}
story.title = "Krongar et " + p1.prefix + " " + p1.name + " " + p2.prefix + " " + p2.name
let rollM = new Roll("1d" + this.adventureData.mission.length).evaluate({ async: false })
story.mission = "La mission de Krongar est de " + this.adventureData.mission[rollM.result - 1].name
if (!p1.isCarriere && !p2.isCarriere) {
let rollC = new Roll("1d" + this.adventureData.carriere.length).evaluate({ async: false })
story.carriere = "Une carrière : " + this.adventureData.carriere[rollC.result - 1]
}
if (!p1.isLieu && !p2.isLieu) {
let rollL1 = new Roll("1d" + this.adventureData.lieux1.length).evaluate({ async: false })
let rollL2 = new Roll("1d" + this.adventureData.lieux2.length).evaluate({ async: false })
story.lieu = "Un lieu : " + this.adventureData.lieux1[rollL1.result - 1] + " " + this.adventureData.lieux2[rollL2.result - 1]
}
if (!p1.isObjet && !p2.isObjet) {
let rollO1 = new Roll("1d" + this.adventureData.objets1.length).evaluate({ async: false })
let rollO2 = new Roll("1d" + this.adventureData.objets2.length).evaluate({ async: false })
story.objet = "Un objet : " + this.adventureData.objets1[rollO1.result - 1] + " " + this.adventureData.objets2[rollO2.result - 1]
}
let rollMOT = new Roll("1d" + this.adventureData.motivation.length).evaluate({ async: false })
story.motivation = "Krongar entreprend cette mission parce que " + this.adventureData.motivation[rollMOT.result - 1]
if (!p1.isEnnemi && !p2.isEnnemi) {
let rollE = new Roll("1d" + this.adventureData.rival.length).evaluate({ async: false })
story.rival = "Un rival : " + this.adventureData.rival[rollE.result - 1]
}
let rollDieu = new Roll("1d6").evaluate({ async: false })
if (rollDieu.result == 6) {
rollDieu = new Roll("1d" + this.adventureData.dieu.length).evaluate({ async: false })
story.dieu = "Un Dieu est impliqué : " + this.adventureData.dieu[rollDieu.result - 1]
}
let rollComp = new Roll("1d6").evaluate({ async: false })
if (rollComp.result >= 5) {
rollComp = new Roll("1d" + this.adventureData.complique1.length).evaluate({ async: false })
story.complication = "Une complication : " + this.adventureData.complique1[rollComp.result - 1]
}
let rollObs = new Roll("1d6").evaluate({ async: false })
if (rollObs.result >= 5) {
rollObs = new Roll("1d" + this.adventureData.obstacle.length).evaluate({ async: false })
story.obstacle = "Un obstacle : " + this.adventureData.obstacle[rollObs.result - 1]
}
let rollRet = new Roll("1d6").evaluate({ async: false })
if (rollRet.result == 6) {
rollRet = new Roll("1d" + this.adventureData.retournement.length).evaluate({ async: false })
story.retournement = "Un retournement : " + this.adventureData.retournement[rollRet.result - 1]
}
let rollRec = new Roll("1d" + this.adventureData.recompense.length).evaluate({ async: false })
story.recompense = "Pour sa peine, Krongar reçoit " + this.adventureData.recompense[rollRec.result - 1]
ChatMessage.create({
alias: this.name,
whisper: BoLUtility.getUsers(user => user.isGM),
content: await renderTemplate('systems/bol/templates/chat/chat-adventure-result.hbs',
{ name: "Aventure !", img: "", story : story})
})
let str = "Krongar et " + p1.prefix + " " + p1.name + " " + p2.prefix + " " + p2.name
//ui.notifications.info("Titre :" + str)
} }
} }

View File

@ -14,7 +14,7 @@
"url": "https://github.com/ZigmundKreud/bol", "url": "https://github.com/ZigmundKreud/bol",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"flags": {}, "flags": {},
"version": "1.3.16", "version": "1.3.17",
"templateVersion": 10, "templateVersion": 10,
"minimumCoreVersion": "0.8.6", "minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",