#8 - Weapn/armor management
This commit is contained in:
parent
9d610215d4
commit
2353ba5ff9
@ -374,13 +374,19 @@ export class SoSActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyWounds( flipData ) {
|
||||
if ( flipData.damageStatus == 'no_damage') {
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-nodamage-taken.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(this.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
return;
|
||||
}
|
||||
|
||||
let wounds = duplicate(this.data.data.wounds);
|
||||
for (let wound of flipData.woundsList ) {
|
||||
if (wound == 'L' ) wounds.light += 1;
|
||||
if (wound == 'M' ) wounds.moderate += 1;
|
||||
if (wound == 'S' ) wounds.severe += 1;
|
||||
if (wound == 'C' ) wounds.critical += 1;
|
||||
}
|
||||
}
|
||||
// Compute total
|
||||
let sumWound = wounds.light + (wounds.moderate*2) + (wounds.severe*3) + (wounds.critical*4);
|
||||
let currentWounds = duplicate(this.data.data.scores.currentwounds);
|
||||
@ -391,6 +397,16 @@ export class SoSActor extends Actor {
|
||||
await this.updateOwnedItem( { _id: bleeding._id, 'data.severity': newSeverity});
|
||||
flipData.isBleeding = newSeverity;
|
||||
}
|
||||
// Stun consequence
|
||||
if ( flipData.nbStun > 0) {
|
||||
let stun = this.data.items.find( item => item.type == 'consequence' && item.name == 'Sun');
|
||||
let newSeverity = stun.severity;
|
||||
for(i=0; i<flipData.nbStun; i++) {
|
||||
newSeverity = SoSUtility.increaseConsequenceSeverity( newSeverity );
|
||||
}
|
||||
await this.updateOwnedItem( { _id: stun._id, 'data.severity': newSeverity});
|
||||
flipData.isStun = newSeverity;
|
||||
}
|
||||
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||
|
||||
flipData.defenderName = this.name;
|
||||
|
@ -66,14 +66,12 @@ export class SoSItemSheet extends ItemSheet {
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.object.options.actor.getOwnedItem(li.data("item-id"));
|
||||
console.log("ITEM", item, li.data("item-id"), li);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
// Update Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.object.options.actor.deleteOwnedItem( li.data("item-id") ).then( this.render(true));
|
||||
//this.render(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -272,10 +272,16 @@ export class SoSCardDeck {
|
||||
flipData.damageCardsuit = flipData.cardSlot[flipData.cardSlotIndex].cardsuit;
|
||||
let damageKey = 'damage_'+ flipData.damageCardsuit;
|
||||
flipData.damageString = flipData.weapon.data[damageKey];
|
||||
let damageRegexp = flipData.damageString.match( /(\d*)([LMSC])/i );
|
||||
flipData.damageValue = damageRegexp[1];
|
||||
flipData.damageSeverity = damageRegexp[2];
|
||||
|
||||
if (flipData.damageString.includes('Str') ) {
|
||||
let damageRegexp = flipData.damageString.match( /Str([\d])?\+?([\d])?([LMSC])/i );
|
||||
flipData.damageValue = (flipData.actor.data.data.stats.strength.value * Number(damageRegexp[1]?damageRegexp[1]:1)) + Number(damageRegexp[2]?damageRegexp[2]:0);
|
||||
flipData.damageSeverity = damageRegexp[3];
|
||||
} else {
|
||||
let damageRegexp = flipData.damageString.match( /(\d*)([LMSC])/i );
|
||||
flipData.damageValue = damageRegexp[1];
|
||||
flipData.damageSeverity = damageRegexp[2];
|
||||
}
|
||||
|
||||
// Now process damage
|
||||
if ( flipData.target) {
|
||||
if ( game.user.isGM ) { // Direct access
|
||||
|
@ -261,8 +261,20 @@ export class SoSUtility extends Entity {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// DR management
|
||||
let armor = flipData.target.actor.data.items.find( item => item.type == 'armor' && item.data.worn);
|
||||
flipData.armorDR = armor ? armor.data.dr : 0;
|
||||
flipData.armorGel = armor ?armor.data.gel : 0;
|
||||
flipData.armorReflect = armor ? armor.data.reflect : 0;
|
||||
let dr = flipData.target.actor.data.data.scores.dr.value + flipData.armorDR;
|
||||
if (flipData.weapon.data.category == 'ballistic') {
|
||||
dr += flipData.armorGel;
|
||||
}
|
||||
if (flipData.weapon.data.category == 'laser') {
|
||||
dr += flipData.armorReflect;
|
||||
}
|
||||
|
||||
let dr = flipData.target.actor.data.data.scores.dr.value;
|
||||
let shock = flipData.target.actor.data.data.scores.shock.value || 1;
|
||||
let defenseCritical = flipData.target.actor.data.data.scores.defense.critical;
|
||||
flipData.damageStatus = 'apply_damage';
|
||||
@ -274,25 +286,35 @@ export class SoSUtility extends Entity {
|
||||
if ( flipData.damageValue < dr) {
|
||||
if (flipData.damageValue < dr / 2) {
|
||||
flipData.damageStatus = "no_damage";
|
||||
// TODO : No damage !
|
||||
flipData.damageReason = "Damage are lesser than DR/2";
|
||||
} else {
|
||||
flipData.damageSeverity = this.decreaseSeverity(flipData.damageSeverity );
|
||||
if ( flipData.damageSeverity == 'N') {
|
||||
flipData.damageStatus = "no_damage";
|
||||
flipData.damageReason = "Severity decreased to nothing";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shock management
|
||||
flipData.woundsList = [];
|
||||
if ( flipData.damageValue >= shock) {
|
||||
let incSeverity = Math.floor(flipData.damageValue / shock);
|
||||
for (let i=0; i<incSeverity; i++) {
|
||||
if ( flipData.damageSeverity == 'C') {
|
||||
flipData.woundsList.push( flipData.damageSeverity );
|
||||
flipData.damageSeverity = 'L';
|
||||
} else {
|
||||
flipData.damageSeverity = this.increaseSeverity( flipData.damageSeverity );
|
||||
flipData.nbStun = 0;
|
||||
if ( flipData.weapon.stun ) { // Stun weapon case
|
||||
if ( flipData.damageValue >= shock ) {
|
||||
flipData.nbStun = Math.floor(flipData.damageValue / shock);
|
||||
}
|
||||
} else {
|
||||
if ( flipData.damageValue >= shock ) {
|
||||
let incSeverity = Math.floor(flipData.damageValue / shock);
|
||||
for (let i=0; i<incSeverity; i++) {
|
||||
if ( flipData.damageSeverity == 'C') {
|
||||
flipData.woundsList.push( flipData.damageSeverity );
|
||||
flipData.damageSeverity = 'L';
|
||||
} else {
|
||||
flipData.nbStun++;
|
||||
flipData.damageSeverity = this.increaseSeverity( flipData.damageSeverity );
|
||||
flipData.damageReason = "Severity increased";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,8 @@
|
||||
{{#if isBleeding}}
|
||||
<label>{{defenderName}} is bleeding with severity {{isBleeding}}. He will have a new {{isBleeding}} wound at the end of the round !</label>
|
||||
{{/if}}
|
||||
{{#if isStun}}
|
||||
<label>{{defenderName}} is has the Stun consequence at {{isStun}} severity !</label>
|
||||
{{/if}}
|
||||
|
||||
</div>
|
||||
|
1
templates/chat-nodamage-taken.html
Normal file
1
templates/chat-nodamage-taken.html
Normal file
@ -0,0 +1 @@
|
||||
<h4>{{defenderName}}: no damages received !</h4>
|
Loading…
Reference in New Issue
Block a user