C++#include <cstdio>
#include <conio.h>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <windows.h>
// variable
char ch; // for input
int op; // to do what : 1.New Day 2.Shop 3.How to play 4.Leave
int chosen = 1; // main interface
int D/*which day*/, v = 114/*money*/;
int T/*time past*/, Now_T/*time now*/, Start_T/*when start*/;
int T_max = 300; // it must less than 10000
// change it to change how many seconds a day for the game
int wh = 1; // 1.hall 2.pancake room 3.snack room
int wh_ = 1;
int end; // end = -1 means end one day
int place = 1; // how many customer places
int place_cost[5] = {0, 50, 200}; // how much to improve
int plate = 0; // plate level
int plate_cost[5] = {50, 100, 500}; // how much to improve
int max_level; // volume level
int max_cost[5] = {30, 70, 150}; // how much to improve
int store_level; // store level
int store_cost[5] = {50, 200, 800}; // how much to improve
int max_pancake[5] = {2, 3, 5, 8}, max_snack[5] = {2, 4, 8, 15}; // volume
int sell[5][5] = {{0, 15, 3, 5}, {0, 20, 5, 8}, {0, 25, 7, 13}, {0, 35, 10, 15}};
int len; // how many customers
int add[10010][5]; // when to add customer
int cus_need[5][5]; // what they need
int cus_satisfied[5][5]; // whether the demand satisfied
char filler[][20] = {"cake", "beef", "cucumber", "sauce", "fry seasoning", "tomato sauce"}; // name of filler
int t[5], start_t[5]; // how long they can wait
char room[][20] = {"", "hall", "pancake room", "snack room"}; // name of rooms
char food[][20] = {"", "pancake", "cola", "chips"}; // name of food
int s[10] = {0, T_max / 15, T_max / 7, T_max / 2}; // how many customers per day
int left_pancake, left_cola, left_chips; // how many goods left
// pancake
struct pancake_ {
int get[10];
int sum() {
return get[1] + get[2] + get[3] + get[4] + get[5];
}
pancake_() { memset(get, 0, sizeof(get)); }
int operator == (const pancake_ &other) {
for (int i = 0; i < 6; i++)
if (get[i] != other.get[i]) return 0;
return 1;
}
} pancake, pancake_for_sell[10], pancake_need[10];
int pick; // whether picked
int chose; // whether chosen
// snack
int box, chips, chips_sum;
int cup, cola, cola_sum;
// store
int st_pancake[10];
int st_pancake_cost[10] = {1, 5, 1, 1, 1, 1}, st_pancake_get[10] = {1, 2, 2, 5, 3, 5};
int cup_cost = 1, cup_get = 10, cola_cost = 3, cola_get = 2;
int box_cost = 1, box_get = 15, potato_cost = 2, potato_get = 1;
int st_cup, st_cola, st_box, st_potato, st_chips;
int st_max_pancake[5][10] = {
{5, 5, 5, 20, 20, 20},
{10, 15, 15, 40, 50, 40},
{20, 30, 30, 70, 80, 70},
{30, 45, 45, 100, 100, 100}};
int st_max_cup[5] = {10, 20, 40, 70};
int st_max_cola[5] = {5, 12, 28, 40};
int st_max_box[5] = {10, 20, 40, 70};
int st_max_potato[5] = {5, 10, 15, 20};
int st_max_chips[5] = {5, 15, 35, 50};
void Welcome();
int Main_Interface();
void How_to_play();
void Store();
void NewDay();
void Shop();
void End();
void NewDay_print();
void NewDay_print_1();
void NewDay_print_2();
void NewDay_print_3();
void NewDay_print_4();
void NewDay_print_5();
void NewDay_print_6();
void NewDay_wk1();
void NewDay_wk2();
void NewDay_wk3();
void NewDay_wk4();
void NewDay_wk5();
void NewDay_wk6();
int main(void) {
srand(time(nullptr));
Welcome();
while (1) {
op = Main_Interface();
if (op == 1) D++, NewDay();
else if (op == 2) Shop();
else if (op == 3) Store();
else if (op == 4) How_to_play();
else break;
}
End();
return 0;
}
void NewDay() {
wh = wh_ = end = 1;
memset(add, 0, sizeof(add));
int cus_sum = s[place];
add[1][0] = 1;
if (rand() % 2) add[1][1] = 1; // the
if (!(rand() % 3)) add[1][2] = 1; // possibility
if (!(rand() % 6)) add[1][3] = 1; // of food
while (!add[1][1] && !add[1][2] && !add[1][3]) {
if (rand() % 2) add[1][1] = 1;
if (!(rand() % 3)) add[1][2] = 1;
if (!(rand() % 6)) add[1][3] = 1;
}
for (int i = 1; i < cus_sum; i++) {
int add_t = i * T_max / cus_sum + rand() % T_max / (cus_sum >> 1) + 1;
while (add_t < 1 || add_t > T_max)
add_t = i * T_max / cus_sum + rand() % T_max / (cus_sum >> 1) + 1;
add[add_t][0] = 1;
if (rand() % 2) add[add_t][1] = 1; // the
if (!(rand() % 3)) add[add_t][2] = 1; // possibility
if (!(rand() % 6)) add[add_t][3] = 1; // of food
while (!add[add_t][1] && !add[add_t][2] && !add[add_t][3]) {
if (rand() % 2) add[add_t][1] = 1;
if (!(rand() % 3)) add[add_t][2] = 1;
if (!(rand() % 6)) add[add_t][3] = 1;
}
} // add customer
T = 0; Start_T = time(nullptr);
NewDay_print();
while (T <= T_max && ~end) {
if (_kbhit()) {
ch = getch();
if (wh == 1)
NewDay_wk1();
else if (wh == 2)
NewDay_wk2();
else if (wh == 3)
NewDay_wk3();
else if (wh == 4)
NewDay_wk4();
else if (wh == 5)
NewDay_wk5();
else
NewDay_wk6();
NewDay_print();
}
Now_T = time(nullptr);
if (Now_T != T + Start_T) {
T = Now_T - Start_T, NewDay_print();
if (add[T][0])
if (len < place) {
len++;
start_t[len] = Now_T;
for (int i = 1; i < 4; i++)
cus_need[len][i] = add[T][i];
memset(cus_satisfied[len], 0, sizeof(cus_satisfied[len]));
t[len] = rand() % 20 + 50;
if (cus_need[len][1]) {
pancake_need[len] = pancake_();
while (!(pancake_need[len].sum())) { // possibility of filler
if (rand() % 3)
pancake_need[len].get[1] = 1;
if (rand() % 2)
pancake_need[len].get[2] = 1;
if (rand() % 2)
pancake_need[len].get[3] = 1;
if (rand() % 3 == 1)
pancake_need[len].get[4] = 1;
if (rand() % 2)
pancake_need[len].get[5] = 1;
}
}
}
}
}
len = 0;
return;
}
void NewDay_print() {
int t_now = time(nullptr);
while (len && (t_now > start_t[len] + t[len] || cus_need[len][1] + cus_need[len][2] + cus_need[len][3] == cus_satisfied[len][1] + cus_satisfied[len][2] + cus_satisfied[len][3])) {
if (cus_need[len][1] + cus_need[len][2] + cus_need[len][3] == cus_satisfied[len][1] + cus_satisfied[len][2] + cus_satisfied[len][3])
for (int j = 1; j < 4; j++)
if (cus_satisfied[len][j])
v += sell[plate][j];
len--;
}
for (int i = len - 1; i > 0; i--) { // delete timeout/finished demand
if (cus_need[i][1] + cus_need[i][2] + cus_need[i][3] == cus_satisfied[i][1] + cus_satisfied[i][2] + cus_satisfied[i][3]) {
for (int j = 1; j < 4; j++)
if (cus_satisfied[i][j])
v += sell[plate][j];
for (int j = i; j < len; j++) {
t[j] = t[j + 1], start_t[j] = start_t[j + 1];
for (int k = 1; k < 4; k++)
cus_need[j][k] = cus_need[j + 1][k];
for (int k = 1; k < 4; k++)
cus_satisfied[j][k] = cus_satisfied[j + 1][k];
pancake_need[j] = pancake_need[j + 1];
}
len--;
}
if (t_now > start_t[i] + t[i]) {
for (int j = i; j < len; j++) {
t[j] = t[j + 1], start_t[j] = start_t[j + 1];
for (int k = 1; k < 4; k++)
cus_need[j][k] = cus_need[j + 1][k];
pancake_need[j] = pancake_need[j + 1];
}
len--;
}
}
system("cls");
puts(" Shawarma Legend"), puts("");
printf(" Day %d || Time last : %ds || coin : %d\n", D, T_max - T, v);
if (wh <= 3) {
putchar(' ');
for (int i = 0, maxi = strlen(room[wh]) + 7; i < maxi; i++)
putchar('-');
putchar('\n');
printf(" room : %s\n", room[wh]);
putchar(' ');
for (int i = 0, maxi = strlen(room[wh]) + 7; i < maxi; i++)
putchar('-');
putchar('\n');
} else puts(" ------------------------------------------");
// customer
printf(" Menu : pancake $%d cola $%d chips $%d\n", sell[plate][1], sell[plate][2], sell[plate][3]);
puts(" ------------------------------------------");
printf(" Limit : pancake %d/%d cola %d/%d chips %d/%d\n", left_pancake, max_pancake[max_level], left_cola, max_snack[max_level], left_chips, max_snack[max_level]);
puts(" ------------------------------------------");
printf(" Customer table (□means not provided √means provided)\n\n");
for (int i = 1; i <= place; i++) {
printf(" place %d : ", i);
if (i > len) puts("No customer");
else {
printf("(time last : %ds || need :", t[i] + start_t[i] - t_now);
for (int j = 1; j < 4; j++) {
if (cus_need[i][j]) {
printf(" %s", food[j]);
if (cus_satisfied[i][j]) printf("√");
else printf("□");
}
}
putchar(')');
putchar('\n');
if (cus_need[i][1] && !cus_satisfied[i][1] && (wh == 1 || wh == 2 || wh == 4)) {
printf(" pancake filler : ");
for (int k = 1, first = 1; k < 6; k++)
if (pancake_need[i].get[k])
(first || printf(", ")), printf("%s", filler[k]), first = 0;
putchar('\n');
}
}
}
puts(" --------------------------------------------------------------------");
if (wh == 1) NewDay_print_1();
else if (wh == 2) NewDay_print_2();
else if (wh == 3) NewDay_print_3();
else if (wh == 4) NewDay_print_4();
else if (wh == 5) NewDay_print_5();
else NewDay_print_6();
return;
}
void NewDay_print_1() {
puts(" Operations: (Please use ↑↓←→or enter)");
puts("");
puts(" sell :");
if (wh_ == 1) {
puts(" *************** ------------- -------------");
puts(" * pancake * | cola | | chips |");
printf(" * sum : %-3d * | sum : %-3d | | sum : %-3d |\n", left_pancake, left_cola, left_chips);
puts(" *************** ------------- -------------");
} else if (wh_ == 2) {
puts(" ------------- *************** -------------");
puts(" | pancake | * cola * | chips |");
printf(" | sum : %-3d | * sum : %-3d * | sum : %-3d |\n", left_pancake, left_cola, left_chips);
puts(" ------------- *************** -------------");
} else if (wh_ == 3) {
puts(" ------------- ------------- ***************");
puts(" | pancake | | cola | * chips *");
printf(" | sum : %-3d | | sum : %-3d | * sum : %-3d *\n", left_pancake, left_cola, left_chips);
puts(" ------------- ------------- ***************");
} else {
puts(" ------------- ------------- -------------");
puts(" | pancake | | cola | | chips |");
printf(" | sum : %-3d | | sum : %-3d | | sum : %-3d |\n", left_pancake, left_cola, left_chips);
puts(" ------------- ------------- -------------");
}
puts("");
puts(" move to :");
if (wh_ < 4) {
puts(" ------------- ------------- -------------");
puts(" | pancake | | snack | | end |");
puts(" | room | | room | -------------");
puts(" ------------- -------------");
} else if (wh_ == 4) {
puts(" *************** ------------- -------------");
puts(" * pancake * | snack | | end |");
puts(" * room * | room | -------------");
puts(" *************** ------------- ");
} else if (wh_ == 5) {
puts(" ------------- *************** -------------");
puts(" | pancake | * snack * | end |");
puts(" | room | * room * -------------");
puts(" ------------- ***************");
} else {
puts(" ------------- ------------- ***************");
puts(" | pancake | | snack | * end *");
puts(" | room | | room | ***************");
puts(" ------------- -------------");
}
return;
}
void NewDay_print_2() {
puts(" Operators : (Please use ↑↓←→or enter)");
puts(" ----------------");
printf(" | ");
if (wh_ == 1)
pancake.get[0] || !st_pancake[0] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("place the cake");
if (wh_ == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
puts(" |");
puts(" ----------------");
puts(" ------------------------");
puts(" Table :");
for (int i = 0; i < 6; i++) {
putchar(' ');
if (i && wh_ == i + 1) {
if (!pancake.get[i] && !pick && st_pancake[i])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
else printf(" ");
printf(" %s(left %d) ", filler[i], st_pancake[i]);
if (pancake.get[i]) puts("(get)");
else putchar('\n');
}
puts(" ------------------------");
puts(" --------------- -----------------");
printf(" | ");
if (wh_ == 7)
pick || !pancake.get[0] || !pancake.sum() ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("pick the cake");
if (wh_ == 7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
printf(" | | ");
if (wh_ == 8)
!pick ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("pack and finish");
if (wh_ == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
if (pick) puts(" | (already)");
else puts(" |");
puts(" --------------- -----------------");
puts(" --------------");
printf(" | ");
if (wh_ == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("back to hall");
if (wh_ == 9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
puts(" |");
printf(" --------------");
return;
}
void NewDay_print_3() {
puts(" Chips workbench :"),
printf(" (left : box %d chips %d)\n\n", st_box, st_chips);
puts("");
if (wh_ < 4) {
if (wh_ == 1) {
puts(" ************ ---------- ----------");
puts(" * box(bag) * | chips | | finish |");
if (box) printf(" * (get) *");
else printf(" * *");
if (chips) printf(" | (get) |");
else printf(" | |");
puts(" ----------");
puts(" ************ ----------");
} else if (wh_ == 2) {
puts(" ---------- ************ ---------- ");
puts(" | box(bag) | * chips * | finish |");
if (box) printf(" | (get) |");
else printf(" | |");
if (chips) printf(" * (get) *");
else printf(" * *");
puts(" ----------");
puts(" ---------- ************");
} else {
puts(" ---------- ---------- ************");
puts(" | box(bag) | | chips | * finish *");
if (box) printf(" | (get) |");
else printf(" | |");
if (chips) printf(" | (get) |");
else printf(" | |");
puts(" ************");
puts(" ---------- ----------");
}
} else {
puts(" ---------- ---------- ----------");
puts(" | box(bag) | | chips | | finish |");
if (box) printf(" | (get) |");
else printf(" | |");
if (chips) printf(" | (get) |");
else printf(" | |");
puts(" ----------");
puts(" ---------- ----------");
}
puts(""), puts(" ------------------------------------------------");
puts(" Cola workbench :"),
printf(" (left : cup %d cola %d)\n\n", st_cup, st_cola);
if (wh_ > 3 && wh_ < 7) {
if (wh_ == 4) {
puts(" ************ ---------- ----------");
puts(" * cup * | cola | | finish |");
if (cup) printf(" * (get) *");
else printf(" * *");
if (cola) printf(" | (get) |");
else printf(" | |");
puts(" ----------");
puts(" ************ ----------");
} else if (wh_ == 5) {
puts(" ---------- ************ ---------- ");
puts(" | cup | * cola * | finish |");
if (cup) printf(" | (get) |");
else printf(" | |");
if (cola) printf(" * (get) *");
else printf(" * *");
puts(" ----------");
puts(" ---------- ************");
} else {
puts(" ---------- ---------- ************");
puts(" | cup | | cola | * finish *");
if (cup) printf(" | (get) |");
else printf(" | |");
if (cola) printf(" | (get) |");
else printf(" | |");
puts(" ************");
puts(" ---------- ----------");
}
} else {
puts(" ---------- ---------- ----------");
puts(" | cup | | cola | | finish |");
if (cup) printf(" | (get) |");
else printf(" | |");
if (cola) printf(" | (get) |");
else printf(" | |");
puts(" ----------");
puts(" ---------- ----------");
}
puts(""), puts(" ------------------------------------------------");
puts("");
if (wh_ == 7) {
puts(" ****************");
puts(" * back to hall *");
puts(" ****************");
} else {
puts(" --------------");
puts(" | back to hall |");
puts(" --------------");
}
return;
}
void NewDay_print_4() {
puts(" Table : (Please use ↑↓or enter)");
if (!left_pancake) puts(" No pancake left!!");
if (!chose && wh_ > left_pancake + 1) wh_ = left_pancake + 1;
if (wh_ > left_pancake + len + 3) {
if (!len) chose = 0, wh_ = left_pancake + len + 1;
else wh_ = left_pancake + len + 3;
}
for (int i = 1; i <= left_pancake; i++) {
if (wh_ == i)
len ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf(" ● "),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf("%d : ", i);
for (int j = 1, first = 1; j < 6; j++)
if (pancake_for_sell[i].get[j])
(first || printf(", ")), printf("%s", filler[j]), first = 0;
if (i == chose) printf(" (chosen)");
puts("");
}
puts(" ---------------------------------------");
if (wh_ == left_pancake + 1)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ● "),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
puts("back to hall");
if (chose) {
puts(" ---------------------------------------");
puts(" Sell it to : ");
for (int i = 1; i <= len; i++) {
if (wh_ == i + left_pancake + 1) {
if (cus_need[i][1] && pancake_for_sell[chose] == pancake_need[wh_ - left_pancake - 1])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
printf(" ● "),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else printf(" ");
printf("customer %d\n", i);
}
if (wh_ == left_pancake + len + 2)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ● "),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
puts("step back");
if (wh_ == left_pancake + len + 3)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ● "),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
puts("throw away");
}
return;
}
void NewDay_print_5() {
printf(" left : %d", left_cola);
puts(left_cola ? "" : " (There's no cola left!)");
puts(" ---------------------------------");
puts(" sell cola to :");
puts("");
if (wh_ > len + 1) wh_ = len + 1;
for (int i = 1; i <= len; i++) {
putchar(' ');
if (wh_ == i) {
if (cus_need[i][2] && !cus_satisfied[i][2] && left_cola)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
else printf(" ");
putchar(' ');
printf("customer %d\n\n", i);
}
putchar(' ');
if (wh_ == len + 1)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
putchar(' ');
puts("back to hall");
return;
}
void NewDay_print_6() {
printf(" left : %d", left_chips);
puts(left_cola ? "" : " (There's no chips left!)");
puts(" ---------------------------------");
puts(" sell chips to :");
puts("");
if (wh_ > len + 1) wh_ = len + 1;
for (int i = 1; i <= len; i++) {
putchar(' ');
if (wh_ == i) {
if (cus_need[i][3] && !cus_satisfied[i][3] && left_chips)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
else printf(" ");
putchar(' ');
printf("customer %d\n\n", i);
}
putchar(' ');
if (wh_ == len + 1)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
putchar(' ');
puts("back to hall");
return;
}
void NewDay_wk1() {
if (ch == 72) {
if (wh_ > 3) wh_ -= 3;
}
if (ch == 80) {
if (wh_ < 4) wh_ += 3;
}
if (ch == 75) {
if (wh_ % 3 != 1) wh_--;
}
if (ch == 77) {
if (wh_ % 3) wh_++;
}
if (ch == 13) {
if (wh_ == 6)
end = -1;
else if (wh_ == 5)
wh = 3, wh_ = 1;
else if (wh_ == 4)
wh = 2, wh_ = 1;
else if (wh_ == 1)
wh = 4, wh_ = 1;
else if (wh_ == 2)
wh = 5, wh_ = 1;
else
wh = 6, wh_ = 1;
}
return;
}
void NewDay_wk2() {
if (ch == 72) {
if (wh_ > 1) wh_--;
if (wh_ == 8 || wh_ == 7) wh_--;
}
if (ch == 80) {
if (wh_ < 9) wh_++;
if (wh_ == 8) wh_++;
}
if (ch == 75 && wh_ == 8) wh_ = 7;
if (ch == 77 && wh_ > 6) wh_ = 8;
if (ch == 13) {
if (wh_ == 9) wh = 1, wh_ = 4;
else if (wh_ == 8) {
if (!pick) {
MessageBox(NULL, "There's no pancake!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (left_pancake >= max_pancake[max_level]) {
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
pick = 0;
pancake.get[0] = 0;
pancake_for_sell[++left_pancake] = pancake, pancake = pancake_();
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
} else if (wh_ == 7) {
if (pancake.get[0])
if (pancake.sum()) pick = 1;
else MessageBox(NULL, "Please add something!", "tips", MB_OK | MB_ICONINFORMATION);
else MessageBox(NULL, "There's no pancake!", "tips", MB_OK | MB_ICONINFORMATION);
} else if (wh_ == 1) {
if (pick) {
MessageBox(NULL, "You have one pancake to finish!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (!st_pancake[0]) {
MessageBox(NULL, "No cake left!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (pancake.get[0])
MessageBox(NULL, "You have added it!", "tips", MB_OK | MB_ICONINFORMATION);
else
st_pancake[0]--, pancake.get[0] = 1;
} else {
if (pick) {
MessageBox(NULL, "You have one pancake to finish!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (!pancake.get[0]) {
MessageBox(NULL, "You should place the pancake first!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (!st_pancake[wh_ - 1]) {
MessageBox(NULL, "No filler left!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (pancake.get[wh_ - 1])
MessageBox(NULL, "You have added it!", "tips", MB_OK | MB_ICONINFORMATION);
else
st_pancake[wh_ - 1]--, pancake.get[wh_ - 1] = 1;
}
}
return;
}
void NewDay_wk3() {
if (ch == 72) {
if (wh_ > 3) wh_ -= 3;
}
if (ch == 80) {
if (wh_ < 5) wh_ += 3;
else wh_ = 7;
}
if (ch == 75) {
if (wh_ % 3 != 1) wh_--;
}
if (ch == 77 && wh_ != 7) {
if (wh_ % 3) wh_++;
}
if (ch == 13) {
if (wh_ == 7) {
wh_ = 5, wh = 1;
return;
}
if (wh_ == 1) {
if (!st_box) {
MessageBox(NULL, "No box left!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (!box) box = 1, st_box--;
else MessageBox(NULL, "No place for new box!", "tips", MB_OK | MB_ICONINFORMATION);
}
if (wh_ == 2) {
if (!st_chips) {
MessageBox(NULL, "No chips left!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (!box) MessageBox(NULL, "There's no box on table!", "tips", MB_OK | MB_ICONINFORMATION);
else if (!chips) chips = 1, box = 0, st_chips--;
else MessageBox(NULL, "No place for new chips!", "tips", MB_OK | MB_ICONINFORMATION);
}
if (wh_ == 3) {
if (!chips) MessageBox(NULL, "There's no finished chips!", "tips", MB_OK | MB_ICONINFORMATION);
else if (left_chips >= max_snack[max_level])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
chips = 0, left_chips++, MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
}
if (wh_ == 4) {
if (!st_cup) {
MessageBox(NULL, "No cup left!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (!cup) cup = 1, st_cup--;
else MessageBox(NULL, "No place for new cup!", "tips", MB_OK | MB_ICONINFORMATION);
}
if (wh_ == 5) {
if (!st_cola) {
MessageBox(NULL, "No cola left!", "tips", MB_OK | MB_ICONINFORMATION);
return;
}
if (!cup) MessageBox(NULL, "There's no cup on table!", "tips", MB_OK | MB_ICONINFORMATION);
else if (!cola) cola = 1, cup = 0, st_cola--;
else MessageBox(NULL, "No place for new cola!", "tips", MB_OK | MB_ICONINFORMATION);
}
if (wh_ == 6) {
if (!cola) MessageBox(NULL, "There's no finished cola!", "tips", MB_OK | MB_ICONINFORMATION);
else if (left_cola >= max_snack[max_level])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
cola = 0, left_cola++, MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
}
}
return;
}
void NewDay_wk4() {
if (ch == 72) {
if (wh_ > 1 && !chose) wh_--;
if (wh_ > left_pancake + 1) wh_--;
}
if (ch == 80) {
if (!chose && wh_ <= left_pancake) wh_++;
if (chose && wh_ <= left_pancake + len + 2) wh_++;
}
if (ch == 13) {
if (wh_ <= left_pancake) {
if (!len) return;
chose = wh_;
wh_ = left_pancake + 2;
} else if (wh_ == left_pancake + 1) {
wh = wh_ = 1; chose = 0;
return;
} else if (wh_ == left_pancake + len + 2) {
wh_ = 1; chose = 0;
return;
} else if (wh_ == left_pancake + len + 3) {
wh_ = 1; chose = 0;
for (int i = chose; i < left_pancake; i++)
pancake_for_sell[i] = pancake_for_sell[i + 1];
left_pancake--;
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
return;
} else {
static int cus = wh_ - left_pancake - 1;
if (!(pancake_for_sell[chose] == pancake_need[cus]))
MessageBox(NULL, "Mismatch!", "tips", MB_OK | MB_ICONINFORMATION);
else {
for (int i = chose; i < left_pancake; i++)
pancake_for_sell[i] = pancake_for_sell[i + 1];
left_pancake--;
chose = 0, wh_ = 1, cus_satisfied[cus][1] = 1;
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
}
}
}
return;
}
void NewDay_wk5() {
if (ch == 72) {
if (wh_ > 1) wh_--;
}
if (ch == 80) {
if (wh_ <= len) wh_++;
}
if (ch == 13) {
if (wh_ == len + 1) wh = 1, wh_ = 2;
else if (cus_need[wh_][2] && !cus_satisfied[wh_][2] && left_cola) {
left_cola--;
cus_satisfied[wh_][2] = 1;
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
}
}
return;
}
void NewDay_wk6() {
if (ch == 72) {
if (wh_ > 1) wh_--;
}
if (ch == 80) {
if (wh_ <= len) wh_++;
}
if (ch == 13) {
if (wh_ == len + 1) wh = 1, wh_ = 3;
else if (cus_need[wh_][3] && !cus_satisfied[wh_][3] && left_chips) {
left_chips--;
cus_satisfied[wh_][3] = 1;
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
}
}
return;
}
void Shop() {
int Shop_wh = 1;
system("cls");
puts(" Shawarma Legend"), puts("");
puts(" Shop"); puts(""); puts(" Please use ↑↓or enter"); puts("");
printf(" coin : %d\n\n", v);
printf(" Place level : %d\n\n", place);
if (place == 3) {
putchar(' ');
if (Shop_wh == 1)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 1) {
if (v < place_cost[place])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", place_cost[place]); puts(""); puts("");
}
printf(" Plate level : %d\n\n", plate);
if (plate == 3) {
putchar(' ');
if (Shop_wh == 2)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 2) {
if (v < plate_cost[plate])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", plate_cost[plate]); puts(""); puts("");
}
printf(" Volume level : %d\n\n", max_level);
if (max_level == 3) {
putchar(' ');
if (Shop_wh == 3)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 3) {
if (v < max_cost[max_level])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", max_cost[max_level]); puts(""); puts("");
}
printf(" Store level : %d\n\n", store_level);
if (max_level == 3) {
putchar(' ');
if (Shop_wh == 4)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 4) {
if (v < store_cost[store_level])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", store_cost[store_level]); puts(""); puts("");
}
if (Shop_wh == 5) {
putchar(' ');
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
puts(" Leave");
} else {
puts(" Leave");
}
while (1)
if (_kbhit()) {
ch = getch();
if (ch == 72 && Shop_wh > 1)
Shop_wh--;
if (ch == 80 && Shop_wh < 5)
Shop_wh++;
if (ch == 13) {
if (Shop_wh == 1) {
if (place == 3)
MessageBox(NULL, "You have reached the highest level!", "tips", MB_OK | MB_ICONINFORMATION);
else if (place_cost[place] > v)
MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= place_cost[place++], MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
} else if (Shop_wh == 2) {
if (plate == 3)
MessageBox(NULL, "You have reached the highest level!", "tips", MB_OK | MB_ICONINFORMATION);
else if (plate_cost[plate] > v)
MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= plate_cost[plate++], MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
} else if (Shop_wh == 3) {
if (max_level == 3)
MessageBox(NULL, "You have reached the highest level!", "tips", MB_OK | MB_ICONINFORMATION);
else if (max_cost[max_level] > v)
MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= max_cost[max_level++], MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
} else if (Shop_wh == 4) {
if (store_level == 3)
MessageBox(NULL, "You have reached the highest level!", "tips", MB_OK | MB_ICONINFORMATION);
else if (store_cost[store_level] > v)
MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= store_cost[store_level++], MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);
} else
return;
}
system("cls");
puts(" Shawarma Legend"), puts("");
puts(" Shop"); puts(""); puts(" Please use ↑↓or enter"); puts("");
printf(" coin : %d\n\n", v);
printf(" Place level : %d\n\n", place);
if (place == 3) {
putchar(' ');
if (Shop_wh == 1)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 1) {
if (v < place_cost[place])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", place_cost[place]); puts(""); puts("");
}
printf(" Plate level : %d\n\n", plate);
if (plate == 3) {
putchar(' ');
if (Shop_wh == 2)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 2) {
if (v < plate_cost[plate])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", plate_cost[plate]); puts(""); puts("");
}
printf(" Volume level : %d\n\n", max_level);
if (max_level == 3) {
putchar(' ');
if (Shop_wh == 3)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 3) {
if (v < max_cost[max_level])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", max_cost[max_level]); puts(""); puts("");
}
printf(" Store level : %d\n\n", store_level);
if (store_level == 3) {
putchar(' ');
if (Shop_wh == 4)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED),
printf("●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else putchar(' '), putchar(' ');
puts(" You have reached the highest level"); puts(""); puts("");
} else {
putchar(' ');
if (Shop_wh == 4) {
if (v < store_cost[store_level])
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
else
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
} else putchar(' '), putchar(' ');
printf(" Upgrade cost $%d\n", store_cost[store_level]); puts(""); puts("");
}
if (Shop_wh == 5) {
putchar(' ');
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
printf("●");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
puts(" Leave");
} else {
puts(" Leave");
}
}
return;
}
void Store() {
int Store_wh = 0;
system("cls");
puts(" Shawarma Legend"), puts("");
printf(" Store (Please use ↑↓or enter) coin : %d\n", v);
puts(" ----------------------------------------------------");
puts(" Pancake :");
for (int i = 0; i < 6; i++) {
puts("");
printf(" %s (left %d | limit %d)\n", filler[i], st_pancake[i], st_max_pancake[store_level][i]);
if (Store_wh == i)
v < st_pancake_cost[i] || st_pancake[i] >= st_max_pancake[store_level][i] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * %s\n", st_pancake_cost[i], st_pancake_get[i], filler[i]);
}
puts(" --------------------------------------");
puts(" Cola :"); puts("");
if (Store_wh == 6)
v < cup_cost || st_cup >= st_max_cup[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * cup(left : %d | limit %d)\n", cup_cost, cup_get, st_cup, st_max_cup[store_level]);
puts("");
if (Store_wh == 7)
v < cola_cost || st_cola >= st_max_cola[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * cola(left : %d | limit %d)\n", cola_cost, cola_get, st_cola, st_max_cola[store_level]);
puts(" --------------------------------------");
puts(" Chips :"); puts("");
if (Store_wh == 8)
v < box_cost || st_box >= st_max_box[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * box(left : %d | limit %d)\n", box_cost, box_get, st_box, st_max_box[store_level]);
puts("");
if (Store_wh == 9)
v < potato_cost || st_potato >= st_max_potato[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * potato(left : %d | limit %d)\n", potato_cost, potato_get, st_potato, st_max_potato[store_level]);
puts("");
if (Store_wh == 10)
!st_potato || st_chips >= st_max_chips[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" 1 * potato → 2 * chips(left : %d | limit %d)\n", st_chips, st_max_chips[store_level]);
puts(" --------------------------------------");
if (Store_wh == 11)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" Leave");
while (1)
if (_kbhit()) {
ch = getch();
if (ch == 72 && Store_wh > 0)
Store_wh--;
else if (ch == 72 && !Store_wh)
Store_wh = 11;
if (ch == 80 && Store_wh < 11)
Store_wh++;
else if (ch == 80 && Store_wh == 11)
Store_wh = 0;
if (ch == 13) {
if (Store_wh == 6) {
if (v < cup_cost) MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else if (st_cup >= st_max_cup[store_level])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= cup_cost, st_cup += cup_get,
(st_cup > st_max_cup[store_level]) && (st_cup = st_max_cup[store_level]),
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);;
} else if (Store_wh == 7) {
if (v < cola_cost) MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else if (st_cola >= st_max_cola[store_level])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= cola_cost, st_cola += cola_get,
(st_cola > st_max_cola[store_level]) && (st_cola = st_max_cola[store_level]),
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);;
} else if (Store_wh == 8) {
if (v < box_cost) MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else if (st_box >= st_max_box[store_level])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= box_cost, st_box += box_get,
(st_box > st_max_box[store_level]) && (st_box = st_max_box[store_level]),
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);;
} else if (Store_wh == 9) {
if (v < potato_cost) MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else if (st_potato >= st_max_potato[store_level])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= potato_cost, st_potato += potato_get,
(st_potato > st_max_potato[store_level]) && (st_potato = st_max_potato[store_level]),
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);;
} else if (Store_wh == 10) {
if (!st_potato) MessageBox(NULL, "Potato is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else if (st_chips >= st_max_chips[store_level])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
st_potato--, st_chips += 2,
(st_chips > st_max_chips[store_level]) && (st_chips = st_max_chips[store_level]),
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);;
} else if (Store_wh == 11) {
return;
} else {
if (v < st_pancake_cost[Store_wh]) MessageBox(NULL, "Your money is not enough!", "tips", MB_OK | MB_ICONINFORMATION);
else if (st_pancake[Store_wh] >= st_max_pancake[store_level][Store_wh])
MessageBox(NULL, "Over limit!", "tips", MB_OK | MB_ICONINFORMATION);
else
v -= st_pancake_cost[Store_wh], st_pancake[Store_wh] += st_pancake_get[Store_wh],
(st_pancake[Store_wh] > st_max_pancake[store_level][Store_wh]) && (st_pancake[Store_wh] = st_max_pancake[store_level][Store_wh]),
MessageBox(NULL, "Successfully completed!", "tips", MB_OK | MB_ICONINFORMATION);;
}
}
system("cls");
puts(" Shawarma Legend"), puts("");
printf(" Store (Please use ↑↓or enter) coin : %d\n", v);
puts(" ----------------------------------------------------");
puts(" Pancake :");
for (int i = 0; i < 6; i++) {
puts("");
printf(" %s (left %d | limit %d)\n", filler[i], st_pancake[i], st_max_pancake[store_level][i]);
if (Store_wh == i)
v < st_pancake_cost[i] || st_pancake[i] >= st_max_pancake[store_level][i] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * %s\n", st_pancake_cost[i], st_pancake_get[i], filler[i]);
}
puts(" --------------------------------------");
puts(" Cola :"); puts("");
if (Store_wh == 6)
v < cup_cost || st_cup >= st_max_cup[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * cup(left : %d | limit %d)\n", cup_cost, cup_get, st_cup, st_max_cup[store_level]);
puts("");
if (Store_wh == 7)
v < cola_cost || st_cola >= st_max_cola[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * cola(left : %d | limit %d)\n", cola_cost, cola_get, st_cola, st_max_cola[store_level]);
puts(" --------------------------------------");
puts(" Chips :"); puts("");
if (Store_wh == 8)
v < box_cost || st_box >= st_max_box[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * box(left : %d | limit %d)\n", box_cost, box_get, st_box, st_max_box[store_level]);
puts("");
if (Store_wh == 9)
v < potato_cost || st_potato >= st_max_potato[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" $%d → %d * potato(left : %d | limit %d)\n", potato_cost, potato_get, st_potato, st_max_potato[store_level]);
puts("");
if (Store_wh == 10)
!st_potato || st_chips >= st_max_chips[store_level] ? SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED) : SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" 1 * potato → 2 * chips(left : %d | limit %d)\n", st_chips, st_max_chips[store_level]);
puts(" --------------------------------------");
if (Store_wh == 11)
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN),
printf(" ●"),
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
else printf(" ");
printf(" Leave");
}
return;
}
void Welcome() {
system("color 11&mode con cols=70 lines=41&title Shawarma Legend");
puts(""); puts(""); puts(""); puts(""); puts("");
printf(" Welcome"); Sleep(500);
printf(" to..."); Sleep(500);
puts(""); puts(""); puts(""); puts("");
printf(" Shawarma Legend!"); Sleep(1000);
return;
}
int Main_Interface() {
system("cls");
puts(" Shawarma Legend"), puts("");
puts(" Main Interface (Please use ↑↓or enter)");
puts("");
printf(" coin : %d\n", v);
puts(""); puts("");
if (chosen == 1)
puts(" ***********************************"),
puts(" * New Game *"),
puts(" ***********************************");
else
puts(" ---------------------------------"),
puts(" | New Game |"),
puts(" ---------------------------------");
if (chosen == 2)
puts(" ***********************************"),
puts(" * Shop *"),
puts(" ***********************************");
else
puts(" ---------------------------------"),
puts(" | Shop |"),
puts(" ---------------------------------");
if (chosen == 3)
puts(" ***********************************"),
puts(" * Store *"),
puts(" ***********************************");
else
puts(" ---------------------------------"),
puts(" | Store |"),
puts(" ---------------------------------");
if (chosen == 4)
puts(" ***********************************"),
puts(" * How to play *"),
puts(" ***********************************");
else
puts(" ---------------------------------"),
puts(" | How to play |"),
puts(" ---------------------------------");
if (chosen == 5)
puts(" ***********************************"),
puts(" * End *"),
puts(" ***********************************");
else
puts(" ---------------------------------"),
puts(" | End |"),
puts(" ---------------------------------");
while (1)
if (_kbhit()) {
ch = _getch();
if (ch == 72 && chosen > 1) {
chosen--;
return Main_Interface();
}
if (ch == 80 && chosen < 5) {
chosen++;
return Main_Interface();
}
if (ch == 13) return chosen;
}
return -1;
}
void How_to_play() {
MessageBox(NULL,
"You can buy materials, make food, sell them, or improve your restaurant to gain money\n"
"\n"
"Details :\n"
" 1.What you can make and sell : pancake, cola, chips\n"
" 2.What you can improve : place for customers, plate for food, volume to place food, store size\n"
" 3.You only can buy materials at night(when you are not at a new day)\n"
" 4.You will get money only when you have satisfied all the demands of a customer\n"
, "tips", MB_OK | MB_ICONINFORMATION);
return;
}
void End() {
system("cls");
puts(""), puts(""), puts(""), puts("");
printf(" WELL DONE!! You have gained $%d\n", v);
puts(""), puts(""), puts("");
puts(" See You Next Time!!");
puts(""), puts(""), puts("");
system("pause");
return;
}