Astrologie !

This commit is contained in:
LeRatierBretonnien 2022-12-25 18:00:42 +01:00
parent bcb377db7a
commit 1bbefd3499
18 changed files with 336 additions and 68 deletions

View File

@ -163,6 +163,10 @@
"BOL.ui.minor": "Mineur",
"BOL.ui.major": "Majeur",
"BOL.ui.majorgroup": "Majeur de Groupe",
"BOL.ui.horoscopeGroup": "Horoscopes de Groupe",
"BOL.ui.horoscopeDiceRemaining": "Dés restants",
"BOL.ui.horoscopeDiceMax": "Dés Max",
"BOL.ui.astrologyNoPoints": "Vous n'avez pas assez de Points d'Astrologie!",
"BOL.ui.advance": "Avancement",
"BOL.ui.isbonusdice": "Fourni un dé bonus?",

View File

@ -160,6 +160,7 @@ export class BoLActorSheet extends ActorSheet {
formData.isAstrologer = this.actor.isAstrologer()
formData.isMysteries = formData.isSorcerer || formData.isAlchemist || formData.isAstrologer
formData.isPriest = this.actor.isPriest()
formData.horoscopeGroupList = game.settings.get("bol", "horoscope-group")
formData.isGM = game.user.isGM

View File

@ -481,15 +481,21 @@ export class BoLActor extends Actor {
let rID = randomID(16)
let horoscopes = duplicate(game.settings.get("bol", "horoscope-group"))
horoscopes[rID] = {
id: rID,
name: game.i18n.localize("BOL.ui.groupHoroscope") + this.name,
maxDice: rollData.careerBonus,
availableDice: rollData.careerBonus,
type: (rollData.isSuccess) ? "bonus": "malus"
}
game.settings.set("bol", "horoscope-group", horoscopes)
}
}
/*-------------------------------------------- */
getAstrologyPoints() {
return this.system.resources.astrologypoints.value
}
/*-------------------------------------------- */
removeHoroscopeMinor( rollData) {
let toDel = []
@ -619,11 +625,6 @@ export class BoLActor extends Actor {
"label": "BOL.featureSubtypes.effects",
"ranked": false,
"items": this.boleffects
},
"horoscopes": {
"label": "BOL.featureSubtypes.horoscope",
"ranked": false,
"items": this.horoscopes
}
}
}

View File

@ -30,6 +30,19 @@ export class BoLRoll {
return appEffects
}
/* -------------------------------------------- */
static buildHoroscopeGroupList() {
let horoscopes = game.settings.get("bol", "horoscope-group")
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})
}
}
return horoList
}
/* -------------------------------------------- */
static getCommonRollData(actor, mode, attribute, aptitude = undefined) {
@ -53,7 +66,8 @@ export class BoLRoll {
mod: 0,
modRanged: 0,
aptValue: 0,
bolEffects: actor.boleffects
bolEffects: actor.boleffects,
horoscopeGroupList: this.buildHoroscopeGroupList()
}
if (aptitude) {
rollData.aptitude = aptitude
@ -94,7 +108,7 @@ export class BoLRoll {
/* -------------------------------------------- */
static async detectDistance(weapon, target) {
let visible, dist
if (weapon.system.properties.ranged || weapon.system.properties.throwing) {
if (target && (weapon.system.properties.ranged || weapon.system.properties.throwing)) {
console.log("target", target, weapon)
visible = canvas.effects.visibility.testVisibility(target.center, { object: _token })
dist = Number(canvas.grid.measureDistances([{ ray: new Ray(_token.center, target.center) }], { gridSpaces: false })).toFixed(2)
@ -205,12 +219,17 @@ export class BoLRoll {
/* -------------------------------------------- */
static horoscopeCheck(actor, event, horoscopeType) {
let cost = (horoscopeType == "minor") ? 1 : 2
if (cost > actor.getAstrologyPoints() ) {
ui.notifications.warn(game.i18n.localize("BOL.ui.astrologyNoPoints"))
return
}
let rollData = this.getCommonRollData(actor, "horoscope", actor.system.attributes.mind)
rollData.careerBonus = actor.getAstrologerBonus()
rollData.horoscopeType = horoscopeType
rollData.horoscopeTypeLabel = "BOL.ui."+horoscopeType
rollData.astrologyPointsCost = (horoscopeType == "minor") ? 1 : 2
rollData.astrologyPointsCost = cost
rollData.label = game.i18n.localize('BOL.ui.makeHoroscope')
rollData.description = game.i18n.localize('BOL.ui.makeHoroscope') + " " + game.i18n.localize(rollData.horoscopeTypeLabel)
@ -276,7 +295,10 @@ export class BoLRoll {
}
this.rollData.bmDice += this.rollData.horoscopeBonus
this.rollData.bmDice -= this.rollData.horoscopeMalus
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;
}
// Keep track of the final effect modifier
this.rollData.effectModifier = effectModifier
@ -425,21 +447,29 @@ export class BoLRoll {
this.updateTotalDice()
})
html.find('#horoscope-bonus-applied').change((event) => {
if (event.currentTarget.value != undefined) {
this.rollData.selectedHoroscope.push( duplicate(this.rollData.horoscopeBonusList[Number(event.currentTarget.value)]) )
this.rollData.selectedHoroscope = []
for (let option of event.currentTarget.selectedOptions) {
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()
})
html.find('#horoscope-malus-applied').change((event) => {
if (event.currentTarget.value != undefined) {
this.rollData.selectedHoroscope.push( duplicate(this.rollData.horoscopeMalusList[Number(event.currentTarget.value)]) )
this.rollData.selectedHoroscope = []
for (let option of event.currentTarget.selectedOptions) {
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()
})
html.find('#horoscope-group-applied').change((event) => {
this.rollData.selectedGroupHoroscopeIndex = event.currentTarget.value
this.updateTotalDice()
})
}
@ -608,7 +638,6 @@ export class BoLDefaultRoll {
if (this.rollData.reroll == undefined) {
this.rollData.reroll = actor.heroReroll()
}
if (this.rollData.registerInit) {
actor.registerInit(this.rollData)
this.rollData.initiativeRank = actor.getInitiativeRank(this.rollData)
@ -616,20 +645,25 @@ export class BoLDefaultRoll {
if (this.rollData.isSuccess && this.rollData.mode == "spell") { // PP cost management
this.rollData.remainingPP = actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor)
}
if (this.rollData.mode == "alchemy") { // PP cost management
actor.resetAlchemyStatus(this.rollData.alchemy._id)
}
if (this.rollData.mode == "bougette" && this.rollData.isFailure) {
actor.decBougette()
}
await this.sendChatMessage()
if (this.rollData.mode == "horoscope") { // PP cost management
actor.manageHoroscope(this.rollData)
}
if (this.rollData.selectedHoroscope.length > 0) { // PP cost management
actor.removeHoroscopeMinor(this.rollData)
}
await this.sendChatMessage()
if (this.rollData.selectedGroupHoroscopeIndex && this.rollData.selectedGroupHoroscopeIndex > 0) { // PP cost management
BoLUtility.removeGroupHoroscope(this.rollData)
}
}
/* -------------------------------------------- */

View File

@ -9,6 +9,12 @@ export class BoLCharacterSummary extends Application {
static displayPCSummary(){
game.bol.charSummary.render(true)
}
/* -------------------------------------------- */
updatePCSummary(){
if ( this.rendered) {
this.render(true)
}
}
/* -------------------------------------------- */
static createSummaryPos() {
@ -60,6 +66,7 @@ export class BoLCharacterSummary extends Application {
}
}
formData.config = game.bol.config
formData.horoscopeGroupList = game.settings.get("bol", "horoscope-group")
if ( toUpdate ) {
this.settings.npcList = newList
@ -123,6 +130,33 @@ export class BoLCharacterSummary extends Application {
game.bol.charSummary.updateNPC()
})
html.find('#horoscope-group-edit-available').change(event => {
const horoId = $(event.currentTarget).data("horo-id")
let newValue = event.currentTarget.value
let horoscopes = duplicate(game.settings.get("bol", "horoscope-group"))
if ( horoId && horoscopes[horoId]) {
horoscopes[horoId].availableDice = Number(newValue)
if (newValue <= 0) {
horoscopes[horoId] = undefined
}
game.settings.set("bol", "horoscope-group", horoscopes)
setTimeout(function() { BoLUtility.updateSheets()}, 800 )
}
})
html.find('#horoscope-group-edit-max').change(event => {
const horoId = $(event.currentTarget).data("horo-id")
let newValue = event.currentTarget.value
let horoscopes = duplicate(game.settings.get("bol", "horoscope-group"))
if ( horoId && horoscopes[horoId]) {
horoscopes[horoId].maxDice = Number(newValue)
if (newValue <= 0) {
horoscopes[horoId] = undefined
}
game.settings.set("bol", "horoscope-group", horoscopes)
setTimeout(function() { BoLUtility.updateSheets()}, 800 )
}
})
}
}

View File

@ -585,5 +585,29 @@ export class BoLUtility {
return item
}
/* -------------------------------------------- */
static updateSheets() {
// Then force opened actor refresh if needed
for (let actor of game.actors) {
if (actor.sheet.rendered) {
actor.sheet.render()
}
}
game.bol.charSummary.updatePCSummary() // Refresh if needed
}
/* -------------------------------------------- */
static removeGroupHoroscope(rollData) {
let horo = rollData.horoscopeGroupList[rollData.selectedGroupHoroscopeIndex]
let horoscopes = duplicate(game.settings.get("bol", "horoscope-group"))
let toChange = duplicate(horoscopes[horo.id])
toChange.availableDice -= horo.nbDice // Remove the dice
if (toChange.availableDice <= 0) {
horoscopes[horo.id] = undefined
} else {
horoscopes[horo.id] = toChange
}
game.settings.set("bol", "horoscope-group", horoscopes)
this.updateSheets()
}
}

View File

@ -76,6 +76,10 @@ export const registerHandlebarsHelpers = function () {
Handlebars.registerHelper('count', function (list) {
return list.length;
})
Handlebars.registerHelper('countKeys', function (obj) {
return Object.keys(obj).length;
})
Handlebars.registerHelper('isEnabled', function (configKey) {
return game.settings.get("bol", configKey);
})
@ -129,7 +133,14 @@ export const registerHandlebarsHelpers = function () {
}
return false
})
Handlebars.registerHelper('upperFirst', function (text) {
if (typeof text !== 'string') return text
return text.charAt(0).toUpperCase() + text.slice(1)
})
Handlebars.registerHelper('upperFirstOnly', function (text) {
if (typeof text !== 'string') return text
return text.charAt(0).toUpperCase()
})
}

View File

@ -16,6 +16,7 @@ export const preloadHandlebarsTemplates = async function () {
"systems/bol/templates/actor/parts/tabs/actor-equipment.hbs",
"systems/bol/templates/actor/parts/tabs/actor-spellalchemy.hbs",
"systems/bol/templates/actor/parts/tabs/actor-biodata.hbs",
"systems/bol/templates/actor/parts/tabs/actor-horoscope-group.hbs",
"systems/bol/templates/actor/parts/tabs/creature-stats.hbs",
"systems/bol/templates/actor/parts/tabs/creature-actions.hbs",
"systems/bol/templates/actor/parts/tabs/vehicle-stats.hbs",

View File

@ -14,7 +14,7 @@
],
"url": "https://www.uberwald.me/gitea/public/bol",
"license": "LICENSE.txt",
"version": "10.4.15",
"version": "10.5.0",
"compatibility": {
"minimum": "10",
"verified": "10",
@ -203,7 +203,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.4.15.zip",
"download": "https://www.uberwald.me/gitea/public/bol/archive/bol-v10.5.0.zip",
"background": "systems/bol/ui/page_accueil.webp",
"gridDistance": 1.5,
"gridUnits": "m",

View File

@ -1,31 +1,83 @@
<ol class="items-list">
{{#if (ne charType "creature")}}
<li class="item flexrow item-header">
<div class="item-name left">{{localize "BOL.ui.biosize"}}</div>
<div class="item-field flex2 left"><input type="text" name="system.details.height" value="{{details.height}}"></div>
<div class="item-name right">{{localize "BOL.ui.bioweight"}}</div>
<div class="item-field flex2 "><input type="text" name="system.details.weight" value="{{details.weight}}"></div>
<div class="item-name right">{{localize "BOL.ui.bioage"}} </div>
<div class="item-field flex2 "><input type="text" name="system.details.age" value="{{details.age}}"></div>
<ol class='items-list'>
{{#if (ne charType 'creature')}}
<li class='item flexrow item-header'>
<div class='item-name left'>
{{localize 'BOL.ui.biosize'}}
</div>
<div class='item-field flex2 left'>
<input
type='text'
name='system.details.height'
value="{{details.height}}"
/>
</div>
<div class='item-name right'>
{{localize 'BOL.ui.bioweight'}}
</div>
<div class='item-field flex2'>
<input
type='text'
name='system.details.weight'
value="{{details.weight}}"
/>
</div>
<div class='item-name right'>
{{localize 'BOL.ui.bioage'}}
</div>
<div class='item-field flex2'>
<input type='text' name='system.details.age' value="{{details.age}}" />
</div>
</li>
<li class="item flexrow item-header">
<div class="item-name left">{{localize "BOL.ui.biohair"}} </div>
<div class="item-field flex2 left"><input type="text" name="system.details.hait" value="{{details.hait}}"></div>
<div class="item-name right">{{localize "BOL.ui.bioeyes"}} </div>
<div class="item-field flex2 "><input type="text" name="system.details.eyes" value="{{details.eyes}}"></div>
<li class='item flexrow item-header'>
<div class='item-name left'>
{{localize 'BOL.ui.biohair'}}
</div>
<div class='item-field flex2 left'>
<input
type='text'
name='system.details.hait'
value="{{details.hait}}"
/>
</div>
<div class='item-name right'>
{{localize 'BOL.ui.bioeyes'}}
</div>
<div class='item-field flex2'>
<input
type='text'
name='system.details.eyes'
value="{{details.eyes}}"
/>
</div>
</li>
<li class="item flexrow item-header">
<div class="item-name left">{{localize "BOL.ui.biosigns"}} </div>
<div class="item-field flex2 left"><input type="text" name="system.details.signs" value="{{details.signs}}"></div>
<li class='item flexrow item-header'>
<div class='item-name left'>
{{localize 'BOL.ui.biosigns'}}
</div>
<div class='item-field flex2 left'>
<input
type='text'
name='system.details.signs'
value="{{details.signs}}"
/>
</div>
</li>
{{else}}
<li class="item flexrow item-header">
<div class="item-name left">Taille </div>
<div class="form-fields center">
<select class="field-value size" name="system.details.size" data-dtype="String">
<li class='item flexrow item-header'>
<div class='item-name left'>
Taille
</div>
<div class='form-fields center'>
<select
class='field-value size'
name='system.details.size'
data-dtype='String'
>
{{#select details.size}}
{{#each config.creatureSize as |value id|}}
<option value="{{id}}">{{localize value}}</option>
<option value="{{id}}">
{{localize value}}
</option>
{{/each}}
{{/select}}
</select>
@ -33,20 +85,40 @@
</li>
{{/if}}
</ol>
<ol class="items-list">
<li class="item flexrow item-header">
<div class="item-name flex4 left">{{localize "BOL.ui.biodescription"}}</div>
<div class="item-field flex1 right"></div>
{{#if (and (not isAstrologer) (countKeys horoscopeGroupList))}}
{{> "systems/bol/templates/actor/parts/tabs/actor-horoscope-group.hbs"}}
{{/if}}
<ol class='items-list'>
<li class='item flexrow item-header'>
<div class='item-name flex4 left'>
{{localize 'BOL.ui.biodescription'}}
</div>
<div class='item-field flex1 right'></div>
</li>
</ol>
{{editor biography target="system.details.biography" button=true owner=owner
editable=editable}}
{{editor
biography
target='system.details.biography'
button=true
owner=owner
editable=editable
}}
<ol class="items-list">
<li class="item flexrow item-header">
<div class="item-name flex4 left">{{localize "BOL.ui.bionotes"}}</div>
<div class="item-field flex1 right"></div>
<ol class='items-list'>
<li class='item flexrow item-header'>
<div class='item-name flex4 left'>
{{localize 'BOL.ui.bionotes'}}
</div>
<div class='item-field flex1 right'></div>
</li>
</ol>
{{editor notes target="system.details.notes" button=true owner=owner editable=editable}}
{{editor
notes
target='system.details.notes'
button=true
owner=owner
editable=editable
}}

View File

@ -0,0 +1,26 @@
<ol class="items-list">
<li class="item flexrow item-header">
<div class="item-name flex4 left">{{localize "BOL.ui.horoscopeGroup"}}</div>
<div class="item-field flex2 center">{{localize "BOL.ui.type"}}</div>
<div class="item-field flex2 center">{{localize "BOL.ui.horoscopeDiceRemaining"}}</div>
<div class="item-field flex2 center">{{localize "BOL.ui.horoscopeDiceMax"}}</div>
<div class="item-field flex1 right"></div>
</li>
{{#each horoscopeGroupList as |horo id|}}
<li class="item flexrow" data-item-id="{{horo.id}}">
<h4 class="item-name flex4 left">
<div class="item-image"><img src="icons/magic/perception/eye-ringed-glow-angry-large-red.webp" /></div>{{horo.name}}
</h4>
<div class="item-field flex2 center">
<span class="item-field">{{upperFirst horo.type}}</span>
</div>
<div class="item-field flex2 center">
<span class="item-field">{{horo.availableDice}}</span>
</div>
<div class="item-field flex2 center">
<span class="item-field">{{horo.maxDice}}</span>
</div>
<div class="item-field flex1 right"></div>
</li>
{{/each}}
</ol>

View File

@ -128,4 +128,7 @@
</li>
{{/each}}
</ol>
{{> "systems/bol/templates/actor/parts/tabs/actor-horoscope-group.hbs"}}
{{/if}}

View File

@ -80,6 +80,33 @@
</li>
{{/each}}
{{#if (countKeys horoscopeGroupList)}}
<li class="item flexrow item-header">
<div class="item-name flex4 left">{{localize "BOL.ui.horoscopeGroup"}}</div>
<div class="item-field flex2 center">{{localize "BOL.ui.type"}}</div>
<div class="item-field flex2 center">{{localize "BOL.ui.horoscopeDiceRemaining"}}</div>
<div class="item-field flex2 center">{{localize "BOL.ui.horoscopeDiceMax"}}</div>
<div class="item-field flex1 right"></div>
</li>
{{#each horoscopeGroupList as |horo id|}}
<li class="item flexrow" data-item-id="{{horo.id}}">
<h4 class="item-name flex4 left">
<div class="item-image"><img src="icons/magic/perception/eye-ringed-glow-angry-large-red.webp" /></div>{{horo.name}}
</h4>
<div class="item-field flex2 center">
<span class="item-field">{{upperFirst horo.type}}</span>
</div>
<div class="item-field flex2 center">
<input class="field-value" type="text" id="horoscope-group-edit-available" value="{{horo.availableDice}}" data-horo-id="{{id}}" data-type="Number">
</div>
<div class="item-field flex2 center">
<input class="field-value" type="text" id="horoscope-group-edit-max" value="{{horo.maxDice}}" data-horo-id="{{id}}" data-type="Number">
</div>
<div class="item-field flex1 right"></div>
</li>
{{/each}}
{{/if}}
</ol>
</form>

View File

@ -37,6 +37,8 @@
{{> "systems/bol/templates/dialogs/effect-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/horoscope-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/adv-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/mod-roll-part.hbs"}}

View File

@ -16,10 +16,10 @@
{{> "systems/bol/templates/dialogs/flaws-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/horoscope-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/effect-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/horoscope-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/adv-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/mod-roll-part.hbs"}}

View File

@ -47,3 +47,27 @@
</div>
</div>
{{/if}}
{{#if (countKeys horoscopeGroupList)}}
<div class='flexrow roll-box'>
<div class='flex1 center bg-darkred'>
<label for='mod'>
{{localize 'BOL.ui.horoscopeGroup'}}
</label>
</div>
<div class='flex1 center cell'>
<select
class='flex1'
name='horoscope-group-applied'
id='horoscope-group-applied'
data-type='String'
>
{{#each horoscopeGroupList as |horoscope index|}}
<option value="{{index}}">
{{horoscope.nbDice}}d{{upperFirstOnly horoscope.type}} - {{horoscope.name}}
</option>
{{/each}}
</select>
</div>
</div>
{{/if}}

View File

@ -65,6 +65,8 @@
{{> "systems/bol/templates/dialogs/flaws-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/horoscope-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/adv-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/mod-roll-part.hbs"}}

View File

@ -58,6 +58,8 @@
{{> "systems/bol/templates/dialogs/effect-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/horoscope-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/adv-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/mod-roll-part.hbs"}}