mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-18 21:39:28 +02:00
Compare commits
2 Commits
018a0091f3
...
c1c66a473b
Author | SHA1 | Date | |
---|---|---|---|
|
c1c66a473b | ||
|
d576da72d2 |
@ -54,19 +54,22 @@ export abstract class PhasePriorityQueue {
|
|||||||
* @todo Remove this eventually once the patchwork bug this is used for is fixed
|
* @todo Remove this eventually once the patchwork bug this is used for is fixed
|
||||||
*/
|
*/
|
||||||
public tryRemovePhase(phaseFilter: (phase: Phase) => boolean, removeCount: number | "all" = 1): number {
|
public tryRemovePhase(phaseFilter: (phase: Phase) => boolean, removeCount: number | "all" = 1): number {
|
||||||
if (typeof removeCount === "string") {
|
if (removeCount === "all") {
|
||||||
removeCount = Number.MAX_SAFE_INTEGER; // For the lulz
|
removeCount = Number.MAX_SAFE_INTEGER;
|
||||||
|
} else if (removeCount < 1) {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
let numRemoved = 0;
|
let numRemoved = 0;
|
||||||
let phaseIndex = this.queue.findIndex(phaseFilter);
|
let phaseIndex = this.queue.findIndex(phaseFilter);
|
||||||
if (phaseIndex === -1) {
|
if (phaseIndex === -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
do {
|
while (numRemoved < removeCount && phaseIndex !== -1) {
|
||||||
this.queue.splice(phaseIndex, 1);
|
this.queue.splice(phaseIndex, 1);
|
||||||
numRemoved++;
|
numRemoved++;
|
||||||
} while (numRemoved < removeCount || (phaseIndex = this.queue.findIndex(phaseFilter)) !== -1);
|
phaseIndex = this.queue.findIndex(phaseFilter);
|
||||||
return removeCount;
|
}
|
||||||
|
return numRemoved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user