Skip to content

Commit

Permalink
Make status Queued only if creature not acted yet in current round
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosDj21 committed Nov 2, 2024
1 parent 07a83e6 commit 280870c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/ui/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,23 @@ export class Queue {

const turnEndMarkerV = [new TurnEndMarkerVignette(turnNum, eventHandlers)];

const newCreatureVNext = (c: Creature) =>
new CreatureVignette(c, turnNum + 1, eventHandlers, is1stCreature(), false);
const newCreatureVNext = (c: Creature) => {
let isCreatureAlreadyShown = false;
for (const oldC of creatures) {
if (oldC.id === c.id) {
isCreatureAlreadyShown = true;
break;
}
}
return new CreatureVignette(
c,
turnNum + 1,
eventHandlers,
is1stCreature(),
false,
isCreatureAlreadyShown,
);
};
const undelayedVsNext = undelayedCsNext.map(newCreatureVNext);
const delayMarkerVNext = hasDelayedNext
? [new DelayMarkerVignette(turnNum + 1, eventHandlers)]
Expand Down Expand Up @@ -359,20 +374,23 @@ class CreatureVignette extends Vignette {
creature: Creature;
isActiveCreature: boolean;
turnNumberIsCurrentTurn: boolean;
isAlreadyShown: boolean;

constructor(
creature: Creature,
turnNumber: number,
eventHandlers: QueueEventHandlers,
isActiveCreature = false,
turnNumberIsCurrentTurn = true,
isAlreadyShown = false,
) {
super();
this.creature = creature;
this.turnNumber = turnNumber;
this.eventHandlers = eventHandlers;
this.isActiveCreature = isActiveCreature;
this.turnNumberIsCurrentTurn = turnNumberIsCurrentTurn;
this.isAlreadyShown = isAlreadyShown;
}

getHash() {
Expand Down Expand Up @@ -431,7 +449,7 @@ class CreatureVignette extends Vignette {

this.el.style.zIndex = this.creature.temp ? '1000' : this.queuePosition + 1 + '';

const stats = this.turnNumberIsCurrentTurn ? this.creature.fatigueText : 'Queued';
const stats = this.isAlreadyShown ? 'Queued' : this.creature.fatigueText;
const statsClasses = ['stats', utils.toClassName(stats)].join(' ');
const statsEl = this.el.querySelector('div.stats');
statsEl.className = statsClasses;
Expand Down

0 comments on commit 280870c

Please sign in to comment.