Gestion armures
This commit is contained in:
parent
d24be22c5e
commit
cde7df1f8e
@ -150,15 +150,16 @@ export class RdDActor extends Actor {
|
|||||||
if ( rollData.pointsDeTache > 0 ) {
|
if ( rollData.pointsDeTache > 0 ) {
|
||||||
let myroll = new Roll("2d10");
|
let myroll = new Roll("2d10");
|
||||||
myroll.roll();
|
myroll.roll();
|
||||||
rollData.degats = parseInt(myroll.result) + parseInt(rollData.arme.data.dommages);
|
rollData.domArmePlusDom = parseInt(rollData.arme.data.dommages);
|
||||||
if ( rollData.selectedCarac.label == "Mêlée" ) // +dom only for Melee
|
if ( rollData.selectedCarac.label == "Mêlée" ) // +dom only for Melee
|
||||||
rollData.degats += parseInt(this.data.data.attributs.plusdom.value);
|
rollData.domArmePlusDom += parseInt(this.data.data.attributs.plusdom.value);
|
||||||
if ( rollData.selectedCarac.label == "Lancer" ) { // +dom only for Melee/Lancer
|
if ( rollData.selectedCarac.label == "Lancer" ) { // +dom only for Melee/Lancer
|
||||||
let bdom = parseInt(this.data.data.attributs.plusdom.value);
|
let bdom = parseInt(this.data.data.attributs.plusdom.value);
|
||||||
if ( bdom > parseInt(rollData.arme.data.dommages)*2 )
|
if ( bdom > parseInt(rollData.arme.data.dommages)*2 )
|
||||||
bdom = parseInt(rollData.arme.data.dommages)*2;
|
bdom = parseInt(rollData.arme.data.dommages)*2;
|
||||||
rollData.degats += bdom
|
rollData.domArmePlusDom += bdom
|
||||||
}
|
}
|
||||||
|
rollData.degats = parseInt(myroll.result) + rollData.domArmePlusDom;
|
||||||
rollData.loc = RdDUtility.getLocalisation();
|
rollData.loc = RdDUtility.getLocalisation();
|
||||||
for (let target of game.user.targets) {
|
for (let target of game.user.targets) {
|
||||||
defenseMsg = RdDUtility.buildDefenseChatCard(this, target, rollData );
|
defenseMsg = RdDUtility.buildDefenseChatCard(this, target, rollData );
|
||||||
@ -329,7 +330,7 @@ export class RdDActor extends Actor {
|
|||||||
nGraves++;
|
nGraves++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( nLegeres == 2) break;
|
if ( nGraves == 2) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( blessuresData.graves > 0 )
|
if ( blessuresData.graves > 0 )
|
||||||
@ -398,17 +399,37 @@ export class RdDActor extends Actor {
|
|||||||
equiperObjet( itemID )
|
equiperObjet( itemID )
|
||||||
{
|
{
|
||||||
let item = this.getOwnedItem(itemID);
|
let item = this.getOwnedItem(itemID);
|
||||||
if ( item && item.data.data )
|
if ( item && item.data.data ) {
|
||||||
item.data.data.equipe = !item.data.data.equipe;
|
let update = duplicate(item);
|
||||||
|
update.data.equipe = !update.data.equipe;
|
||||||
|
this.updateEmbeddedEntity("OwnedItem", update);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
computeArmure( locData )
|
computeArmure( locData, domArmePlusDom )
|
||||||
{
|
{
|
||||||
let protection = 0;
|
let protection = 0;
|
||||||
for (const item of this.data.items) {
|
for (const item of this.data.items) {
|
||||||
if (item.type == "armure" && item.data.equipe) {
|
if (item.type == "armure" && item.data.equipe) {
|
||||||
protection += item.data.protection;
|
let update = duplicate(item);
|
||||||
|
let myroll = new Roll(update.data.protection.toString());
|
||||||
|
myroll.roll();
|
||||||
|
protection += myroll.total;
|
||||||
|
update.data.deterioration += domArmePlusDom;
|
||||||
|
domArmePlusDom = 0; // Reset it
|
||||||
|
if ( update.data.deterioration >= 10) {
|
||||||
|
update.data.deterioration = 0;
|
||||||
|
if ( update.data.protection.toString().length == 1 )
|
||||||
|
update.data.protection = "d"+update.data.protection+"-0";
|
||||||
|
else {
|
||||||
|
let regex = /d\(d+)\-(\d+)/g;
|
||||||
|
let res = regex.exec( update.data.protection );
|
||||||
|
update.data.protection = "d"+res[1]+"-"+(parseInt(res[2])+1);
|
||||||
|
}
|
||||||
|
/* TODO - POST chat message */
|
||||||
|
}
|
||||||
|
this.updateEmbeddedEntity("OwnedItem", update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Final protect", protection);
|
console.log("Final protect", protection);
|
||||||
@ -419,7 +440,7 @@ export class RdDActor extends Actor {
|
|||||||
encaisserDommages( attackerRoll )
|
encaisserDommages( attackerRoll )
|
||||||
{
|
{
|
||||||
//let attackerRoll = rollData.attackerRoll;
|
//let attackerRoll = rollData.attackerRoll;
|
||||||
let degatsReel = attackerRoll.degats - this.computeArmure(attackerRoll.loc);
|
let degatsReel = attackerRoll.degats - this.computeArmure(attackerRoll.loc, attackerRoll.domArmePlusDom);
|
||||||
console.log("RollData from attacker!", attackerRoll, degatsReel);
|
console.log("RollData from attacker!", attackerRoll, degatsReel);
|
||||||
|
|
||||||
let result = RdDUtility.computeBlessuresSante(degatsReel);
|
let result = RdDUtility.computeBlessuresSante(degatsReel);
|
||||||
|
Loading…
Reference in New Issue
Block a user