谁能帮我用c++写一个小游戏,骰子的,高分悬赏谢谢啦!!!最好带注释

游戏规则:玩家投两次骰子,将点数相加,如果和为7或者11就赢了,为2,3,12就输了,为4568910,就再投一次,直到投到你自己第一次投到的点数(4568910)才算胜利,如果投到7,则游戏者输。
要求:用RollDice函数 模拟投的两次骰子,Game函数模拟进行一次游戏。主函数中要玩家选择继续游戏还是退出游戏,最好还要限速游戏获胜次数
typedef enum{WIN, LOSE, TIE} GameStatus;// WIN:赢,LOSE:输,TIE:平局
在实现时可声明骰子游戏类DiceGame,将上面讲的函数作为类的辅助函数,类中含方法Game(),用来运行游戏,下面为用伪代码描述的整个游戏的参考流程。
//最好带注释

#include <iostream>
#include <ctime>
#include <cstdlib>

using std::cout;
using std::cin;
using std::endl;

typedef enum {
    WIN,
    LOSE,
    TIE
}GameStatus;

int RollDice()
{
    int dice1, dice2;

    srand(time(0));
    dice1 = 1 + rand() % 6;

    srand(time(0));
    dice2 = 1 + rand() % 6;

    return dice1 + dice2;
}

class DiceGame
{
public:
    DiceGame()
    {
        m_lastSum = -1;
    }

    GameStatus Game()
    {
        GameStatus ret;
        int sum = RollDice();
        if (m_lastSum != -1)
            cout << "上一次点数和为 " << m_lastSum << ", 此次的点数和为 " << sum << endl;
        else if (m_lastSum == -1)
            cout << "此次的点数和为 " << sum << endl;

        if (m_lastSum == -1)
        {
            if (sum == 7 || sum == 11)
                ret = WIN;
            else if (sum == 2 || sum == 3 || sum == 12)
                ret = LOSE;
            else
            {
                ret = TIE;
                m_lastSum = sum;
            }
        }
        else
        {
            if (sum == m_lastSum)
                ret = WIN;
            else
                ret = LOSE;
            m_lastSum = -1;
        }
        return ret;
    }


private:
    int m_lastSum;
};

int main(int argc, char* argv[])
{
    char input;
    const char* result[] = {"本次赢了", "本次输了", "本次平局"};
    DiceGame instance;
    cout << "开始游戏:" << endl;
    while(1)
    {
        cout << result[instance.Game()] << endl;
        cout << "是否继续游戏?(输入q退出游戏,输入其他字符继续游戏):";
        cin.get(input);
        if (input == 'q')
        {
            cout << "游戏结束!" << endl;
            break;
        }
        else if (input != '\n')             // 防止用户不输入任何字符就直接输入回车键
        {
            cin.clear();
            cin.ignore(1024, '\n');
        }
    }
    return 0;
}

如果是在cmd里运行的话可以的,但是如果要做出UI的话就要Python了。本人Python忠实用户,要Python代码这就给

#include
using namespace std;

class Game
{
private:
int die1;
int die2;
int tzs;
public:
int RollDice(); //函数原型 //抛骰子函数

void PlayGame(); //进行一次游戏

void GetHelp();//游戏帮助

};

enum GameStatus{ WIN, LOSE, PLAYING }; //枚举游戏状态;

int Game::RollDice() //抛骰子函数
{
int die1 = 1 + rand() % 6;
int die2 = 1 + rand() % 6;
int tzs = die1 + die2;
cout << "Player rooled " << die1 << "+" << die2 << "=" << tzs << endl;
return tzs;
}

void Game::PlayGame()
{
int a;
cout << "输入任何数字开始游戏:";
cin >> a;
int tzs, first;
int GameStatus;
tzs = RollDice();
switch (tzs){
case 7:
case 11:
GameStatus = WIN;
break;
case 2:
case 3:
case 12:
GameStatus = LOSE;
break;
default:
GameStatus = PLAYING;
first = tzs;
break;
}
while (GameStatus == PLAYING)
{
tzs = RollDice();
if (tzs = first)
GameStatus = WIN;

    else if (tzs = 7)
        GameStatus = LOSE;
}

if (GameStatus == WIN)
    cout << "你赢啦" << endl;
else if (GameStatus == LOSE)
    cout << "很遗憾你输了" << endl;

char j;
char y;
cout << "想继续玩此游戏吗? 输入'y'或'Y'则继续,输入其他字符则退出游戏。" << endl;
cin >> y;
while (y == 'y' || 'Y')
{
    if (y == 'y')
    {
        cout << "输入任意字符游戏开始" << endl;
        cin >> j;
        cout << "游戏开始\n\n\n\n";
        Game::PlayGame();
    }
    break;
}

}

void Game::GetHelp(){

cout << endl

    << "    比赛规则:每人初始积分为100分,从1号开始掷骰子,骰子出现后,"
    << "根据点数减去掷骰人的相应积分, 如 减去 10*(6-点数),然后"
    << "根据点数多少,就依次向后数掷骰的点数同等数量的人,被数到的"
    << "被数到的最后一个人继续掷骰子,计算积分,依此类推。"
    << "如果某人掷骰子后,其积分小于等于0则出列,余下的人继续按照此法进行游戏,直到剩下最后一个人,为胜利者。"
    << endl << endl << endl;

}

int main()
{

cout << endl
    << "                            **************************************************\n\n"
    << "                                           欢迎进入掷骰子游戏\n\n"
    << "                            **************************************************\n\n"
    << endl << endl << endl;
int o;

cout << "                                          ------------------------" << endl;
cout << "                                          |请输入你要选择的项目  |" << endl;
cout << "                                          |1.玩一手游戏          |" << endl;
cout << "                                          |2.查看帮助            |" << endl;
cout << "                                          |3.退出游戏            |" << endl;
cout << "                                          ------------------------" << endl;

cin >> o;
switch (o)
{
case 1:


    char j;
    cout << "                                          输入任意字符游戏开始" << endl;
    cin >> j;
    cout << "                                          游戏开始\n\n\n\n";
    Game obj;
    obj.PlayGame();
    break;
case 2:
    obj.GetHelp();
    break;
case 3:
    break;
default:
    cout << "                                          对不起你输入的不在范围内" << endl;
    break;
}
return 0;

}

如帮助到您,请采纳!

#include<iostream>
#include<cstdlib>
using namespace std;

enum GameStatus {WIN,LOSE,PLAYING};  //枚举游戏状态

int rollDice() {
    int dice1, dice2,sum;
    dice1 = 1 + rand() % 6;  //将产生的随机数转成范围1-6的骰子的点数
    dice2 = 1 + rand() % 6;
    sum = dice1 + dice2;
    return sum;
}

int main() {
    unsigned seed;
    GameStatus status;
    int sum,MyPoint;
    cin >> seed;
    srand(seed);
    sum = rollDice();
    switch (sum)
    {
    case 7:
    case 11:status = WIN;
        break;
    case 2:
    case 3:
    case 12:status = LOSE;
        break;
    default:status = PLAYING; MyPoint = sum;
        break;
    }
    while (status==PLAYING)
    {
        sum = rollDice();
        if (sum == MyPoint)
            status = WIN;
        else if (sum == 7)
            status = LOSE;
    }
    if (status == WIN)
        cout << "player win";
    else     //此时只有输和赢两种状态
        cout << "player lose";
    return 0;
}

https://www.cnblogs.com/pgzhang/p/9069916.html