mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 05:49:32 +02:00
Compare commits
1 Commits
398cdeb8f1
...
3723b68c2e
Author | SHA1 | Date | |
---|---|---|---|
|
3723b68c2e |
@ -54,22 +54,19 @@ 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 (removeCount === "all") {
|
if (typeof removeCount === "string") {
|
||||||
removeCount = Number.MAX_SAFE_INTEGER;
|
removeCount = Number.MAX_SAFE_INTEGER; // For the lulz
|
||||||
} 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;
|
||||||
}
|
}
|
||||||
while (numRemoved < removeCount && phaseIndex !== -1) {
|
do {
|
||||||
this.queue.splice(phaseIndex, 1);
|
this.queue.splice(phaseIndex, 1);
|
||||||
numRemoved++;
|
numRemoved++;
|
||||||
phaseIndex = this.queue.findIndex(phaseFilter);
|
} while (numRemoved < removeCount || (phaseIndex = this.queue.findIndex(phaseFilter)) !== -1);
|
||||||
}
|
return removeCount;
|
||||||
return numRemoved;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user