-
Notifications
You must be signed in to change notification settings - Fork 2
/
quesoqueue.h
75 lines (60 loc) · 1.81 KB
/
quesoqueue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#include "level.h"
#include "twitch.h"
#include <deque>
#include <optional>
#include <string>
#include <vector>
typedef std::tuple<std::deque<Level>,std::deque<Level>> PriorityQueso;
class QuesoQueue {
public:
QuesoQueue(const Twitch &twitch);
/**
* Adds a level to queue; limit one per viewer.
*/
std::string Add(Level level);
/**
* Removes the level submitted by the user. Or, if the user is admin,
* remove the level with the specified username
*/
std::string Remove(std::string username);
std::string ModRemove(std::string username);
/**
* Replaces the level a user currently has in queue with a new code.
*/
std::string Replace(std::string username, std::string newLevelCode);
/**
* Pop the top of the queue and return the new top (subject to priority queue split)
*/
std::optional<Level> Next();
/**
* Report the level currently being played (not subject to priority queue split)
*/
std::optional<Level> Current();
/**
* Takes the front level, and pushes it to the back.
*/
std::optional<Level> Punt();
/**
* Pull the next level from the specified user to the front of the queue.
* Pop the current level.
*/
std::optional<Level> Dip(std::string username);
/**
* Split the stored level queue into online and offline for printing
*/
PriorityQueso List();
/**
* Report the requester's level's position in the JIT pqueue.
*/
int Position(std::string username);
void SaveState();
void LoadLastState();
private:
bool isValidLevelCode(std::string levelCode);
bool isOnline(Level l);
std::deque<Level> _levels;
std::optional<Level> _current;
Twitch _twitch; // query online state
const size_t maxSize = 15;
};