From e1954e1dafff1da12c3d29e39e5af161bfa9df2b Mon Sep 17 00:00:00 2001 From: Kaias26 Date: Tue, 4 Sep 2018 13:57:16 +0200 Subject: [PATCH] update Weapon UI --- Naheulbeuk/Naheulbeuk.html | 231 +++++++++++++++++++++++-------------- 1 file changed, 143 insertions(+), 88 deletions(-) diff --git a/Naheulbeuk/Naheulbeuk.html b/Naheulbeuk/Naheulbeuk.html index e852288e73..2533164ab3 100644 --- a/Naheulbeuk/Naheulbeuk.html +++ b/Naheulbeuk/Naheulbeuk.html @@ -54,11 +54,17 @@ updateXP(); }); // Ammos & Weapons - on("change:repeating_armes:arme_range", function( e ) { - updateWeaponRange( e ); - }); on("change:repeating_armes:munition_nom", function( e ) { - updateAmmo( e ); + if( e[ "sourceType"] === "player" ) { + updateAmmo( e ); + } + }); + on("change:repeating_armes:arme_portee change:repeating_armes:arme_at change:repeating_armes:arme_degats change:repeating_armes:arme_bonusforce change:repeating_armes:munition_modad change:repeating_armes:munition_degats", function( e ) { + var idRow = e[ "sourceAttribute" ].split( '_' )[2]; + updateWeapon( idRow ); + }); + on("change:stats_jet_total change:stats_attaque_total change:bonusdegatsforce", function( e ) { + updateWeapons(); }); // Total golds on("change:richesse_or change:richesse_argent change:richesse_cuivre", function() { @@ -312,51 +318,73 @@ }); } - function updateWeaponRange( eventInfo ) { - var range_selected = eventInfo[ "newValue" ]; - var idWeapon = eventInfo[ "sourceAttribute" ].split( '_' )[2]; + function updateWeapon( idRow ) { var sWeapon = {}; - getAttrs( [ 'stats_attaque_total', 'stats_jet_total' ] , function( v ) { + getAttrs( [ + `repeating_armes_${idRow}_arme_portee`, `repeating_armes_${idRow}_arme_at`, `repeating_armes_${idRow}_arme_degats`, `repeating_armes_${idRow}_arme_bonusforce`, + `repeating_armes_${idRow}_munition_modAd`, `repeating_armes_${idRow}_munition_degats`, + "stats_jet_total", "stats_attaque_total", "bonusdegatsforce" + ] , function( v ) { - sWeapon[ 'repeating_armes_' + idWeapon + '_arme_munition_display' ] = 0; - sWeapon[ 'repeating_armes_' + idWeapon + '_arme_jet' ] = v[ 'stats_attaque_total' ]; + sWeapon[ 'repeating_armes_' + idRow + '_arme_munition_display' ] = 0; + sWeapon[ 'repeating_armes_' + idRow + '_arme_totalat' ] = safeInt( v[ "stats_attaque_total" ] ) + safeInt( v[ `repeating_armes_${idRow}_arme_at` ] ); + sWeapon[ 'repeating_armes_' + idRow + '_arme_totaldegats' ] = v[ `repeating_armes_${idRow}_arme_degats` ]; - if( range_selected === 'Dist.' ) { - sWeapon[ 'repeating_armes_' + idWeapon + '_arme_munition_display' ] = 1; - sWeapon[ 'repeating_armes_' + idWeapon + '_arme_jet' ] = v[ 'stats_jet_total' ]; + if( v[ `repeating_armes_${idRow}_arme_portee` ] === 'Dist.' ) { + sWeapon[ 'repeating_armes_' + idRow + '_arme_munition_display' ] = 1; + sWeapon[ 'repeating_armes_' + idRow + '_arme_totalat' ] = safeInt( v[ "stats_jet_total" ] ) + safeInt( v[ `repeating_armes_${idRow}_arme_at` ] ) + safeInt( v[ `repeating_armes_${idRow}_munition_modAd` ] ); + sWeapon[ 'repeating_armes_' + idRow + '_arme_totaldegats' ] = v[ `repeating_armes_${idRow}_arme_degats` ] + " + " + v[ `repeating_armes_${idRow}_munition_degats` ]; } + if( v[ `repeating_armes_${idRow}_arme_bonusforce` ] === "1" ) { + sWeapon[ 'repeating_armes_' + idRow + '_arme_totaldegats' ] += " + " + v[ "bonusdegatsforce" ]; + } + + console.log(v); + console.log(sWeapon); + setAttrs( sWeapon, { silent: true } ); }); } + function updateWeapons() { + getSectionIDs( "repeating_armes", function(idArray) { + for( var i in idArray ) { + updateWeapon( idArray[ i ] ); + } + }); + } + function updateAmmo( eventInfo ) { var ammo_selected = eventInfo[ "newValue" ]; - var idWeapon = eventInfo[ "sourceAttribute" ].split( '_' )[2]; + var idRow = eventInfo[ "sourceAttribute" ].split( '_' )[2]; var idAmmo = 0; var sWeapon = {}; - sWeapon[ 'repeating_armes_' + idWeapon + '_munition_degats' ] = 0; - sWeapon[ 'repeating_armes_' + idWeapon + '_munition_modAd' ] = 0; - sWeapon[ 'repeating_armes_' + idWeapon + '_munition_nom' ] = ''; - - setAttrs( sWeapon, { silent: true } ); + sWeapon[ 'repeating_armes_' + idRow + '_munition_degats' ] = ""; + sWeapon[ 'repeating_armes_' + idRow + '_munition_modAd' ] = 0; + sWeapon[ 'repeating_armes_' + idRow + '_munition_nom' ] = ""; getSectionIDs( "repeating_munitions", function(idarray) { getAttrs( [ ...idarray.map(id => `repeating_munitions_${id}_munition_nom`) ], function( sValues ) { for( var i in idarray ) { if( ammo_selected === sValues[`repeating_munitions_${idarray[i]}_munition_nom`] ) { - var idAmmo = idarray[i]; - getAttrs( [ `repeating_munitions_${idAmmo}_munition_modAd`, `repeating_munitions_${idAmmo}_munition_degats` ], function( v ) { - sWeapon[ 'repeating_armes_' + idWeapon + '_munition_degats' ] = v[ `repeating_munitions_${idAmmo}_munition_degats` ]; - sWeapon[ 'repeating_armes_' + idWeapon + '_munition_modAd' ] = v[ `repeating_munitions_${idAmmo}_munition_modAd` ]; - sWeapon[ 'repeating_armes_' + idWeapon + '_munition_nom' ] = ammo_selected; - - setAttrs( sWeapon, { silent: true } ); - }); + idAmmo = idarray[i]; } } + + if( idAmmo != 0 ) { + getAttrs( [ `repeating_munitions_${idAmmo}_munition_modAd`, `repeating_munitions_${idAmmo}_munition_degats` ], function( v ) { + sWeapon[ 'repeating_armes_' + idRow + '_munition_degats' ] = v[ `repeating_munitions_${idAmmo}_munition_degats` ]; + sWeapon[ 'repeating_armes_' + idRow + '_munition_modAd' ] = v[ `repeating_munitions_${idAmmo}_munition_modAd` ]; + sWeapon[ 'repeating_armes_' + idRow + '_munition_nom' ] = ammo_selected; + + setAttrs( sWeapon ); + }); + } else { + setAttrs( sWeapon ); + } }); }); } @@ -612,7 +640,7 @@ ], "repeating": [ { zone:"competences", attr: ["competence_nom", "competence_effet", "competence_epreuve", "competence_jet", "competence_mod"] }, - { zone:"armes", attr: ["arme_nom", "arme_range", "arme_jet", "arme_at", "arme_prd", "arme_degats", "arme_rup", "arme_munition_display", "munition_nom", "munition_modad", "munition_degats", "arme_effet", "arme_note"] }, + { zone:"armes", attr: ["arme_nom", "arme_portee", "arme_at", "arme_prd", "arme_degats", "arme_rup", "arme_munition_display", "munition_nom", "munition_modad", "munition_degats", "arme_effet", "arme_note", "arme_bonusforce" ] }, { zone:"armures", attr: ["armure_nom", "armure_prphy", "armure_prmag", "armure_rup", "armure_effet"] }, { zone:"sacs", attr: ["sac_nom", "sac_charge_max"] }, { zone:"materiels", attr: ["materiel_nom", "materiel_poids"] }, @@ -1538,79 +1566,106 @@
Arme
Portée
-
Mod. AT
-
Mod. PRD
-
Dégats
-
RUP.
+
AT
+
PRD
+
Dégats
Jets
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + +
+
+ y +
+
+
Mod. AT :
+
+ +
+
Mod. PRD :
+
+ +
+
Dégats :
+
+ +
+
RUP :
+
+ +
+
-
-
- -
-
- - -
-
- -
-
- -
-
- -
-
- -
-
- - - -
-
- -
-
- Munition + +
+ +
+
Bonus Force ? :
+
+
+ +
+
Munition :
+
+ +
+
Mod. AD :
+
+ +
+
Dégats :
+
+ +
+
-
- + +
+
+ Bonus / Effets : +
+
+ +
-
- +
+
+ Notes: +
+
+ +
-
-
-
- -
-
-
-
- Bonus / Effets -
-
- -
-
- Notes et détails -
-
-


- Le Bonus / Malus aux dégats octroyé par la Force est inclus automatiquement dans les jets de dégats : + Le Bonus / Malus aux dégats octroyé par la Force :