全部评论 1

  • 顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶#include <bits/stdc++.h>
    #include <conio.h>
    using namespace std;
    void memu();
    struct Pickaxe {
    int a[5] = {20, 30, 50};
    int hardness, grade;
    Pickaxe (int grade = 0) {
    this -> grade = grade;
    }
    };
    struct Player {
    vector <Pickaxe> pickaxe;
    int mines[5] = {0, 0, 0};
    int money = 0;
    int power = 114514;
    };
    Player player;
    struct Mine {
    int n;
    char mine[50][50];
    bool isShow[50][50];
    string information;
    struct Pos {
    int x, y;
    Pos (int x = 1, int y = 1) {
    this -> x = x;
    this -> y = y;
    }
    };
    Pos playerPos;
    Mine (int n = 4, Pos pos = {1, 1}) {
    this -> n = n;
    playerPos = pos;
    information = "";
    srand(time(0));
    for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
    mine[i][j] = rand() % 2 ? ' ' : '';
    isShow[i][j] = 0;
    }
    }
    mine[rand() % (n - 1) + 2][rand() % (n - 1) + 2] = 'O';
    isShow[playerPos.x][playerPos.y] = 1;
    }
    void pr() {
    system("cls");
    for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
    if (i == playerPos.x && j == playerPos.y) {
    printf("@");
    } else if (isShow[i][j]) {
    printf("%c", mine[i][j]);
    } else {
    printf("#");
    }
    printf(" ");
    }
    printf("\n");
    }
    printf("%s\n", information.c_str());
    printf("体力:%d", player.power);
    }
    void dig(int x, int y) {
    if (!isShow[x][y] && player.power) {
    if (mine[x][y] == '
    ') {
    int r = rand() % 100 + 1;
    if (1 <= r && r <= 75) {
    r = 0;
    } else if (76 <= r && r <= 95) {
    r = 1;
    } else {
    r = 2;
    }
    player.mines[r]++;
    string s[5] = {"铁", "金", "钻石"};
    information = "你挖到了" + s[r] + "矿";
    } else if (mine[x][y] == 'O') {
    information = "你挖到了通往下一层的洞口";
    } else {
    information = "你什么都没挖到";
    }
    isShow[x][y] = 1;
    player.power--;
    } else {
    information = "";
    }
    }
    int playerMove(char key) {
    int d[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
    int f = -1;
    switch (key) {
    case 'w':
    f = 0;
    break;
    case 's':
    f = 1;
    break;
    case 'a':

    1周前 来自 浙江

    1

热门讨论