自制游戏——AC荣耀装备版
2024-08-17 13:27:51
发布于:浙江
灵感来源:Blown sand的游戏——AC荣耀
游玩方法:复制
注意:程序存档时会在你的电脑上生成文档,不要阻止
存档后尽量不要删那个文档,除非你要毁号(doge)
还没做完,不喜勿喷
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
struct people{//结构体
double hp,hpmax,attack,defense,money,exp,pv,buffa,buffd,buffhm,jubuffa,jubuffd,jubuffhm,numbuffa,numbuffd,numbuffhm;
}a[2];
int equip1[11]={1,0,0,0,0,0,0,0,0,0,0},chuan[6]={0},pumian=0;
string equip2[11]={"无","贤者的庇佑","红莲斗篷","莫辛纳甘","抵抗之靴","七杀剑","背带裤","平底锅","水滴","派蒙","激光发射器"};
int lifew(){
ofstream outfile("存档.txt");//存档,得意之作
outfile<<a[0].hp*3<<endl;
outfile<<a[0].hpmax*3<<endl;
outfile<<a[0].attack*3<<endl;
outfile<<a[0].defense*3<<endl;
outfile<<a[0].money*3<<endl;
outfile<<a[0].exp*3<<endl;
outfile<<a[0].pv*3<<endl;
for(int i=0;i<11;i++){
outfile<<equip1[i]*3<<endl;
}
for(int i=0;i<7;i++){
outfile<<chuan[i]*3<<endl;
}
outfile.close();
return 0;
}
int lifer(){
ifstream file("存档.txt");//读档
double line;
file>>a[0].hp;a[0].hp/=3;
file>>a[0].hpmax;a[0].hpmax/=3;
file>>a[0].attack;a[0].attack/=3;
file>>a[0].defense;a[0].defense/=3;
file>>a[0].money;a[0].money/=3;
file>>a[0].exp;a[0].exp/=3;
file>>a[0].pv;a[0].pv/=3;
for(int i=0;i<11;i++){
file>>equip1[i];equip1[i]/=3;
}
for(int i=0;i<7;i++){
file>>chuan[i];chuan[i]/=3;
}
file.close();
return 0;
}
int general_attack(int i){//普攻
int exp=0;
if(pumian==1){//无视防御的情况
a[1].hp-=a[0].attack*a[0].buffa*a[0].jubuffa;
}
else{
a[1].hp-=a[0].attack*a[0].buffa*a[0].jubuffa-a[1].defense*a[1].buffd;
}
exp+=(a[0].attack*a[0].buffa*a[0].jubuffa)*30;//加经验
if(i==1){
cout<<"你进行了一次普攻,造成";
if(pumian==1){
cout<<a[0].attack*a[0].buffa*a[0].jubuffa<<"点伤害";
}
else{
cout<<a[0].attack*a[0].buffa*a[0].jubuffa-a[1].defense*a[1].buffd<<"点伤害";
}
cout<<endl;
}
return exp;
}
int di_general_attack(int i){//对手普攻
a[0].hp-=a[1].attack*a[1].buffa-((a[0].defense+a[0].numbuffd)*a[0].buffd*a[0].jubuffd);
if(i==1){
cout<<"对手进行了一次普攻,造成"<<a[1].attack*a[1].buffa-((a[0].defense+a[0].numbuffd)*a[0].buffd*a[0].jubuffd)<<"点伤害"<<endl;
}
}
int surrender(){//投降
system("cls");
cout<<"你投降了。"<<endl<<"你没有得到任何东西。";
Sleep(2000);
}
int fight(){//战斗
int n,exp=0,fuhuo=0,wodong=0,didong=0,CD[3]={0,0,0};
double pailv=0.10;
a[0].jubuffa=1.00;
a[0].jubuffd=1.00;
a[0].jubuffhm=1.00;
if(equip1[1]==1&&chuan[0]==1){
fuhuo=1;
}
if(equip1[10]==1&&chuan[6]==10){
pumian=1;
}
system("cls");
srand(time(NULL));//初始化随机数
//设置对手属性
a[1].hp=rand()%80+(a[0].hp-20);
a[1].attack=rand()%100+(a[0].attack-60);
if(a[1].attack<=0) a[1].attack=2;
if(a[1].attack>a[0].attack) a[1].attack-=10;
a[1].defense=rand()%10+(a[0].defense-8);
if(a[1].defense<0) a[1].defense=0;
if(a[1].defense>a[0].defense) a[1].defense-=2;
a[1].buffa=1.00;
a[1].buffd=1.00;
a[1].buffhm=1.00;
string name[10]={"\"别叫我写c++\"","\"张斌老师\"","\"AC狗小黑子\"","\"不食·嘎门\"","\"大香蕉\"","\"开朗的程序猿\"","\"劳大\"","\"趋泥大爸\"","\"怪盗缺德\"","\"买核弹的小女孩\"",};
for(int i=0;i<rand()%100;i++){//真·匹配
system("cls");
cout<<"匹配中.";
for(int j=0;j<i%6;j++) cout<<".";
cout<<endl;
Sleep(i*30);
}
system("cls");
cout<<"匹配成功,你的对手是:"<<name[rand()%10]<<endl;
int dihpmax=a[1].hp;
cout<<"对手生命:"<<a[1].hp<<" ";
cout<<"对手攻击:"<<a[1].attack*a[1].buffa<<" ";
cout<<"对手防御:"<<a[1].defense*a[1].buffd<<endl;
cout<<"你的生命:"<<a[0].hp<<" ";
cout<<"你的攻击:"<<a[0].attack*a[0].buffa<<" ";
cout<<"你的防御:"<<(a[0].defense+a[0].numbuffd)*a[0].buffd<<endl;
Sleep(3000);
while(a[0].hp>0&&a[1].hp>0){
system("cls");
//我方攻击
if(wodong==0){//判断是否冻结
do{//重复直到得到正确答案,后同
cout<<"-------------------------------"<<endl;
cout<<"你要:1.普攻;2.技能;3.投降:"; //选择操作
cin>>n;
switch(n){
case 1:if(equip1[7]==1&&a[1].hp<=dihpmax*0.15&&chuan[6]==7){
a[1].hp=0;cout<<"对方血量过低,触发平底锅被动"<<endl;//平底锅被动,后同
}exp+=general_attack(1);break;break;
case 2:if(equip1[3]==0&&equip1[5]==0&&equip1[6]==0){
cout<<"没有技能,自动普攻"<<endl;
if(equip1[7]==1&&a[1].hp<=dihpmax*0.15&&chuan[6]==7){
a[1].hp=0;cout<<"对方血量过低,触发平底锅被动"<<endl;
}
exp+=general_attack(1);
break;
}else{
int ke[3]={0,0,0};
string jiname[3]={"1.狙击 ","2.人剑合一 ","3.唱跳 "}; //仨技能
if(equip1[3]==1&&CD[0]==0&&chuan[3]==3) ke[0]=1;
if(equip1[5]==1&&CD[1]==0&&chuan[3]==5) ke[1]=1;
if(equip1[6]==1&&CD[2]==0&&chuan[1]==6) ke[2]=1;
for(int i=0;i<3;i++){
if(ke[i]==1) cout<<jiname[i];
}
cout<<"请选择你要使用的技能:";
int m;
cin>>m;
do{
switch(m){
case 1:if(ke[0]==1&&CD[0]==0&&chuan[3]==3){//狙击
if(rand()%5==1){//20%概率(低了点吧)
a[0].buffa*=10.00;
exp+=general_attack(0);
a[0].buffa/=10.00;
cout<<"狙击成功"<<endl;
}
else{
cout<<"狙击失败"<<endl;
}
CD[0]=3;
break;
}else cout<<"技能未拥有或正在冷却中,自动普攻"<<endl;
if(equip1[7]==1&&a[1].hp<=dihpmax*0.15&&chuan[6]==7){
a[1].hp=0;cout<<"对方血量过低,触发平底锅被动"<<endl;
}exp+=general_attack(1);Sleep(2000);break;
case 2:if(ke[1]==1&&CD[1]==0&&chuan[3]==5){//人剑合一
//我看过一部动画片叫斗罗大陆,有原著的。巧了,主角叫唐三,作者是唐家三少???
//这个技能来源于斗1的角色尘心的大招(第七魂技),会叠一堆buff
a[0].buffa*=2.50;
exp+=general_attack(1);
if(equip1[7]==1&&a[1].hp<=dihpmax*0.15&&chuan[6]==7){
a[1].hp=0;cout<<"对方血量过低,触发平底锅被动"<<endl;
}
a[0].buffa/=2.50;
a[0].jubuffd*=1.10;
CD[1]=4;
break;
}else cout<<"技能未拥有或正在冷却中,自动普攻"<<endl;
if(equip1[7]==1&&a[1].hp<=dihpmax*0.15&&chuan[6]==7){
a[1].hp=0;cout<<"对方血量过低,触发平底锅被动"<<endl;
}exp==general_attack(1);Sleep(2000);break;
case 3:if(ke[2]==1&&CD[2]==0&&chuan[1]==6){//唱跳
a[0].hp+=a[0].hpmax*a[0].buffhm*0.03;
a[1].buffd*=0.90;
CD[2]=2;
break;
//鸡你太美~呗呗~
}else cout<<"技能未拥有或正在冷却中,自动普攻"<<endl;
if(equip1[7]==1&&a[1].hp<=dihpmax*0.15&&chuan[6]==7){
a[1].hp=0;cout<<"对方血量过低,触发平底锅被动"<<endl;
}exp+=general_attack(1);Sleep(2000);break;
default:cout<<"技能未拥有或正在冷却中,自动普攻"<<endl;
if(equip1[7]==1&&a[1].hp<=dihpmax*0.15&&chuan[6]==7){
a[1].hp=0;cout<<"对方血量过低,触发平底锅被动"<<endl;
}exp+=general_attack(1);Sleep(2000);break;
}
}while(m!=1&&m!=2&&m!=3);
}break;
case 3:surrender();return 0;break;
default:break;
}
}while(n!=1&&n!=2&&n!=3);
int jiji=rand()%100;
if(jiji<(pailv*100)&&chuan[5]==9&&equip1[9]==1){//派蒙(原神,启动!)
pailv=0.10;
didong++;
cout<<"派蒙冻结了时间,对手一回合无法行动"<<endl;
}
else if(chuan[5]==9&&equip1[9]==1){
pailv+=0.10;
cout<<"派蒙未冻结时间,概率增加"<<endl;
}
}
else{
cout<<"你本回合无法行动"<<endl;
wodong--;
}//冻结的情况
if(equip1[2]==1){//红莲斗篷
a[0].buffa*=0.30;
exp+=general_attack(0);
a[0].buffa/=0.30;
cout<<"红莲斗篷对敌人造成了伤害"<<endl;
}
cout<<"对手生命:"<<a[1].hp<<" ";
cout<<"对手攻击:"<<a[1].attack*a[1].buffa<<" ";
cout<<"对手防御:"<<a[1].defense*a[1].buffd<<endl;
cout<<"你的生命:"<<a[0].hp<<" ";
cout<<"你的攻击:"<<a[0].attack*a[0].buffa*a[0].jubuffa<<" ";
cout<<"你的防御:"<<(a[0].defense+a[0].numbuffd)*a[0].buffd*a[0].jubuffd<<endl<<endl;
Sleep(2000);
//对手攻击
if(didong==0){
int jid=rand()%100;
if(jid%20==0&&a[0].pv>=5){//偷窃,5级以后出现
int tou=(rand()%10+1)*3;
a[0].money-=tou;
wodong++;
cout<<"对手使用了技能\"偷窃\",偷取了你"<<tou<<"钱,你的心理被破坏了,一回合不能行动"<<endl;
}
else if(jid%50==0&&a[0].pv>=12){//惩戒,12级以后出现
wodong+=2;
a[1].buffa*=2.50;
di_general_attack(0);
a[1].buffa/=2.50;
cout<<"对手使用技能\"惩戒\",眩晕了你并对你造成了伤害,你两回合不能行动"<<endl;
}
else if(jid%25==0&&a[0].pv>=10){//用血量攻击,10级以后出现
a[1].buffa*=2.50;
di_general_attack(0);
a[1].buffa/=2.50;
a[1].hp-=dihpmax*0.10;
cout<<"对手消耗血量对你进行攻击"<<endl;
}
else if(jid%30==0&&a[0].pv>=8){//强化,8级以后出现
a[0].jubuffa*=0.90;
a[1].buffa*=1.10;
a[1].buffd+=1.10;
cout<<"对手大吼一声,给自己壮胆,同时对你造成威慑,你的攻击下降10%,对手的攻击和防御增加10%"<<endl;
}
else if(jid%10==0&&a[0].pv>=3){//回血,3级以后出现
int hui=dihpmax*0.05+rand()%(dihpmax/10);
a[1].hp+=hui;
cout<<"对手使用了技能\"回血\",回复了"<<hui<<"血"<<endl;
}
else if(jid%15==0&&a[0].pv>=2){//暴击(鸡?),2级以后出现
a[1].buffa*=2.00;
di_general_attack(0);
cout<<"对手进行了暴击,对你造成了"<<a[1].attack*a[1].buffa-((a[0].defense+a[0].numbuffd)*a[0].buffd*a[0].jubuffd)<<"点伤害"<<endl;
a[1].buffa/=2.00;
}
else di_general_attack(1);//普攻
}
else{
cout<<"对手本回合无法行动"<<endl;didong--;
}
cout<<"对手生命:"<<a[1].hp<<" ";
cout<<"对手攻击:"<<a[1].attack*a[1].buffa<<" ";
cout<<"对手防御:"<<a[1].defense*a[1].buffd<<endl;
cout<<"你的生命:"<<a[0].hp<<" ";
cout<<"你的攻击:"<<a[0].attack*a[0].buffa*a[0].jubuffa<<" ";
cout<<"你的防御:"<<(a[0].defense+a[0].numbuffd)*a[0].buffd*a[0].jubuffd<<endl<<endl;
Sleep(2000);
if(a[0].hp<=0&&fuhuo==1){//贤者的庇佑(复活甲?)
cout<<"你没血了,自动复活"<<endl;
a[0].hp=0;
a[0].hp+=(a[0].hpmax+a[0].numbuffhm)*a[0].buffhm*a[0].jubuffhm*0.20;
fuhuo--;
Sleep(2000);
}
for(int i=0;i<3;i++){//减冷却
if(CD[i]>0){
CD[i]--;
}
}
}
//判断输赢
if(a[0].hp<=0){
cout<<"你失败了。"<<endl;
a[0].hp=0;
a[0].money+=a[0].pv*100/5+100;//等级越高,金币越多
exp/=2;//输了经验减半
}
else if(a[1].hp<=0){
cout<<"你赢了。"<<endl;
a[0].money+=a[0].pv*100+600;
}
a[0].exp+=exp;
a[0].hp+=a[0].hpmax*a[0].buffhm*0.10;
cout<<"你获得了"<<exp<<"经验与一些钱"<<endl;
Sleep(2000);
}
int equip(){//装备
int lei[11]={0,1,1,4,3,4,2,7,6,6,7},n;
system("cls");
cout<<"拥有:";
for(int i=1;i<11;i++){
if(equip1[i]==1){
cout<<equip2[i]<<" ";
}
}
//显示装备
cout<<endl<<"装备栏:"<<endl;
cout<<"1.衣服:"<<equip2[chuan[0]]<<endl;
cout<<"2.裤子:"<<equip2[chuan[1]]<<endl;
cout<<"3.鞋子:"<<equip2[chuan[2]]<<endl;
cout<<"4.主武器:"<<equip2[chuan[3]]<<endl;
cout<<"5.头盔:"<<equip2[chuan[4]]<<endl;
cout<<"6.伙伴:"<<equip2[chuan[5]]<<endl;
cout<<"7.副武器:"<<equip2[chuan[6]]<<endl;
//替换装备
cout<<"输入你要替换的装备位置,输入其他返回:";
cin>>n;
if(n>7||n<1) int clear();
else{//替换装备
string abc;cout<<"装备名称:";cin>>abc;
int sb=-1;
for(int i=0;i<11;i++){
if(equip2[i]==abc&&lei[i]==n&&equip1[i]==1) sb=i;
if(equip2[i]==abc&&lei[i]==0&&equip1[i]==1) sb=i;
}
if(sb==-1){
cout<<"你没有这件装备";
Sleep(2000);
equip();
}
else chuan[n-1]=sb;cout<<"装备成功";Sleep(2000);
}
}
int shop(){//商店
int n;
int equipmoney[11]={0,5000,1500,2500,1200,3000,2000,6000,8888,10000,7500};
system("cls");
cout<<"-------------------------------"<<endl;
cout<<"| 商 店 |"<<endl;
cout<<"-------------------------------"<<endl;
cout<<"相同系列有buff哦!"<<endl;
cout<<"(衣服)(王者)1.贤者的庇佑:每局可复活1次,血量回复20% 5000元"<<endl;
cout<<"(衣服)(王者)2.红莲斗篷:每回合对对手造成普攻30%的伤害 1500元"<<endl;
cout<<"(主武器)(和平)3.莫辛纳甘:获得技能:狙击,成功概率20%,成功后对对手造成普攻1000%的伤害,冷却2回合 2500元"<<endl;
cout<<"(鞋子)(王者)4.抵抗之靴:提高50%的防御 1200元"<<endl;
cout<<"(主武器)(斗罗)5.七杀剑:获得技能:人剑合一,使下次普攻伤害提高150%并进行一次普攻,同时在本局内提高10%防御力;被动:伤害提高50%,冷却3回合 3000元"<<endl;
cout<<"(裤子)(鬼畜)6.背带裤:获得技能:唱跳,永久减少对手10%的防御力并回复3%血,冷却1回合 2000元"<<endl;
cout<<"(副武器)(和平)7.平底锅:当对手血量小于其最大血量的15%,使用普攻可直接击杀 6000元"<<endl;
cout<<"(伙伴)(三体)8.水滴:提高100点防御 8888元"<<endl;
cout<<"(伙伴)(原神)9.派蒙:每回合有10%概率冻结时间,使对手一回合不能行动,若未冻结,则概率增加10%,冻结后概率回到10% 10000元"<<endl;
cout<<"(副武器)(三体)10.激光发射器:使普攻无视对方防御 7500元"<<endl;
cout<<"(副武器)(三体)10.激光发射器:使普攻无视对方防御 7500元"<<endl;
cout<<"输入其他返回。";
cin>>n;
if(n<1||n>10) int clear();
else{
if(a[0].money>=equipmoney[n]&&equip1[n]==0){//买装备成功
cout<<"购买成功";
a[0].money-=equipmoney[n];
equip1[n]=1;
Sleep(2000);
int shop();
}
else if(equip1[n]==1){//买过了
cout<<"你已经买过了";
Sleep(2000);
int shop();
}
else{//没马内
cout<<"你没钱了";
Sleep(2000);
int shop();
}
}
}
int peoplepv(){//显示数值
int n;
system("cls");
cout<<"血:"<<a[0].hp<<" ";
cout<<"血量上限:"<<a[0].hpmax*a[0].buffhm<<" ";
cout<<"攻击:"<<a[0].attack*a[0].buffa<<" ";
cout<<"防御:"<<(a[0].defense+a[0].numbuffd)*a[0].buffd<<" ";
cout<<"马内:"<<a[0].money<<" ";
cout<<"经验:"<<a[0].exp<<" ";
cout<<"等级:"<<a[0].pv<<"升级需要:"<<a[0].pv*a[0].pv*1000<<"经验"<<endl;
cout<<"输入任意内容返回:";
cin>>n;
int clear();
}
int clear(){//不是主函数,胜似主函数
a[0].buffa=1.00;
a[0].buffd=1.00;
a[0].buffhm=1.00;
a[0].numbuffa=0.00;
a[0].numbuffd=0.00;
a[0].numbuffhm=0.00;
if(chuan[2]==4) a[0].buffd*=1.50;
if(chuan[3]==5) a[0].buffa*=1.50;
if(chuan[5]==8) a[0].numbuffd+=100.00;
int n;
if(a[0].hp>a[0].hpmax*a[0].buffhm) a[0].hp=a[0].hpmax*a[0].buffhm;
do{
system("cls");
cout<<"-------------------------------"<<endl;
cout<<"| 首 页 |"<<endl;
cout<<"-------------------------------"<<endl;
cout<<"请选择:1.战斗;2.升级;3.商店;4.角色信息;5.装备;6.存档;7.读档。"<<endl;
cin>>n;
switch(n){
case 1:fight();break;
case 2:if(a[0].exp>=a[0].pv*a[0].pv*1000){//升级
a[0].exp-=a[0].pv*a[0].pv*1000;
a[0].pv++;
a[0].attack+=a[0].pv*10;
a[0].defense+=a[0].pv;
a[0].hpmax+=a[0].pv*500;
a[0].hp+=a[0].pv*100;
cout<<"升级成功";
Sleep(2000);
}
else{
cout<<"经验不足";
Sleep(2000);
}break;
case 3:shop();break;
case 4:peoplepv();break;
case 5:equip();break;
case 6:lifew();cout<<"存档成功";Sleep(2000);clear();break;
case 7:lifer();cout<<"读档成功";Sleep(2000);clear();break;
case 114514:a[0].money+=10000;a[0].exp+=100000;cout<<"资源获取成功";break;//兑换码,测试用
default:clear();break;
}
}while(n!=1&&n!=2&&n!=3&&n!=4&&n!=5&&n!=6&&n!=7);
}
int main(){//没错主函数就这么一点
//设置初始参数
a[0].hp=100;
a[0].hpmax=500;
a[0].attack=10;
a[0].defense=1;
a[0].money=300;
a[0].exp=0;
a[0].pv=1;
a[0].buffa=1.00;
a[0].buffd=1.00;
a[0].buffhm=1.00;
while(true) clear();
return 0;
}
全部评论 3
[图片](file:///C:/Users/Administrator/Desktop/%E6%89%B9%E6%B3%A8%202024-08-16%20154212.png)
2024-08-16 来自 浙江
0有BUG!!
2024-08-16 来自 浙江
0什么BUG?
2024-08-16 来自 浙江
0描述清楚
2024-08-16 来自 浙江
0当运行时第7行会报错,并会显示
C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'string' does not name a type
C:\Users\Administrator\Desktop\未命名55.cpp In function 'int lifew()':
9 2 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'ofstream' was not declared in this scope
10 2 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'outfile' was not declared in this scope
10 22 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'endl' was not declared in this scope
C:\Users\Administrator\Desktop\未命名55.cpp In function 'int lifer()':
27 2 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'ifstream' was not declared in this scope
29 2 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'file' was not declared in this scope
C:\Users\Administrator\Desktop\未命名55.cpp In function 'int general_attack(int)':
56 3 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'cout' was not declared in this scope
63 9 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'endl' was not declared in this scope
C:\Users\Administrator\Desktop\未命名55.cpp In function 'int di_general_attack(int)':
70 3 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'cout' was not declared in this scope
70 126 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'endl' was not declared in this scope
C:\Users\Administrator\Desktop\未命名55.cpp In function 'int surrender()':
75 2 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'cout' was not declared in this scope
75 22 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'endl' was not declared in this scope
C:\Users\Administrator\Desktop\未命名55.cpp In function 'int fight()':
91 17 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'time' was not declared in this scope
103 2 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'string' was not declared in this scope
106 3 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'cout' was not declared in this scope
108 9 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'endl' was not declared in this scope
112 2 C:\Users\Administrator\Desktop\未命名55.cpp [Error] 'cout' w2024-08-16 来自 浙江
0
点赞吧qwq
2024-08-16 来自 浙江
0
有帮助,赞一个