剧情黑暗的文字游戏,套路深,别中招哦!
由于套路很深,代码也有点长:

#include <windows.h>
#include <cstdio>
#include <string>
#include <iostream>
#include <fstream>
#include <conio.h>
#include <ctime>
#include <stdlib.h>
using namespace std;

class Weapon {
public:
    string name;
    int price, attack;
};
class Clothes {
public:
    string name;
    int price, defence;
};
class Medicine {
public:
    string name;
    int price, add_hp;
};
class Player {
public:
    string name, pasword;
    int hp, weapon, clothes, rating, money;
    Player() {
        hp = 100;
        weapon = 0;
        clothes = 0;
        rating = 0;
        money = 0;
    }
    int Grade() {
        if (rating < 200) {
            return 7;
        } else if (rating < 400) {
            return 10;
        } else if (rating < 600) {
            return 9;
        } else if (rating < 800) {
            return 13;
        } else if (rating < 1000) {
            return 14;
        } else {
            return 12;
        }
    }
    void PrintNameSlowly() {
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), Grade());
        for (int i = 0; i < name.length(); i++) {
            cout << name[i];
            Sleep(80);
        }
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
    }
    void PrintName() {
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), Grade());
        cout << name;
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
    }
};

const int NUMBER_OF_WEAPONS = 6, NUMBER_OF_CLOTHES = 6, NUMBER_OF_MEDICINES = 3;
int g_num_players, g_player, g_sum_player_fight, g_sum_enemy_fight, g_hp_enemy;
bool g_run, g_areFighting;
Player players[101];
Weapon weapons[NUMBER_OF_WEAPONS] =
    {
        {"hands", 0, 10},
        {"small nife", 100, 20},
        {"big nife", 200, 40},
        {"pistol", 300, 50},
        {"assault rifle", 400, 60},
        {"sniper rifle", 500, 80}};
Clothes clothes[NUMBER_OF_CLOTHES] =
    {
        {"vest", 0, 4},
        {"T-shirt", 60, 8},
        {"shirt", 120, 24},
        {"jacket", 180, 32},
        {"coat", 240, 48},
        {"armor", 300, 64}};
Medicine medicines[NUMBER_OF_MEDICINES] =
    {
        {"plaster", 10, 20},
        {"bandage", 40, 50},
        {"specific drug", 100, 80}};
char player_default[5][5] =
    {
        {' ', ' ', 'O', ' ', ' '},
        {' ', '/', '|', '\\', '_'},
        {' ', '\\', '|', ' ', ' '},
        {' ', '/', ' ', '\\', ' '},
        {'/', ' ', ' ', ' ', '\\'}};
char player_hand_attack[5][5] =
    {
        {' ', ' ', 'O', '_', '_'},
        {' ', '/', '|', ' ', ' '},
        {' ', '\\', '|', ' ', ' '},
        {' ', '/', ' ', '\\', ' '},
        {'/', ' ', ' ', ' ', '\\'}};
char player_foot_attack[5][5] =
    {
        {' ', ' ', ' ', ' ', ' '},
        {'O', '_', '_', ' ', '/'},
        {'/', '\\', ' ', '/', ' '},
        {'\\', ' ', '|', ' ', ' '},
        {' ', ' ', '|', ' ', ' '}};
char player_die[5][5] =
    {
        {' ', ' ', '/', ' ', ' '},
        {'O', '/', '_', '_', ' '},
        {' ', '\\', ' ', ' ', '/'},
        {' ', ' ', '\\', '/', ' '},
        {' ', ' ', ' ', '\\', '_'}};
char enemy_default[5][5] =
    {
        {' ', ' ', 'O', ' ', ' '},
        {'_', '/', '|', '\\', ' '},
        {' ', ' ', '|', '/', ' '},
        {' ', '/', ' ', '\\', ' '},
        {'/', ' ', ' ', ' ', '\\'}};
char enemy_hand_attack[5][5] =
    {
        {'_', '_', 'O', ' ', ' '},
        {' ', ' ', '|', '\\', ' '},
        {' ', ' ', '|', '/', ' '},
        {' ', '/', ' ', '\\', ' '},
        {'/', ' ', ' ', ' ', '\\'}};
char enemy_foot_attack[5][5] =
    {
        {' ', ' ', ' ', ' ', ' '},
        {'\\', ' ', '_', '_', 'O'},
        {' ', '\\', ' ', '/', '\\'},
        {' ', ' ', '|', ' ', '/'},
        {' ', ' ', '|', ' ', ' '}};
char enemy_die[5][5] =
    {
        {' ', ' ', '\\', ' ', ' '},
        {' ', '_', '_', '\\', 'O'},
        {'\\', ' ', ' ', '/', ' '},
        {' ', '\\', '/', ' ', ' '},
        {'_', '/', ' ', ' ', ' '}};
char player_face[5][5];
char enemy_face[5][5];

void Welcome(), Login(), Register(), Init(), Start(), Home(), Shop(), Supermarket(), Bar(), Park(), CityCenter(), ShowSelf();
void GoOut(), Die(), RecordData(), Quit(), PrintSlowly(string), Pause(), PlayerControlFight(), EnemyControlFight(), ShowFight();
int Fight(string), SuiJi();

void Welcome() {
    system("cls");
    cout << "Welcome to Dark World!" << endl;
    cout << "----------------------------------" << endl;
    cout << "1.Login 2.Register 3.Quit" << endl;
    cout << "----------------------------------" << endl;
    cout << "You have no accound? Register one." << endl;
    cout << "----------------------------------" << endl;
    g_player = 0;
}
void Login() {
    if (g_num_players > 0) {
        string name, pasword;
        cout << "----------------------------------" << endl;
        cout << "Name:";
        cin >> name;
        cout << "Pasword:";
        cin >> pasword;
        cout << "----------------------------------" << endl;
        bool find_name = false;
        int j = 0;
        for (int i = 1; i <= g_num_players; i++) {
            if (name == players[i].name) {
                find_name = true;
                j = i;
                break;
            }
        } if (find_name) {
            if (pasword == players[j].pasword) {
                cout << "Logined successfully!" << endl;
                g_player = j;
                Pause();
                Start();
            }
            else {
                cout << "Wrong pasword!" << endl;
                Pause();
                Init();
            }
        } else {
            cout << "Wrong name!" << endl;
            Pause();
            Init();
        }
    } else {
        cout << "You have no accound!" << endl;
        Pause();
        Init();
    }
}
void Register() {
    cout << "----------------------------------" << endl;
    cout << "Name(Without space):";
    string name, pasword;
    cin >> name;
    cout << "Pasword(Without space):";
    cin >> pasword;
    cout << "----------------------------------" << endl;
    bool has_registered = false;
    for (int i = 1; i <= g_num_players; i++) {
        if (players[i].name == name) {
            has_registered = true;
            break;
        }
    }
    if (has_registered) {
        cout << "The name has been used before." << endl;
        Pause();
        Init();
    } else {
        g_num_players++;
        players[g_num_players].name = name;
        players[g_num_players].pasword = pasword;
        g_player = g_num_players;
        RecordData();
        cout << "Registered successfully!" << endl;
        Pause();
        Start();
    }
}
void Init() {
    g_run = true;
    Welcome();
    try {
        ifstream fin("DarkWorld.dat");
        fin >> g_num_players;
        for (int i = 1; i <= g_num_players; i++) {
            fin >> players[i].name >> players[i].pasword >> players[i].hp >> players[i].rating >> players[i].money >> players[i].weapon >> players[i].clothes;
        }
        fin.close();
    } catch (...) {
        g_num_players = 0;
    }
    int choose;
    do {
        cin >> choose;
    } while (not(choose >= 1 and choose <= 3));
    if (choose == 1) {
        Login();
    } else if (choose == 2) {
        Register();
    } else {
        Quit();
    }
}
void Start() {
    system("cls");
    if (players[g_player].rating < 1500) {
        PrintSlowly("Hello, ");
        players[g_player].PrintNameSlowly();
        PrintSlowly("!\n");
        PrintSlowly("You are a killer from light world, now you are in a dark world.\n");
        PrintSlowly("Your task is killing people as many as you can,\n");
        PrintSlowly("because people here are very bad,\n");
        PrintSlowly("if you not kill them, then they will kill you!\n");
        PrintSlowly("Can you live in the end?\n");
    } else {
        PrintSlowly("Good job, ");
        players[g_player].PrintNameSlowly();
        PrintSlowly("!\n");
        PrintSlowly("You ruled the dark world!\n");
        PrintSlowly("Now you can do anything you want!\n");
    }
    Pause();
}
void Home() {
    while (g_run) {
        system("cls");
        cout << "home          |";
        players[g_player].PrintName();
        cout << endl;
        cout << "-----------------------------------------" << endl;
        cout << "1.My information 2.Go out 3.Quit 4.Logout" << endl;
        cout << "-----------------------------------------" << endl;
        int choose;
        cin >> choose;
        switch (choose) {
        case 1:
            ShowSelf();
            break;
        case 2:
            GoOut();
            break;
        case 3:
            Quit();
            break;
        case 4:
            RecordData();
            Init();
            break;
        default:
            break;
        }
    }
}
void Shop() {
    system("cls");
    cout << "shop" << endl;
    cout << "-------------------------------" << endl;
    PrintSlowly("The boss of shop: Hello! Can I help you?\n");
    cout << "1.No, thanks." << endl;
    cout << "2.Yes, please." << endl;
    cout << "3.Sorry, I want to kill you and take all things away!" << endl;
    int choose;
    do {
        cin >> choose;
    } while (not(choose >= 1 and choose <= 3));
    if (choose == 1) {
        PrintSlowly("The boss of shop: Good bye...\n");
    }
    else if (choose == 2) {
        do {
            PrintSlowly("The boss of shop: OK. What do you need, weapons, clothes, or medicines?\n");
            cout << "1.Weapons." << endl;
            cout << "2.Clothes" << endl;
            cout << "3.Medicines." << endl;
            cout << "4.No, thanks." << endl;
            do {
                cin >> choose;
            } while (not(choose >= 1 and choose <= 4));
            if (choose == 1) {
                PrintSlowly("The boss: Here are the weapons.\n");
                for (int i = 1; i < NUMBER_OF_WEAPONS; i++) {
                    cout << i << ".name: " << weapons[i].name << endl;
                    cout << "  price: " << weapons[i].price << endl;
                    cout << "  attack: " << weapons[i].attack << endl;
                }
                cout << NUMBER_OF_WEAPONS << ".back" << endl;
                PrintSlowly("The boss: Which weapon do you want?\n");
                int choose1;
                do {
                    cin >> choose1;
                } while (not(choose1 >= 1 and choose1 <= NUMBER_OF_WEAPONS));
                if (choose1 != NUMBER_OF_WEAPONS) {
                    if (players[g_player].money >= weapons[choose1].price) {
                        PrintSlowly("Bought successfully!\n");
                        players[g_player].money -= weapons[choose1].price;
                        players[g_player].weapon = choose1;
                    } else {
                        PrintSlowly("You don't have enough money!\n");
                    }
                }
            } else if (choose == 2) {
                PrintSlowly("The boss: Here are the clothes.\n");
                for (int i = 1; i < NUMBER_OF_CLOTHES; i++) {
                    cout << i << ".name: " << clothes[i].name << endl;
                    cout << "  price: " << clothes[i].price << endl;
                    cout << "  defence: " << clothes[i].defence << endl;
                }
                cout << NUMBER_OF_CLOTHES << ".back" << endl;
                PrintSlowly("The boss: Which clothes do you want?\n");
                int choose1;
                do {
                    cin >> choose1;
                } while (not(choose1 >= 1 and choose1 <= NUMBER_OF_CLOTHES));
                if (choose1 != NUMBER_OF_CLOTHES) {
                    if (players[g_player].money >= clothes[choose1].price) {
                        PrintSlowly("Bought successfully!\n");
                        players[g_player].money -= clothes[choose1].price;
                        players[g_player].clothes = choose1;
                    } else {
                        PrintSlowly("You don't have enough money!\n");
                    }
                }
            } else if (choose == 3) {
                PrintSlowly("The boss: Here are the medicines.\n");
                for (int i = 0; i < NUMBER_OF_MEDICINES; i++) {
                    cout << i + 1 << ".name: " << medicines[i].name << endl;
                    cout << "  price: " << medicines[i].price << endl;
                    cout << "  hp+: " << medicines[i].add_hp << endl;
                }
                cout << NUMBER_OF_MEDICINES + 1 << ".back" << endl;
                PrintSlowly("The boss: Which medicine do you need?\n");
                int choose1;
                do {
                    cin >> choose1;
                } while (not(choose1 >= 1 and choose1 <= NUMBER_OF_MEDICINES + 1));
                if (choose1 != NUMBER_OF_MEDICINES + 1) {
                    if (players[g_player].money >= medicines[choose1 - 1].price) {
                        PrintSlowly("Bought successfully!\n");
                        players[g_player].money -= medicines[choose1 - 1].price;
                        players[g_player].hp += medicines[choose1 - 1].add_hp;
                        if (players[g_player].hp > 100) {
                            players[g_player].hp = 100;
                        }
                    } else {
                        PrintSlowly("You don't have enough money!\n");
                    }
                }
            }
        } while (choose != 4);
        PrintSlowly("The boss: Welcome to back, goodbye!\n");
    } else if (choose == 3) {
        PrintSlowly("The boss: Oh, are you able to do that? I think not. Hit him!\n");
        PrintSlowly("One strong man comes here.\n");
        int enemyHp = 100;
        while (players[g_player].hp > 0 and enemyHp > 0) {
            PrintSlowly("The strong man hits you!\n");
            int scar = 30 - clothes[players[g_player].clothes].defence;
            if (scar < 0) {
                scar = 0;
            }
            players[g_player].hp -= scar;
            PrintSlowly("Your hp substracted by ");
            cout << scar;
            PrintSlowly(" !\n");
            if (players[g_player].hp <= 0) {
                players[g_player].hp = 0;
                break;
            }
            int choose1;
            do {
                PrintSlowly("What should you do?\n");
                if (players[g_player].weapon == 0) {
                    cout << "1.Hit him" << endl;
                } else if (players[g_player].weapon == 1) {
                    cout << "1.Cut him" << endl;
                } else if (players[g_player].weapon == 2) {
                    cout << "1.Cut him" << endl;
                } else {
                    cout << "1.Shot him" << endl;
                }
                cout << "2.Run away" << endl;
                cout << "3.My information" << endl;
                do {
                    cin >> choose1;
                } while (not(choose1 >= 1 and choose1 <= 3));
                if (choose1 == 3) {
                    ShowSelf();
                }
            } while (choose1 == 3);
            if (choose1 == 1) {
                if (players[g_player].weapon == 0) {
                    PrintSlowly("You hit him!\n");
                } else if (players[g_player].weapon == 1 or players[g_player].weapon == 1) {
                    PrintSlowly("You cut him!\n");
                } else {
                    PrintSlowly("You shot him!\n");
                }
                enemyHp -= weapons[players[g_player].weapon].attack;
                PrintSlowly("The strong man's hp substracted by ");
                cout << weapons[players[g_player].weapon].attack;
                PrintSlowly("!\n");
            } else if (choose1 == 2) {
                PrintSlowly("You ran away!\n");
                PrintSlowly("The boss: Don't let me see you again!\n");
                break;
            }
        } if (enemyHp <= 0) {
            enemyHp = 0;
            PrintSlowly("You killed the strong man!\n");
            players[g_player].money += 200;
            PrintSlowly("You get 200 money!\n");
        } if (players[g_player].hp == 0) {
            Die();
        }
    }
    Pause();
}
void Supermarket() {
    system("cls");
    cout << "supermarket" << endl;
    cout << "----------------------------------" << endl;
    if (players[g_player].rating < 1000) {
        PrintSlowly("The boss: Do you want to buy anything? We have nothing to sell. But we have a rule, anyone who comes here must dies!\n");
        if (players[g_player].rating < 200) {
            PrintSlowly("The boss: Mike, hit him!\n");
            PrintSlowly("One man named Mike comes here.\n");
            int enemyHp = 100;
            while (enemyHp > 0 and players[g_player].hp > 0) {
                PrintSlowly("Mike hits you!\n");
                int scar = 5;
                scar -= clothes[players[g_player].clothes].defence;
                if (scar < 0) {
                    scar = 0;
                }
                players[g_player].hp -= scar;
                PrintSlowly("Your hp substracted by ");
                cout << scar;
                PrintSlowly("!\n");
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    break;
                }
                int choose;
                do {
                    PrintSlowly("What should you do?\n");
                    if (players[g_player].weapon == 0) {
                        cout << "1.Hit him" << endl;
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        cout << "1.Cut him" << endl;
                    } else {
                        cout << "1.Shot him" << endl;
                    }
                    cout << "2.Run away" << endl;
                    cout << "3.My information" << endl;
                    cin >> choose;
                    if (choose == 3) {
                        ShowSelf();
                    }
                } while (choose == 3);
                if (choose == 1) {
                    if (players[g_player].weapon == 0) {
                        PrintSlowly("You hit Mike!\n");
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        PrintSlowly("You cut Mike!\n");
                    } else {
                        PrintSlowly("You shot Mike!\n");
                    }
                    enemyHp -= weapons[players[g_player].weapon].attack;
                    PrintSlowly("Mike's hp substracted by ");
                    cout << weapons[players[g_player].weapon].attack;
                    PrintSlowly("!\n");
                } else {
                    int random = rand() % 10;
                    if (random <= 3) {
                        PrintSlowly("Ran away successfully!\n");
                        break;
                    } else {
                        PrintSlowly("You want to run away.\n");
                        PrintSlowly("The boss: Mike, catch him!\n");
                        PrintSlowly("Mike catches you up!\n");
                    }
                }
            } if (enemyHp <= 0) {
                PrintSlowly("You beat Mike and get 20 rating and 30 money!\n");
                players[g_player].rating += 20;
                players[g_player].money += 30;
                if (players[g_player].rating >= 200) {
                    PrintSlowly("Mike died.\n");
                }
                else {
                    PrintSlowly("Mike ran away.\n");
                }
            } if (players[g_player].hp == 0) {
                Die();
            }
        } else if (players[g_player].rating < 400) {
            PrintSlowly("The boss: Jack, hit him!\n");
            PrintSlowly("One man named Jack comes here.\n");
            int enemyHp = 100;
            while (enemyHp > 0 and players[g_player].hp > 0) {
                PrintSlowly("Jack hits you!\n");
                int scar = 16;
                scar -= clothes[players[g_player].clothes].defence;
                if (scar < 0) {
                    scar = 0;
                }
                players[g_player].hp -= scar;
                PrintSlowly("Your hp substracted by ");
                cout << scar;
                PrintSlowly("!\n");
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    break;
                }
                int choose;
                do {
                    PrintSlowly("What should you do?\n");
                    if (players[g_player].weapon == 0) {
                        cout << "1.Hit him" << endl;
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        cout << "1.Cut him" << endl;
                    } else {
                        cout << "1.Shot him" << endl;
                    }
                    cout << "2.Run away" << endl;
                    cout << "3.My information" << endl;
                    cin >> choose;
                    if (choose == 3) {
                        ShowSelf();
                    }
                } while (choose == 3);
                if (choose == 1) {
                    if (players[g_player].weapon == 0) {
                        PrintSlowly("You hit Jack!\n");
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        PrintSlowly("You cut Jack!\n");
                    } else {
                        PrintSlowly("You shot Jack!\n");
                    }
                    enemyHp -= weapons[players[g_player].weapon].attack;
                    PrintSlowly("Jack's hp substracted by ");
                    cout << weapons[players[g_player].weapon].attack;
                    PrintSlowly("!\n");
                } else {
                    int random = rand() % 10;
                    if (random <= 3) {
                        PrintSlowly("Ran away successfully!\n");
                        break;
                    } else {
                        PrintSlowly("You want to run away.\n");
                        PrintSlowly("The boss: Jack, catch him!\n");
                        PrintSlowly("Jack catches you up!\n");
                    }
                }
            } if (enemyHp <= 0) {
                PrintSlowly("You beat Jack and get 40 rating and 50 money!\n");
                players[g_player].rating += 40;
                players[g_player].money += 50;
                if (players[g_player].rating >= 600) {
                    PrintSlowly("Jack died.\n");
                } else {
                    PrintSlowly("Jack ran away.\n");
                }
            } if (players[g_player].hp == 0) {
                Die();
            }
        } else if (players[g_player].rating < 600) {
            PrintSlowly("The boss: Eric, hit him!\n");
            PrintSlowly("One man named Eric comes here.\n");
            int enemyHp = 100;
            while (enemyHp > 0 and players[g_player].hp > 0) {
                PrintSlowly("Eric hits you!\n");
                int scar = 24;
                scar -= clothes[players[g_player].clothes].defence;
                if (scar < 0) {
                    scar = 0;
                }
                players[g_player].hp -= scar;
                PrintSlowly("Your hp substracted by ");
                cout << scar;
                PrintSlowly("!\n");
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    break;
                }
                int choose;
                do {
                    PrintSlowly("What should you do?\n");
                    if (players[g_player].weapon == 0) {
                        cout << "1.Hit him" << endl;
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        cout << "1.Cut him" << endl;
                    } else {
                        cout << "1.Shot him" << endl;
                    }
                    cout << "2.Run away" << endl;
                    cout << "3.My information" << endl;
                    cin >> choose;
                    if (choose == 3) {
                        ShowSelf();
                    }
                } while (choose == 3);
                if (choose == 1) {
                    if (players[g_player].weapon == 0) {
                        PrintSlowly("You hit Eric!\n");
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        PrintSlowly("You cut Eric!\n");
                    } else {
                        PrintSlowly("You shot Eric!\n");
                    }
                    enemyHp -= weapons[players[g_player].weapon].attack;
                    PrintSlowly("Eric's hp substracted by ");
                    cout << weapons[players[g_player].weapon].attack;
                    PrintSlowly("!\n");
                } else {
                    int random = rand() % 10;
                    if (random <= 3) {
                        PrintSlowly("Ran away successfully!\n");
                        break;
                    } else {
                        PrintSlowly("You want to run away.\n");
                        PrintSlowly("The boss: Eric, catch him!\n");
                        PrintSlowly("Eric catches you up!\n");
                    }
                }
            } if (enemyHp <= 0) {
                PrintSlowly("You killed Eric and get 60 rating and 70 money!\n");
                players[g_player].rating += 60;
                players[g_player].money += 70;
                if (players[g_player].rating >= 400) {
                    PrintSlowly("Eric died.\n");
                } else {
                    PrintSlowly("Eric ran away.\n");
                }
            } if (players[g_player].hp == 0) {
                Die();
            }
        } else if (players[g_player].rating < 800) {
            PrintSlowly("The boss: Bob, hit him!\n");
            PrintSlowly("One man named Bob comes here.\n");
            int enemyHp = 100;
            while (enemyHp > 0 and players[g_player].hp > 0) {
                PrintSlowly("Bob hits you!\n");
                int scar = 32;
                scar -= clothes[players[g_player].clothes].defence;
                if (scar < 0) {
                    scar = 0;
                }
                players[g_player].hp -= scar;
                PrintSlowly("Your hp substracted by ");
                cout << scar;
                PrintSlowly("!\n");
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    break;
                }
                int choose;
                do {
                    PrintSlowly("What should you do?\n");
                    if (players[g_player].weapon == 0) {
                        cout << "1.Hit him" << endl;
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        cout << "1.Cut him" << endl;
                    } else {
                        cout << "1.Shot him" << endl;
                    }
                    cout << "2.Run away" << endl;
                    cout << "3.My information" << endl;
                    cin >> choose;
                    if (choose == 3) {
                        ShowSelf();
                    }
                } while (choose == 3);
                if (choose == 1) {
                    if (players[g_player].weapon == 0) {
                        PrintSlowly("You hit Bob!\n");
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        PrintSlowly("You cut Bob!\n");
                    } else {
                        PrintSlowly("You shot Bob!\n");
                    }
                    enemyHp -= weapons[players[g_player].weapon].attack;
                    PrintSlowly("Bob's hp substracted by ");
                    cout << weapons[players[g_player].weapon].attack;
                    PrintSlowly("!\n");
                } else {
                    int random = rand() % 10;
                    if (random <= 3) {
                        PrintSlowly("Ran away successfully!\n");
                        break;
                    } else {
                        PrintSlowly("You want to run away.\n");
                        PrintSlowly("The boss: Bob, catch him!\n");
                        PrintSlowly("Bob catches you up!\n");
                    }
                }
            } if (enemyHp <= 0) {
                PrintSlowly("You beat Bob and get 80 rating and 90 money!\n");
                players[g_player].rating += 80;
                players[g_player].money += 90;
                if (players[g_player].rating >= 600) {
                    PrintSlowly("Bob died.\n");
                } else {
                    PrintSlowly("Bob ran away.\n");
                }
            }
            if (players[g_player].hp == 0) {
                Die();
            }
        } else if (players[g_player].rating < 1000) {
            PrintSlowly("The boss: Smith, hit him!\n");
            PrintSlowly("One man named Smith comes here.\n");
            int enemyHp = 100;
            while (enemyHp > 0 and players[g_player].hp > 0) {
                PrintSlowly("Smith hits you!\n");
                int scar = 40;
                scar -= clothes[players[g_player].clothes].defence;
                if (scar < 0) {
                    scar = 0;
                }
                players[g_player].hp -= scar;
                PrintSlowly("Your hp substracted by ");
                cout << scar;
                PrintSlowly("!\n");
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    break;
                }
                int choose;
                do {
                    PrintSlowly("What should you do?\n");
                    if (players[g_player].weapon == 0) {
                        cout << "1.Hit him" << endl;
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        cout << "1.Cut him" << endl;
                    } else {
                        cout << "1.Shot him" << endl;
                    }
                    cout << "2.Run away" << endl;
                    cout << "3.My information" << endl;
                    cin >> choose;
                    if (choose == 3) {
                        ShowSelf();
                    }
                } while (choose == 3);
                if (choose == 1) {
                    if (players[g_player].weapon == 0) {
                        PrintSlowly("You hit Smith!\n");
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        PrintSlowly("You cut Smith!\n");
                    } else {
                        PrintSlowly("You shot Smith!\n");
                    }
                    enemyHp -= weapons[players[g_player].weapon].attack;
                    PrintSlowly("Smith's hp substracted by ");
                    cout << weapons[players[g_player].weapon].attack;
                    PrintSlowly("!\n");
                } else {
                    int random = rand() % 10;
                    if (random <= 3) {
                        PrintSlowly("Ran away successfully!\n");
                        break;
                    } else {
                        PrintSlowly("You want to run away.\n");
                        PrintSlowly("The boss: Smith, catch him!\n");
                        PrintSlowly("Smith catches you up!\n");
                    }
                }
            } if (enemyHp <= 0) {
                PrintSlowly("You beat Smith and get 100 rating and 150 money!\n");
                players[g_player].rating += 100;
                players[g_player].money += 150;
                if (players[g_player].rating >= 800) {
                    PrintSlowly("Smith died.\n");
                } else {
                    PrintSlowly("Smith ran away.\n");
                }
            } if (players[g_player].hp == 0) {
                Die();
            }
        } else {
            PrintSlowly("The boss: It seems that I have to kill you by myself.");
            PrintSlowly("The boss comes over with an assualt rifle!\n");
            int enemyHp = 100;
            while (enemyHp > 0 and players[g_player].hp > 0) {
                PrintSlowly("Boss shots you!\n");
                int scar = 60;
                scar -= clothes[players[g_player].clothes].defence;
                if (scar < 0) {
                    scar = 0;
                }
                players[g_player].hp -= scar;
                PrintSlowly("Your hp substracted by ");
                cout << scar;
                PrintSlowly("!\n");
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    break;
                }
                int choose;
                do {
                    PrintSlowly("What should you do?\n");
                    if (players[g_player].weapon == 0) {
                        cout << "1.Hit him" << endl;
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        cout << "1.Cut him" << endl;
                    } else {
                        cout << "1.Shot him" << endl;
                    }
                    cout << "2.Run away" << endl;
                    cout << "3.My information" << endl;
                    cin >> choose;
                    if (choose == 3) {
                        ShowSelf();
                    }
                } while (choose == 3);
                if (choose == 1) {
                    if (players[g_player].weapon == 0) {
                        PrintSlowly("You hit boss!\n");
                    } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                        PrintSlowly("You cut boss!\n");
                    } else {
                        PrintSlowly("You shot boss!\n");
                    }
                    enemyHp -= weapons[players[g_player].weapon].attack;
                    PrintSlowly("Boss's hp substracted by ");
                    cout << weapons[players[g_player].weapon].attack;
                    PrintSlowly("!\n");
                } else {
                    int random = rand() % 10;
                    if (random <= 3) {
                        PrintSlowly("Ran away successfully!\n");
                        break;
                    } else {
                        PrintSlowly("You want to run away.\n");
                        PrintSlowly("The boss: Don't run away!\n");
                        PrintSlowly("Boss catches you up!\n");
                    }
                }
            }
            if (enemyHp <= 0) {
                PrintSlowly("You beat boss and get 200 rating and 300 money!\n");
                players[g_player].rating += 200;
                players[g_player].money += 300;
                if (players[g_player].rating >= 1000) {
                    PrintSlowly("The boss died.\n");
                } else {
                    PrintSlowly("The boss ran away.\n");
                }
            } if (players[g_player].hp == 0) {
                Die();
            }
        }
    } else {
        PrintSlowly("Nobody is here.\n");
    }
    Pause();
}
void Bar() {
    system("cls");
    cout << "Bar" << endl;
    cout << "------------------------------" << endl;
    if (players[g_player].rating < 1000) {
        PrintSlowly("The boss: Hello, what would you like to drink?\n");
        players[g_player].PrintNameSlowly();
        cout << ":" << endl;
        cout << "1.What kind of drink do you have?" << endl;
        cout << "2.No, thanks." << endl;
        int choose;
        do {
            cin >> choose;
        } while (choose != 1 and choose != 2);
        if (choose == 1) {
            PrintSlowly("The boss: We only have some beer. If you want it, please pay 20 money.\n");
            players[g_player].PrintNameSlowly();
            cout << ":" << endl;
            cout << "1.OK, I want some." << endl;
            cout << "2.Sorry, I have no money." << endl;
            do {
                cin >> choose;
            } while (choose != 1 and choose != 2);
            if (choose == 1) {
                if (players[g_player].rating >= 20) {
                    players[g_player].rating -= 20;
                    PrintSlowly("The boss: Good. Now, you are a member of our team.\n");
                    players[g_player].PrintNameSlowly();
                    PrintSlowly(": Your team? No!\n");
                    PrintSlowly("The boss: Oh, you made the worst decision. Hit him!\n");
                    PrintSlowly("Five strong men come and hit you.\n");
                    PrintSlowly("Your hp substract by 50!\n");
                    players[g_player].hp -= 50;
                    if (players[g_player].hp <= 0) {
                        players[g_player].hp = 0;
                        Die();
                    } else {
                        players[g_player].PrintNameSlowly();
                        cout << ": Why?" << endl;
                        PrintSlowly("The boss: Because anyone who refuse to join us must die! Hit him!\n");
                        int enemyHp = 100;
                        while (enemyHp > 0 and players[g_player].hp > 0) {
                            PrintSlowly("The strong men hit you!\n");
                            int scar = 50;
                            scar -= clothes[players[g_player].clothes].defence;
                            if (scar < 0) {
                                scar = 0;
                            }
                            players[g_player].hp -= scar;
                            PrintSlowly("Your hp substracted by ");
                            cout << scar;
                            PrintSlowly("!\n");
                            if (players[g_player].hp <= 0) {
                                players[g_player].hp = 0;
                                break;
                            }
                            int choose;
                            do {
                                PrintSlowly("What should you do?\n");
                                if (players[g_player].weapon == 0) {
                                    cout << "1.Hit them" << endl;
                                } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                                    cout << "1.Cut them" << endl;
                                } else {
                                    cout << "1.Shot them" << endl;
                                }
                                cout << "2.Run away" << endl;
                                cout << "3.My information" << endl;
                                cin >> choose;
                                if (choose == 3) {
                                    ShowSelf();
                                }
                            } while (choose == 3);
                            if (choose == 1) {
                                if (players[g_player].weapon == 0) {
                                    PrintSlowly("You hit them!\n");
                                } else if (players[g_player].weapon == 1 or players[g_player].weapon == 2) {
                                    PrintSlowly("You cut them!\n");
                                } else {
                                    PrintSlowly("You shot them!\n");
                                }
                                enemyHp -= weapons[players[g_player].weapon].attack;
                                PrintSlowly("Their hp substracted by ");
                                cout << weapons[players[g_player].weapon].attack;
                                PrintSlowly("!\n");
                            } else {
                                PrintSlowly("Ran away successfully!\n");
                                PrintSlowly("The boss: How lucky you are!\n");
                                break;
                            }
                        } if (enemyHp <= 0) {
                            PrintSlowly("You beat them and get 200 rating and 300 money!\n");
                            players[g_player].rating += 200;
                            players[g_player].money += 300;
                            if (players[g_player].rating >= 1000) {
                                PrintSlowly("The strong men died.\n");
                            } else {
                                PrintSlowly("The strong men ran away.\n");
                            }
                        } if (players[g_player].hp == 0) {
                            Die();
                        }
                    }
                } else {
                    players[g_player].PrintNameSlowly();
                    PrintSlowly(": Oh, I don't have enough money.\n");
                    PrintSlowly("The boss: OK. Take him out!\n");
                    PrintSlowly("Two strong men come and push you out of door.\n");
                }
            } else {
                PrintSlowly("The boss: OK. Take him out!\n");
                PrintSlowly("Two strong men come and push you out of door.\n");
            }
        } else {
            PrintSlowly("The boss: Goodbye, but you'd better not come again.\n");
            players[g_player].PrintNameSlowly();
            PrintSlowly(": ...\n");
        }
    } else {
        PrintSlowly("Nobody is here.\n");
        PrintSlowly("Everyone ran away because you killed too many people, they are afraid of you.\n");
        players[g_player].PrintNameSlowly();
        PrintSlowly(": (^w^)\n");
    }
    Pause();
}
void Park() {
    system("cls");
    cout << "Park" << endl;
    cout << "------------------------------" << endl;
    if (players[g_player].rating < 800) {
        PrintSlowly("There are many people.\n");
        if (players[g_player].rating < 200) {
            PrintSlowly("There is an old man selling snacks.\n");
            PrintSlowly("The old man: Hello, do you want some snacks?\n");
            players[g_player].PrintNameSlowly();
            PrintSlowly(":\n");
            cout << "1.Yes, I do." << endl;
            cout << "2.No, I don't." << endl;
            int choose;
            do {
                cin >> choose;
            } while (choose != 1 and choose != 2);
            if (choose == 1) {
                PrintSlowly("One young man comes: Don't eat the snacks! All of them are poison!\n");
                players[g_player].PrintNameSlowly();
                PrintSlowly("(?o_o): Really?\n");
                PrintSlowly("The old man: Don't believe him! He is the worst person in this park!\n");
                PrintSlowly("The young man: The real worst person is you!\n");
                players[g_player].PrintNameSlowly();
                PrintSlowly("(!-_-): Don't argue!\n");
                players[g_player].PrintNameSlowly();
                PrintSlowly(":\n");
                cout << "1.Let me try." << endl;
                cout << "2.I see, bye!" << endl;
                do {
                    cin >> choose;
                } while (choose != 1 and choose != 2);
                if (choose == 1) {
                    PrintSlowly("The old man(^_^): Here you are.\n");
                    PrintSlowly("You get the snack and taste it...\n");
                    players[g_player].PrintNameSlowly();
                    PrintSlowly("(!x_x): It's poison!\n");
                    players[g_player].hp -= 50;
                    PrintSlowly("Your hp substracted by 50!\n");
                    if (players[g_player].hp <= 0) {
                        players[g_player].hp = 0;
                        Die();
                    } else {
                        players[g_player].PrintNameSlowly();
                        PrintSlowly("(QWQ): I'll kill you!\n");
                        PrintSlowly("The old man: Sorry, I have no time to fight, goodbye!\n");
                        PrintSlowly("The old man ran away quickly...\n");
                        players[g_player].PrintNameSlowly();
                        PrintSlowly("(QAQ): ...\n");
                    }
                } else {
                    PrintSlowly("The old man: Please trust me...\n");
                }
            } else {
                int sj = SuiJi() % 10;
                if (sj < 6) {
                    PrintSlowly("The old man(OoO#): I'm angry today, I want to fight with you.\n");
                    players[g_player].PrintNameSlowly();
                    PrintSlowly("(^o^): Hahaha! Do you think you can beat me? You are so old!\n");
                    PrintSlowly("The old man(OoO#): I'm the most famous kong fu master in the past, let's begin!\n");
                    players[g_player].PrintNameSlowly();
                    PrintSlowly(": (!o_o)\n");
                    Pause();
                    int result = Fight("the old man");
                    if (result == 1) {
                        players[g_player].rating += 100;
                        if (players[g_player].rating >= 200) {
                            PrintSlowly("You killed the old man and get 100 rating and 150 money!\n");
                            players[g_player].money += 150;
                        } else {
                            PrintSlowly("You beat the old man and get 100 rating and 110 money!\n");
                            players[g_player].money += 110;
                        }
                    } else if (result == 0) {
                        Die();
                    } else {
                        PrintSlowly("Ran away successfully!\n");
                    }
                } else {
                    PrintSlowly("The old man: I'm happy today, I don't want to fight with you.\n");
                    players[g_player].PrintNameSlowly();
                    PrintSlowly("(-_-): ...\n");
                }
            }
        } else if (players[g_player].rating < 400) {
            PrintSlowly("One man appeared behind you suddenly with a knife!\n");
            PrintSlowly("You turn back quikly.\n");
            players[g_player].PrintNameSlowly();
            PrintSlowly("(!o_o): What are you doing!?\n");
            PrintSlowly("The man: I'm want to kill you!\n");
            players[g_player].PrintNameSlowly();
            PrintSlowly(": Why!?\n");
            PrintSlowly("The man: Because killing people is my hobby!\n");
            players[g_player].PrintNameSlowly();
            PrintSlowly("(!OwO): ...\n");
            PrintSlowly("What should you do?\n");
            cout << "1.Attack him." << endl;
            cout << "2.Run away." << endl;
            cout << "3.Keep talking." << endl;
            int choose;
            do {
                cin >> choose;
            } while (choose != 1 and choose != 2 and choose != 3);
            if (choose == 1) {
                int enemy_hp = 100;
                players[g_player].PrintNameSlowly();
                if (players[g_player].weapon == 0) {
                    PrintSlowly(" hit the man!\n");
                } else if (players[g_player].weapon < 3) {
                    PrintSlowly(" cut the man!\n");
                } else {
                    PrintSlowly(" shoot the man!\n");
                }
                enemy_hp -= weapons[players[g_player].weapon].attack;
                if (enemy_hp <= 80) {
                    PrintSlowly("The man: You are strong, but I'll...I'll...I'll...I'll run away!\n");
                    PrintSlowly("The man run quickly!\n");
                    PrintSlowly("What should you do?\n");
                    cout << "1.Catch him." << endl;
                    cout << "2.Give up." << endl;
                    do {
                        cin >> choose;
                    } while (choose != 1 and choose != 2);
                    if (choose == 1) {
                        players[g_player].PrintNameSlowly();
                        PrintSlowly(": Don't run away!\n");
                        PrintSlowly("You run after him.\n");
                        int random_number = SuiJi()%10;
                        if (random_number < 4) {
                            PrintSlowly("You catched up with him.\n");
                            PrintSlowly("What will you do next?\n");
                            cout << "1.Attack him." << endl;
                            cout << "2.Catch him and ask him." << endl;
                            do {
                                cin >> choose;
                            } while (choose != 1 and choose != 2);
                            if (choose == 1) {
                                if (players[g_player].weapon == 0) {
                                    PrintSlowly("You hit him!\n");
                                } else if (players[g_player].weapon <= 2) {
                                    PrintSlowly("You cut him!\n");
                                } else {
                                    PrintSlowly("You shoot him!\n");
                                }
                                enemy_hp -= weapons[players[g_player].weapon].attack;
                                if (enemy_hp <= 0) {
                                    players[g_player].rating += 150;
                                    if (players[g_player].rating >= 400) {
                                        PrintSlowly("You killed the man and get 150 rating, 170 money!\n");
                                        players[g_player].money += 170;
                                    } else {
                                        PrintSlowly("You beat the man and get 150 rating, 150 money!\n");
                                        players[g_player].money += 150;
                                    }
                                } else {
                                    PrintSlowly("The man(!x_x): Oh, I can't be killed by you!\n");
                                    PrintSlowly("The man dropped a smoke grenade and then you can't saw anything.\n");
                                    PrintSlowly("After a few minutes, you could see things around you, but the man was disappeared.\n");
                                }
                            } else {
                                PrintSlowly("You catched him and asked him.\n");
                                players[g_player].PrintNameSlowly();
                                PrintSlowly(": What's your name?\n");
                                PrintSlowly("The man: You can call me killer john.\n");
                                players[g_player].PrintNameSlowly();
                                PrintSlowly(": I'm a killer, too. Do you know how to kill a killer?\n");
                                PrintSlowly("The killer: No, I don't. It's my first time to kill a killer.\n");
                                players[g_player].PrintNameSlowly();
                                PrintSlowly("(^_^#): That's interesting. Now, let me teach you.\n");
                                PrintSlowly("When you wanted to attack the killer, the killer left a smoke grenade and ran away quickly.\n");
                                PrintSlowly("You couldn't see anything in a few minutes.\n");
                                PrintSlowly("When you could see things around you, the killer was disappeared.\n");
                                players[g_player].PrintNameSlowly();
                                PrintSlowly("(o_o#): ***...\n");
                            }
                        } else {
                            PrintSlowly("The man ran so quickly that you couldn't catch up with him.\n");
                        }
                    } else {
                        players[g_player].PrintNameSlowly();
                        PrintSlowly(": (^w^)\n");
                    }
                } else {
                    PrintSlowly("The man polled out a pistol: *** you!\n");
                    PrintSlowly("Bang! He shot you.\n");
                    players[g_player].hp -= 20;
                    PrintSlowly("Your hp substracted by 20!\n");
                    if (players[g_player].hp <= 0) {
                        players[g_player].hp = 0;
                        Die();
                    } else {
                        PrintSlowly("What will you do next?\n");
                        cout << "1.Run away." << endl;
                        cout << "2.Attack him." << endl;
                        do {
                            cin >> choose;
                        } while (choose != 1 and choose != 2);
                        if (choose == 1) {
                            PrintSlowly("Ran away sccessfully.\n");
                        } else {
                            while (enemy_hp > 0 and players[g_player].hp > 0) {
                                if (players[g_player].weapon == 0) {
                                    PrintSlowly("You hit him!\n");
                                } else if (players[g_player].weapon < 3) {
                                    PrintSlowly("You cut him!\n");
                                } else {
                                    PrintSlowly("You shot him!\n");
                                }
                                enemy_hp -= weapons[players[g_player].weapon].attack;
                                if (enemy_hp <= 0) {
                                    enemy_hp = 0;
                                    break;
                                }
                                int scar = 20-clothes[players[g_player].clothes].defence;
                                if (scar < 0) {
                                    scar = 0;
                                }
                                PrintSlowly("The man shot you!\n");
                                PrintSlowly("Your hp substracted by ");
                                cout << scar;
                                PrintSlowly("!\n");
                                if (players[g_player].hp <= 0) {
                                    players[g_player].hp = 0;
                                    break;
                                }
                                PrintSlowly("What will you do next?\n");
                                cout << "1.Attack." << endl;
                                cout << "2.Run away." << endl;
                                do {
                                    cin >> choose;
                                } while (choose != 1 and choose != 2);
                                if (choose == 2) {
                                    PrintSlowly("Ran away sccessfully!\n");
                                    break;
                                }
                            } if (enemy_hp == 0) {
                                players[g_player].rating += 110;
                                if (players[g_player].rating >= 400) {
                                    PrintSlowly("You killed him and got 110 rating and 150 money.\n");
                                    players[g_player].money += 150;
                                } else {
                                    PrintSlowly("You beat him and got 110 rating and 100 money.\n");
                                    players[g_player].money += 100;
                                }

                            } if (players[g_player].hp == 0) {
                                Die();
                            }
                        }
                    }
                }
            } else if (choose == 2) {
                PrintSlowly("You ran away.\n");
            } else {
                players[g_player].PrintNameSlowly();
                PrintSlowly(": Are you a killer?\n");
                PrintSlowly("The man: Sure!\n");
                players[g_player].PrintNameSlowly();
                PrintSlowly(": How many people did you kill?\n");
                PrintSlowly("The killer: I don't remember that number, but I remember it is very large.\n");
                players[g_player].PrintNameSlowly();
                PrintSlowly(": Oh, so you are very strong.\n");
                PrintSlowly("The killer: Of course!\n");
                players[g_player].PrintNameSlowly();
                PrintSlowly(": But I want to know how strong you are, if you can follow a rule and kill me, you are really strong.\n");
                PrintSlowly("The killer: What's the rule?\n");
                players[g_player].PrintNameSlowly();
                PrintSlowly(": That is you must not move in 10 seconds, but then you can kill me.\n");
                PrintSlowly("The killer: So easy, let's begin!\n");
                PrintSlowly("Then the man stood here and not move at all.\n");
                PrintSlowly("You ran away quickly and shouted: You are very strong but very silly! (^w^)\n");
            }
        } else if (players[g_player].rating < 600) {

        }
    } else {
        PrintSlowly("None is here.\n");
        PrintSlowly("Everyone knows that you are a scary killer and you may kill any person any minute.\n");
        PrintSlowly("It seems that you made a big diference.\n");
        players[g_player].PrintNameSlowly();
        PrintSlowly(": (^W^)\n");
    }
    Pause();
}
void CityCenter() {
    system("cls");
}
void ShowSelf() {
    players[g_player].PrintName();
    cout << endl;
    cout << "--------------------------------" << endl;
    cout << "hp: " << players[g_player].hp << endl;
    cout << "rating: " << players[g_player].rating << endl;
    cout << "money: " << players[g_player].money << endl;
    cout << "weapon: " << weapons[players[g_player].weapon].name << endl;
    cout << "clothes: " << clothes[players[g_player].clothes].name << endl;
    cout << "--------------------------------" << endl;
    Pause();
}
void GoOut() {
    system("cls");
    cout << "Where are you going?" << endl;
    cout << "--------------------------------" << endl;
    cout << "1.home" << endl;
    cout << "2.shop" << endl;
    cout << "3.supermarket" << endl;
    cout << "4.Dark Bar" << endl;
    cout << "5.park" << endl;
    cout << "6.center of city" << endl;
    cout << "Type other numbers to back." << endl;
    cout << "--------------------------------" << endl;
    int choose;
    cin >> choose;
    switch (choose) {
    case 1:
        Home();
        break;
    case 2:
        Shop();
        break;
    case 3:
        Supermarket();
        break;
    case 4:
        Bar();
        break;
    case 5:
        Park();
        break;
    case 6:
        CityCenter();
        break;
    default:
        break;
    }
}
int Fight(string name) {
    system("cls");
    PrintSlowly("Then you have to have a fight with ");
    PrintSlowly(name);
    PrintSlowly(".\n");
    PrintSlowly("Press a, d to move, press j, i to attack.\n");
    PrintSlowly("Try your best, if you can't win and want to run away, please type q when you fight.\n");
    Pause();
    system("cls");
    g_sum_player_fight = 0;
    g_sum_enemy_fight = 75;
    g_hp_enemy = 100;
    g_areFighting = true;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            player_face[i][j] = player_default[i][j];
        }
    }
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            enemy_face[i][j] = enemy_default[i][j];
        }
    }
    while (g_areFighting) {
        ShowFight();
        PlayerControlFight();
        if (g_areFighting) {
            EnemyControlFight();
        }
    }
    ShowFight();
    if (g_hp_enemy == 0) {
        return 1;
    } else if (players[g_player].hp == 0) {
        return 0;
    }
    return -1;
}
void Die() {
    PrintSlowly("Unluckily, you died.\n");
    PrintSlowly("You have to restart the game.\n");
    players[g_player].hp = 100;
    players[g_player].rating = 0;
    players[g_player].weapon = 0;
    players[g_player].clothes = 0;
}
void RecordData() {
    ofstream fout("DarkWorld.dat");
    fout << g_num_players << endl;
    for (int i = 1; i <= g_num_players; i++) {
        fout << players[i].name << ' ' << players[i].pasword << ' ' << players[i].hp << ' ' << players[i].rating << ' ' << players[i].money << ' ' << players[i].weapon << ' ' << players[i].clothes << endl;
    }
    fout.close();
}
void Quit() {
    RecordData();
    PrintSlowly("Quit...\n");
    g_run = false;
}
void PrintSlowly(string text) {
    for (int i = 0; i < text.length(); i++) {
        cout << text[i];
        Sleep(80);
    }
}
void Pause() {
    cout << "Press any key to continue...";
    getch();
    cout << endl;
}
void PlayerControlFight() {
    while (kbhit()) {
        char ch = getch();
        if (ch == 'a') {
            if (g_sum_player_fight > 0) {
                g_sum_player_fight--;
            }
        } else if (ch == 'd') {
            if (g_sum_player_fight < g_sum_enemy_fight - 5) {
                g_sum_player_fight++;
            }
        } else if (ch == 'j') {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    player_face[i][j] = player_hand_attack[i][j];
                }
            }
            ShowFight();
            if (g_sum_enemy_fight == g_sum_player_fight + 5) {
                g_hp_enemy -= 10;
                if (g_hp_enemy <= 0) {
                    g_hp_enemy = 0;
                    for (int i = 0; i < 5; i++) {
                        for (int j = 0; j < 5; j++) {
                            enemy_face[i][j] = enemy_die[i][j];
                        }
                    }
                    g_areFighting = false;
                }
            }
            ShowFight();
            ShowFight();
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    player_face[i][j] = player_default[i][j];
                }
            }
        } else if (ch == 'i') {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    player_face[i][j] = player_foot_attack[i][j];
                }
            }
            ShowFight();
            if (g_sum_enemy_fight == g_sum_player_fight + 5) {
                g_hp_enemy -= 20;
                if (g_sum_enemy_fight <= 75 - 10) {
                    g_sum_enemy_fight += 10;
                } if (g_hp_enemy <= 0) {
                    g_hp_enemy = 0;
                    for (int i = 0; i < 5; i++) {
                        for (int j = 0; j < 5; j++) {
                            enemy_face[i][j] = enemy_die[i][j];
                        }
                    }
                    g_areFighting = false;
                }
            }
            ShowFight();
            ShowFight();
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    player_face[i][j] = player_default[i][j];
                }
            }
        } else if (ch == 'q') {
            g_areFighting = false;
        }
    }
}
void EnemyControlFight() {
    if (g_sum_enemy_fight > g_sum_player_fight + 5) {
        g_sum_enemy_fight--;
    } else {
        int sj = SuiJi() % 2;
        if (sj == 0) {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    enemy_face[i][j] = enemy_hand_attack[i][j];
                }
            }
            ShowFight();
            if (g_sum_enemy_fight == g_sum_player_fight + 5) {
                players[g_player].hp -= 10;
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    for (int i = 0; i < 5; i++) {
                        for (int j = 0; j < 5; j++) {
                            player_face[i][j] = player_die[i][j];
                        }
                    }
                    g_areFighting = false;
                }
            }
            ShowFight();
            ShowFight();
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    enemy_face[i][j] = enemy_default[i][j];
                }
            }
        } else {
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    enemy_face[i][j] = enemy_foot_attack[i][j];
                }
            }
            ShowFight();
            if (g_sum_enemy_fight == g_sum_player_fight + 5) {
                players[g_player].hp -= 20;
                if (g_sum_player_fight >= 10) {
                    g_sum_player_fight -= 10;
                }
                if (players[g_player].hp <= 0) {
                    players[g_player].hp = 0;
                    for (int i = 0; i < 5; i++) {
                        for (int j = 0; j < 5; j++) {
                            player_face[i][j] = player_die[i][j];
                        }
                    }
                    g_areFighting = false;
                }
            }
            ShowFight();
            ShowFight();
            for (int i = 0; i < 5; i++) {
                for (int j = 0; j < 5; j++) {
                    enemy_face[i][j] = enemy_default[i][j];
                }
            }
        }
    }
}
void ShowFight() {
    Sleep(80);
    system("cls");
    for (int i = 0; i < 5; i++) {
        for (int j = 1; j <= g_sum_player_fight; j++) {
            cout << ' ';
        }
        for (int j = 0; j < 5; j++) {
            cout << player_face[i][j];
        }
        for (int j = 1; j <= g_sum_enemy_fight - g_sum_player_fight - 5; j++) {
            cout << ' ';
        }
        for (int j = 0; j < 5; j++) {
            cout << enemy_face[i][j];
        }
        if (g_sum_enemy_fight < 75) {
            cout << endl;
        }
    }
    players[g_player].PrintName();
    cout << ": " << players[g_player].hp << endl;
    cout << "enemy: " << g_hp_enemy << endl;
}
int SuiJi() {
    srand(time(0));
    return rand();
}
int main(int argc, char const *argv[]) {
    Init();
    Home();
    Pause();
    return 0;
}