跳到正文

休闲·娱乐

wake-up war 1V1 version

seanli1008约 6 分钟
原文

这是 2025年9月26日 存档的第 1 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月10日
篇幅
约 6 分钟

版本

  1. v6当前
  2. v5
  3. v4
  4. v3
更早的 2 个版本
  1. v2
  2. v1
C++
//wake-up war 1V1 version
//Created by seanli1008 on 2025/9/26.
//Copyright (c) 2025年 seanli1008. All rights reserved.
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
bool over(){
	if(!pl[1].hp){
		cout<<"player 2 is the winner!"<<endl;
		return true;
	}
	if(!pl[2].hp){
		cout<<"player 1 is the winner!"<<endl;
		return true;
	}
	return false;
}
void job_skill(int x){
	
}
void sleeping(int x){
	if(pl[x].asleep){
		pl[x].sleep_round++;
		if(pl[x].sleep_round==3)
			pl[x].sleep_round=pl[x].asleep=0;
	}
}
void move(int x,string dest){
	int to=0;
	if(dest=="shop")
		to=1;
	if(dest=="pharmacy")
		to=2;
	if(dest=="car shop")
		to=3;
	if(dest=="factory")
		to=4;
	if(dest=="pool")	
		to=5;
	pl[x].pos=to;
	if(place[dest].electric_web_exist){
		pl[x].at_door=1;
		if(!pl[x].taipingtianshu){
			if(!pl[x].rubber)
				pl[x].hp-=0.5;
			else
				pl[x].rubber_hp-=0.5;
		}
	}
}
void purchase(int x,string item){
	if(pl[x].pos==0 || pl[x].pos==5){
		cout<<"Invalid operation!"<<endl;
		return;
	}
	if(pl[x].pos==4){
		if(item=="hammer")
			pl[x].hammer_num++;
		else if(item=="lightning"){
			pl[x].ltn_num++;
			pl[x].ltn_time+=3;
		}
		else if(item=="laser"){
			pl[x].laser_num++;
			pl[x].laser_time++;
		}
	}
	if(pl[x].pos==3){
		if(item=="car"){
			pl[x].car_num++;
			pl[x].powered=0;
			pl[x].car_fix=2;
			pl[x].car_hp=3;
		}
		if(item=="oil")
			pl[x].oil_num++;
	}
	if(pl[x].pos==2){
		if(item=="medicine")
			pl[x].med_num++;
		if(item=="speed medicine")
			pl[x].speed_med_num++;
		if(item=="poison")
			pl[x].poison_num++;
		if(item=="jisu")
			pl[x].jisu_num++;
		if(item=="instruction")
			pl[x].instruction++;
		if(item=="mask")
			pl[x].on_mask=1;
	}
}
int main(){
	cout<<"wake-up war developed by seanli1008"<<endl;
	Sleep(200);
	system("cls");
	cout<<"player 1, please choose your job: 1 - shop assistance 2 - doctor 3 - racer 4 - swimmer 5 - physicist 6 - madman 7 - Alzheimer 8 - magician"<<endl;
	cin>>pl[1].job;
	cout<<"player 2, please choose your job: 1 - shop assistance 2 - doctor 3 - racer 4 - swimmer 5 - physicist 6 - madman 7 - Alzheimer 8 - magician"<<endl;
	cin>>pl[2].job;
	job_skill(1);
	job_skill(2);
	while(!over()){
		sleeping(1);
		sleeping(2);
		int x=rnd()%2+1;
		cout<<"player "<<x<<"'s turn"<<endl;
		string op;
		cin>>op;
		getline(cin,op);
		if(!pl[x].awake){
			if(op!="wake"){
				cout<<"Invalid operation"<<endl;
				continue;
			}
			pl[x].awake=1;
		}
		if(op[0]=='g' && op[1]=='o' && op[2]==' ' && op[3]=='t' && op[4]=='o'){
			string dest="";
			for(int i=5;i<op.size();i++)
				dest+=op[i];
			move(x,dest);
		}
		if(op[0]=='b' && op[1]=='u' && op[2]=='y' && op[3]==' '){
			string item="";
			for(int i=4;i<op.size();i++)
				item+=op[i];
			purchase(x,item);
		}
	}
	return 0;
}