forked from public/bol
Meilleure gestion initiative
This commit is contained in:
@ -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,8 +450,8 @@ 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
|
||||
this.updateTotalDice()
|
||||
@ -459,8 +460,8 @@ 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
|
||||
this.updateTotalDice()
|
||||
@ -469,7 +470,7 @@ export class BoLRoll {
|
||||
this.rollData.selectedGroupHoroscopeIndex = event.currentTarget.value
|
||||
this.updateTotalDice()
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -577,7 +578,7 @@ export class BoLRoll {
|
||||
rollbase = 0
|
||||
}
|
||||
|
||||
let diceData = BoLUtility.getDiceData()
|
||||
let diceData = BoLUtility.getDiceData()
|
||||
const modifiers = rollbase + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus + rollData.effectModifier
|
||||
const formula = (isMalus) ? rollData.nbDice + "d" + diceData.diceFormula + "kl2 + " + modifiers : rollData.nbDice + "d" + diceData.diceFormula + "kh2 + " + modifiers
|
||||
rollData.formula = formula
|
||||
@ -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)
|
||||
|
Reference in New Issue
Block a user