#8 - Weapn/armor management
This commit is contained in:
parent
9d610215d4
commit
2353ba5ff9
@ -374,6 +374,12 @@ export class SoSActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async applyWounds( flipData ) {
|
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);
|
let wounds = duplicate(this.data.data.wounds);
|
||||||
for (let wound of flipData.woundsList ) {
|
for (let wound of flipData.woundsList ) {
|
||||||
if (wound == 'L' ) wounds.light += 1;
|
if (wound == 'L' ) wounds.light += 1;
|
||||||
@ -391,6 +397,16 @@ export class SoSActor extends Actor {
|
|||||||
await this.updateOwnedItem( { _id: bleeding._id, 'data.severity': newSeverity});
|
await this.updateOwnedItem( { _id: bleeding._id, 'data.severity': newSeverity});
|
||||||
flipData.isBleeding = 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 } );
|
await this.update( { 'data.scores.currentwounds': currentWounds, 'data.wounds': wounds } );
|
||||||
|
|
||||||
flipData.defenderName = this.name;
|
flipData.defenderName = this.name;
|
||||||
|
@ -66,14 +66,12 @@ export class SoSItemSheet extends ItemSheet {
|
|||||||
html.find('.item-edit').click(ev => {
|
html.find('.item-edit').click(ev => {
|
||||||
const li = $(ev.currentTarget).parents(".item");
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
const item = this.object.options.actor.getOwnedItem(li.data("item-id"));
|
const item = this.object.options.actor.getOwnedItem(li.data("item-id"));
|
||||||
console.log("ITEM", item, li.data("item-id"), li);
|
|
||||||
item.sheet.render(true);
|
item.sheet.render(true);
|
||||||
});
|
});
|
||||||
// Update Inventory Item
|
// Update Inventory Item
|
||||||
html.find('.item-delete').click(ev => {
|
html.find('.item-delete').click(ev => {
|
||||||
const li = $(ev.currentTarget).parents(".item");
|
const li = $(ev.currentTarget).parents(".item");
|
||||||
this.object.options.actor.deleteOwnedItem( li.data("item-id") ).then( this.render(true));
|
this.object.options.actor.deleteOwnedItem( li.data("item-id") ).then( this.render(true));
|
||||||
//this.render(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -272,9 +272,15 @@ export class SoSCardDeck {
|
|||||||
flipData.damageCardsuit = flipData.cardSlot[flipData.cardSlotIndex].cardsuit;
|
flipData.damageCardsuit = flipData.cardSlot[flipData.cardSlotIndex].cardsuit;
|
||||||
let damageKey = 'damage_'+ flipData.damageCardsuit;
|
let damageKey = 'damage_'+ flipData.damageCardsuit;
|
||||||
flipData.damageString = flipData.weapon.data[damageKey];
|
flipData.damageString = flipData.weapon.data[damageKey];
|
||||||
|
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 );
|
let damageRegexp = flipData.damageString.match( /(\d*)([LMSC])/i );
|
||||||
flipData.damageValue = damageRegexp[1];
|
flipData.damageValue = damageRegexp[1];
|
||||||
flipData.damageSeverity = damageRegexp[2];
|
flipData.damageSeverity = damageRegexp[2];
|
||||||
|
}
|
||||||
|
|
||||||
// Now process damage
|
// Now process damage
|
||||||
if ( flipData.target) {
|
if ( flipData.target) {
|
||||||
|
@ -262,7 +262,19 @@ export class SoSUtility extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dr = flipData.target.actor.data.data.scores.dr.value;
|
// 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 shock = flipData.target.actor.data.data.scores.shock.value || 1;
|
let shock = flipData.target.actor.data.data.scores.shock.value || 1;
|
||||||
let defenseCritical = flipData.target.actor.data.data.scores.defense.critical;
|
let defenseCritical = flipData.target.actor.data.data.scores.defense.critical;
|
||||||
flipData.damageStatus = 'apply_damage';
|
flipData.damageStatus = 'apply_damage';
|
||||||
@ -274,17 +286,24 @@ export class SoSUtility extends Entity {
|
|||||||
if ( flipData.damageValue < dr) {
|
if ( flipData.damageValue < dr) {
|
||||||
if (flipData.damageValue < dr / 2) {
|
if (flipData.damageValue < dr / 2) {
|
||||||
flipData.damageStatus = "no_damage";
|
flipData.damageStatus = "no_damage";
|
||||||
// TODO : No damage !
|
flipData.damageReason = "Damage are lesser than DR/2";
|
||||||
} else {
|
} else {
|
||||||
flipData.damageSeverity = this.decreaseSeverity(flipData.damageSeverity );
|
flipData.damageSeverity = this.decreaseSeverity(flipData.damageSeverity );
|
||||||
if ( flipData.damageSeverity == 'N') {
|
if ( flipData.damageSeverity == 'N') {
|
||||||
flipData.damageStatus = "no_damage";
|
flipData.damageStatus = "no_damage";
|
||||||
|
flipData.damageReason = "Severity decreased to nothing";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shock management
|
// Shock management
|
||||||
flipData.woundsList = [];
|
flipData.woundsList = [];
|
||||||
|
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 ) {
|
if ( flipData.damageValue >= shock ) {
|
||||||
let incSeverity = Math.floor(flipData.damageValue / shock);
|
let incSeverity = Math.floor(flipData.damageValue / shock);
|
||||||
for (let i=0; i<incSeverity; i++) {
|
for (let i=0; i<incSeverity; i++) {
|
||||||
@ -292,7 +311,10 @@ export class SoSUtility extends Entity {
|
|||||||
flipData.woundsList.push( flipData.damageSeverity );
|
flipData.woundsList.push( flipData.damageSeverity );
|
||||||
flipData.damageSeverity = 'L';
|
flipData.damageSeverity = 'L';
|
||||||
} else {
|
} else {
|
||||||
|
flipData.nbStun++;
|
||||||
flipData.damageSeverity = this.increaseSeverity( flipData.damageSeverity );
|
flipData.damageSeverity = this.increaseSeverity( flipData.damageSeverity );
|
||||||
|
flipData.damageReason = "Severity increased";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,8 @@
|
|||||||
{{#if isBleeding}}
|
{{#if isBleeding}}
|
||||||
<label>{{defenderName}} is bleeding with severity {{isBleeding}}. He will have a new {{isBleeding}} wound at the end of the round !</label>
|
<label>{{defenderName}} is bleeding with severity {{isBleeding}}. He will have a new {{isBleeding}} wound at the end of the round !</label>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if isStun}}
|
||||||
|
<label>{{defenderName}} is has the Stun consequence at {{isStun}} severity !</label>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
</div>
|
</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