111
2025-10-04 21:22:22
发布于:浙江
#include <windows.h>
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;
// ==================== 用户自定义部分 ====================
// 循环宏定义
#define fw(l,r,i,j) for(int i=l,END##i=r;i<=END##i;i+=j)
#define fs(r,l,i,j) for(int i=r,END##i=l;i>=END##i;i-=j)
#define ms(arr, val) memset(arr, val, sizeof(arr))
// 常用类型别名
typedef long long ll;
typedef double d;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef const ll coll;
// 输入输出优化函数
void oi(void) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
// 文件重定向函数
void fr(ll x, str s) {
if(x == 1) {
str s1 = s + ".in", s2 = s + ".out";
freopen(s1.c_str(), "r", stdin);
freopen(s2.c_str(), "w", stdout);
} else if(x == 2) {
fclose(stdin);
fclose(stdout);
}
}
coll ARMSS = 10;
ll h = 100, gold;
bool timesfled = 0;
void cls() {
system("pause & cls");
}
struct Arm {
ll grade, durability;
};
struct ARM : Arm {
str name;
bool f;
};
ll armsum = 4;
struct ENEMy {
str name;
ll hp, grade;
};
class ENEMY;
class ARMS {
private:
str name;
ll grade, durability;
bool f;
public:
ARMS(str name, ll grade, ll durability, bool f) {
this->name = name;
this->grade = grade;
this->durability = durability;
this->f = f;
}
ARM dataviewing() {
ARM temp;
temp.grade = this->grade;
temp.durability = this->durability;
temp.name = this->name;
temp.f = this->f;
return temp;
}
void attack(ENEMY& a);
void ARMsell() {
f = 0;
}
};
class ENEMY {
private:
str name;
ll hp, grade;
public:
void hurt(ll damage) {
this->hp = max(this->hp - damage, 0LL);
}
ENEMY(str name, ll hp, ll grade) {
this->name = name;
this->hp = hp;
this->grade = grade;
}
bool die() {
return this->hp <= 0;
}
ENEMy dataviewing() {
ENEMy temp;
temp.name = this->name;
temp.hp = this->hp;
temp.grade = this->grade;
return temp;
}
void attack();
};
void ARMS::attack(ENEMY& a) {
if(this->durability >= 1) {
ENEMy c = a.dataviewing();
a.hurt(this->grade);
this->durability--;
ENEMy b = a.dataviewing();
printf("使用%s对%s造成%lld点伤害\n%s还剩%lld点耐久\n%s还剩%lld点血\n",
this->name.c_str(), b.name.c_str(), min(this->grade, c.hp),
this->name.c_str(), this->durability, b.name.c_str(), b.hp);
} else {
printf("耐久不足!\n");
}
}
void ENEMY::attack() {
h = max(h - this->grade, 0LL);
printf("收到来自%s的%lld点伤害,还剩%lld点血。\n", this->name.c_str(), grade, h);
}
bool player_die() {
return h <= 0;
}
ll endcheck(ENEMY a) {
if(player_die()) return 2;
if(a.die()) return 1;
return 0;
}
vector<ARMS> arm;
void merchant();
void shelf();
void armsell();
void armsshop() {
printf("欢迎进入武器市场……\n");
ll num;
printf("1.奸商\n");
printf("2.武器锻造商\n");
printf("3.群众\n");
cin >> num;
switch(num) {
case 1:
merchant();
break;
case 2:
break;
case 3:
break;
default:
printf("还想干嘛!\n");
break;
}
}
void merchant() {
printf("欢迎光临本店,要啥自己挑。\n");
printf("1.二手武器货架\n");
printf("2.武器贩卖\n");
ll num;
cin >> num;
switch(num) {
case 1:
shelf();
break;
case 2:
armsell();
break;
default:
printf("还想干嘛!\n");
break;
}
}
void shelf() {
ll Size = rand() % 4 + 1;
vector<Arm> ARm;
for(ll i = 0; i < Size; i++) {
ARm.push_back({rand() % 50 + 3, rand() % 100 + 10});
}
tiaoxuanwuqi:
for(ll i = 0; i < Size; i++) {
printf("%lld.伤害%lld 耐久%lld\n", i + 1, ARm[i].grade, ARm[i].durability);
}ll num;
cin >> num;
if(num > Size || num < 1) {
printf("哪来那么多武器给你挑?\n");
cls();
goto tiaoxuanwuqi;
}
printf("1.跑路\n");
printf("2.老老实实付钱\n");
ll nu;
cin >> nu;
switch(nu) {
case 1: {
ll probability = rand() % 100;
if(probability >= 90) {
printf("跑路成功!牛逼!");
} else {
printf("敢跑路!!!\n");
if(timesfled) printf("还来,上次没打你是吧!!!\n");
ll probability2 = rand() % 100;
if(probability2 < 95 || timesfled) {
ll damage = (timesfled ? 100LL : rand() % 80 + 10);
printf("被肘击了,扣%lld点血。\n", damage);
h = max(h - damage, 0LL);
} else {
printf("放你一马!\n");
}
timesfled = 1;
}
break;
}
case 2: {
ll grade = ARm[num - 1].grade, durability = ARm[num - 1].durability;
ll money = grade * 2 + durability * 3 + rand() % 100;
printf("给钱!%lld金币!\n", money);
printf("1.付钱\n");
printf("2.讲价\n");
ll choice;
cin >> choice;
switch(choice) {
case 1: {
if(gold < money) {
printf("没钱还来买!!!滚!\n");
return;
}
gold -= money;
printf("花费了%lld点金币!\n", money);
cls();
printf("为自己的武器取个名字吧!");
str name;
cin >> name;
arm.push_back(ARMS(name, grade, durability, true));
break;
}
case 2:
// 讲价功能待实现
break;
default:
printf("还想干嘛!\n");
break;
}
break; }
default:
printf("还想干嘛!\n");
break;
}
}
void armsell() {
if(arm.empty()) {
printf("你没有任何武器可卖!\n");
return;
}
for(ll i = 0; i < arm.size(); i++) {
ARM ar = arm[i].dataviewing();
printf("%lld.%s 耐久%lld 伤害%lld\n", i + 1, ar.name.c_str(), ar.durability, ar.grade);
}
printf("卖哪个赶紧挑!\n");
ll num;
cin >> num;
num--;
if(num >= arm.size() || num < 0) {
printf("你哪来那么多武器!\n");
} else if(num == 0 && arm.size() > 0) {
printf("空手指你还卖,滚!\n");
} else {
ARM ar = arm[num].dataviewing();
ll money = ar.grade * 2 + ar.durability * 3 - rand() % 100;
printf("%lld金币,拿了赶紧走!\n", money);
gold += money;
arm.erase(arm.begin() + num);
}
}
int main() {
srand(time(0));
gold = 1000000000000;
armsshop();
return 0;
}
全部评论 1
大佬牛逼!!!
2025-10-05 来自 浙江
0















有帮助,赞一个