Manage wounds
This commit is contained in:
parent
cfcc3b3201
commit
fb0eb9dcc8
@ -26,6 +26,8 @@ export class SoSActorSheet extends ActorSheet {
|
||||
let data = super.getData();
|
||||
|
||||
data.data.edgecard = this.actor.getEdgesCard();
|
||||
data.data.deckSize = this.actor.getDeckSize();
|
||||
|
||||
data.data.skills = this.actor.data.items.filter( item => item.type == 'skill').sort( (a, b) => {
|
||||
if ( a.name > b.name ) return 1;
|
||||
return -1;
|
||||
|
@ -59,6 +59,12 @@ export class SoSActor extends Actor {
|
||||
}
|
||||
this.controlScores();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDeckSize() {
|
||||
return this.cardDeck.getDeckSize();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getEdgesCard( ) {
|
||||
let edgesCard = duplicate(this.cardDeck.data.cardEdge);
|
||||
|
@ -94,6 +94,11 @@ export class SoSCardDeck {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDeckSize() {
|
||||
return this.data.deck.length;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCardSuit( cardName ) {
|
||||
if ( cardName[0] == 'c') return 'club';
|
||||
|
@ -139,6 +139,18 @@ export class SoSCombat extends Combat {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
decreaseAPFromActor( actorId ) {
|
||||
for( let combatant of this.combatants) {
|
||||
//console.log(combatant);
|
||||
if ( combatant.actor.data._id == actorId ) {
|
||||
let phase = this.phaseSetup[combatant._id];
|
||||
phase.remainingAP -= 1;
|
||||
if ( phase.remainingAP < 0 ) phase.remainingAP = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setupActorActions(actionConf) {
|
||||
console.log("Setting combat for phase : ", actionConf);
|
||||
|
@ -35,19 +35,21 @@ export class SoSUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
onSocketMesssage( msg ) {
|
||||
if( !game.user.isGM ) return; // Only GM
|
||||
|
||||
if (msg.name == 'msg_declare_actions' ) {
|
||||
if (game.user.isGM) {
|
||||
let combat = game.combats.get( msg.data.combatId); // Get the associated combat
|
||||
combat.setupActorActions( msg.data );
|
||||
}
|
||||
let combat = game.combats.get( msg.data.combatId); // Get the associated combat
|
||||
combat.setupActorActions( msg.data );
|
||||
} else if (msg.name == 'msg_close_action') {
|
||||
if (game.user.isGM) {
|
||||
game.combat.closeAction( msg.data.uniqId );
|
||||
}
|
||||
game.combat.closeAction( msg.data.uniqId );
|
||||
} else if (msg.name == 'msg_request_defense') {
|
||||
if (game.user.isGM) {
|
||||
SoSUtility.applyDamage( msg.data );
|
||||
}
|
||||
SoSUtility.applyDamage( msg.data );
|
||||
} else if (msg.name == 'msg_reaction_cover') {
|
||||
SoSUtility.reactionCover( msg.data.uniqId );
|
||||
} else if (msg.name == 'msg_reaction_melee') {
|
||||
SoSUtility.reactionMelee( msg.data.uniqId );
|
||||
} else if (msg.name == 'msg_reaction_hit') {
|
||||
SoSUtility.reactionHit( msg.data.uniqId );
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +121,7 @@ export class SoSUtility {
|
||||
if ( game.user.isGM ) {
|
||||
game.combat.closeAction( uniqId );
|
||||
} else {
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
game.socket.emit("system.foundryvtt-shadows-over-sol", {
|
||||
name: "msg_close_action", data: { uniqId: uniqId} } );
|
||||
}
|
||||
}
|
||||
@ -132,6 +134,32 @@ export class SoSUtility {
|
||||
html.on("click", '#button-end-action', event => {
|
||||
SoSUtility.closeAction( event );
|
||||
});
|
||||
|
||||
html.on("click", '#button-reaction-cover', event => {
|
||||
let uniqId = event.currentTarget.attributes['data-uniq-id'].value;
|
||||
if ( game.user.isGM ) {
|
||||
SoSUtility.reactionCover( uniqId );
|
||||
} else {
|
||||
game.socket.emit("system.foundryvtt-shadows-over-sol", { name: "msg_reaction_cover", data: { uniqId: uniqId} } );
|
||||
}
|
||||
});
|
||||
|
||||
html.on("click", '#button-reaction-melee', event => {
|
||||
let uniqId = event.currentTarget.attributes['data-uniq-id'].value;
|
||||
if ( game.user.isGM ) {
|
||||
SoSUtility.reactionMelee( uniqId );
|
||||
} else {
|
||||
game.socket.emit("system.foundryvtt-shadows-over-sol", { name: "msg_reaction_melee", data: { uniqId: uniqId} } );
|
||||
}
|
||||
});
|
||||
html.on("click", '#button-reaction-hit', event => {
|
||||
let uniqId = event.currentTarget.attributes['data-uniq-id'].value;
|
||||
if ( game.user.isGM ) {
|
||||
SoSUtility.reactionHit( uniqId );
|
||||
} else {
|
||||
game.socket.emit("system.foundryvtt-shadows-over-sol", { name: "msg_reaction_hit", data: { uniqId: uniqId} } );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -144,14 +172,24 @@ export class SoSUtility {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static increaseConsequenceSeverity( severity ) {
|
||||
if ( severity == 'none') return 'light';
|
||||
if ( severity == 'light') return 'moderate';
|
||||
if ( severity == 'moderate') return 'severe';
|
||||
if ( severity == 'severe') return 'critical';
|
||||
return 'critical';
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static increaseConsequenceSeverity( severity ) {
|
||||
if ( severity == 'none') return 'light';
|
||||
if ( severity == 'light') return 'moderate';
|
||||
if ( severity == 'moderate') return 'severe';
|
||||
if ( severity == 'severe') return 'critical';
|
||||
return 'critical';
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getConsequenceSeverityLevel( severity) {
|
||||
if ( severity == 'none') return 0;
|
||||
if ( severity == 'light') return 1;
|
||||
if ( severity == 'moderate') return 2;
|
||||
if ( severity == 'severe') return 3;
|
||||
if ( severity == 'critical') return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static increaseSeverity( severity ) {
|
||||
@ -180,6 +218,17 @@ export class SoSUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async applyDamage( flipData ) {
|
||||
if (!this.registry) this.registry = {};
|
||||
|
||||
if ( flipData.isReaction) {
|
||||
flipData.magnitude = flipData.finalScore - flipData.tn; // Update magnitude
|
||||
if ( flipData.magnitude < 0 ) {
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-reaction-result.html', flipData );
|
||||
ChatMessage.create( { content: html });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let dr = flipData.target.actor.data.data.scores.dr.value;
|
||||
let shock = flipData.target.actor.data.data.scores.shock.value;
|
||||
let defenseCritical = flipData.target.actor.data.data.scores.defense.critical;
|
||||
@ -228,22 +277,50 @@ export class SoSUtility {
|
||||
flipData.coverConsequence = defender.data.items.find( item => item.type == 'consequence' && item.name == 'Cover');
|
||||
flipData.APavailable = game.combat.getAPFromActor( defender.data._id );
|
||||
console.log("FLIPDATE : ", flipData);
|
||||
if ( flipData.APavailable > 0) {
|
||||
if ( !flipData.isReaction && flipData.APavailable > 0) {
|
||||
if ( (flipData.weapon.data.category == 'melee' ) || ( (flipData.weapon.data.category == 'laser' || flipData.weapon.data.category == 'ballistic') &&
|
||||
flipData.coverConsequence.data.severity != 'none') ) {
|
||||
flipData.coverSeverityLevel = this.getSeverityLevel( flipData.coverConsequence.data.severity ) * 2;
|
||||
flipData.coverSeverityLevel = this.getConsequenceSeverityLevel( flipData.coverConsequence.data.severity ) * 2;
|
||||
flipData.coverSeverityFlag = (flipData.coverSeverityLevel > 0);
|
||||
flipData.isMelee = (flipData.weapon.data.category == 'melee' );
|
||||
let melee = defender.data.items.find( item => item.type == 'skill' && item.name == 'Melee');
|
||||
flipData.defenderMelee = melee.data.value;
|
||||
flipData.uniqId = randomID(16);
|
||||
this.registry[flipData.uniqId] = flipData;
|
||||
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/chat-damage-request-dodge.html', flipData );
|
||||
ChatMessage.create( { content: html, whisper: [ChatMessage.getWhisperRecipients(flipData.target.actor.name), ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
return; // Wait message response
|
||||
}
|
||||
}
|
||||
flipData.isReaction = false;
|
||||
this.takeWounds( flipData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static reactionCover( uniqId) {
|
||||
let flipData = this.registry[uniqId];
|
||||
flipData.tn += flipData.coverSeverityLevel;
|
||||
flipData.isReaction = true;
|
||||
game.combat.decreaseAPFromActor( flipData.target.actor._id );
|
||||
SoSUtility.applyDamage( flipData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static reactionMelee( uniqId) {
|
||||
let flipData = this.registry[uniqId];
|
||||
flipData.tn += flipData.defenderMelee;
|
||||
flipData.isReaction = true;
|
||||
game.combat.decreaseAPFromActor( flipData.target.actor._id );
|
||||
SoSUtility.applyDamage( flipData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static reactionHit( uniqId) {
|
||||
let flipData = this.registry[uniqId];
|
||||
flipData.isReaction = true;
|
||||
SoSUtility.takeWounds( flipData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static takeWounds( flipData ) {
|
||||
let defender = game.actors.get( flipData.target.actor._id);
|
||||
|
@ -1032,7 +1032,7 @@ ul, li {
|
||||
cursor: pointer;
|
||||
color: #ffffff;
|
||||
font-family: Neuropol;
|
||||
font-size: 14px;
|
||||
font-size: 0.9rem;
|
||||
padding: 4px 12px 0px 12px;
|
||||
text-decoration: none;
|
||||
text-shadow: 0px 1px 0px #4d3534;
|
||||
|
@ -73,12 +73,13 @@
|
||||
|
||||
<div class="flexrow">
|
||||
<span class="flexcol">
|
||||
<h3 class="edge-name">Edge cards : </h3>
|
||||
<h3 class="edge-name">Current deck size : {{data.deckSize}} cards</h3>
|
||||
<span class="edge-name"><a class="reset-deck-full">Reset full deck and edges</a></span>
|
||||
<span class="edge-name"><a class="draw-new-edge">Draw a new Edge card</a></span>
|
||||
<span class="edge-name"><a class="reset-deck">Reset deck only (ie after a Joker)</a></span>
|
||||
</span>
|
||||
<span class="edge-name">
|
||||
<h3 class="edge-name">Edge cards : </h3>
|
||||
{{#each data.edgecard as |card key|}}
|
||||
<img class="card-img" src="{{card.path}}" data-edit="img" title="{{card.cardName}}" />
|
||||
{{/each}}
|
||||
|
@ -1,10 +1,13 @@
|
||||
<h4>{{target.actor.name}} has {{remainingAP}} AP and can react to the attack from {{actor.name}} !</h4>
|
||||
<h4>{{target.actor.name}} has {{APavailable}} AP and can react to the attack from {{actor.name}} !</h4>
|
||||
<div class="flexcol">
|
||||
{{#if coverSeverityFlag}}
|
||||
<label>Add cover consequence bonus * 2 to your defense : {{coverSeverityLevel}}</label>
|
||||
<a class='chat-card-button' id='button-reaction-cover' data-uniq-id='{{uniqId}}' data-actor-id='{{target.actor._id}}'>
|
||||
Add cover consequence bonus x 2 to your defense : {{coverSeverityLevel}}</a>`
|
||||
{{/if}}
|
||||
{{#if isMelee}}
|
||||
<label>Add Melee level to your defense : {{defenderMelee}}</label>
|
||||
<a class='chat-card-button' id='button-reaction-melee' data-uniq-id='{{uniqId}}' data-actor-id='{{target.actor._id}}'>
|
||||
Add Melee level to your defense : {{defenderMelee}}</a>`
|
||||
{{/if}}
|
||||
<label>Do not dodge and get the hit ! </label>
|
||||
<a class='chat-card-button' id='button-reaction-hit' data-uniq-id='{{uniqId}}' data-actor-id='{{target.actor._id}}'>
|
||||
Do not dodge and get the hit !</a>`
|
||||
</div>
|
||||
|
4
templates/chat-reaction-result.html
Normal file
4
templates/chat-reaction-result.html
Normal file
@ -0,0 +1,4 @@
|
||||
<h4>{{target.actor.name}} reacted and has avoided damages !</h4>
|
||||
<div class="flexcol">
|
||||
<label>Score : {{finalScore}} - Target defense : {{tn}} / {{targetCritical}}</label>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user