- BC20270080's blog
玉防闪(未完工)
- 2025-2-24 15:26:57 @
本博客仅限于将校内校外代码进行传输
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int slowout(char *p)
{
while(1)
{
if(*p!=0)
printf("%c",*p++);
else
break;
Sleep(70);
}
}
/**
0 = 命
1 = 玉
2 = 防
3 = 盾 4 = 钟
5 = 闪
6 = 戳 7 = 2戳 8 = 3戳 9 = 4戳
10 = 小电 11 = 中电 12 = 大电 13 = 雷神
14 = 小猪 15 = 中猪 16 = 大猪 17 = 吴猪 18 = 聪明吴猪
19 = 重拳 20 = 天帝 21 = 无相
22 = 暴击 23 = 重击 24 = 痛击
25 = 马丁 26 = 百变马丁
27 = 黑洞 28 = 白洞 29 = 虫洞
30 = 狒狒 31 = 暗黑狒狒
32 = 绝杀 33 = 超级绝杀
34 = 斩 35 = 元气斩 36 = 猪油斩
37 = 蕉蕉 38 = 暗黑蕉蕉
39 = 甩剑
40 = 哈哈
**/
struct numbers
{
bool flag;//表示是否出过中猪
float belong[41];//表示剩余资源数量
bool if_shang;//上挂状态
void simple_reset()
{
for(int i = 1;i <= 40;i++) belong[i] = 0;
belong[0] = 1;
flag = false;
}
};
numbers a,b;//a是真人,b是人机
void intro()
{
printf("");
return;
}
bool decision(numbers x,int id,int last,int last_last)
{
if(x.if_shang && id != 27) return true;
switch(id)
{
case 1: return true;
case 2: return true;
case 3: return x.belong[2] >= 1.0;
case 4: return x.belong[3] >= 2.0 || x.belong[4] >= 1.0;
case 5: return true;
case 6: return x.belong[1] >= 0.5;
case 7: return x.belong[6] >= 2.0;
case 8: return last == 7;
case 9: return last == 8;
case 10: return x.belong[5] >= 1.5;
case 11: return x.belong[10] >= 2.0;
case 12: return x.belong[11] >= 2.0;
case 13: return last == 12;
case 14: return x.belong[1] >= 1.0;
case 15: return x.belong[14] >= 2.0;
case 16: return x.belong[15] >= 2.0;
case 17: return x.belong[16] >= 1.0;
case 18: return last == 17;
case 19: return x.belong[1] >= 1.5;
case 20: return x.belong[19] >= 2.0;
case 21: return x.belong[20] >= 2.0;
case 22: return x.belong[1] >= 1.0 && x.belong[2] >= 1.0;
case 23: return x.belong[22] >= 2.0;
case 24: return x.belong[23] >= 2.0;
case 25: return x.belong[19] >= 1.0 || x.belong[22] >= 1.0;
case 26: return last == 25;
case 27: return x.belong[1] >= 2.0;
case 28: return x.belong[27] >= 1.0 && x.belong[39] >= 1.0;
case 29: return x.belong[28] >= 1.0 && x.belong[27] >= 1.0;
case 30: return x.belong[39] >= 2.5 || (x.belong[1] >= 4.0 && x.belong[2] >= 2.0);
case 31: return x.belong[30] >= 2.0;
case 32: return x.belong[1] >= 10.0;
case 33: return x.belong[32] >= 2.0;
case 34: return x.belong[1] >= 0.5 && x.belong[2] >= 0.5;
case 35: return x.belong[34] >= 2.0;
case 36: return x.belong[35] >= 1.0 && x.flag;
case 37: return x.belong[37] >= 1.0;
case 38: return x.belong[38] >= 1.0;
case 39: return true;
case 40: return last != 40 || last_last != 40;
}
}
string return_name(int id)
{
switch(id)
{
case 1: return "玉 ";
case 2: return "防 ";
case 3: return "盾 ";
case 4: return "钟 ";
case 5: return "闪 ";
case 6: return "戳 ";
case 7: return "二戳 ";
case 8: return "三戳 ";
case 9: return "四戳 ";
case 10: return "小电 ";
case 11: return "中电 ";
case 12: return "大电 ";
case 13: return "雷神 ";
case 14: return "小猪 ";
case 15: return "中猪 ";
case 16: return "大猪 ";
case 17: return "吴猪 ";
case 18: return "聪明吴猪 ";
case 19: return "重拳 ";
case 20: return "天帝 ";
case 21: return "无相 ";
case 22: return "暴击 ";
case 23: return "重击 ";
case 24: return "痛击 ";
case 25: return "马丁 ";
case 26: return "百变马丁 ";
case 27: return "黑洞 ";
case 28: return "白洞 ";
case 29: return "虫洞 ";
case 30: return "狒狒 ";
case 31: return "暗黑狒狒 ";
case 32: return "绝杀 ";
case 33: return "超级绝杀 ";
case 34: return "斩 ";
case 35: return "元气斩 ";
case 36: return "猪油斩 ";
case 37: return "蕉蕉 ";
case 38: return "暗黑蕉蕉 ";
case 39: return "甩剑 ";
case 40: return "哈哈 ";
}
}
void saydone(numbers x,int last,int last_last)
{
for(int id = 1;id <= 40;id++)
{
if(!decision(x,id,last,last_last)) continue;
cout << return_name(id) << "...编号" << id << endl;
}
printf("请问你要出什么:");
return;
}
void do_after(numbers x,int id)
{
switch(id)
{
case 1: x.belong[1]++;
case 2: x.belong[2]++;
case 3: x.belong[3]++;
case 4: if(x.belong[3] >= 2) {x.belong[3] -= 2;x.belong[4]++;}
case 5: x.belong[5]++;
case 6: {x.belong[1] -= 0.5;x.belong[6]++;}
case 7: x.belong[6] -= 2;
case 8: break;
case 9: break;
case 10: {x.belong[5] -= 1.5;x.belong[10]++;}
case 11: {x.belong[10] -= 2;x.belong[11]++;}
case 12: return x.belong[11] >= 2.0;
case 13: return last == 12;
case 14: return x.belong[1] >= 1.0;
case 15: return x.belong[14] >= 2.0;
case 16: return x.belong[15] >= 2.0;
case 17: return x.belong[16] >= 1.0;
case 18: return last == 17;
case 19: return x.belong[1] >= 1.5;
case 20: return x.belong[19] >= 2.0;
case 21: return x.belong[20] >= 2.0;
case 22: return x.belong[1] >= 1.0 && x.belong[2] >= 1.0;
case 23: return x.belong[22] >= 2.0;
case 24: return x.belong[23] >= 2.0;
case 25: return x.belong[19] >= 1.0 || x.belong[22] >= 1.0;
case 26: return last == 25;
case 27: return x.belong[1] >= 2.0;
case 28: return x.belong[27] >= 1.0 && x.belong[39] >= 1.0;
case 29: return x.belong[28] >= 1.0 && x.belong[27] >= 1.0;
case 30: return x.belong[39] >= 2.5 || (x.belong[1] >= 4.0 && x.belong[2] >= 2.0);
case 31: return x.belong[30] >= 2.0;
case 32: return x.belong[1] >= 10.0;
case 33: return x.belong[32] >= 2.0;
case 34: return x.belong[1] >= 0.5 && x.belong[2] >= 0.5;
case 35: return x.belong[34] >= 2.0;
case 36: return x.belong[35] >= 1.0 && x.flag;
case 37: return x.belong[37] >= 1.0;
case 38: return x.belong[38] >= 1.0;
case 39: return true;
case 40: return last != 40 || last_last != 40;
}
}
void startgame()
{
int i = 0,t;
a.simple_reset();b.simple_reset();
int last = 0,be4_last = 0;//上回合和上上回合
while(a.belong[0] > 0 && b.belong[0] > 0)
{
i++;
slowout("第");
printf("%d",i);
slowout("回合\n");
slowout("这回合你可以出:\n");
saydone(a,last,be4_last);
while(cin >> t)
{
if(!decision(a,t,last,be4_last)) printf("\n你现在不能出这个!请重新考虑:");
else break;
}
}
}
int main()
{
intro();
int games = 1;
while(true)
{
games++;
startgame();
slowout("游戏结束!\n");
int again = MessageBox(NULL,"还要再玩一局吗","请选择",MB_YESNO);
if(again == 7)
{
printf("期待下次游玩!\n");
return 0;
}
else if(again == 6)
{
slowout("第");
printf("%d",games);
slowout("局:");
}
}
}