-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
115 lines (97 loc) · 2.12 KB
/
main.cpp
File metadata and controls
115 lines (97 loc) · 2.12 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <sys/stat.h>
using namespace std;
#include "lib/system/data/DATA.hpp"
#include "lib/system.hpp"
#include "lib/struct-define.hpp"
#include "lib/version.hpp"
#include "lib/readworld.hpp"
#include "lib/checkdata.hpp"
#include "lib/output.hpp"
#include "lib/move.hpp"
#include "lib/endless.hpp"
#include "lib/select.hpp"
int readytorun (int &i)
{
HIDE_CURSOR ();
syscls ();
thread output_thread (dooutput);
output_thread.detach ();
OUTPUT_STOP = 0, AdventureMove::GAMEDIED = 0, AdventureMove::GAMEWIN = 0;
int k = AdventureMove::ctrl (i);
if (k == -1) return 1;
if (k != 0)
{
i = k - 1;
}
SHOW_CURSOR ();
OUTPUT_STOP = 1;
return 0;
}
int adventure ()
{
int k = SelectFunc::func_select ();
if (k == -1) return 0;
if (k == -2)
{
if (check_custom_data (SelectFunc::ipt)) return 1;
read_world (-1, string (SelectFunc::ipt));
int a = 0;
readytorun (a);
return 0;
}
for (int i = k; i <= SelectOutput::PIDMAX; i ++)
{
read_world (i);
if (readytorun (i)) break;
}
SHOW_CURSOR ();
return 0;
}
int endless ()
{
HIDE_CURSOR ();
syscls ();
// thread output_thread (dooutput);
// output_thread.detach ();
OUTPUT_STOP = 0, AdventureMove::GAMEDIED = 0, AdventureMove::GAMEWIN = 0;
int k = Endless::ctrl ();
// if (k == -1) return 1;
SHOW_CURSOR ();
return k;
}
int chapter_start ()
{
int k = ChapterFunc::func_chapter ();
if (k == -1) return 0;
if (k == 0) return adventure ();
if (k == 1) return endless ();
return 0;
}
int main (int argc, char * argv[])
{
if (argc > 1)
{
if (strcmp (argv[1], "version") == 0)
{
version_output ();
return 0;
}
else
{
printf ("Command not found!\n");
return 1;
}
}
if (! checkdata (SelectOutput::PIDMAX))
{
return 1;
}
// return chapter_start ();
return adventure ();
}