forked from sashavol/Frozlunky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaily.h
99 lines (79 loc) · 2.49 KB
/
daily.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma once
#include "spelunky.h"
#include "seeder.h"
#include "gamedetect.h"
#include "remove_daily.h"
#include "patch_group.h"
#include "new_game_detector.h"
#include "oneplayer_only.h"
#include "game_hooks.h"
#include "custom_hud.h"
#include "frozboards/score_info.h"
#include "frozboards/session.h"
#include <chrono>
#include <map>
#include <vector>
#include <functional>
#define DAILY_INVALID 0
#define DAILY_WAITING 1
#define DAILY_WAITING2 2
#define DAILY_INPROGRESS 3
#define DAILY_COMPLETED 4
#define UPDATE_INTERVAL_MS 100
#define FROZBOARDS_URL ""
#define FROZLUNKY_URL "https://spelunky-fyi.github.io/Frozlunky/"
class DailyInstance {
public:
typedef std::chrono::high_resolution_clock::time_point time_point;
typedef std::map<time_point, Frozboards::TrackedValues> points_data;
private:
time_point waiting_point;
unsigned current_status;
std::shared_ptr<Frozboards::Session> session;
std::shared_ptr<Spelunky> spel;
std::shared_ptr<Seeder> seeder;
std::shared_ptr<GameHooks> hooks;
std::shared_ptr<DerandomizePatch> dp;
std::shared_ptr<PatchGroup> core;
std::shared_ptr<PatchGroup> special;
std::shared_ptr<OnePlayerOnlyPatch> opop;
std::shared_ptr<CustomHudPatch> chp;
NewGameDetector ngd;
GameChangeDetector gcd;
std::string seed;
double score;
bool locked_seed;
bool one_player_only;
std::map<time_point, Frozboards::TrackedValues> points;
Frozboards::TrackedValuesSet important;
private:
void submit_score(bool success);
Frozboards::TrackedValues track_values();
bool validate_points();
void progress_cycle();
void waiting_cycle();
Frozboards::TrackedValues append_lastlevel_score();
public:
DailyInstance(std::shared_ptr<Frozboards::Session> session,
std::shared_ptr<Spelunky> spel,
std::shared_ptr<Seeder> seeder,
std::shared_ptr<DerandomizePatch> dp,
std::shared_ptr<CustomHudPatch> chp,
std::shared_ptr<PatchGroup> core_patches,
std::shared_ptr<PatchGroup> special_patches);
~DailyInstance();
void cycle();
unsigned status();
double total_score();
void force_end() {
this->current_status = DAILY_INVALID;
}
std::shared_ptr<Frozboards::Session> get_session() {
return this->session;
}
private:
static void ForceLeaderboardStatus(bool value);
static void OnLeaderboard(std::function<void(bool)> result_callback);
public:
static void Available(std::shared_ptr<Spelunky> spel, std::shared_ptr<DerandomizePatch> dp, std::function<void(bool)> result_callback);
};