Meilleure gestion initiative

This commit is contained in:
LeRatierBretonnien 2023-03-15 17:35:07 +01:00
parent 5df2b7e624
commit 0c502a2188
5 changed files with 29 additions and 130 deletions

109
.gitignore vendored
View File

@ -1,108 +1 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
package-lock.json
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# BOL Data
#/data/
.history/

View File

@ -765,7 +765,7 @@ export class BoLActor extends Actor {
}
/*-------------------------------------------- */
getInitiativeRank(rollData = undefined, isCombat = false) {
getInitiativeRank(rollData = undefined, isCombat = false, combatData) {
if (!rollData) {
rollData = this.getFlag("world", "last-initiative")
}
@ -775,7 +775,8 @@ export class BoLActor extends Actor {
if (!rollData) {
fvttInit = -1
if ( isCombat ) {
ui.notifications.warn(game.i18n.localize("BOL.ui.warninitiative"))
ui.notifications.info(game.i18n.localize("BOL.ui.warninitiative"))
BoLRoll.aptitudeCheck(this, "init", undefined, combatData )
}
} else {
if (rollData.isLegendary) {

View File

@ -33,11 +33,11 @@ export class BoLRoll {
/* -------------------------------------------- */
static buildHoroscopeGroupList() {
let horoscopes = game.settings.get("bol", "horoscope-group")
let horoList = [ { id: -1, name: "Aucun", type: "malus", nbDice: 0 }]
let horoList = [{ id: -1, name: "Aucun", type: "malus", nbDice: 0 }]
for (let id in horoscopes) {
let horo = horoscopes[id]
for (let i=0; i<horo.availableDice; i++) {
horoList.push( { id: id, name: horo.name, type: horo.type, nbDice: i+1})
for (let i = 0; i < horo.availableDice; i++) {
horoList.push({ id: id, name: horo.name, type: horo.type, nbDice: i + 1 })
}
}
return horoList
@ -78,7 +78,7 @@ export class BoLRoll {
}
/* -------------------------------------------- */
static attributeCheck(actor, key) {
static attributeCheck(actor, key, event, combatData) {
let attribute = eval(`actor.system.attributes.${key}`)
@ -91,7 +91,7 @@ export class BoLRoll {
}
/* -------------------------------------------- */
static aptitudeCheck(actor, key) {
static aptitudeCheck(actor, key, event, combatData) {
let aptitude = eval(`actor.system.aptitudes.${key}`)
let attrKey = this.getDefaultAttribute(key)
@ -101,6 +101,7 @@ export class BoLRoll {
rollData.label = (aptitude.label) ? game.i18n.localize(aptitude.label) : null
rollData.description = game.i18n.localize('BOL.ui.aptitudeCheck') + " - " + game.i18n.localize(aptitude.label)
rollData.combatData = combatData // For initiative mainly
return this.displayRollDialog(rollData)
}
@ -219,8 +220,8 @@ export class BoLRoll {
/* -------------------------------------------- */
static horoscopeCheck(actor, event, horoscopeType) {
let cost = (horoscopeType == "minor") ? 1 : 2
if (cost > actor.getAstrologyPoints() ) {
let cost = (horoscopeType == "minor") ? 1 : 2
if (cost > actor.getAstrologyPoints()) {
ui.notifications.warn(game.i18n.localize("BOL.ui.astrologyNoPoints"))
return
}
@ -228,7 +229,7 @@ export class BoLRoll {
rollData.careerBonus = actor.getAstrologerBonus()
rollData.horoscopeType = horoscopeType
rollData.horoscopeTypeLabel = "BOL.ui."+horoscopeType
rollData.horoscopeTypeLabel = "BOL.ui." + horoscopeType
rollData.astrologyPointsCost = cost
rollData.label = game.i18n.localize('BOL.ui.makeHoroscope')
rollData.description = game.i18n.localize('BOL.ui.makeHoroscope') + " " + game.i18n.localize(rollData.horoscopeTypeLabel)
@ -295,7 +296,7 @@ export class BoLRoll {
}
this.rollData.bmDice += this.rollData.horoscopeBonus
this.rollData.bmDice -= this.rollData.horoscopeMalus
if ( this.rollData.selectedGroupHoroscopeIndex && this.rollData.selectedGroupHoroscopeIndex > 0) {
if (this.rollData.selectedGroupHoroscopeIndex && this.rollData.selectedGroupHoroscopeIndex > 0) {
let horo = this.rollData.horoscopeGroupList[this.rollData.selectedGroupHoroscopeIndex]
this.rollData.bmDice += (horo.type == "malus") ? -horo.nbDice : horo.nbDice;
}
@ -449,7 +450,7 @@ export class BoLRoll {
html.find('#horoscope-bonus-applied').change((event) => {
this.rollData.selectedHoroscope = []
for (let option of event.currentTarget.selectedOptions) {
this.rollData.selectedHoroscope.push( duplicate(this.rollData.horoscopeBonusList[Number(option.index)]) )
this.rollData.selectedHoroscope.push(duplicate(this.rollData.horoscopeBonusList[Number(option.index)]))
}
let horoscopes = $('#horoscope-bonus-applied').val()
this.rollData.horoscopeBonus = (!horoscopes || horoscopes.length == 0) ? 0 : horoscopes.length
@ -459,7 +460,7 @@ export class BoLRoll {
html.find('#horoscope-malus-applied').change((event) => {
this.rollData.selectedHoroscope = []
for (let option of event.currentTarget.selectedOptions) {
this.rollData.selectedHoroscope.push( duplicate(this.rollData.horoscopeBonusList[Number(option.index)]) )
this.rollData.selectedHoroscope.push(duplicate(this.rollData.horoscopeBonusList[Number(option.index)]))
}
let horoscopes = $('#horoscope-malus-applied').val()
this.rollData.horoscopeMalus = (!horoscopes || horoscopes.length == 0) ? 0 : horoscopes.length
@ -624,7 +625,7 @@ export class BoLDefaultRoll {
await r.roll({ "async": false })
let diceData = BoLUtility.getDiceData()
console.log("DICEDATA", diceData)
//console.log("DICEDATA", diceData)
const activeDice = r.terms[0].results.filter(r => r.active)
const diceTotal = activeDice.map(r => r.result).reduce((a, b) => a + b)
this.rollData.roll = r
@ -643,6 +644,10 @@ export class BoLDefaultRoll {
if (this.rollData.registerInit) {
actor.registerInit(this.rollData)
this.rollData.initiativeRank = actor.getInitiativeRank(this.rollData)
if (this.rollData.combatData) { // If combatData present
let combat = game.combats.get(this.rollData.combatData.combatId)
combat.setInitiative(this.rollData.combatData.combatantId, this.rollData.initiativeRank)
}
}
if (this.rollData.isSuccess && this.rollData.mode == "spell") { // PP cost management
this.rollData.remainingPP = actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor)

View File

@ -25,7 +25,7 @@ export class BoLCombatManager extends Combat {
// calculate initiative
for (let cId = 0; cId < ids.length; cId++) {
const combatant = this.combatants.get(ids[cId])
let fvttInit = combatant.actor.getInitiativeRank(false, true)
let fvttInit = combatant.actor.getInitiativeRank(false, true, {combatId: this.id, combatantId: combatant.id } )
fvttInit += (cId / 100)
await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]);
}

View File

@ -14,7 +14,7 @@
],
"url": "https://www.uberwald.me/gitea/public/bol",
"license": "LICENSE.txt",
"version": "10.5.7",
"version": "10.5.8",
"compatibility": {
"minimum": "10",
"verified": "10"
@ -202,7 +202,7 @@
],
"socket": true,
"manifest": "https://www.uberwald.me/gitea/public/bol/raw/v10/system.json",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.7.zip",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.8.zip",
"background": "systems/bol/ui/page_accueil.webp",
"gridDistance": 1.5,
"gridUnits": "m",