#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
char c;
int n=100,lu_di_shu_liang=2200,zp_bh[110][110];
int xxx[4]={-1,1,0,0},yyy[4]={0,0,-1,1};
int homex,homey,men_fang_xiang,renx,reny,bei_bao_rl=4;
char ma[6][110][110],cun[110][110];
bool vis[110][110],ren_wet,ren_hui_jia,ren_sheng_bing;
int ye_shou_shu_liang=50,tail;
int ren_hand=5,ti_li_zhi=300,zp_tl,huo_guang[110][110];
string warn,ndd;
long long qi_shi_shi_jian,ys_shang_ci_dong,shi_sj,ks_shi_sj,kkksc;
long long shang_ci_shua_xin;
int qhuo[10010][3],huo_tl;
int t_tot,g_tot,ls_huo_tot,huo_tot,tian_qi,xiao_shi;
queue<int>huo_hs;
struct YE_SHOU{
int x,y;
bool huo_zhe;
}ye_shou[10010];
struct ZHANG_PENG{
int x,y,ne,cwg_sl;
}zhang_peng[10010];
struct CHU_WU_GE{
string namee;
int shu_liang,pre,ne;
}chu_wu_ge[100010];
struct BEI_BAO{
string namee;
int shu_liang;
}bei_bao[10];
void clearScreen(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 };
SetConsoleCursorPosition( hConsole, coordScreen );
// printf("\033[2J");
// printf("\033[%d;%dH",0,0);
}
priority_queue<pair<int,pair<int,int> > >q;
int rnd(int l,int r){
return rand()%(r-l+1)+l;
}
void sheng_cheng_map(){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
ma[0][i][j]='-';
}
}
int sl=rnd(50,60);
homex=rnd(1,n);homey=rnd(1,n);men_fang_xiang=rnd(0,3);
q.push(make_pair(-rnd(1,100000),make_pair(homex,homey)));
ma[0][homex][homey]=' ';
vis[homex][homey]=true;
lu_di_shu_liang--;
for(int i=1;i<=sl;i++){
int x=rnd(1,n),y=rnd(1,n);
if(vis[x][y]==false){
vis[x][y]=true;
lu_di_shu_liang--;
q.push(make_pair(-rnd(lu_di_shu_liang,10000),make_pair(x,y)));
}
}
while(q.empty()==false&&lu_di_shu_liang>0){
lu_di_shu_liang--;
int x=q.top().second.first,y=q.top().second.second;q.pop();
/*if(ma[0][x][y]!='H')*/ma[0][x][y]=' ';
for(int i=0;i<4;i++){
int xx=x+xxx[i],yy=y+yyy[i];
if(xx>=1&&xx<=n&&yy>=1&&yy<=n&&vis[xx][yy]==false){
vis[xx][yy]=true;
q.push(make_pair(-rnd(lu_di_shu_liang,10000),make_pair(xx,yy)));
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(ma[0][i][j]!='-')continue;
int cnt=0;
for(int k=0;k<4;k++){
int xx=i+xxx[k],yy=j+yyy[k];
if(xx>=1&&xx<=n&&yy>=1&&yy<=n){
if(ma[0][xx][yy]!='-')cnt++;
}
}
if(cnt>=rnd(2,3))ma[0][i][j]=' ';
}
}
return;
}
void plant_trees(int xx){
if(t_tot>100)return;
while(xx--){
int x=rnd(1,100),y=rnd(1,100);
if((x==renx&&y==reny)||ma[0][x][y]!=' '||ma[2][x][y]!=0||ma[3][x][y]!=0||ma[4][x][y]!=0)continue;
ma[2][x][y]='T';t_tot++;if(t_tot>100)return;
}
return;
}
void plant_grass(int xx){
if(g_tot>70)return;
while(xx--){
int x=rnd(1,100),y=rnd(1,100);
if((x==renx&&y==reny)||ma[0][x][y]!=' '||ma[2][x][y]!=0||ma[3][x][y]!=0||ma[4][x][y]!=0)continue;
ma[3][x][y]='G';g_tot++;if(g_tot>70)return;
}
return;
}
void diao_guo_shi(){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(ma[2][i][j]=='T'){
for(int k=0;k<4;k++){
int x=i+xxx[k],y=j+yyy[k];
if((x==renx&&y==reny)||ma[0][x][y]!=' '||ma[2][x][y]!=0||ma[4][x][y]!=0||rnd(1,2)!=1)continue;
ma[3][x][y]='F';
}
}
}
}
return;
}
void fang_ye_shou(){
for(int i=1;i<=ye_shou_shu_liang;i++){
int x=rnd(1,100),y=rnd(1,100);
if(ye_shou[i].huo_zhe==true||(x==renx&&y==reny)||ma[0][x][y]!=' '||ma[2][x][y]!=0||ma[3][x][y]!=0)continue;
ye_shou[i].huo_zhe=true;
ye_shou[i].x=x;
ye_shou[i].y=y;
// cout<<ye_shou[i].x<<" "<<ye_shou[i].y<<"\n";
ma[4][x][y]='K';
}
//exit(0);
return;
}
int abs_(int x){
if(x<0)return -x;return x;
}
int mhd_juli(int x,int y,int xx,int yy){
return abs_(x-xx)+abs_(y-yy);
}
void ye_shou_clear(){
for(int i=1;i<=ye_shou_shu_liang;i++){
if(ye_shou[i].huo_zhe==false)continue;
ma[4][ye_shou[i].x][ye_shou[i].y]=0;
}
return;
}
void ye_shou_xian_shi(){
for(int i=1;i<=ye_shou_shu_liang;i++){
if(ye_shou[i].huo_zhe==false)continue;
ma[4][ye_shou[i].x][ye_shou[i].y]='K';
if(ye_shou[i].x==renx&&ye_shou[i].y==reny)ti_li_zhi-=20;
}
return;
}
void ye_shou_yi_dong(){
for(int i=1;i<=ye_shou_shu_liang;i++){
if(ye_shou[i].huo_zhe==false)continue;
int xx=-1,yy=-1;
if(ren_hui_jia==false&&mhd_juli(ye_shou[i].x,ye_shou[i].y,renx,reny)<=20){
for(int j=0;j<4;j++){
int x=ye_shou[i].x+xxx[j],y=ye_shou[i].y+yyy[j];
if(x>=1&&x<=n&&y>=1&&y<=n&&ma[2][x][y]==0&&ma[1][x][y]==0&&ma[0][x][y]==' '){
if(xx==-1||mhd_juli(x,y,renx,reny)<mhd_juli(xx,yy,renx,reny)){
xx=x;yy=y;
}
}
}
if(rnd(0,3)==0){
int rrnd=rnd(0,3);
xx=ye_shou[i].x+xxx[rrnd];yy=ye_shou[i].y+yyy[rrnd];
}
}
else{
int rrnd=rnd(0,3);
xx=ye_shou[i].x+xxx[rrnd];yy=ye_shou[i].y+yyy[rrnd];
}
if(xx<1||xx>n||yy<1||yy>n||ma[2][xx][yy]!=0||ma[1][xx][yy]!=0||ma[0][xx][yy]!=' ')continue;
ye_shou[i].x=xx;ye_shou[i].y=yy;
}
return;
}
void puts_map(){
int l=max(renx-3,1);l=min(l,n-6);
int ll=max(reny-3,1);ll=min(ll,n-6);
for(int i=l;i<=l+6;i++){
for(int j=ll;j<=ll+6;j++){
for(int k=3;k>=0;k--){
if(ma[k][i][j]==0)continue;
cun[i][j]=ma[k][i][j];
break;
}
if(i==renx&&j==reny)cun[i][j]='@';
if(ma[4][i][j]!=0)cun[i][j]=ma[4][i][j];
}
}
for(int i=l;i<=l+6;i++){
for(int j=ll;j<=ll+6;j++){
// long long timeeee=((time(0)-qi_shi_shi_jian)%1440)/60;
// if(timeeee>=6&&timeeee<18&&ma[0][i][j]==' ')printf("\033[42;37m");
// if(timeeee>=6&&timeeee<18&&ma[0][i][j]=='-')printf("\033[44;37m");
putchar(cun[i][j]);
// if(timeeee>=6&&timeeee<18)printf("\033[40;37m");
}
puts("");
}
return;
}
void write_int(int x){
char Cc,flg=0;
if(x/100!=0){flg=1;Cc=x/100+'0';putchar(Cc);}
else{Cc=' ';putchar(Cc);}
x%=100;
if(x/10!=0||flg==1){flg=1;Cc=x/10+'0';putchar(Cc);}
else{Cc=' ';putchar(Cc);}
x%=10;
if(x!=0||flg==1){Cc=x+'0';putchar(Cc);}
else{Cc=' ';putchar(Cc);}
return;
}
void sc_chu_wu_ge(int x){
printf("编号:%d\n",x);
if(chu_wu_ge[x].namee=="无"){
puts("储存物品:无");return;
}
cout<<"储存物品:"<<chu_wu_ge[x].namee<<"*"<<chu_wu_ge[x].shu_liang<<"\n";
return;
}
bool find_wp(string namee,int x){
int maxxx=0;
for(int i=1;i<=bei_bao_rl;i++){
if(bei_bao[i].namee==namee){
maxxx+=bei_bao[i].shu_liang;
}
}
if(maxxx<x){
return false;
}
return true;
}
bool xiao_hao_wu_ping(string namee,int x){
if(!find_wp(namee,x)){
warn="材料不足!";
return false;
}
for(int i=1;i<=bei_bao_rl;i++){
if(bei_bao[i].namee==namee){
if(bei_bao[i].shu_liang>=x){
bei_bao[i].shu_liang-=x;x=0;
}
else{
x-=bei_bao[i].shu_liang;bei_bao[i].shu_liang=0;
}
if(bei_bao[i].shu_liang==0){
bei_bao[i].namee="无";
}
}
if(x==0)break;
}
return true;
}
bool pd_chu_cun(string namee,int x,int ew){
for(int i=1;i<=bei_bao_rl;i++){
if(bei_bao[i].namee==namee||bei_bao[i].namee=="无"){
return true;
}
}
if(ew==1)puts("背包空间不足,请清理后再来");Sleep(1000);
return false;
}
bool chu_cun_wu_ping(string namee,int x){
for(int i=1;i<=bei_bao_rl;i++){
if(bei_bao[i].namee==namee){
bei_bao[i].shu_liang+=x;
return true;
}
}
for(int i=1;i<=bei_bao_rl;i++){
if(bei_bao[i].namee=="无"){
bei_bao[i].namee=namee;
bei_bao[i].shu_liang+=x;
return true;
}
}
warn="空间不足!";
return false;
}
void du_qu_lian_biao(int x){
int nw=zhang_peng[x].ne;
while(1){system("cls");
sc_chu_wu_ge(nw);
puts("1.前一个 2.后一个 3.删除此储物格(回收木材*1)");
puts("4.新建一个储物格(消耗木材*2) 5.取出物品 0.退出");
c=getch();
if(c=='1'){
if(chu_wu_ge[nw].pre==0){
warn="这已经是第一个啦!";
}
else{
nw=chu_wu_ge[nw].pre;warn="";
}
}
else if(c=='2'){
if(chu_wu_ge[nw].ne==0){
warn="这已经是最后一个啦!";
}
else{
nw=chu_wu_ge[nw].ne;warn="";
}
}
else if(c=='3'){
if(zhang_peng[x].cwg_sl<=1){
warn="家中至少有一个储物格!";
}
else{warn="";
chu_cun_wu_ping("木材",1);
if(chu_wu_ge[nw].pre==0){
zhang_peng[x].ne=chu_wu_ge[nw].ne;
chu_wu_ge[chu_wu_ge[nw].ne].pre=0;
nw=chu_wu_ge[nw].ne;
}
else if(chu_wu_ge[nw].ne==0){
chu_wu_ge[chu_wu_ge[nw].pre].ne=0;
nw=chu_wu_ge[nw].pre;
}
else{
chu_wu_ge[chu_wu_ge[nw].pre].ne=chu_wu_ge[nw].ne;
chu_wu_ge[chu_wu_ge[nw].ne].pre=chu_wu_ge[nw].pre;
nw=chu_wu_ge[nw].ne;
}
}
}
else if(c=='4'){
if(xiao_hao_wu_ping("木材",2)){warn="";
tail++;zhang_peng[x].cwg_sl++;
chu_wu_ge[tail].pre=nw;
chu_wu_ge[tail].ne=chu_wu_ge[nw].ne;
chu_wu_ge[tail].namee="无";
chu_wu_ge[nw].ne=tail;nw=tail;
}
}
else if(c=='5'){
puts("请输入放入的背包位置编号");
c=getch();
if(c>'4'){
warn="无效操作";
}
else{warn="";
if(bei_bao[c-'0'].namee==chu_wu_ge[nw].namee){
bei_bao[c-'0'].shu_liang+=chu_wu_ge[nw].shu_liang;
chu_wu_ge[nw].shu_liang=0;chu_wu_ge[nw].namee="无";
}
else{
swap(bei_bao[c-'0'].namee,chu_wu_ge[nw].namee);
swap(bei_bao[c-'0'].shu_liang,chu_wu_ge[nw].shu_liang);
}
}
}
else{
warn="";
return;
}
cout<<warn<<"\n";
Sleep(500);
}
return;
}
void jian_zhang_peng(int x,int y){
if(ma[0][x][y]==' '&&ma[2][x][y]==0&&ma[3][x][y]==0&&ma[4][x][y]==0&&xiao_hao_wu_ping("木材",10)){
zp_tl++;
zp_bh[x][y]=zp_tl;
tail++;
chu_wu_ge[tail].namee="无";
zhang_peng[zp_tl].ne=tail;
zhang_peng[zp_tl].cwg_sl=1;
ma[2][x][y]='H';
}
return;
}
void cha_xun_zhuang_tai(){
while(1){
system("cls");
for(int i=1;i<=bei_bao_rl;i++){
cout<<i<<"."<<bei_bao[i].namee;
if(bei_bao[i].namee!="无"){
cout<<"*"<<bei_bao[i].shu_liang;
}
puts("");
}
cout<<"时间:Day"<<((time(0)-qi_shi_shi_jian)/1440)+1<<" "<<((time(0)-qi_shi_shi_jian)%1440)/60<<"时\n";
cout<<"生命值&体力值:"<<ti_li_zhi<<"\n";
cout<<"手中物品:"<<ren_hand<<"\n";
cout<<"坐标:行"<<renx<<"列"<<reny<<"\n";
cout<<"天气:";
if(tian_qi==0)puts("晴");
else if(tian_qi==1)puts("阴");
else puts("雨");
if(ren_wet)cout<<"你湿了\n";
if(ren_sheng_bing)cout<<"你病了\n";
//-------------------------------------
puts("按空格退出,输入1~4丢弃物品");
c=getch();
if(c==32){
system("cls");
return;
}
else{
int cc=c-'0';
bei_bao[cc].namee="无";
bei_bao[cc].shu_liang=0;
}
}
return;
}
void shua_xin_wu_zi(){
fang_ye_shou();
diao_guo_shi();
plant_trees(150);
plant_grass(70);
return;
}
void jin_ru_zhang_peng(int x){
system("cls");
system("color 07");
if(x==0)return;
ren_hui_jia=true;
while(1){
system("cls");
puts("1.合成物品 2.查看储物格 3.睡觉 4.查看状态 0.退出");
c=getch();
if(c=='1'){warn="";
puts("请输入您要合成的物品:");
puts("1.弓(木材*5=弓)");
puts("2.箭(木材*1+铁矿石*1=箭*2)");
puts("3.钓竿(铁矿石*3+木材*1=钓竿)");
puts("4.铲子(铁矿石*3+木材*3=铲子)");
puts("5.斧头(铁矿石*3+木材*3=斧头)");
puts("6.草药(草*5=草药)");
puts("0.退出");
c=getch();
if(c=='1'){
if(pd_chu_cun("弓",1,1)&&xiao_hao_wu_ping("木材",5)){
chu_cun_wu_ping("弓",1);
}
}
if(c=='2'){
if(pd_chu_cun("箭",2,1)&&find_wp("铁矿石",1)&&xiao_hao_wu_ping("木材",1)){
xiao_hao_wu_ping("铁矿石",1);
chu_cun_wu_ping("箭",2);
}
}
if(c=='3'){
if(pd_chu_cun("钓竿",1,1)&&find_wp("铁矿石",3)&&xiao_hao_wu_ping("木材",1)){
xiao_hao_wu_ping("铁矿石",3);
chu_cun_wu_ping("钓竿",1);
}
}
if(c=='4'){
if(pd_chu_cun("铲子",1,1)&&find_wp("铁矿石",3)&&xiao_hao_wu_ping("木材",3)){
xiao_hao_wu_ping("铁矿石",3);
chu_cun_wu_ping("铲子",1);
}
}
if(c=='5'){
if(pd_chu_cun("斧头",1,1)&&find_wp("铁矿石",3)&&xiao_hao_wu_ping("木材",3)){
xiao_hao_wu_ping("铁矿石",3);
chu_cun_wu_ping("斧头",1);
}
}
if(c=='6'){
if(pd_chu_cun("草药",1,1)&&xiao_hao_wu_ping("草",5)){
chu_cun_wu_ping("草药",1);
}
}
if(c=='0')continue;
}
else if(c=='2'){
du_qu_lian_biao(x);
}
else if(c=='3'){
system("cls");
puts("请输入睡眠时间(单位:小时)");
int xyx;cin>>xyx;if(xyx<=0)continue;
qi_shi_shi_jian-=xyx*60;
ti_li_zhi-=xyx;
puts("睡觉ing...");
// fang_ye_shou();
// diao_guo_shi();
// plant_trees(150);
// plant_grass(70);
Sleep(1000);
system("cls");
puts("该起床了");Sleep(1000);
system("cls");
if(ti_li_zhi<=0){
puts("你死了qaq");
cout<<"难度:"<<ndd<<"\n";
cout<<"你的死亡时间为:Day"<<((time(0)-qi_shi_shi_jian)/1440)+1<<" "<<((time(0)-qi_shi_shi_jian)%1440)/60<<"时\n";
printf("你本轮游戏时间为%lld时%lld分%lld秒\n",(time(0)-kkksc)/3600,((time(0)-kkksc)%3600)/60,(time(0)-kkksc)%60);
system("pause");exit(0);
}
}
else if(c=='4'){
cha_xun_zhuang_tai();
}
else{
ren_hui_jia=false;
system("cls");
return;
}
cout<<warn<<"\n";Sleep(500);
}
return;
}
bool chai_zhang_peng(int x,int y){
if(ma[2][x][y]=='H'){
ma[2][x][y]=0;zp_bh[x][y]=0;
chu_cun_wu_ping("木材",7);
if(bei_bao[ren_hand].namee=="斧头"){
ti_li_zhi-=10;
}
else{
ti_li_zhi-=30;
}
return true;
}
return false;
}
bool kan_shu(int x,int y){
if(ma[2][x][y]=='T'){t_tot--;
ma[2][x][y]=0;
chu_cun_wu_ping("木材",2);
if(bei_bao[ren_hand].namee=="斧头"){
ti_li_zhi-=10;
}
else{
ti_li_zhi-=30;
}
return true;
}
return false;
}
bool she_jian(int x,int y,int fx){
int flg=0;x=renx;y=reny;
if(bei_bao[ren_hand].namee!="弓"||!xiao_hao_wu_ping("箭",1))return false;
ti_li_zhi--;
for(int i=1;i<=5;i++){
Sleep(50);
ma[4][x][y]=0;
x+=xxx[fx],y+=yyy[fx];
if(flg==1)break;
if(x<1||x>n||y<1||y>n)break;
ma[4][x][y]='+';
for(int i=1;i<=ye_shou_shu_liang;i++){
if(ye_shou[i].huo_zhe==false)continue;
if(ye_shou[i].x==x&&ye_shou[i].y==y){
ye_shou[i].huo_zhe=false;
ma[3][ye_shou[i].x][ye_shou[i].y]='M';
flg=1;ma[4][x][y]=0;break;
}
}
long long sjj=time(0);
clearScreen();
puts_map();
write_int(renx);putchar(' ');write_int(reny);puts("");
cout<<"体力值&生命值:";
write_int(ti_li_zhi);
}
ma[4][x][y]=0;
return true;
}
bool fang_mu_tou(int x,int y){
if(ma[0][x][y]!=' '||ma[2][x][y]!=0||ma[3][x][y]!=0||ma[4][x][y]!=0||bei_bao[ren_hand].namee!="木材")return false;
if(!xiao_hao_wu_ping("木材",1))return false;
ti_li_zhi--;
ma[2][x][y]='W';return true;
}
bool dian_huo(int x,int y){
if(ma[0][x][y]!=' '||ma[2][x][y]!='W'||ma[3][x][y]!=0||ma[4][x][y]!=0||bei_bao[ren_hand].namee!="木材")return false;
if(!xiao_hao_wu_ping("木材",1))return false;
ti_li_zhi--;
ma[2][x][y]='#';huo_tot++;
if(huo_hs.empty()){
huo_tl++;qhuo[huo_tl][0]=time(0)-qi_shi_shi_jian;
qhuo[huo_tl][1]=x;qhuo[huo_tl][2]=y;
}
else{
int xx=huo_hs.front();huo_hs.pop();
qhuo[xx][0]=time(0)-qi_shi_shi_jian;
qhuo[xx][1]=x;qhuo[xx][2]=y;
}
int fgg=0;
for(int i=0;i<4;i++){
if(ma[0][x+xxx[i]][y+yyy[i]]=='-'){fgg=1;
continue;
}
ma[1][x+xxx[i]][y+yyy[i]]='*';
huo_guang[x+xxx[i]][y+yyy[i]]++;
}
if(fgg==1)ls_huo_tot++;
return true;
}
bool mie_huo(int x,int y,int qw){//puts("$");Sleep(10000);
if(ma[0][x][y]!=' '||ma[2][x][y]!='#'||ma[3][x][y]!=0||ma[4][x][y]!=0)return false;
if(qw==1)ti_li_zhi--;
ma[2][x][y]=0;huo_tot--;//puts("%");Sleep(10000);
for(int i=1;i<=huo_tl;i++){
if(qhuo[i][1]==x&&qhuo[i][2]==y){
qhuo[i][1]=qhuo[i][2]=0;
huo_hs.push(i);break;
}
}int fgg=0;
for(int i=0;i<4;i++){
if(ma[0][x+xxx[i]][y+yyy[i]]=='-'){
fgg=1;continue;
}
huo_guang[x+xxx[i]][y+yyy[i]]--;
if(huo_guang[x+xxx[i]][y+yyy[i]]<=0)ma[1][x+xxx[i]][y+yyy[i]]=0;
}
ls_huo_tot--;
return true;
}
bool chai_mu_tou(int x,int y){
if(ma[0][x][y]!=' '||ma[2][x][y]!='W'||ma[3][x][y]!=0||ma[4][x][y]!=0||bei_bao[ren_hand].namee=="木材")return false;
ti_li_zhi--;
ma[2][x][y]=0;
return true;
}
bool zao_chuan(int x,int y){
if(ma[0][x][y]!='-'||bei_bao[ren_hand].namee!="木材")return false;
if(!xiao_hao_wu_ping("木材",5))return false;
ti_li_zhi-=5;
ma[2][x][y]='B';return true;
}
bool diao_yu(int x,int y){
if(bei_bao[ren_hand].namee!="钓竿")return false;
if(pd_chu_cun("生肉",1,0)==false){
system("cls");
puts("背包已满,是否继续本次钓鱼?[Y/N]");
char gcgc=getch();system("cls");
if(gcgc=='N')return true;
}system("cls");
if(ma[0][x][y]!='-')return false;
if(bei_bao[ren_hand].namee!="钓竿"||!xiao_hao_wu_ping("蚯蚓",1))return false;
ti_li_zhi--;
system("cls");
puts("等待鱼上钩~");
Sleep(1000);
int qwq=rnd(1,100);
if(qwq<=50){
puts("啥也没钓到QAQ");
}
else if(qwq<=80){
puts("钓到小鱼*1 获得生肉*1");
chu_cun_wu_ping("生肉",1);
}
else if(qwq<=97){
puts("钓到鱼*1 获得生肉*2");
chu_cun_wu_ping("生肉",2);
}
else{
puts("钓到大鱼*1 获得生肉*3");
chu_cun_wu_ping("生肉",3);
}
Sleep(1000);
system("cls");
return true;
}
bool kao_rou(int x,int y){
if(ma[2][x][y]!='#'||bei_bao[ren_hand].namee!="生肉")return false;
if(!xiao_hao_wu_ping("生肉",1))return false;
chu_cun_wu_ping("熟肉",1);
ti_li_zhi--;
return true;
}
bool chai_chuan(int x,int y){
if(ma[2][x][y]!='B')return false;
ti_li_zhi--;chu_cun_wu_ping("木材",3);
ma[2][x][y]=0;return true;
}
bool zhong_shu(int x,int y){
if(ma[0][x][y]!=' '||ma[2][x][y]!=0||ma[3][x][y]!=0||ma[4][x][y]!=0||bei_bao[ren_hand].namee!="种子")return false;
if(!xiao_hao_wu_ping("种子",1))return false;
ti_li_zhi--;
if(rnd(1,5)==1){
t_tot++;
ma[2][x][y]='T';
}
return true;
}
void wsad(int x,int y,int fx){
if(x<1||x>n||y<0||y>n)return;
if(she_jian(x,y,fx));
else if(chai_zhang_peng(x,y));
else if(kan_shu(x,y));
else if(fang_mu_tou(x,y));
else if(dian_huo(x,y));
else if(kao_rou(x,y));
else if(mie_huo(x,y,1));
else if(chai_mu_tou(x,y));
else if(zao_chuan(x,y));
else if(diao_yu(x,y));
else if(chai_chuan(x,y));
else if(zhong_shu(x,y));
return;
}
void q_jian(int x,int y){
ti_li_zhi--;
if(ma[3][x][y]=='M'&&chu_cun_wu_ping("生肉",2)){
ma[3][x][y]=0;
}
if(ma[3][x][y]=='G'&&chu_cun_wu_ping("草",1)){
g_tot--;
ma[3][x][y]=0;
}
if(ma[3][x][y]=='F'&&chu_cun_wu_ping("果实",1)){
ma[3][x][y]=0;
}
if(ma[2][x][y]=='H'){
jin_ru_zhang_peng(zp_bh[x][y]);
}
return;
}
void e_wa(int x,int y){
if(pd_chu_cun("蚯蚓",1,0)==false||pd_chu_cun("铁矿石",1,0)==false){
system("cls");
puts("背包已满,是否继续本次挖掘?[Y/N]");
char gcgc=getch();system("cls");
if(gcgc=='N')return;
}
if(ma[0][x][y]!=' ')return;
if(bei_bao[ren_hand].namee=="铲子")ti_li_zhi-=10;
else ti_li_zhi-=30;
system("cls");
puts("挖地ing~");
Sleep(1000);
int qwq=rnd(1,100);
if(qwq<=50){
puts("啥也没挖到QAQ");
}
else if(qwq<=80){
puts("挖到蚯蚓*1");
chu_cun_wu_ping("蚯蚓",1);
}
else{
puts("挖到铁矿石*1");
chu_cun_wu_ping("铁矿石",1);
}
Sleep(1000);
system("cls");
return;
}
void c_chi(){
if(bei_bao[ren_hand].namee=="果实"){
ti_li_zhi+=10;
xiao_hao_wu_ping("果实",1);
chu_cun_wu_ping("种子",1);
}
if(bei_bao[ren_hand].namee=="生肉"){
xiao_hao_wu_ping("生肉",1);
ti_li_zhi+=50;
if(rnd(0,1)==0)ren_sheng_bing=true;
}
if(bei_bao[ren_hand].namee=="熟肉"){
xiao_hao_wu_ping("熟肉",1);
ti_li_zhi+=50;
}
if(bei_bao[ren_hand].namee=="草药"){
xiao_hao_wu_ping("草药",1);
ren_sheng_bing=false;
}
if(ti_li_zhi>1000)ti_li_zhi=1000;
return;
}
int slptflg;
void slputs(string zfc){
int len=zfc.size();
for(int i=0;i<len;i++){
cout<<zfc[i];
if(kbhit())slptflg=1;
if(slptflg==0)Sleep(40);
}puts("");
return;
}
int main(){
HANDLE hOutput;
COORD coord={0,0};
hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
cci.bVisible=0;
cci.dwSize=1;
SetConsoleCursorInfo(hOutput, &cci);
//system("color 01");
srand(time(0));slptflg=0;
slputs("欢迎来到cnk漂流记小隔膜1.0测试版");
slputs("getchar123荣誉出品");
slputs("你是cnk,");
slputs("你出海经商时遭遇龙卷风,");
slputs("被刮到了一个荒岛上。");
slputs("你需要运用你AKIOI的智慧在荒岛上生存,");
slputs("并努力回到人类文明。");
system("pause");
system("cls");slptflg=0;
slputs("回复1查看游戏帮助,2直接开始游戏");
slputs("(如果你是第一次来到此游戏,请先查看帮助)");
cin>>c;system("cls");slptflg=0;
if(c=='1'){
slputs("上下左右键移动");
slputs("WSAD射箭/砍树/钓鱼/吃/(放木头/点火/灭火)");
slputs("(具体是什么操作取决于你手里拿的是什么)");
slputs("Q拾捡,E挖洞,1/2/3/4/5切换手中物品(5为空手)");
slputs("水果/生肉/熟肉为食物,可以增加一定体力");
slputs("吃生肉(有一定几率)/弄湿自己没有及时烘干会生病");
slputs("弓+箭可以用于防身,射程为5");
slputs("铲子/斧头可提高挖洞/砍树效率");
slputs("钓竿+蚯蚓用来钓鱼,船让你进入水中而不被弄湿");
slputs("H家,K野兽,T果树,F果实,M肉, (空格)陆地,-水,G草,#火堆,*火堆的光和热");
slputs("物品具体的用途还有合成物品的规则比较复杂");
slputs("具体见https://www.luogu.com.cn/paste/nyxr5gb1");
system("pause");
system("cls");slptflg=0;
}
slputs("你选择的难度为:1.简单 2.中等 3.困难 4.挑战不可能");
cin>>c;
if(c=='1'){ndd="简单";
ti_li_zhi=500;
}
if(c=='2'){ndd="中等";
ti_li_zhi=400;
}
if(c=='3'){ndd="困难";
ti_li_zhi=300;
}
if(c=='4'){ndd="挑战不可能";
ti_li_zhi=200;
}
slputs("生成地图ing...");
sheng_cheng_map();
renx=homex;reny=homey;
plant_trees(300);
plant_grass(70);
diao_guo_shi();
fang_ye_shou();
bei_bao[1].namee=bei_bao[2].namee=bei_bao[3].namee=bei_bao[4].namee=bei_bao[5].namee="无";
system("cls");slptflg=0;
slputs("你在一片海滩上醒来");
slputs("你看到了一旁破了个大洞的船");
slputs("你知道马上就要涨潮了");
slputs("只要一涨潮,它就会被冲走");
slputs("你决定在里面搜索一些有用的物品");
slputs("你找到了若干件物品,但由于时间原因,你只能带走一件");
slputs("你决定带走:");
slputs("1.熟肉*20");
slputs("2.生肉*30");
slputs("3.木材*30");
slputs("4.铁矿石*20");
cin>>c;
if(c=='1')chu_cun_wu_ping("熟肉",20);
if(c=='2')chu_cun_wu_ping("生肉",30);
if(c=='3')chu_cun_wu_ping("木材",30);
if(c=='4')chu_cun_wu_ping("铁矿石",20);
system("cls");slptflg=0;
slputs("涨潮了,船被冲走,你开始了你的岛上生活");
system("pause");system("cls");
qi_shi_shi_jian=time(0)-360;
kkksc=time(0);
shang_ci_shua_xin=360;
while(1){
int flag=0,flgg=0;
if(kbhit()){flag=1;
if(ma[2][renx][reny]=='B')flgg=1;
char gc=getch();
if(gc==-32){
char gcgc=getch();
if(gcgc==72){//上
int x=renx+xxx[0],y=reny+yyy[0];
if(x>=1&&x<=n&&y>=1&&y<=n&&ma[2][x][y]!='T'&&ma[2][x][y]!='#'&&ma[2][x][y]!='W'){
if(flgg==1&&ma[0][x][y]=='-'&&ma[2][x][y]==0){
ma[2][renx][reny]=0;ma[2][x][y]='B';
}
renx=x;reny=y;ti_li_zhi--;
}
}
if(gcgc==80){//下
int x=renx+xxx[1],y=reny+yyy[1];
if(x>=1&&x<=n&&y>=1&&y<=n&&ma[2][x][y]!='T'&&ma[2][x][y]!='#'&&ma[2][x][y]!='W'){
if(flgg==1&&ma[0][x][y]=='-'&&ma[2][x][y]==0){
ma[2][renx][reny]=0;ma[2][x][y]='B';
}
renx=x;reny=y;ti_li_zhi--;
}
}
if(gcgc==75){//左
int x=renx+xxx[2],y=reny+yyy[2];
if(x>=1&&x<=n&&y>=1&&y<=n&&ma[2][x][y]!='T'&&ma[2][x][y]!='#'&&ma[2][x][y]!='W'){
if(flgg==1&&ma[0][x][y]=='-'&&ma[2][x][y]==0){
ma[2][renx][reny]=0;ma[2][x][y]='B';
}
renx=x;reny=y;ti_li_zhi--;
}
}
if(gcgc==77){//右
int x=renx+xxx[3],y=reny+yyy[3];
if(x>=1&&x<=n&&y>=1&&y<=n&&ma[2][x][y]!='T'&&ma[2][x][y]!='#'&&ma[2][x][y]!='W'){
if(flgg==1&&ma[0][x][y]=='-'&&ma[2][x][y]==0){
ma[2][renx][reny]=0;ma[2][x][y]='B';
}
renx=x;reny=y;ti_li_zhi--;
}
}
}
//-------------------------
if(gc=='w'){//shang
int x=renx+xxx[0],y=reny+yyy[0];
wsad(x,y,0);
}
if(gc=='s'){//xia
int x=renx+xxx[1],y=reny+yyy[1];
wsad(x,y,1);
}
if(gc=='a'){//zuo
int x=renx+xxx[2],y=reny+yyy[2];
wsad(x,y,2);
}
if(gc=='d'){//you
int x=renx+xxx[3],y=reny+yyy[3];
wsad(x,y,3);
}
if(gc=='q'){//jian
int x=renx,y=reny;
q_jian(x,y);
}
if(gc=='e'){//wa
int x=renx,y=reny;
e_wa(x,y);
}
if(gc=='x'){//jian fang zi
int x=renx,y=reny;
jian_zhang_peng(x,y);
}
if(gc=='c'){//chi
c_chi();
}
//----------------------
if(gc=='1'){
ren_hand=1;
}
if(gc=='2'){
ren_hand=2;
}
if(gc=='3'){
ren_hand=3;
}
if(gc=='4'){
ren_hand=4;
}
if(gc=='5'){
ren_hand=5;
}
if(gc==32){
cha_xun_zhuang_tai();
}
}
if((ma[0][renx][reny]=='-'&&ma[2][renx][reny]!='B')||tian_qi==2){
shi_sj=time(0)-qi_shi_shi_jian;if(ks_shi_sj==0){ks_shi_sj=time(0)-qi_shi_shi_jian;ren_wet=true;}
}
if(ren_wet==true&&time(0)-qi_shi_shi_jian-ks_shi_sj>180){
ren_sheng_bing=true;
}
if(ma[1][renx][reny]=='*'||time(0)-qi_shi_shi_jian-shi_sj>180){
ks_shi_sj=0;shi_sj=0;ren_wet=false;
}
long long sjj=time(0);
if(ys_shang_ci_dong>time(0)){
ys_shang_ci_dong=time(0);
}
if(xiao_shi>time(0)){
xiao_shi=time(0);
}
if(sjj-ys_shang_ci_dong>=1){
if(((time(0)-qi_shi_shi_jian)%1440)/60<6||((time(0)-qi_shi_shi_jian)%1440)/60>=18){
system("color 01");
}
else{
system("color 07");
}
if(shang_ci_shua_xin>time(0))shang_ci_shua_xin=time(0);
int tttmmm=time(0)-qi_shi_shi_jian;
for(int i=1;i<=5&&shang_ci_shua_xin+1440<=tttmmm;i++){
shua_xin_wu_zi();shang_ci_shua_xin+=1440;
}shang_ci_shua_xin=tttmmm;
for(int i=1;i<=huo_tl;i++){
if(qhuo[i][1]!=0&&qhuo[i][2]!=0&&(time(0)-qi_shi_shi_jian)-qhuo[i][0]>60){
mie_huo(qhuo[i][1],qhuo[i][2],0);//puts("&");Sleep(10000);
}
}
flag=1;ys_shang_ci_dong=sjj;
ye_shou_clear();
ye_shou_yi_dong();
ye_shou_xian_shi();
}
if(sjj-xiao_shi>=60){
xiao_shi=sjj;
int rndd=rnd(-1,1);
if((((time(0)-qi_shi_shi_jian)%1440)/60<6||((time(0)-qi_shi_shi_jian)%1440)/60>=18)&&tian_qi+rndd<3&&tian_qi+rndd>=0)tian_qi+=rndd;
if(ren_sheng_bing==true)ti_li_zhi-=20;
else ti_li_zhi-=3;
if(time(0)-qi_shi_shi_jian>=4320){
if(rnd(1,50)<=huo_tot){
system("cls");
puts("一架飞机飞来,它看到了你的火光,你获救了");
cout<<"难度:"<<ndd<<"\n";
printf("你本轮游戏时间为%lld时%lld分%lld秒\n",(time(0)-kkksc)/3600,((time(0)-kkksc)%3600)/60,(time(0)-kkksc)%60);
cout<<"你的获救时间为:Day"<<((time(0)-qi_shi_shi_jian)/1440)+1<<" "<<((time(0)-qi_shi_shi_jian)%1440)/60<<"时\n";
system("pause");
return 0;
}
if(rnd(1,50)<=ls_huo_tot){
system("cls");
puts("一条船开来,它看到了你的火光,你获救了");
cout<<"难度:"<<ndd<<"\n";
printf("你本轮游戏时间为%lld时%lld分%lld秒\n",(time(0)-kkksc)/3600,((time(0)-kkksc)%3600)/60,(time(0)-kkksc)%60);
cout<<"你的获救时间为:Day"<<((time(0)-qi_shi_shi_jian)/1440)+1<<" "<<((time(0)-qi_shi_shi_jian)%1440)/60<<"时\n";
system("pause");
return 0;
}
}
}
if(flag==1){
clearScreen();
//system("cls");
puts_map();
write_int(renx);putchar(' ');write_int(reny);puts("");
cout<<"体力值&生命值:";
write_int(ti_li_zhi);
//cout<<" "<<qhuo[1][0]<<" "<<time(0)-qi_shi_shi_jian;
//cout<<sjj<<" "<<ys_shang_ci_dong<<" "<<time(0)<<" "<<shi_sj<<" "<<ks_shi_sj<<" "<<time(0)-qi_shi_shi_jian;
}
if(ti_li_zhi<=0){
system("cls");
puts("你死了qaq");
cout<<"难度:"<<ndd<<"\n";
printf("你本轮游戏时间为%lld时%lld分%lld秒\n",(time(0)-kkksc)/3600,((time(0)-kkksc)%3600)/60,(time(0)-kkksc)%60);
cout<<"你的死亡时间为:Day"<<((time(0)-qi_shi_shi_jian)/1440)+1<<" "<<((time(0)-qi_shi_shi_jian)%1440)/60<<"时\n";
system("pause");
return 0;
}
}
return 0;
}/*
更新日志:
2020/8/13写完此game
2020/8/20调完难度
2020/9/1修正灭火的bug
2020/9/2修正储物格的bug,拾捡&合成时空间不足会阻止操作,更改了刷新机制
2020/9/3修正刷新的bug,优化了开头,挖掘和钓鱼时会有空间不足提示,优化了操作
2020/9/21开头可按任意键跳过
2020/11/17降低难度,修改钓鱼误判的bug
*/剪贴板
剪贴板 a5otj5w3
剪贴板信息
剪贴板信息
- 收录
- 更新