制作团队:洛谷813622(Igallta) 989571(_ayaka_)
Mod:_ayaka_
双人模式:Igallta
公告:
原先的9.8改名为 Alpha 1.0,以后每次更新都增加 0.1。
Alpha 1.11 改为 Beta 1.0。
手铐机制:朝自己开枪也算一个回合,例如:
上手铐+朝自己开枪 -> 朝对面开枪 -> 对面回合
Data:
Data 9.3:新增设定:对方死了之后对方的手铐也会解掉。
Data Alpha 1.1 :为防止有人钻牛角尖,大部分改为 string 类型。
Data Alpha 1.2 :为防止有些人数道具是第几号数大脑过载数晕过去了,显示道具时会增加编号。
Data Alpha 1.3 :不能命名为上帝、God…不然就会&%#@&)DHD*#。
Data Alpha 1.4 :游戏结束后并不会立刻窗口结束,而是会等三秒后按任意键结束。
Data Alpha 1.5 :增加等待时间,让你反应过来(原来只有 100ms,现在改为 500ms)。
Data Alpha 1.6 :缩短代码长度,没错,仅此而已。
Data Alpha 1.7 :增加如果射出的是实弹那么窗口就会抖动、每次获得的道具从固定4个改为 1~4 随机。以及优化游玩体验。
Data Alpha 1.8 :经讨论,认为道具设置为 1~5 个/次更为合适。
Data Alpha 1.9 :优化玩家体验。
Data Alpha 1.10 :修复关于输入无限循环的 bug。
Data Beta 1.0 :删除死亡后手铐解除的机制。
Data Beta 1.1 :修复在开发手铐时不小心让p1直接获得12个手铐的bug(汗),优化玩家体验。
Date Beta 1.2:大大缩短代码长度(目前有 bug 无法游玩)
/*
作者:洛谷813622、989571 csdn:luogu_Igallta
严禁搬迁
这个版本是Beta 1.1版本
*/
#include<bits/stdc++.h>
#include<windows.h>
#define clr system("cls")
#define int long long
using namespace std;
string dj[] = {"放大镜", "华子", "小刀", "饮料", "手铐"}, zd[] = {"空弹", "实弹"}, pl1, pl2;
bool is1 = 1, sk, zs; //sk:手铐 zs:打自己
int yu, kb, sd, b1 = 2, win1,win2,b2 = 2, ls = 1, hit = 1, mxb = 2, jl; //jl:记录被挂手铐后局数
vector<int>dj1, dj2;
queue<int>g;//枪械装弹
inline void dist(int atime, int st = 20) {
int shake_distance = 10, x, y, width, height;
int counts = atime / st / 2;
RECT rect;
HWND window = NULL, oldwindow = NULL;
for (int i = 1; i <= counts; i++) {
window = GetForegroundWindow();
if (window != oldwindow) {
GetWindowRect(window, &rect);
x = rect.left;
y = rect.top;
width = rect.right - x;
height = rect.bottom - y;
oldwindow = window;
}
MoveWindow(window, x - shake_distance, y, width, height, TRUE);
Sleep(st);
MoveWindow(window, x + shake_distance, y, width, height, TRUE);
Sleep(st);
}
}
inline void split() {
clr;
int shake_time = 20, shake_distance = 10, x, y, width, height;
RECT rect;
HWND window = NULL, oldwindow = NULL;
clr;
for (int i = 1; i <= 300; i++) {
window = GetForegroundWindow();
if (window != oldwindow) {
GetWindowRect(window, &rect);
x = rect.left;
y = rect.top;
width = rect.right - x;
height = rect.bottom - y;
oldwindow = window;
}
MoveWindow(window, x - shake_distance, y, width, height, TRUE);
Sleep(shake_time);
MoveWindow(window, x + shake_distance, y, width, height, TRUE);
Sleep(shake_time);
if (i == 1)cout << "你";
else if (i == 20)cout << "怎";
else if (i == 40)cout << "么";
else if (i == 60)cout << "这";
else if (i == 80)cout << "么";
else if (i == 100)cout << "不";
else if (i == 120)cout << "听";
else if (i == 140)cout << "话";
else if (i == 160)cout << "呢";
else if (i == 170)cout << "?";
else if (i == 180)cout << "你";
else if (i == 200)cout << "让";
else if (i == 220)cout << "我";
else if (i == 240)cout << "要";
else if (i == 260)cout << "消";
else if (i == 280)cout << "失";
else if (i == 300)cout << "了";
}
int t = 250;
while (t--) {
cout << "ERROR ";
Sleep(3);
}
t = 20;
while (t--)system("start cmd");
t = 20;
while (t--) {
MessageBox(NULL, "ERROR!", "ERROR", MB_OK | MB_ICONWARNING);
}
exit(0);
}
inline void dontagain() {
clr;
Sleep(500);
for (int i = 0; i <= 2; i++) {
cout << '.';
Sleep(1000);
}
cout << "够";
Sleep(2000);
cout << "了!!!\n";
dist(800);
system("pause");
cout << "你再这样程序就出 bug 了!\n";
system("pause");
clr;
}
inline void drink() {
int tmpo = g.front();
g.pop();
cout << "你选择了饮料!退出的这发子弹是:" << zd[tmpo] << "!\n";
--yu;
if (tmpo) {
--sd;
} else --kb;
Sleep(1500);
}
inline void over() {
Sleep(1000);
system("pause");
clr;
++ls;
}
inline void fdj() {
cout << "当前子弹:";
cout << zd[g.front()] << '\n';
Sleep(1500);
}
signed main() {
cout << "玩家1的名字:";
cin >> pl1;
int cnt1 = 0, cnt2 = 0;
while (pl1 == "上帝" || pl1 == "GOD" || pl1 == "GOd" || pl1 == "GoD" || pl1 == "God" || pl1 == "gOD" || pl1 == "goD" || pl1 == "gOd" || pl1 == "god") {
if (cnt1 == 6) {
dontagain();
}
if (cnt1 == 12) {
split();
}
cout << "ERROR 010101000110100001100101001000000100011101101111011001000010000001101000011000010111001100100000011000100110010101100101011011100010000001100100011001010110000101100100001011000111100101101111011101010010000001100011011000010110111000100111011101000010000001101110011000010110110101100101001000000111100101101111011101010111001000100000011011100110100101100011011010110110111001100001011011010110010100100000001000100100011101101111011001000010001000101110";
cout << "\n你需要重新输入一个名字......\n";
++cnt1;
cin >> pl1;
}
cout << "玩家2的名字:";
cin >> pl2;
while (pl2 == "上帝" || pl2 == "GOD" || pl2 == "GOd" || pl2 == "GoD" || pl2 == "God" || pl2 == "gOD" || pl2 == "goD" || pl2 == "gOd" || pl2 == "god") {
if (cnt2 == 6) {
dontagain();
}
if (cnt2 == 12) {
split();
}
cout << "ERROR 010101000110100001100101001000000100011101101111011001000010000001101000011000010111001100100000011000100110010101100101011011100010000001100100011001010110000101100100001011000111100101101111011101010010000001100011011000010110111000100111011101000010000001101110011000010110110101100101001000000111100101101111011101010111001000100000011011100110100101100011011010110110111001100001011011010110010100100000001000100100011101101111011001000010001000101110";
cout << "\n你需要重新输入一个名字......\n";
cin >> pl2;
}
clr;
cout << "现在讲解规则:\n小刀:可以让下一发子弹伤害变成两倍\n华子:可以回一滴血\n放大镜:你可以查看当前子弹\n饮料:可以退一发子弹\n手铐:可以限制对方一回合动不了\n一共有3轮。\n";
Sleep(1200);
system("pause");
clr;
start:
;
if (ls == 4) {
clr;
cout << "局数已到,游戏结束。\n";
if(win1>win2){
cout<<"p1赢了!";
}else cout<<"p2赢了!";
Sleep(2000);
system("pause");
exit(0);
}
//初始化
b1 = 2 * ls;
b2 = 2 * ls;
hit = 1;
zs = 0;
sk = 0;
yu = 0;
kb = 0;
sd = 0;
jl = 0;
mxb = b1;
dj1.clear();
dj2.clear();
while (g.size())g.pop();
cout << "第" << ls << "局\n目前比分(p1 : p2):"<<win1<<" : "<<win2<<'\n';
Sleep(1200);
clr;
while (1) {
clr;
srand(time(0));
if (!yu) {
sc:
;
int k = rand() % 5 + 1;
cout << "现在开始上道具!\n" << pl1 << "(p1)获得了:";
for (int i = 1; i <= k; i++) {
int t = rand() % 5;
dj1.push_back(t);
cout << dj[t] << ' ';
Sleep(500);
}
cout << "\n现在" << pl1 << "(p1)拥有道具:\n";
for (auto v : dj1) {
cout << dj[v] << ' ';
}
cout << '\n';
Sleep(1200);
system("pause");
clr;
cout << pl2 << "(p2)获得了:";
for (int i = 1; i <= k; i++) {
int t = rand() % 5;
dj2.push_back(t);
cout << dj[t] << ' ';
Sleep(500);
}
cout << "\n现在" << pl2 << "(p2)拥有道具:\n";
for (auto v : dj2) {
cout << dj[v] << ' ';
}
cout << '\n';
Sleep(1200);
system("pause");
clr;
kb = rand() % 6 + 1;
sd = rand() % 6 + 1;
yu = (kb + sd);
int tk = kb, ts = sd;
cout << "空包弹有:" << kb << " 实弹有:" << sd << '\n';
cout << "装填子弹中......\n";
srand(time(0));
for (int i = 1; i <= yu; i++) {
bool k = rand() % 2;
if (k) {
if (tk) {
g.push(0);
--tk;
} else {
g.push(1);
--ts;
}
} else {
if (ts) {
g.push(1);
--ts;
} else {
g.push(0);
--tk;
}
}
}
Sleep(1200);
}
cout << "\n现在" << pl1 << "(p1)拥有道具:\n";
for (auto v : dj1) {
cout << dj[v] << ' ';
}
cout << "\n现在" << pl2 << "(p2)拥有道具:\n";
for (auto v : dj2) {
cout << dj[v] << ' ';
}
cout << "\n生命值(p1,p2):" << b1 << "," << b2 << "\n";
cout << "空包弹有:" << kb << "发,实弹有:" << sd << "发\n";
if (is1) {
cout << "现在是" << pl1 << "(p1)的回合\n";
use1:
;
if (dj1.size()) {
cout << "\n现在" << pl1 << "(p1)拥有道具:\n";
int total = 0;
for (auto v : dj1) {
cout << (++total) << "号:" << dj[v] << " ";
}
cout << "你要使用道具吗?(Y/N)\n";
string t;
ques:
;
cin >> t;
if (t.size() > 1) {
cout << "请重新输入:";
goto ques;
}
char q = t[0];
q = toupper(q);
if (q == 'Y') {
cout << "\n请告诉我要使用道具在你拥有的的编号(从1开始;输入0代表不小心输错不使用道具):";
int bh;
string inp;
quesd1:
;
cin >> inp;
if (inp.size() > 1) {
cout << "不合法!\n请重新输入!";
goto quesd1;
}
if (!isdigit(inp[0])) {
cout << "不合法!\n请重新输入!";
goto quesd1;
}
bh = inp[0] - 49;
if (bh == -1)goto hit1;
if (bh > dj1.size() - 1 || bh < 0) {
cout << "不合法!\n请重新输入!";
goto quesd1;
} else {
int tmp = dj1[bh];
dj1.erase(dj1.begin() + bh);
switch (tmp) {
case 0: {
fdj();
break;
}
case 1: {
if (b1 == mxb) {
cout << "达到上限值,无法回复。";
} else {
++b1;
cout << "你选择了华子!\n" << pl1 << "回复1点血量,现在他有" << b1 << "条生命值!";
}
Sleep(1500);
break;
}
case 2: {
if (hit == 2) {
cout << "你在本回合已经使用了小刀,不能再使用了!将会新加小刀至末尾。\n";
dj1.push_back(2);
} else {
hit = 2;
cout << "你选择了小刀!这一回合将造成双倍伤害!\n";
}
Sleep(1500);
break;
}
case 3: {
drink();
break;
}
case 4: {
if (sk) {
cout << "别人已经被铐起来了.....将把手铐移至末尾!\n";
dj1.push_back(4);
} else {
sk = 1;
jl = 0;
cout << "你选择了手铐!下一回合敌人将无法移动!\n";
}
Sleep(1500);
break;
}
}
if (!yu) {
goto sc;
}
goto use1;
}
} else if (q == 'N') {
cout << "好的。";
} else {
cout << "请重新输入:";
goto ques;
}
}
hit1:
;
cout << "你要打谁?(0:自己 1:另一名玩家):";
string ht1;
bool ht;
cin>>ht1;
if(ht1.size()>1||!isdigit(ht1[0])){
cout<<"请重新输入!\n";
goto hit1;
}
ht=(ht1[0]-48);
int k = g.front();
if (ht) {
if (k) {
cout << "当前是实弹!" << pl2 << "受到了" << hit << "点伤害!\n";
dist(400);
b2 -= hit;
--sd;
} else {
cout << "很遗憾,当前是空包弹。\n";
--kb;
}
} else {
zs = 1;
if (k) {
cout << "哦豁,当前是实弹!" << pl1 << "受到了" << hit << "点伤害!\n";
dist(400);
b1 -= hit;
--sd;
} else {
cout << "恭喜你,当前是空包弹!\n";
--kb;
}
}
g.pop();
Sleep(1000);
--yu;
hit = 1;
} else {
cout << "现在是" << pl2 << "(p2)的回合\n";
use2:
;
if (dj2.size()) {
char q;
int total = 0;
cout << "\n现在" << pl2 << "(p2)拥有道具:\n";
for (auto v : dj2) {
cout << (++total) << "号:" << dj[v] << " ";
}
ques2:
;
cout << "\n你要使用道具吗?(Y/N)\n";
string t;
cin >> t;
if (t.size() > 1) {
cout << "请重新输入:";
goto ques2;
}
q = t[0];
q = toupper(q);
if (q == 'Y') {
cout << "\n请告诉我要使用道具在你拥有的的编号(从1开始;输入0代表不小心输错不使用道具):";
string inp;
quesd2:
;
cin >> inp;
if (inp.size() > 1) {
cout << "不合法!\n请重新输入!";
goto quesd2;
}
if (!isdigit(inp[0])) {
cout << "不合法!\n请重新输入!";
goto quesd2;
}
int bh = inp[0] - 49;
if (bh == -1) {
goto hit2;
}
if (bh > dj2.size() - 1 || bh < 0) {
cout << "不合法!\n请重新输入!";
goto quesd2;
} else {
int tmp = dj2[bh];
dj2.erase(dj2.begin() + bh);
switch (tmp) {
case 0: {
fdj();
break;
}
case 1: {
if (b2 == mxb) {
cout << "达到上限值,无法回复。";
} else {
++b2;
cout << "你选择了华子!\n" << pl2 << "回复1点血量,现在他有" << b2 << "条生命值!";
}
Sleep(1500);
break;
}
case 2: {
if (hit == 2) {
cout << "你在本回合已经使用了小刀,不能再使用了!将会新加小刀至末尾。\n";
dj2.push_back(2);
} else {
hit = 2;
cout << "你选择了小刀!这一回合将造成双倍伤害!\n";
}
Sleep(1500);
break;
}
case 3: {
drink();
break;
}
case 4: {
if (sk) {
cout << "别人已经被铐起来了......将把手铐移至末尾!\n";
dj2.push_back(4);
} else {
sk = 1;
jl = 0;
cout << "你选择了手铐!下一回合敌人将无法移动!\n";
}
Sleep(1500);
break;
}
}
if (!yu) {
goto sc;
}
goto use2;
}
} else if (q == 'N') {
cout << "好的。";
} else {
cout << "请重新输入:";
goto ques2;
}
}
hit2:
;
cout << "你要打谁?(0:自己 1:另一名玩家):";
string ht1;
bool ht;
cin >> ht1;
if(ht1.size()>1 || !isdigit(ht1[0])){
cout<<"请重新输入!\n";
goto hit2;
}
ht=(ht1[0]-48);
int k = g.front();
if (ht) {
if (k) {
cout << "当前是实弹!" << pl1 << "受到了" << hit << "点伤害!\n";
dist(400);
b1 -= hit;
--sd;
} else {
cout << "很遗憾,当前是空包弹。\n";
--kb;
}
} else {
zs = 1;
if (k) {
cout << "哦豁,当前是实弹!" << pl2 << "受到了" << hit << "点伤害!\n";
dist(400);
b2 -= hit;
--sd;
} else {
cout << "恭喜你,当前是空包弹!\n";
--kb;
}
}
g.pop();
Sleep(1000);
--yu;
hit = 1;
}
if (b1 <= 0) {
clr;
cout << pl2 << "赢了\n";
++win2;
over();
goto start;
}
if (b2 <= 0) {
clr;
cout << pl1 << "赢了\n";
++win1;
over();
goto start;
}
if (sk) {
++jl;
if (jl == 2) {
sk = 0;
jl = 0;
}
}
if (!sk && !zs) {
is1 = 1 - is1;
}
zs = 0;
}
return 0;
}
如果你的 Dev 说这个代码 CE,解决方案如下:
最顶上一栏的“工具” -> “编译选项” -> “编译时加入以下参数”
填 -std=c++14 -O2 -lm -static
如果还是 CE,并且提示的里面含有 -std=c++14 -O2 -lm -static
,那么代表你的 Dev 版本过低,你需要下载 DevC++5.11 或 DevC++6.5(推荐下载 DevC++6.5)。
其他编译器(诸如 VSCode Codeblock)我不知道,反正你使用的是 c++14 及以上版本即可。
历代版本:
Alpha 1.2
Alpha 1.3
Alpha 1.4
Alpha 1.5
Alpha 1.6
Alpha 1.7
Alpha 1.8
Alpha 1.9
Alpha 1.10
Beta 1.0
Beta 1.1
Beta 1.2 很严重bug,修复中,请勿游玩
另外,我们也提供 Mod 玩法:
三国杀版本
-
如果原版复刻出现了 bug,请私信 Igallta 或者给这个博客回复。
-
如果Mod出现了 bug,请私信 _ayaka_ 或者给ta的博客回复。
-
有 bug 一定要说!而且一定要说明确,比如某些同学只说手铐有问题,我也不知道你出现了什么问题,只知道手铐有问题,导致我 de 了半天一点问题都没看出来,也一头雾水。如果你自己非要钻牛角尖,输入个什么转义字符啊,ctrl啊…那些我们也没办法。就不要发出来了。
真要求改的话,你可以去找找 C/C++ 作者,和ta谈谈…