update Weapon UI
This commit is contained in:
+143
-88
@@ -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 @@
|
||||
<div class="sheet-tableth">
|
||||
<div class="sheet-col" style="width: 256px;">Arme</div>
|
||||
<div class="sheet-col" style="width: 66px;">Portée</div>
|
||||
<div class="sheet-col" style="width: 66px;">Mod. AT</div>
|
||||
<div class="sheet-col" style="width: 66px;">Mod. PRD</div>
|
||||
<div class="sheet-col" style="width: 66px;">Dégats</div>
|
||||
<div class="sheet-col" style="width: 66px;">RUP.</div>
|
||||
<div class="sheet-col" style="width: 66px;">AT</div>
|
||||
<div class="sheet-col" style="width: 66px;">PRD</div>
|
||||
<div class="sheet-col" style="width: 96px;">Dégats</div>
|
||||
<div class="sheet-col" style="width: 166px;">Jets</div>
|
||||
</div>
|
||||
|
||||
<fieldset class="repeating_armes">
|
||||
<div class="sheet-group">
|
||||
<div class="sheet-row">
|
||||
<div class="sheet-col" style="width: 260px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_Arme_Nom" value="" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<select name="attr_Arme_Portee">
|
||||
<option value="Mélée" selected="selected">Mélée</option>
|
||||
<option value="Dist.">Dist.</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput sheet-autoCalc" name="attr_Arme_TotalAT" value="0" readonly="readonly" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput sheet-autoCalc" name="attr_Arme_TotalPRD" value="@{Stats_Parade_total}+@{Arme_PRD}" readonly="readonly" disabled="true" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 100px;">
|
||||
<input type="text" class="sheet-autoCalc" name="attr_Arme_TotalDegats" value="1d6" readonly="readonly" style="width: 100px;" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 170px;">
|
||||
<button type="roll" value="@{displayJet} &{template:default} {{name=Attaque de @{Personnage_Nom} avec @{Arme_Nom} }} {{ AT= @{Arme_TotalAT} }} {{ Résultat=[[1d20]] }}"> AT </button>
|
||||
<button type="roll" value="@{displayJet} &{template:default} {{name=Parade de @{Personnage_Nom} avec @{Arme_Nom} }} {{ PRD=@{Arme_TotalPRD} }} {{ Résultat=[[1d20]] }}"> PRD </button>
|
||||
<button type="roll" class="sheet-rollDegats" value="@{displayJet} &{template:default} {{name=Dégats de @{Personnage_Nom} avec @{Arme_Nom}}} {{ Dégats= [[ @{Arme_TotalDegats} ]] }}"> Dégats </button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="checkbox" name="attr_CoupSpecial_config" class="sheet-config-flag" value="1" /><span class="sheet-cog">y</span>
|
||||
<div class="sheet-config">
|
||||
<div class="sheet-row">
|
||||
<div class="sheet-col" style="width: 110px;"><b>Mod. AT :</b></div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="number" name="attr_Arme_AT" value="0" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 110px; text-align: right;"><b>Mod. PRD :</b></div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="number" name="attr_Arme_PRD" value="0" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 110px; text-align: right;"><b>Dégats :</b></div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput" name="attr_Arme_Degats" value="1d6" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 110px; text-align: right;"><b>RUP :</b></div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput" name="attr_Arme_RUP" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="sheet-row" style="background-color: #eee;padding: 5px; border-radius: 10px;">
|
||||
<div class="sheet-col" style="width: 260px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_Arme_Nom" value="" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<select name="attr_arme_range">
|
||||
<option value="Mélée" selected="selected">Mélée</option>
|
||||
<option value="Dist.">Dist.</option>
|
||||
</select>
|
||||
<input type="hidden" name="attr_Arme_Jet" value="@{Stats_Attaque_total}">
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="number" name="attr_Arme_AT" value="0" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="number" name="attr_Arme_PRD" value="0" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput" name="attr_Arme_Degats" value="1d6" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput" name="attr_Arme_RUP" value="" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 170px;">
|
||||
<button type="roll" value="@{displayJet} &{template:default} {{name=Attaque de @{Personnage_Nom} avec @{Arme_Nom} }} {{ AT=@{Arme_Jet} + [[ @{Arme_At} + @{munition_modAd} ]] }} {{ Résultat=[[1d20]] }}"> AT </button>
|
||||
<button type="roll" value="@{displayJet} &{template:default} {{name=Parade de @{Personnage_Nom} avec @{Arme_Nom} }} {{ PRD=@{Stats_Parade_total} + @{Arme_PRD} }} {{ Résultat=[[1d20]] }}"> PRD </button>
|
||||
<button type="roll" class="sheet-rollDegats" value="@{displayJet} &{template:default} {{name=Dégats de @{Personnage_Nom} avec @{Arme_Nom}}} {{ Dégats=[[@{Arme_Degats} + @{munition_degats} + @{BonusDegatsForce}]] }}"> Dégats </button>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
<input type="checkbox" class="sheet-hidden sheet-display-arme_munition" name="attr_Arme_Munition_display" value=1>
|
||||
<div class="sheet-display-arme_munition">
|
||||
<div class="sheet-col" style="width: 100px; padding-top: 5px;">
|
||||
<b>Munition</b>
|
||||
<input type="checkbox" class="sheet-hidden sheet-display-arme_munition" name="attr_Arme_Munition_display" value=1>
|
||||
<div class="sheet-display-arme_munition">
|
||||
|
||||
<div class="sheet-row">
|
||||
<div class="sheet-col" style="width: 110px;"><b>Bonus Force ? :</b></div>
|
||||
<div class="sheet-col" style="width: 70px;"><input type="checkbox" name="attr_Arme_bonusForce" value="1" checked="checked"></div>
|
||||
</div>
|
||||
|
||||
<div class="sheet-row ">
|
||||
<div class="sheet-col" style="width: 110px;"><b>Munition : </b></div>
|
||||
<div class="sheet-col" style="width: 250px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_munition_nom" value="" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 110px; text-align: right;"><b>Mod. AD : </b></div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput sheet-autoCalc" name="attr_munition_modAd" value="0" readonly="readonly" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 110px; text-align: right;"><b>Dégats : </b></div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput sheet-autoCalc" name="attr_munition_degats" value="0" readonly="readonly" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 230px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_munition_nom" value="" />
|
||||
|
||||
<div class="sheet-row">
|
||||
<div class="sheet-col" style="width: 110px;">
|
||||
<b>Bonus / Effets : </b>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 650px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_Arme_Effet" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput sheet-autoCalc" name="attr_munition_modAd" value="0" readonly="readonly" />
|
||||
<div class="sheet-row">
|
||||
<div class="sheet-col" style="width: 110px;">
|
||||
<b>Notes: </b>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 650px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_Arme_Note" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 70px;">
|
||||
<input type="text" class="sheet-shortInput sheet-autoCalc" name="attr_munition_degats" value="0" readonly="readonly" />
|
||||
</div>
|
||||
<br clear="all">
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 100px;padding-top: 5px;">
|
||||
<b>Bonus / Effets</b>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 230px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_Arme_Effet" value="" />
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 145px;padding-top: 5px; text-align:right">
|
||||
<b>Notes et détails</b>
|
||||
</div>
|
||||
<div class="sheet-col" style="width: 290px;">
|
||||
<input type="text" class="sheet-noBorder" name="attr_Arme_Note" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
</fieldset>
|
||||
<br>
|
||||
<span class="sheet-hint">Le Bonus / Malus aux dégats octroyé par la Force est inclus automatiquement dans les jets de dégats : <input class="sheet-shortInput sheet-autoCalc" name="attr_BonusDegatsForce" value="0" readonly="readonly" type="text"></span>
|
||||
<span class="sheet-hint">Le Bonus / Malus aux dégats octroyé par la Force : <input class="sheet-shortInput sheet-autoCalc" name="attr_BonusDegatsForce" value="0" readonly="readonly" type="text"></span>
|
||||
</div>
|
||||
<br />
|
||||
<div class="sheet-munitions">
|
||||
|
||||
Reference in New Issue
Block a user