Merge branch 'spelling' into 'master'
Prevent the combat script from crashing when there's a token without an assigned actor See merge request LeRatierBretonnien/foundryvtt-shadows-over-sol!4
This commit is contained in:
commit
529146a91b
@ -15,13 +15,14 @@ export class SoSCombat extends Combat {
|
|||||||
for( let combatant of this.combatants) {
|
for( let combatant of this.combatants) {
|
||||||
this.setInitiative(combatant._id, -1 ); // Reset init
|
this.setInitiative(combatant._id, -1 ); // Reset init
|
||||||
let uniq = randomID(16);
|
let uniq = randomID(16);
|
||||||
|
const name = combatant.actor ? combatant.actor.data.name : combatant.name;
|
||||||
if ( combatant.players[0]) {
|
if ( combatant.players[0]) {
|
||||||
// A player controls this combatant -> message !
|
// A player controls this combatant -> message !
|
||||||
ChatMessage.create( { content: `New round ! Click on the button below to declare the actions of ${combatant.actor.data.name} for round ${this.round} !<br>
|
ChatMessage.create( { content: `New round ! Click on the button below to declare the actions of ${name} for round ${this.round} !<br>
|
||||||
<a class='chat-card-button' id='button-declare-actions' data-uniq-id='${uniq}' data-combatant-id='${combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Declare actions</a>`,
|
<a class='chat-card-button' id='button-declare-actions' data-uniq-id='${uniq}' data-combatant-id='${combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Declare actions</a>`,
|
||||||
whisper: [ combatant.players[0].data._id] } );
|
whisper: [ combatant.players[0].data._id] } );
|
||||||
} else {
|
} else {
|
||||||
ChatMessage.create( { content: `New round ! Click on the button below to declare the actions of ${combatant.actor.data.name} for round ${this.round} !<br>
|
ChatMessage.create( { content: `New round ! Click on the button below to declare the actions of ${name} for round ${this.round} !<br>
|
||||||
<a class='chat-card-button' id='button-declare-actions' data-uniq-id='${uniq}' data-combatant-id='${combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Declare actions</a>`,
|
<a class='chat-card-button' id='button-declare-actions' data-uniq-id='${uniq}' data-combatant-id='${combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Declare actions</a>`,
|
||||||
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
||||||
}
|
}
|
||||||
@ -57,11 +58,12 @@ export class SoSCombat extends Combat {
|
|||||||
let actionData = this.phaseSetup[combatantId];
|
let actionData = this.phaseSetup[combatantId];
|
||||||
if ( actionData.phaseArray[phaseIndex].name != 'No Action' ) {
|
if ( actionData.phaseArray[phaseIndex].name != 'No Action' ) {
|
||||||
let combatant = this.combatants.find( comb => comb._id == actionData.combatantId);
|
let combatant = this.combatants.find( comb => comb._id == actionData.combatantId);
|
||||||
|
const name = combatant.actor ? combatant.actor.data.name : combatant.name;
|
||||||
actionList.push( { combatant: combatant,
|
actionList.push( { combatant: combatant,
|
||||||
action: actionData.phaseArray[phaseIndex],
|
action: actionData.phaseArray[phaseIndex],
|
||||||
isDone: false
|
isDone: false
|
||||||
});
|
});
|
||||||
actionMsg += `<br>${combatant.actor.name} is going to : ${actionData.phaseArray[phaseIndex].name}`;
|
actionMsg += `<br>${name} is going to : ${actionData.phaseArray[phaseIndex].name}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( actionList.length == 0) {
|
if ( actionList.length == 0) {
|
||||||
@ -75,14 +77,15 @@ export class SoSCombat extends Combat {
|
|||||||
for ( let action of actionList) {
|
for ( let action of actionList) {
|
||||||
let uniq = randomID(16);
|
let uniq = randomID(16);
|
||||||
action.uniqId = uniq; // Easy tracking with chat messages
|
action.uniqId = uniq; // Easy tracking with chat messages
|
||||||
|
const name = action.combatant.actor ? action.combatant.actor.data.name : action.combatant.name;
|
||||||
if ( action.combatant.players[0]) {
|
if ( action.combatant.players[0]) {
|
||||||
// A player controls this combatant -> message !
|
// A player controls this combatant -> message !
|
||||||
ChatMessage.create( { content: `Phase ${this.phaseNumber} ! ${action.combatant.actor.data.name} must perform a <strong>${action.action.name}</strong> action.
|
ChatMessage.create( { content: `Phase ${this.phaseNumber} ! ${name} must perform a <strong>${action.action.name}</strong> action.
|
||||||
When done, click on the button below to close the action.
|
When done, click on the button below to close the action.
|
||||||
<a class='chat-card-button' id='button-end-action' data-uniq-id='${uniq}' data-combatant-id='${action.combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Action is done !</a>`,
|
<a class='chat-card-button' id='button-end-action' data-uniq-id='${uniq}' data-combatant-id='${action.combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Action is done !</a>`,
|
||||||
whisper: [ action.combatant.players[0].data._id] } );
|
whisper: [ action.combatant.players[0].data._id] } );
|
||||||
} else {
|
} else {
|
||||||
ChatMessage.create( { content: `Phase ${this.phaseNumber} ! ${action.combatant.actor.data.name} must perform a <strong>${action.action.name}</strong> action.<br>
|
ChatMessage.create( { content: `Phase ${this.phaseNumber} ! ${name} must perform a <strong>${action.action.name}</strong> action.<br>
|
||||||
When done, click on the button below to close the action.
|
When done, click on the button below to close the action.
|
||||||
<a class='chat-card-button' id='button-end-action' data-uniq-id='${uniq}' data-combatant-id='${action.combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Action is done !</a>`,
|
<a class='chat-card-button' id='button-end-action' data-uniq-id='${uniq}' data-combatant-id='${action.combatant._id}' data-combat-id='${this._id}' data-round='${this.round}'>Action is done !</a>`,
|
||||||
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
||||||
@ -96,6 +99,7 @@ export class SoSCombat extends Combat {
|
|||||||
applyConsequences( ) {
|
applyConsequences( ) {
|
||||||
if (game.user.isGM ) {
|
if (game.user.isGM ) {
|
||||||
for( let combatant of this.combatants) {
|
for( let combatant of this.combatants) {
|
||||||
|
if (!combatant.actor) continue; // Can't check tokens without assigned actors, Maybe print chat message about bleeding happening so that the GM can manually track this?
|
||||||
let bleeding = combatant.actor.data.items.find( item => item.type == 'consequence' && item.name == 'Bleeding');
|
let bleeding = combatant.actor.data.items.find( item => item.type == 'consequence' && item.name == 'Bleeding');
|
||||||
combatant.actor.applyConsequenceWound( bleeding.data.severity, "bleeding" );
|
combatant.actor.applyConsequenceWound( bleeding.data.severity, "bleeding" );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user