Gestion des progression
This commit is contained in:
parent
a100da7cd9
commit
634feabb75
@ -124,10 +124,21 @@ export class Imperium5Actor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
incDecKarma( value ) {
|
||||
transferToSource( nbSuccess) {
|
||||
let karma = duplicate(this.system.karma)
|
||||
karma.value += value
|
||||
karma.source += Number(nbSuccess)
|
||||
let nbKarma = Math.floor(karma.source / 3)
|
||||
karma.value += nbKarma
|
||||
karma.source -= nbKarma*3
|
||||
this.update( { 'system.karma': karma})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
decOneKarma( ) {
|
||||
let karma = duplicate(this.system.karma)
|
||||
karma.value--
|
||||
karma.value = Math.max(karma.value, 0)
|
||||
karma.xp++
|
||||
this.update( { 'system.karma': karma})
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,18 @@ export class Imperium5Utility {
|
||||
Handlebars.registerHelper('exists', function (val) {
|
||||
return val != null && val != undefined;
|
||||
})
|
||||
Handlebars.registerHelper('for', function (from, to, incr, block) {
|
||||
var accum = '';
|
||||
for (var i = from; i < to; i += incr)
|
||||
accum += block.fn(i);
|
||||
return accum;
|
||||
})
|
||||
Handlebars.registerHelper('times', function(n, block) {
|
||||
var accum = '';
|
||||
for(var i = 1; i <= n; ++i)
|
||||
accum += block.fn(i);
|
||||
return accum;
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -123,6 +135,14 @@ export class Imperium5Utility {
|
||||
rollData.previousMessageId = Imperium5Utility.findChatMessageId(event.currentTarget)
|
||||
this.applySingularite(rollData, resultIndex)
|
||||
})
|
||||
|
||||
html.on("change", '.transfer-success', event => {
|
||||
let nbSuccess = event.currentTarget.value
|
||||
let rollData = this.getRollDataFromMessage(event)
|
||||
rollData.previousMessageId = Imperium5Utility.findChatMessageId(event.currentTarget)
|
||||
this.applySuccessTransfer(rollData, nbSuccess)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -341,11 +361,11 @@ export class Imperium5Utility {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
rollData.nbKarma = 0
|
||||
if (rollData.useKarma) {
|
||||
actor.incDecKarma(-1)
|
||||
actor.decOneKarma()
|
||||
rollData.nbKarma++
|
||||
}
|
||||
if (rollData.usedCapacite != "none") {
|
||||
actor.incDecKarma(-1)
|
||||
actor.decOneKarma()
|
||||
rollData.nbKarma++
|
||||
}
|
||||
|
||||
@ -365,6 +385,7 @@ export class Imperium5Utility {
|
||||
rollData.resultsPC = duplicate(myRoll.terms[0].results)
|
||||
// Calcul réussites
|
||||
this.computeReussites(rollData)
|
||||
rollData.realSuccessPC = rollData.successPC // To manage source transfer
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData)
|
||||
@ -401,6 +422,21 @@ export class Imperium5Utility {
|
||||
content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "imperium5-roll-data", rollData)
|
||||
this.removeChatMessageId(rollData.previousMessageId)
|
||||
}
|
||||
|
||||
/* ------------------------- ------------------- */
|
||||
static async applySuccessTransfer(rollData, nbSuccess) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.transferToSource( nbSuccess)
|
||||
rollData.realSuccessPC -= nbSuccess
|
||||
rollData.sourceTransfer = nbSuccess
|
||||
rollData.nbUnitesNarration = Math.max(rollData.realSuccessPC - 1, 0)
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-imperium5/templates/chat-generic-result.html`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "imperium5-roll-data", rollData)
|
||||
this.removeChatMessageId(rollData.previousMessageId)
|
||||
}
|
||||
|
||||
/* ------------------------- ------------------- */
|
||||
@ -530,6 +566,7 @@ export class Imperium5Utility {
|
||||
useKarma: false,
|
||||
usedCapacite: "none",
|
||||
seuil: 2,
|
||||
nbSuccessSource: 0,
|
||||
useSingularites: game.settings.get("fvtt-imperium5", "use-singularite"),
|
||||
useEntropieReussite: game.settings.get("fvtt-imperium5", "use-entropie-reussite")
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
"flags": {}
|
||||
}
|
||||
],
|
||||
"version": "10.0.5",
|
||||
"version": "10.0.6",
|
||||
"compatibility": {
|
||||
"minimum": "10",
|
||||
"verified": "10",
|
||||
@ -67,5 +67,5 @@
|
||||
"background": "images/ui/imperium5_welcome_page.webp",
|
||||
"url": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5",
|
||||
"manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/raw/branch/master/system.json",
|
||||
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/archive/fvtt-imperium5-v10.0.5.zip"
|
||||
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-imperium5/archive/fvtt-imperium5-v10.0.6.zip"
|
||||
}
|
@ -46,18 +46,33 @@
|
||||
<li>Seuil : {{seuil}}
|
||||
{{#if (count paradigmes)}}
|
||||
<select class="common-button select-apply-paradigme" type="text" value="{{selectedParadigme}}" data-dtype="String">
|
||||
{{#select selectedParadigme}}
|
||||
<option value="none">Pas de paradigme</option>
|
||||
{{#each paradigmes as |para key|}}
|
||||
<option value="{{para.key}}">{{para.label}} ({{para.value}})</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
{{#select selectedParadigme}}
|
||||
<option value="none">Pas de paradigme</option>
|
||||
{{#each paradigmes as |para key|}}
|
||||
<option value="{{para.key}}">{{para.label}} ({{para.value}})</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
{{/if}}
|
||||
</li>
|
||||
|
||||
<li>Succés : {{successPC}}</li>
|
||||
<li>Succés : {{realSuccessPC}}
|
||||
{{#if realSuccessPC}}
|
||||
<select class="common-button transfer-success" type="text" value="{{nbSuccessSource}}" data-dtype="Number">
|
||||
{{#select nbSuccessSource}}
|
||||
<option value="none">0 succès -> Source</option>
|
||||
{{#times realSuccessPC}}
|
||||
<option value="{{this}}">{{this}} succès -> Source</option>
|
||||
{{/times}}
|
||||
{{/select}}
|
||||
</select>
|
||||
{{/if}}
|
||||
</li>
|
||||
|
||||
{{#if sourceTransfer}}
|
||||
<li>Succés transférés à la Source : {{sourceTransfer}}</li>
|
||||
{{/if}}
|
||||
|
||||
<li>Succés de Réalité : {{successGM}}</li>
|
||||
|
||||
<li>Unités de narration : {{nbUnitesNarration}}</li>
|
||||
|
Loading…
Reference in New Issue
Block a user