Initiative from PHASE OK
This commit is contained in:
@ -10,21 +10,57 @@ export class SoSCombat extends Combat {
|
||||
async nextRound() {
|
||||
console.log("NEXT ROUND !!!!");
|
||||
|
||||
if ( game.user.isGM ) {
|
||||
ChatMessage.create( { content: `New round !! Click on the button below to declare your actions for round ${this.round} !<br>
|
||||
<a class='chat-card-button' id='button-declare-actions' data-combat-id='${this._id} data-round='${this.round}'>Declare actions</a>`,
|
||||
whisper: game.users.map(user => user.data._id) } );
|
||||
if ( game.user.isGM ) {
|
||||
for( let combatant of this.combatants) {
|
||||
let uniq = randomID(16);
|
||||
if ( combatant.players[0]) {
|
||||
// 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>
|
||||
<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] } );
|
||||
} 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>
|
||||
<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") ] } );
|
||||
}
|
||||
}
|
||||
}
|
||||
super.nextRound();
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getPhaseRank( actionConf) {
|
||||
for (let i=2; i>=0; i--) {
|
||||
let action = actionConf.phaseArray[i];
|
||||
if (action.name != "No Action") {
|
||||
console.log("Init is : ", i+1);
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
setupActorActions(actionConf) {
|
||||
console.log("Setting combat for phase : ", actionConf);
|
||||
|
||||
if ( !this.phaseSetup) this.phaseSetup = []; // Opportunistic init
|
||||
if ( !this.phaseSetup[this.round] ) this.phaseSetup[this.round] = {}; // Bis
|
||||
|
||||
// Keep track
|
||||
this.phaseSetup[this.round][actionConf.userId] = actionConf;
|
||||
this.phaseSetup[this.round][actionConf.combatantId] = actionConf;
|
||||
console.log( this.combatants);
|
||||
let combatant = this.combatants.find( comb => comb._id == actionConf.combatantId);
|
||||
this.setInitiative( actionConf.combatantId, this.getPhaseRank( actionConf ) );
|
||||
|
||||
let actionsDone = true
|
||||
for( let combatant of this.combatants) {
|
||||
if ( !combatant.initiative ) actionsDone = false;
|
||||
}
|
||||
if ( actionsDone ) {
|
||||
ChatMessage.create( { content: `Action phase has been completed ! Now proceeding with actions.`,
|
||||
whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user