forked from akmaldika/Tubes-Alstrukdat-Kel-F
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
165 lines (153 loc) · 4.76 KB
/
main.c
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include <stdio.h>
#include <stdlib.h>
#include "library.h"
#include "Command/CommandGame.h"
int main()
{
/* KAMUS */
ListResep ListRsp;
ListMakanan ListMkn;
ListMakanan ListMakananEXP;
ListMakanan ListDeliveryDone;
SIMULATOR BMO;
Stack Undo, Redo;
Notifikasi Notif;
boolean FlagDelivDone;
boolean FlagMakananEXP;
boolean isActionSucces;
boolean isStartGame;
/* ALGORITMA */
/* Inisiasi program */
SetUpListMakanan(&ListMkn, "Config/Config_Makanan.txt");
CreateLR(&ListRsp);
readListLR(&ListRsp, "Config/Config_Resep.txt");
CreateSim(&BMO, "Config/Config_Peta.txt");
const SIMULATOR InitSim = BMO;
CreateNotifikasi(&Notif);
CreateEmptyStack(&Undo);
CreateEmptyStack(&Redo);
CreateListMakanan(&ListMakananEXP);
CreateListMakanan(&ListDeliveryDone);
splashInitGame();
printf("\nMasukkan command: ");
STARTCOMMAND();
STARTWORD();
// Cek Start command error mcna nerima START sam EXIT, loop sampai benar
commandStartError();
isStartGame = isLineSame(currentLine, "START");
// while loop
while (isStartGame)
{
printf("-- Ketik apapun untuk berlanjut --");
STARTCOMMAND();
STARTWORD();
printf("Notifikasi: \n");
displayNotifikasi(Notif);
CreateNotifikasi(&Notif);
DisplayTIMEFull(WAKTU(BMO));
displayMap(MAP(BMO));
// STARTCOMMAND semua yang diterima kecuali START
printf("\nMasukkan command: ");
STARTCOMMAND();
STARTWORD();
// cek benar salah, loop sampai benar
commandInGameError();
if (isWordSame(currentWord, "HELP"))
{
helpInGame();
}
else if (isWordSame(currentWord, "BUY"))
{
BuyFood(&BMO, ListMkn, &isActionSucces);
if (isActionSucces)
{
min1menitAll(&DELIV(BMO), &INVENTORY(BMO), &FlagDelivDone, &FlagMakananEXP, &EXPIREDFOOD(Notif), &DELIVEREDFOOD(Notif));
NextMin(&WAKTU(BMO));
}
}
else if (isWordSame(currentWord, "MIX"))
{
if (isAdjacent(BMO, 'M')) {
COOKFOOD(&BMO, ListMkn, ListRsp, &Notif, "Mix");
} else {
printf("BNMO tidak berada di area Mix!!\n ");
}
}
else if (isWordSame(currentWord, "CHOP"))
{
if (isAdjacent(BMO, 'C')) {
COOKFOOD(&BMO, ListMkn, ListRsp, &Notif, "Chop");
} else {
printf("BNMO tidak berada di area Chop!!\n ");
}
}
else if (isWordSame(currentWord, "FRY"))
{
if (isAdjacent(BMO, 'F')) {
COOKFOOD(&BMO, ListMkn, ListRsp, &Notif, "Fry");
} else {
printf("BNMO tidak berada di area Fry!!\n ");
}
}
else if (isWordSame(currentWord, "BOIL"))
{
if (isAdjacent(BMO, 'B')) {
COOKFOOD(&BMO, ListMkn, ListRsp, &Notif, "Boil");
} else {
printf("BNMO tidak berada di area Boil!!\n ");
}
}
else if (isWordSame(currentWord, "MOVE"))
{
ADVWORD();
Move(&BMO, currentWord, &isActionSucces);
if (isActionSucces){
min1menitAll(&DELIV(BMO), &INVENTORY(BMO), &FlagDelivDone, &FlagMakananEXP, &EXPIREDFOOD(Notif), &DELIVEREDFOOD(Notif));
NextMin(&WAKTU(BMO));
}
}
else if (isWordSame(currentWord, "WAIT"))
{
WAIT(&BMO, &FlagDelivDone, &FlagMakananEXP, &EXPIREDFOOD(Notif), &DELIVEREDFOOD(Notif));
}
else if (isWordSame(currentWord, "DELIVERY"))
{
DELIVERY(BMO);
}
else if (isWordSame(currentWord, "INVENTORY"))
{
INVENTORYMakanan(BMO);
}
else if (isWordSame(currentWord, "CATALOG"))
{
Catalogue(ListMkn);
}
else if (isWordSame(currentWord, "COOKBOOK"))
{
COOKBOOKFOOD(ListRsp, ListMkn);
}
else if (isWordSame(currentWord, "RECOMMENDATION"))
{
RECOMMENDATION(BMO, ListRsp, ListMkn);
}
else if (isWordSame(currentWord, "UNDO"))
{
undoGame(&BMO, InitSim, &Notif, &Undo, &Redo);
}
else if (isWordSame(currentWord, "REDO"))
{
redoGame(&BMO, &Notif, &Undo, &Redo);
}
else if (isWordSame(currentWord, "EXIT"))
{
isStartGame = false;
}
saveUndoRedoGame(BMO, InitSim, Notif, &Undo, &Redo);
// Atur Notif
}
// until command/currentLine = exit
// splash exit
splashExitGame();
// -program selesai-
return 0;
}