Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define HOMESTATE 0
- #define STREETSTATE 1
- #define PARKSTATE 2
- #define SHOPSTATE 3
- #define TURMASTATE 4
- #define SCHOOLSTATE 5
- bool is_first = true;
- int state = 0, new_state = 0;
- int food_count = 5, money_count = 0;
- int home(bool first)
- {
- if (first)
- {
- Serial.println("Welcome to the home! Press S to go street or press 1 to eat.");
- }
- char c = Serial.read();
- if (c == 'S' || c == 's')
- {
- return STREETSTATE;
- }
- else if (c == '1')
- {
- if (food_count > 0)
- {
- Serial.println("Eating...");
- food_count--;
- }
- else
- {
- Serial.println("404 Eat not found");
- }
- }
- return HOMESTATE;
- }
- int street(bool first)
- {
- if (first)
- {
- Serial.println("Welcome to the street! Press P to go park or press H to go home. Press S to steal eat.");
- }
- char c = Serial.read();
- if (c == 'P' || c == 'p')
- {
- return PARKSTATE;
- }
- else if (c == 'H' || c == 'h')
- {
- return HOMESTATE;
- } else if (c == 'S' || c == 's')
- {
- int i = rand() % 10;
- if (i < 2) {
- if (money_count > 20 ) {
- Serial.println("You na butilki. -20 money");
- money_count -= 20;
- }
- else {
- Serial.println("You na butilki and v turme");
- return TURMASTATE;
- }
- } else if (i >= 2 and i <= 8) {
- Serial.println("You stealed 5 eat sucsessfull!");
- food_count += 5;
- } else {
- Serial.println("You stealed 20 money sucsessfull!");
- money_count += 20;
- }
- }
- return STREETSTATE;
- } int park(bool first)
- {
- if (first)
- {
- Serial.println("Welcome to the park! Press F to go home, press s to go shop,press v to go school");
- }
- char c = Serial.read();
- if (c == 'F' || c == 'f')
- {
- return HOMESTATE;
- } else if (c == 'S' || c == 's')
- {
- return SHOPSTATE;
- } else if (c == 'V' || c == 'v')
- {
- return SCHOOLSTATE;
- }
- return PARKSTATE;
- } void balance_show() {
- Serial.print("Balance: ");
- Serial.print(money_count);
- Serial.print(", Eat: ");
- Serial.println(food_count);
- }
- int shop(bool first)
- {
- if (first)
- {
- Serial.println("Welcome to the shop!");
- balance_show();
- Serial.println("1 - Sold eat (3 money per 1 eat)");
- Serial.println("2 - Buy eat (5 money per 1 eat)");
- Serial.println("N - Go home");
- Serial.println(" Press F to go school");
- }
- char c = Serial.read();
- if (c == 'N' || c == 'n')
- {
- return HOMESTATE;
- } else if (c == '1')
- {
- if (food_count > 0)
- {
- food_count -= 1;
- money_count += 3;
- balance_show();
- } else
- {
- Serial.println("404 Eat not found");
- }
- } else if (c == '2')
- {
- } else if (c == 'F' || c == 'f') {
- return SCHOOLSTATE;
- }
- if (money_count > 0)
- {
- food_count += 1;
- money_count -= 5;
- balance_show();
- } else
- {
- Serial.println("404 Money not found");
- }
- return SHOPSTATE;
- }
- int turma(bool first)
- {
- if (first)
- {
- Serial.println("Welcome to the turma! Press g to go on the bottle, press h to go home and give mysor 5 eda");
- }
- char c = Serial.read();
- if (c == 'H' || c == 'h')
- {
- if (food_count >= 5) {
- food_count -= 5;
- return HOMESTATE;
- }
- else {
- Serial.println("you dont have eda you can clean parasha to give eda(3) or bit patroller to go away(4)");
- }
- } else if (c == 'G' || c == 'g')
- {
- Serial.println("Oyy my. shalyniska");
- } else if (c == '3') {
- Serial.println(" you good worker and na edy");
- food_count += 1 ;
- } else if (c == '4') {
- int i = rand() % 2;
- if (i == 0) {
- return HOMESTATE ;
- } else {
- Serial.println(" Game over you on the big bottle!");
- money_count = 0;
- food_count = 5;
- }
- }
- return TURMASTATE;
- }
- int school(bool first) {
- static int q_number = 0;
- if (first) {
- Serial.println("Welcome to the shool");
- Serial.println("Press n to ho home");
- Serial.println("Here you may get the moooneyy,you can asered my qestions for each question you will get 5 money");
- Serial.println("The first qestion : how much is 240:6? a: 1, b:40, c: 10 ");
- }
- char c = Serial.read();
- if (q_number == 0) {
- if (c == 'b') {
- Serial.println("Nice you righ");
- money_count += 5 ;
- Serial.println("qestion namber two : how much is 999 : 2? a : 499,5 ; b:500 ; c:499,9");
- q_number++;
- } else if (c != -1) {
- Serial.println("NO no no");
- }
- } else if (q_number == 1) {
- if (c == 'a') {
- Serial.println("Nice you righ");
- money_count += 5 ;
- Serial.println("qestion namber three : how much is 500 :25? a:20,b:25,c:22 ");
- q_number++;
- } else if (c != -1) {
- Serial.println("NO no no");
- }
- } else if (q_number == 2) {
- if (c == 'a') {
- Serial.println("Nice you righ");
- money_count += 5 ;
- Serial.println("qestion namber four : how much is 344 : 2? a:154,b:162,c:172");
- q_number++;
- } else if (c != -1) {
- Serial.println("NO no no");
- }
- } else if (q_number == 3) {
- if (c == 'c') {
- Serial.println("Nice you righ");
- money_count += 5 ;
- q_number++;
- } else if (c == 'N' || c == 'n')
- {
- return HOMESTATE;
- } else if (c != -1) {
- Serial.println("NO no no");
- }
- }
- return SCHOOLSTATE;
- }
- void setup()
- {
- Serial.begin(9600);
- }
- void loop()
- {
- srand(millis());
- switch (state)
- {
- case HOMESTATE:
- new_state = home(is_first);
- is_first = false;
- break;
- case STREETSTATE:
- new_state = street(is_first);
- is_first = false;
- break;
- case PARKSTATE:
- new_state = park(is_first);
- is_first = false;
- break;
- case SHOPSTATE:
- new_state = shop(is_first);
- is_first = false;
- break;
- case TURMASTATE:
- new_state = turma(is_first);
- is_first = false;
- break;
- case SCHOOLSTATE:
- new_state = school(is_first);
- is_first = false;
- break;
- }
- if (state != new_state)
- {
- state = new_state;
- is_first = true;
- }
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement