|
|
|
@ -9,22 +9,26 @@ export class SoSCombat extends Combat {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
requestActions() {
|
|
|
|
|
if (game.user.isGM && !this.actionsRequested) {
|
|
|
|
|
console.log("REQUEST ACTIONS !!!");
|
|
|
|
|
console.log("REQUEST ACTIONS !!!")
|
|
|
|
|
this.actionsRequested = true;
|
|
|
|
|
this.phaseSetup = {}; // Reset each new round/update
|
|
|
|
|
for (let combatant of this.combatants) {
|
|
|
|
|
this.setInitiative(combatant._id, -1 ); // Reset init
|
|
|
|
|
let uniq = randomID(16);
|
|
|
|
|
this.setInitiative(combatant.id, -1); // Reset init
|
|
|
|
|
let uniq = randomID(16)
|
|
|
|
|
const name = combatant.actor ? combatant.actor.name : combatant.name;
|
|
|
|
|
if ( combatant.players[0]) {
|
|
|
|
|
if (combatant.players && combatant.players[0]) {
|
|
|
|
|
// A player controls this combatant -> message !
|
|
|
|
|
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>`,
|
|
|
|
|
whisper: [ combatant.players[0].data._id] } );
|
|
|
|
|
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>`,
|
|
|
|
|
whisper: [combatant.players[0].id]
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
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>`,
|
|
|
|
|
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
|
|
|
|
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>`,
|
|
|
|
|
whisper: ChatMessage.getWhisperRecipients("GM"),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -58,8 +62,9 @@ export class SoSCombat extends Combat {
|
|
|
|
|
let actionData = this.phaseSetup[combatantId];
|
|
|
|
|
if (actionData.phaseArray[phaseIndex].name != 'No Action') {
|
|
|
|
|
let combatant = this.combatants.find(comb => comb._id == actionData.combatantId);
|
|
|
|
|
const name = combatant.actor ? combatant.actor.data.name : combatant.name;
|
|
|
|
|
actionList.push( { combatant: combatant,
|
|
|
|
|
const name = combatant.actor ? combatant.actor.name : combatant.name;
|
|
|
|
|
actionList.push({
|
|
|
|
|
combatant: combatant,
|
|
|
|
|
action: actionData.phaseArray[phaseIndex],
|
|
|
|
|
isDone: false
|
|
|
|
|
});
|
|
|
|
@ -77,18 +82,22 @@ export class SoSCombat extends Combat {
|
|
|
|
|
for (let action of actionList) {
|
|
|
|
|
let uniq = randomID(16);
|
|
|
|
|
action.uniqId = uniq; // Easy tracking with chat messages
|
|
|
|
|
const name = action.combatant.actor ? action.combatant.actor.data.name : action.combatant.name;
|
|
|
|
|
const name = action.combatant.actor ? action.combatant.actor.name : action.combatant.name;
|
|
|
|
|
if (action.combatant.players[0]) {
|
|
|
|
|
// A player controls this combatant -> message !
|
|
|
|
|
ChatMessage.create( { content: `Phase ${this.phaseNumber} ! ${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.
|
|
|
|
|
<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] } );
|
|
|
|
|
<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].id]
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
ChatMessage.create( { content: `Phase ${this.phaseNumber} ! ${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.
|
|
|
|
|
<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") ] } );
|
|
|
|
|
<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")
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Save for easy access
|
|
|
|
@ -100,8 +109,8 @@ export class SoSCombat extends Combat {
|
|
|
|
|
if (game.user.isGM) {
|
|
|
|
|
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');
|
|
|
|
|
combatant.actor.applyConsequenceWound( bleeding.data.severity, "bleeding" );
|
|
|
|
|
let bleeding = combatant.actor.items.find(item => item.type == 'consequence' && item.name == 'Bleeding');
|
|
|
|
|
combatant.actor.applyConsequenceWound(bleeding.system.severity, "bleeding");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -109,8 +118,8 @@ export class SoSCombat extends Combat {
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
closeAction(uniqId) {
|
|
|
|
|
// Delete message !
|
|
|
|
|
const toDelete = game.messages.filter(it => it.data.content.includes( uniqId ));
|
|
|
|
|
toDelete.forEach(it => it.delete());
|
|
|
|
|
const toDelete = game.messages.filter(it => it.content.includes(uniqId));
|
|
|
|
|
toDelete.forEach(it => it.delete())
|
|
|
|
|
|
|
|
|
|
let action = this.currentActions.find(_action => _action.uniqId == uniqId);
|
|
|
|
|
if (action) {
|
|
|
|
@ -139,8 +148,8 @@ export class SoSCombat extends Combat {
|
|
|
|
|
getAPFromActor(actorId) {
|
|
|
|
|
for (let combatant of this.combatants) {
|
|
|
|
|
//console.log(combatant);
|
|
|
|
|
if ( combatant.actor.data._id == actorId ) {
|
|
|
|
|
let phase = this.phaseSetup[combatant._id];
|
|
|
|
|
if (combatant.actor.id == actorId) {
|
|
|
|
|
let phase = this.phaseSetup[combatant.id];
|
|
|
|
|
return phase.remainingAP;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -151,8 +160,8 @@ export class SoSCombat extends Combat {
|
|
|
|
|
decreaseAPFromActor(actorId) {
|
|
|
|
|
for (let combatant of this.combatants) {
|
|
|
|
|
//console.log(combatant);
|
|
|
|
|
if ( combatant.actor.data._id == actorId ) {
|
|
|
|
|
let phase = this.phaseSetup[combatant._id];
|
|
|
|
|
if (combatant.actor.id == actorId) {
|
|
|
|
|
let phase = this.phaseSetup[combatant.id];
|
|
|
|
|
phase.remainingAP -= 1;
|
|
|
|
|
if (phase.remainingAP < 0) phase.remainingAP = 0;
|
|
|
|
|
}
|
|
|
|
@ -164,8 +173,7 @@ export class SoSCombat extends Combat {
|
|
|
|
|
console.log("Setting combat for phase : ", actionConf, actionConf.uniqId);
|
|
|
|
|
|
|
|
|
|
// Delete message !
|
|
|
|
|
const toDelete = game.messages.filter(it => it.data.content.includes( actionConf.uniqId ));
|
|
|
|
|
console.log("MESSAGE : ", toDelete);
|
|
|
|
|
const toDelete = game.messages.filter(it => it.content.includes(actionConf.uniqId));
|
|
|
|
|
toDelete.forEach(it => it.delete());
|
|
|
|
|
|
|
|
|
|
if (!this.phaseSetup) this.phaseSetup = {}; // Opportunistic init
|
|
|
|
@ -182,8 +190,10 @@ export class SoSCombat extends Combat {
|
|
|
|
|
}
|
|
|
|
|
if (actionsDone) {
|
|
|
|
|
this.actionsRequested = false;
|
|
|
|
|
ChatMessage.create( { content: `Action declaration has been completed ! Now proceeding with actions.`,
|
|
|
|
|
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
|
|
|
|
ChatMessage.create({
|
|
|
|
|
content: `Action declaration has been completed ! Now proceeding with actions.`,
|
|
|
|
|
whisper: ChatMessage.getWhisperRecipients("GM")
|
|
|
|
|
})
|
|
|
|
|
this.phaseNumber = 3;
|
|
|
|
|
this.nextTurn();
|
|
|
|
|
}
|
|
|
|
|