Gestion preliminaire de l'XP

This commit is contained in:
sladecraven 2020-08-13 22:28:56 +02:00
parent d215629c9b
commit 5fa82a5ee7
10 changed files with 92 additions and 5 deletions

BIN
icons/sorts/sort_hypnos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 KiB

BIN
icons/sorts/sort_narcos.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 KiB

BIN
icons/sorts/sort_oniros.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 KiB

View File

@ -44,6 +44,7 @@ export class RdDActorSheet extends ActorSheet {
} }
// Competence per category // Competence per category
data.competenceByCategory = {}; data.competenceByCategory = {};
let competenceXPTotal = 0;
if (data.itemsByType.competence) { if (data.itemsByType.competence) {
for (const item of data.itemsByType.competence) { for (const item of data.itemsByType.competence) {
//console.log("Push...", item, item.data.categorie); //console.log("Push...", item, item.data.categorie);
@ -52,9 +53,17 @@ export class RdDActorSheet extends ActorSheet {
list = []; list = [];
data.competenceByCategory[item.data.categorie] = list; data.competenceByCategory[item.data.categorie] = list;
} }
competenceXPTotal += RdDUtility.computeCompetenceXPCost(item)
list.push(item); list.push(item);
} }
} }
data.data.competenceXPTotal = competenceXPTotal;
//console.log("XP competence : ", competenceXPTotal);
// Compute current carac sum
let sum = 0;
Object.values(data.data.carac).forEach(carac => { if (!carac.derivee) { sum += parseInt(carac.value) } } );
data.data.caracSum = sum;
// Force empty arme, at least for Esquive // Force empty arme, at least for Esquive
if (data.itemsByType.arme == undefined ) data.itemsByType.arme = []; if (data.itemsByType.arme == undefined ) data.itemsByType.arme = [];

View File

@ -272,6 +272,7 @@ export class RdDActor extends Actor {
data: defenseMsg data: defenseMsg
} ); } );
} else { } else {
defenseMsg.whisper = [ game.user];
ChatMessage.create( defenseMsg ); ChatMessage.create( defenseMsg );
} }
} }
@ -294,7 +295,26 @@ export class RdDActor extends Actor {
{ {
let comp = RdDUtility.findCompetence( this.data.items, compName); let comp = RdDUtility.findCompetence( this.data.items, compName);
if ( comp ) { if ( comp ) {
const update = {_id: comp._id, 'data.niveau': compValue }; let troncList = RdDUtility.isTronc( compName );
let maxNiveau = compValue;
if ( troncList ) {
let troncCompValue = (compValue > 0) ? 0 : compValue; // Clamp it to 0
for(let troncName of troncList) {
if ( troncName != compName) {
console.log("Update competence tronc", troncName, compValue);
let comp2 = RdDUtility.findCompetence( this.data.items, troncName);
if (comp2.data.niveau > maxNiveau) maxNiveau = comp2.data.niveau;
if ( comp2.data.niveau <= 0 && comp2.data.niveau < troncCompValue ) { // Update only of below 0
const update = {_id: comp2._id, 'data.niveau': compValue };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
}
}
}
if ( compValue < maxNiveau) { // Manage case when someone set a value below
compValue = (maxNiveau > 0) ? 0 : maxNiveau;
}
}
const update = {_id: comp._id, 'data.niveau': maxNiveau };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
} else { } else {
console.log("Competence not found", compName); console.log("Competence not found", compName);

View File

@ -24,6 +24,15 @@ Hooks.once("init", async function() {
// preload handlebars templates // preload handlebars templates
RdDUtility.preloadHandlebarsTemplates(); RdDUtility.preloadHandlebarsTemplates();
// Create specific settings
game.settings.register("foundryvtt-reve-de-dragon", "configuration", {
name: "configuration",
scope: "world",
config: false,
type: Object
});
//game.settings.get("<systemName>","<settingName>") to retrieve it and game.settings.set("<systemName>","<settingName>", <newValue>)
/** /**
* Set an initiative formula for the system * Set an initiative formula for the system
* @type {String} * @type {String}

View File

@ -12,6 +12,16 @@ const level_category = {
"tir": "-8", "tir": "-8",
"lancer": "-8" "lancer": "-8"
} }
const competenceTroncs = [ ["Esquive", "Dague", "Corps à corps"],
["Epée à 1 main", "Epée à 2 mains", "Hache à 1 main", "Hache à 2 mains", "Lance", "Masse à 1 main", "Masse à 2 mains"] ];
const competence_xp = {
"-11" : [ 5, 10, 15, 25, 35, 45, 55, 70, 85, 100, 115, 135, 155, 175 ],
"-8" : [ 10, 20, 30, 40, 55, 70, 85, 100, 120, 140,160],
"-6" : [ 10, 20, 35, 50, 65, 80, 100, 120, 140],
"-4" : [ 15, 30, 45, 60, 80, 100, 120]
}
// This table starts at 0 -> niveau -10
const competence_xp_par_niveau = [ 5, 5, 5, 10, 10, 10, 10, 15, 15, 15, 15, 20, 20, 20, 20, 30, 30, 40, 40, 60, 60, 100, 100, 100, 100, 100, 100, 100, 100, 100];
const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"]; const carac_array = [ "taille", "apparence", "constitution", "force", "agilite", "dexterite", "vue", "ouie", "odoratgout", "volonte", "intellect", "empathie", "reve", "chance", "melee", "tir", "lancer", "derobee"];
const bonusmalus = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10]; const bonusmalus = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10];
const specialResults = [ { "part": 0, "epart": 0, "etotal": 0 }, // 0 const specialResults = [ { "part": 0, "epart": 0, "etotal": 0 }, // 0
@ -204,6 +214,18 @@ export class RdDUtility {
return container.append(table); return container.append(table);
} }
/* -------------------------------------------- */
static isTronc( compName )
{
for (let troncList of competenceTroncs) {
for (let troncName of troncList) {
if ( troncName == compName)
return troncList;
}
}
return false;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static getResolutionField(caracValue, levelValue ) static getResolutionField(caracValue, levelValue )
{ {
@ -215,6 +237,21 @@ export class RdDUtility {
return CONFIG.RDD.resolutionTable[caracValue][levelValue+10]; return CONFIG.RDD.resolutionTable[caracValue][levelValue+10];
} }
/* -------------------------------------------- */
static computeCompetenceXPCost( competence )
{
let minLevel = competence.data.base;
if ( minLevel == competence.data.niveau) return 0;
if ( competence.data.niveau < -10) return 0;
let xp = 0;
for (let i=minLevel+1; i<=competence.data.niveau; i++) {
xp += competence_xp_par_niveau[i+10];
//console.log(i, i+10, competence_xp_par_niveau[i+10]);
}
return xp;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeCarac( data) static computeCarac( data)
{ {
@ -481,6 +518,7 @@ export class RdDUtility {
} else if (sockmsg.msg == "msg_defense" ) { } else if (sockmsg.msg == "msg_defense" ) {
let defenderActor = game.actors.get( sockmsg.data.defenderid ); let defenderActor = game.actors.get( sockmsg.data.defenderid );
if ( (game.user.isGM && !defenderActor.isPC) || (defenderActor.isPC && game.user.character.id == defenderActor.id ) ) { if ( (game.user.isGM && !defenderActor.isPC) || (defenderActor.isPC && game.user.character.id == defenderActor.id ) ) {
console.log("User is pushing message...", game.user.name);
sockmsg.data.whisper = [ game.user ]; sockmsg.data.whisper = [ game.user ];
sockmsg.data.blind = true; sockmsg.data.blind = true;
sockmsg.data.rollMode = "blindroll"; sockmsg.data.rollMode = "blindroll";

View File

@ -2,7 +2,7 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "L'implémentation de Rêve de Dragon pour FoundryVTT", "description": "L'implémentation de Rêve de Dragon pour FoundryVTT",
"version": "0.8.3", "version": "0.8.4",
"minimumCoreVersion": "0.6.0", "minimumCoreVersion": "0.6.0",
"compatibleCoreVersion": "0.6.2", "compatibleCoreVersion": "0.6.2",
"templateVersion": 23, "templateVersion": 23,

View File

@ -77,6 +77,10 @@
{{/if}} {{/if}}
</li> </li>
{{/each}} {{/each}}
<li class="competence flexrow">
<span class="carac-label flexrow" name="carac-total">Total Caractéristiques </span>
<span class="competence-value flexrow" name="carac-total-value">{{data.caracSum}} </span>
</li>
</ol> </ol>
</div> </div>
<div class="flex-group-left flexcol" > <div class="flex-group-left flexcol" >
@ -244,7 +248,14 @@
</li> </li>
{{/each}} {{/each}}
</ol> </ol>
<div></div> <div>
<ol class="item-list">
<li class="item flexrow">
<span class="competence-label">Total XP compétences</span>
<span class="competence-value">{{data.competenceXPTotal}}</span>
</li>
</ol>
</div>
<div></div> <div></div>
</div> </div>
</div> </div>