diff --git a/module/actor.js b/module/actor.js index ef4d45f..06cb815 100644 --- a/module/actor.js +++ b/module/actor.js @@ -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 { 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); }); } diff --git a/module/sos-card-deck.js b/module/sos-card-deck.js index 91c460f..3fef1ba 100644 --- a/module/sos-card-deck.js +++ b/module/sos-card-deck.js @@ -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 diff --git a/module/sos-utility.js b/module/sos-utility.js index c855925..137972c 100644 --- a/module/sos-utility.js +++ b/module/sos-utility.js @@ -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= 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{{defenderName}} is bleeding with severity {{isBleeding}}. He will have a new {{isBleeding}} wound at the end of the round ! {{/if}} + {{#if isStun}} + + {{/if}} diff --git a/templates/chat-nodamage-taken.html b/templates/chat-nodamage-taken.html new file mode 100644 index 0000000..ecd19db --- /dev/null +++ b/templates/chat-nodamage-taken.html @@ -0,0 +1 @@ +

{{defenderName}}: no damages received !