花了两天做出来的游戏,可玩(求赞)
2026-04-08 13:34:04
发布于:广东
赞赞赞
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
const int CARD_TYPES = 8;
const string CARD_NAMES[] = {"☆ 普通卡", "☆☆ 稀有卡", "☆☆☆ 史诗卡", "☆☆☆☆ 传说卡", "?? 限定卡", "?? 节日卡", "? 联动卡", "?? 典藏卡"};
const int CARD_COLORS[] = {7, 10, 11, 14, 13, 12, 9, 15};
const double PROB[] = {0.40, 0.25, 0.15, 0.10, 0.04, 0.03, 0.02, 0.01};
const int CARD_VALUE[] = {1, 2, 5, 10, 20, 30, 50, 100};
const int MYSTERY_TYPES = 6;
const string MYSTERY_NAMES[] = {"? 小福袋", "?? 惊喜礼盒", "?? 星光宝箱", "?? 钻石秘匣", "?? 王者宝库", "?? 神赐宝箱"};
const int MYSTERY_COLORS[] = {13, 12, 14, 11, 10, 9};
const int MYSTERY_BASE[] = {50, 200, 500, 1000, 5000, 10000};
struct Card {
int id;
string name;
int count;
int color;
int value;
};
struct Mystery {
int id;
string name;
int count;
int color;
int basePoints;
};
Card inventory[CARD_TYPES];
Mystery mysteryInv[MYSTERY_TYPES];
int totalDraws = 0;
int tenDrawCount = 0;
int hundredDrawCount = 0;
int thousandDrawCount = 0;
int tenThousandDrawCount = 0;
int hundredThousandDrawCount = 0;
int millionDrawCount = 0;
int mysteryCount = 0;
int pityCount = 0;
const int PITY_LIMIT = 50;
void setColor(int color) {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
}
void gotoxy(int x, int y) {
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void hideCursor() {
CONSOLE_CURSOR_INFO cursorInfo;
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
cursorInfo.bVisible = false;
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
}
void initInventory() {
for (int i = 0; i < CARD_TYPES; i++) {
inventory[i].id = i;
inventory[i].name = CARD_NAMES[i];
inventory[i].count = 0;
inventory[i].color = CARD_COLORS[i];
inventory[i].value = CARD_VALUE[i];
}
for (int i = 0; i < MYSTERY_TYPES; i++) {
mysteryInv[i].id = i;
mysteryInv[i].name = MYSTERY_NAMES[i];
mysteryInv[i].count = 0;
mysteryInv[i].color = MYSTERY_COLORS[i];
mysteryInv[i].basePoints = MYSTERY_BASE[i];
}
}
void drawTitle() {
setColor(14);
gotoxy(30, 2);
cout << "╔══════════════════════════════╗";
gotoxy(30, 3);
cout << "║ ? 抽卡模拟器 ? ║";
gotoxy(30, 4);
cout << "╚══════════════════════════════╝";
setColor(7);
}
void drawStats() {
setColor(11);
gotoxy(2, 2);
cout << "总抽卡次数: " << totalDraws;
gotoxy(2, 3);
cout << "十连抽: " << tenDrawCount;
gotoxy(2, 4);
cout << "百连抽: " << hundredDrawCount;
gotoxy(2, 5);
cout << "千连抽: " << thousandDrawCount;
gotoxy(2, 6);
cout << "万连抽: " << tenThousandDrawCount;
gotoxy(2, 7);
cout << "十万连抽: " << hundredThousandDrawCount;
gotoxy(2, 8);
cout << "百万连抽: " << millionDrawCount;
gotoxy(2, 9);
cout << "神秘礼盒: " << mysteryCount;
gotoxy(2, 10);
cout << "保底计数: " << pityCount << "/" << PITY_LIMIT;
setColor(7);
}
void drawInventory() {
setColor(14);
gotoxy(2, 12);
cout << "═══════════ 卡牌图鉴 ═══════════";
setColor(7);
for (int i = 0; i < CARD_TYPES; i++) {
setColor(inventory[i].color);
gotoxy(2, 14 + i);
cout << inventory[i].name << " x" << inventory[i].count << " (价值" << inventory[i].value << "积分)";
}
setColor(14);
gotoxy(40, 12);
cout << "═══════════ 神秘礼盒 ═══════════";
setColor(7);
for (int i = 0; i < MYSTERY_TYPES; i++) {
setColor(mysteryInv[i].color);
gotoxy(40, 14 + i);
cout << mysteryInv[i].name << " x" << mysteryInv[i].count << " (底价" << mysteryInv[i].basePoints << "积分)";
}
setColor(7);
}
void drawMenu() {
setColor(10);
gotoxy(70, 2);
cout << "[1] 单抽 (10积分)";
gotoxy(70, 4);
cout << "[2] 十连抽 (100积分)";
gotoxy(70, 6);
cout << "[3] 百连抽 (1000积分)";
gotoxy(70, 8);
cout << "[4] 千连抽 (10000积分)";
gotoxy(70, 10);
cout << "[5] 万连抽 (100000积分)";
gotoxy(70, 12);
cout << "[6] 十万连抽 (1000000积分)";
gotoxy(70, 14);
cout << "[7] 百万连抽 (10000000积分)";
gotoxy(70, 16);
cout << "[8] 神秘礼盒 (500积分)";
gotoxy(70, 18);
cout << "[9] 查看图鉴";
gotoxy(70, 20);
cout << "[0] 充值积分";
gotoxy(70, 22);
cout << "[A] 卡牌换积分";
gotoxy(70, 24);
cout << "[B] 礼盒换积分";
gotoxy(70, 26);
cout << "[C] 退出游戏";
setColor(7);
}
int drawCard() {
double r = (double)rand() / RAND_MAX;
double sum = 0;
for (int i = 0; i < CARD_TYPES; i++) {
sum += PROB[i];
if (r <= sum) return i;
}
return 0;
}
int drawMystery() {
// 礼盒随机开出的积分倍数 (1~10倍)
return rand() % 10 + 1;
}
void openMystery(int &points) {
if (points < 500) {
setColor(12);
gotoxy(50, 28);
cout << "积分不足!需要500积分!";
Sleep(1000);
gotoxy(50, 28);
cout << " ";
return;
}
points -= 500;
mysteryCount++;
int type = rand() % MYSTERY_TYPES;
int mult = drawMystery();
int gain = mysteryInv[type].basePoints * mult;
mysteryInv[type].count++;
points += gain;
setColor(mysteryInv[type].color);
gotoxy(50, 28);
cout << "?? 开出 " << mysteryInv[type].name << " x1,获得 " << gain << " 积分! (倍数x" << mult << ")";
Sleep(1500);
gotoxy(50, 28);
cout << " ";
}
void showResult(int cardCounts[]) {
system("cls");
drawTitle();
setColor(14);
gotoxy(35, 6);
cout << "★★★★★ 抽卡结果 ★★★★★";
int hasCard = 0;
for (int i = 0; i < CARD_TYPES; i++) {
if (cardCounts[i] > 0) {
setColor(inventory[i].color);
gotoxy(30, 8 + hasCard);
cout << inventory[i].name << " x" << cardCounts[i];
hasCard++;
}
}
if (hasCard == 0) {
setColor(7);
gotoxy(30, 8);
cout << "什么都没有...";
}
setColor(15);
gotoxy(30, 20);
cout << "按任意键继续...";
_getch();
}
void singleDraw(int &points) {
if (points < 10) {
setColor(12);
gotoxy(50, 28);
cout << "积分不足!请充值!";
Sleep(1000);
gotoxy(50, 28);
cout << " ";
return;
}
points -= 10;
totalDraws++;
pityCount++;
int cardId;
if (pityCount >= PITY_LIMIT) {
cardId = 3;
pityCount = 0;
} else {
cardId = drawCard();
if (cardId >= 3) pityCount = 0;
}
inventory[cardId].count++;
int cardCounts[CARD_TYPES] = {0};
cardCounts[cardId] = 1;
showResult(cardCounts);
}
void multiDraw(int &points, int times, int cost, const string &name, int &drawCount) {
if (points < cost) {
setColor(12);
gotoxy(50, 28);
cout << "积分不足!需要" << cost << "积分!";
Sleep(1000);
gotoxy(50, 28);
cout << " ";
return;
}
points -= cost;
drawCount++;
int cardCounts[CARD_TYPES] = {0};
for (int i = 0; i < times; i++) {
totalDraws++;
pityCount++;
int cardId;
if (pityCount >= PITY_LIMIT) {
cardId = 3;
pityCount = 0;
} else {
cardId = drawCard();
if (cardId >= 3) pityCount = 0;
}
inventory[cardId].count++;
cardCounts[cardId]++;
}
showResult(cardCounts);
}
void exchangeCards(int &points) {
system("cls");
drawTitle();
drawInventory();
setColor(15);
gotoxy(30, 20);
cout << "选择要兑换的卡牌编号 (1-" << CARD_TYPES << "): ";
int choice;
cin >> choice;
choice--;
if (choice < 0 || choice >= CARD_TYPES) {
setColor(12);
gotoxy(30, 22);
cout << "无效选择!";
Sleep(1000);
return;
}
if (inventory[choice].count == 0) {
setColor(12);
gotoxy(30, 22);
cout << "你没有这张卡!";
Sleep(1000);
return;
}
setColor(15);
gotoxy(30, 22);
cout << "兑换几张? (1-" << inventory[choice].count << "): ";
int num;
cin >> num;
if (num < 1 || num > inventory[choice].count) {
setColor(12);
gotoxy(30, 24);
cout << "数量无效!";
Sleep(1000);
return;
}
int gain = num * inventory[choice].value;
inventory[choice].count -= num;
points += gain;
setColor(10);
gotoxy(30, 24);
cout << "兑换成功!获得 " << gain << " 积分!";
Sleep(1500);
}
void exchangeMystery(int &points) {
system("cls");
drawTitle();
drawInventory();
setColor(15);
gotoxy(30, 20);
cout << "选择要兑换的礼盒编号 (1-" << MYSTERY_TYPES << "): ";
int choice;
cin >> choice;
choice--;
if (choice < 0 || choice >= MYSTERY_TYPES) {
setColor(12);
gotoxy(30, 22);
cout << "无效选择!";
Sleep(1000);
return;
}
if (mysteryInv[choice].count == 0) {
setColor(12);
gotoxy(30, 22);
cout << "你没有这个礼盒!";
Sleep(1000);
return;
}
setColor(15);
gotoxy(30, 22);
cout << "兑换几张? (1-" << mysteryInv[choice].count << "): ";
int num;
cin >> num;
if (num < 1 || num > mysteryInv[choice].count) {
setColor(12);
gotoxy(30, 24);
cout << "数量无效!";
Sleep(1000);
return;
}
int gain = num * mysteryInv[choice].basePoints;
mysteryInv[choice].count -= num;
points += gain;
setColor(10);
gotoxy(30, 24);
cout << "兑换成功!获得 " << gain << " 积分!";
Sleep(1500);
}
void showInventory() {
system("cls");
drawTitle();
drawInventory();
setColor(15);
gotoxy(30, 20);
cout << "按任意键返回主菜单...";
_getch();
}
int main() {
system("title 抽卡模拟器");
system("mode con cols=110 lines=35");
hideCursor();
srand(time(0));
initInventory();
int points = 10000;
char choice;
while (true) {
system("cls");
drawTitle();
drawStats();
drawInventory();
drawMenu();
setColor(15);
gotoxy(70, 28);
cout << "当前积分: " << points;
setColor(7);
gotoxy(70, 30);
cout << "请选择: ";
cin >> choice;
if (choice == '1') {
singleDraw(points);
} else if (choice == '2') {
multiDraw(points, 10, 100, "十连抽", tenDrawCount);
} else if (choice == '3') {
multiDraw(points, 100, 1000, "百连抽", hundredDrawCount);
} else if (choice == '4') {
multiDraw(points, 1000, 10000, "千连抽", thousandDrawCount);
} else if (choice == '5') {
multiDraw(points, 10000, 100000, "万连抽", tenThousandDrawCount);
} else if (choice == '6') {
multiDraw(points, 100000, 1000000, "十万连抽", hundredThousandDrawCount);
} else if (choice == '7') {
multiDraw(points, 1000000, 10000000, "百万连抽", millionDrawCount);
} else if (choice == '8') {
openMystery(points);
} else if (choice == '9') {
showInventory();
} else if (choice == '0') {
int add;
setColor(11);
gotoxy(70, 32);
cout << "充值金额: ";
cin >> add;
points += add;
setColor(10);
gotoxy(70, 33);
cout << "充值成功!当前积分: " << points;
Sleep(1500);
} else if (choice == 'A' || choice == 'a') {
exchangeCards(points);
} else if (choice == 'B' || choice == 'b') {
exchangeMystery(points);
} else if (choice == 'C' || choice == 'c') {
setColor(12);
gotoxy(70, 32);
cout << "感谢游玩,再见!";
Sleep(1000);
break;
}
}
return 0;
}
累死我了,有什么不会玩的,找我就行
全部评论 1
经常跟他玩反义词游戏,如“精”对“傻”,“诱”对“逼”,然后给他一段文字,让他反义最后两个字,便会出现奇葩回答(Deep seek):
2026-04-13 来自 广东
1




















有帮助,赞一个