#38 - Gestion des armes 1/2mains

This commit is contained in:
sladecraven 2020-11-23 20:40:56 +01:00
parent 73441000a2
commit 1c2a60017d
7 changed files with 53 additions and 18 deletions

View File

@ -62,7 +62,8 @@ export class RdDActorSheet extends ActorSheet {
// Force empty arme, at least for Esquive
if (data.itemsByType.arme == undefined ) data.itemsByType.arme = [];
for (const arme of data.itemsByType.arme) {
let arme2mains = []; // tablea contenant la duplication des armes 1m/2m
for (const arme of data.itemsByType.arme) {
arme.data.niveau = 0; // Per default, TODO to be fixed
for ( const melee of data.competenceByCategory.melee ) {
if (melee.name == arme.data.competence )
@ -76,8 +77,19 @@ export class RdDActorSheet extends ActorSheet {
if (lancer.name == arme.data.competence )
arme.data.niveau = lancer.data.niveau
}
// Dupliquer les armes pouvant être à 1 main et 2 mains en patchant la compétence
if (arme.data.unemain && arme.data.deuxmains) {
let arme2main = duplicate(arme);
arme2main.data.competence = arme2main.data.competence.replace(" 1 main", " 2 mains"); // Replace !
for ( const melee of data.competenceByCategory.melee ) {
if (melee.name == arme2main.data.competence )
arme2main.data.niveau = melee.data.niveau
}
arme2mains.push(arme2main);
}
}
data.itemsByType.arme = data.itemsByType.arme.concat(arme2mains); // Merge all cases
// To avoid armour and so on...
data.data.combat = duplicate( RdDUtility.checkNull(data.itemsByType['arme']));
@ -237,7 +249,8 @@ export class RdDActorSheet extends ActorSheet {
// Roll Weapon1
html.find('.arme-label a').click((event) => {
let armeName = event.currentTarget.text;
this.actor.rollArme( armeName);
let competenceName = event.currentTarget.attributes['data-competence-name'].value;
this.actor.rollArme( armeName, competenceName);
});
// Display TMR, normal
html.find('.visu-tmr a').click((event) => {

View File

@ -1032,13 +1032,15 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
rollArme( armeName )
rollArme( armeName, competenceName=undefined )
{
let armeItem = this.data.items.find(item=>item.type==="arme" && (item.name === armeName));
if ( armeItem && armeItem.data.competence )
this.rollCompetence( armeItem.data.competence, armeItem );
else
this.rollCompetence( armeName ); //Bypass mode!
if (armeItem ) {
if ( competenceName == undefined) competenceName = armeItem.data.competence;
this.rollCompetence( competenceName, armeItem );
} else {
this.rollCompetence( armeName ); //Bypass mode!
}
}
/* -------------------------------------------- */
@ -1059,7 +1061,7 @@ export class RdDActor extends Actor {
if ( competence.type == 'competencecreature') { // Specific case for Creatures
if ( competence.data.iscombat ) {
armeItem = { name: name, data: { dommages: competence.data.dommages} };
armeItem = { name: name, data: { dommages: competence.data.dommages, dommagesReels: competence.data.dommages} };
}
competence.data.defaut_carac = "carac_creature"; // Fake default competence
competence.data.categorie = "creature"; // Fake default competence
@ -1068,6 +1070,16 @@ export class RdDActor extends Actor {
rollData.carac = { carac_creature: { label: name, value: competence.data.carac_value } };
} else { // Usual competence
rollData.competence = competence;
armeItem.data.dommagesReels = armeItem.data.dommages; // Per default
if ( !armeItem.data.unemain && !armeItem.data.deuxmains) // Force default
armeItem.data.unemain = true;
if (armeItem.data.unemain && armeItem.data.deuxmains) { // manage 1/2 main
//console.log("Weapon", armeItem.data.dommages);
if ( name.toLowerCase().includes("1 main") )
armeItem.data.dommagesReels = Number(armeItem.data.dommages.split("/")[0]);
else // 2 mains
armeItem.data.dommagesReels = Number(armeItem.data.dommages.split("/")[1]);
}
rollData.arme = armeItem;
rollData.carac = this.data.data.carac;
}

View File

@ -2,10 +2,10 @@
"name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT",
"version": "0.9.77",
"version": "0.9.78",
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.6",
"templateVersion": 47,
"templateVersion": 48,
"author": "LeRatierBretonnien",
"esmodules": [ "module/rdd-main.js", "module/hook-renderChatLog.js" ],
"styles": ["styles/simple.css"],

View File

@ -537,15 +537,17 @@
"quantite": 1,
"encombrement": 0,
"equipe": false,
"dommages": 0,
"force": 0,
"dommages": "0",
"force": "0",
"resistance": 0,
"competence": "",
"cout": 0,
"portee_courte": 0,
"portee_moyenne": 0,
"portee_extreme": 0,
"rapide": false
"rapide": false,
"deuxmains": false,
"unemain": false
},
"munition": {
"description": "",

View File

@ -320,7 +320,7 @@
<ol class="item-list">
{{#each data.combat as |arme key|}}
<li class="item flexrow" data-item-id="{{arme._id}}">
<span class="arme-label" name="data.armes[{{key}}].name"><a>{{arme.name}}</a></span>
<span class="arme-label" name="data.armes[{{key}}].name"><a data-competence-name="{{arme.data.competence}}">{{arme.name}}</a></span>
<span class="competence-label" name="data.armes[{{key}}].data.competence">{{arme.data.competence}}</span>
<span class="competence-label" name="data.armes[{{key}}].data.niveau">{{numberFormat arme.data.niveau decimals=0 sign=true}}</span>
<span class="competence-label" name="data.armes[{{key}}].data.dommages">{{numberFormat arme.data.dommages decimals=0 sign=true}}</span>

View File

@ -32,7 +32,7 @@
{{#if arme}}
<div>
<label>Arme : {{arme.name}}</label>
<label>Degats : {{arme.data.dommages}}</label>
<label>Degats : {{arme.data.dommagesReels}}</label>
<label for="xp">Coups Non Mortels ? </label>
<input class="attribute-value" type="checkbox" id="coupsNonMortels" name="coupsNonMortels" {{#if coupsNonMortels}}checked{{/if}}/>
</div>

View File

@ -18,7 +18,7 @@
</div>
<div class="form-group">
<label for="niveau">Dommmages </label>
<input class="attribute-value" type="text" name="data.dommages" value="{{data.dommages}}" data-dtype="Number"/>
<input class="attribute-value" type="text" name="data.dommages" value="{{data.dommages}}" data-dtype="String"/>
</div>
<div class="form-group">
<label for="xp">Résistance </label>
@ -30,12 +30,20 @@
</div>
<div class="form-group">
<label for="xp">Force min. </label>
<input class="attribute-value" type="text" name="data.force" value="{{data.force}}" data-dtype="Number"/>
<input class="attribute-value" type="text" name="data.force" value="{{data.force}}" data-dtype="String"/>
</div>
<div class="form-group">
<label for="xp">Arme rapide ? </label>
<input class="attribute-value" type="checkbox" name="data.rapide" {{#if data.rapide}}checked{{/if}}/>
</div>
<div class="form-group">
<label for="xp">A Une main ? </label>
<input class="attribute-value" type="checkbox" name="data.unemain" {{#if data.unemain}}checked{{/if}}/>
</div>
<div class="form-group">
<label for="xp">A Deux mains ? </label>
<input class="attribute-value" type="checkbox" name="data.deuxmains" {{#if data.deuxmains}}checked{{/if}}/>
</div>
<div class="form-group">
<label for="xp">Portée courte </label>
<input class="attribute-value" type="text" name="data.portee_courte" value="{{data.portee_courte}}" data-dtype="Number"/>