大富翁 V1.2

chen_zhe 沙雕 2020-06-15 15:56:25 2020-06-18 16:58:43 6

本次更新de掉了一个很难遇到(除非你很穷或租金太高)的bug,命运卡略有扩展,祝大家玩的开心!

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <windows.h>
#include <conio.h>
#include <time.h>
using namespace std;
inline void movexy(int x,int y)
{
	COORD position={x,y};
	HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hOut,position);
}
int chess[50];//上边:21-30,右边:31-40,下边:10-1,左边:11-20
char picture[12]={'.','#','$','m','c','@','&','?','<','>','/','+'};
int m2=4,c2=5,xf=1,cs=1;
struct m
{
	int money;
	int way;
	bool stop;
	void __init__()
	{
		money=1500;
		way=1;
	}
	void mov(int k)
	{
		chess[way]=m2;
		way=(way+k)%40;
		if(way==0) way=40;
		m2=chess[way];
		chess[way]=3;
	}
	void go(int k=11)
	{
		chess[way]=m2;
		way=k;
		if(k==11) stop=true;
		m2=chess[k];
		chess[k]=3;
	}
};
struct super
{
	int money;
	int way;
	bool stop;
	void __init__()
	{
		money=1500;
		way=1;
	}
	void mov(int k)
	{
		chess[way]=c2;
		way=(way+k)%40;
		if(way==0) way=40;
		c2=chess[way];
		chess[way]=4;
	}
	void go(int k=11)
	{
		chess[way]=c2;
		way=k;
		if(k==11) stop=true;
		c2=chess[k];
		chess[k]=4;
	}
};
m me;
super com;
inline void draw()
{
	if(cs/15*2>xf) xf=cs/15*2;
	system("cls");
	movexy(27,5);
	for(int i=21; i<=30; i++)
	{	
		putchar(picture[chess[i]]);
		putchar(' ');
	}
	putchar(picture[chess[31]]);
	movexy(27,6);
	int k=7;
	for(int i=20; i>=12; i--)
	{
		putchar(picture[chess[i]]);
		putchar('\t');
		putchar('\t');
		printf("       ");
		putchar(picture[chess[52-i]]);
		movexy(27,k++);
	}
	putchar(picture[chess[11]]);
	putchar(' ');
	for(int i=10; i>=1; i--)
	{
		putchar(picture[chess[i]]);
		putchar(' ');
	}
	movexy(27,k+1);
	printf("消费指数:%d   第%d回合",xf,cs);
	movexy(27,k+2);
	printf("我的钱数:%d 电脑钱数:%d",me.money,com.money);
}
struct city
{
	int smoney;
	int price;
	int money;
	int house;
	char* name;
	int a[8]={200,150,100,50,50,100,150,200};
	int t[5]={1,6,25,26,40};
	bool fate;
	bool shui;
	bool tsdc;
	bool jy;
	bool gojy;
	bool ts;
	void get(string n)
	{
		name=new char[n.size()+1];
		strcpy(name,n.c_str());
	}
}citys[50];
inline void in(int i,string na,int p,int m)
{
	citys[i].price=p;
	citys[i].money=m;
	citys[i].get(na);
}
inline void ini(int i)
{
	citys[i].fate=true;
	chess[i]=7;
}
inline void it(int i,int mon)
{
	citys[i].shui=true;
	citys[i].smoney=mon;
	chess[i]=6;
}
int main(){
	int m,x;
	srand(time(NULL));
	me.__init__();
	com.__init__();
	chess[1]=3;
	citys[1].name="起点";
	in(2,"阿童木大街",60,2);
	ini(3);
	in(4,"雷欧大街",60,4);
	it(5,200);
	in(6,"长途铁路线",200,25);
	in(7,"唐老鸭大街",100,6);
	ini(8);
	in(9,"匹诺曹大街",100,6);
	in(10,"小木克大街",120,8);
	citys[11].jy=true;
	chess[11]=8;
	in(12,"查尔斯大街",140,10);
	in(13,"电灯公司",120,28);
	in(14,"鲁滨逊大街",140,10);
	in(15,"伊丽莎白大街",160,12);
	in(16,"新干线",200,25);
	in(17,"詹姆斯广场",160,12);
	ini(18);
	in(19,"阿里巴巴大街",180,14);
	in(20,"辛伯达大街",200,18);
	citys[21].jy=true;
	chess[21]=10;
	in(22,"印度洋大街",220,18);
	in(23,"丘比特大街",220,18);
	ini(24);
	in(25,"维纳斯大街",240,20);
	in(26,"地铁",200,25);
	in(27,"大西洋大街",260,22);
	in(28,"皮卡欢大街",260,22);
	in(29,"自来水厂",120,28);
	in(30,"马文公园",280,24);
	citys[31].gojy=true;
	chess[31]=9;
	in(32,"太平洋大街",300,26);
	in(33,"汤姆大街",300,26);
	ini(34);
	in(35,"威尼斯大街",320,28);
	in(36,"短途线",200,25);
	ini(37);
	in(38,"停车场",350,35);
	it(39,100);
	in(40,"海滨",400,50);
	movexy(30,10);
	citys[6].tsdc=true;
	citys[13].tsdc=true;
	citys[16].tsdc=true;
	citys[26].tsdc=true;
	citys[29].tsdc=true;
	citys[36].tsdc=true;
	citys[3].fate=false;
	citys[3].ts=true;
	chess[3]=11;
	citys[18].fate=false;
	citys[18].ts=true;
	chess[18]=11;
	citys[34].fate=false;
	citys[34].ts=true;
	chess[34]=11;
	citys[37].fate=false;
	citys[37].ts=true;
	chess[37]=11;
	system("title 大富翁 version:1.2");
	system("color 3A");
	printf("欢迎来到大富翁v1.2!");
	movexy(30,11);
	printf("本游戏制作者:张齐松\n");
	movexy(30,12);
	printf("祝您玩的开心!");
	movexy(30,13);
	printf("按空格看规则,其他键立即开始游戏");
	if(getch()==' ')
	{
		system("cls");
		movexy(24,6);
		printf("本游戏是大富翁的模拟版,模拟得不怎么样");
		movexy(30,7);
		printf("每个格子有八种状态:");
		movexy(10,8);
		printf("“.”,地产;“#”,我的地产;“$”,电脑的地产;“m”,玩家;");
		movexy(8,9);
		printf("“c”,电脑玩家;“?”命运;“&”,付税点;“@”,起点;“+”随机得钱或付税");
		movexy(10,10);
		printf("您先移动,移动时请按空格键(速度切忌太慢),屏幕顶端会打印游戏消息");
		movexy(15,11);
		printf("您移动后,电脑将会在2秒后自动移动,请不要多按键!");
		movexy(15,12);
		printf("特殊地产:电灯公司,自来水厂,各种铁路不能升级房子!");
		movexy(25,13);
		printf("特殊地点:“<”表示监狱,经过此处没反应");
		movexy(18,14);
		printf("“>”表示进入监狱,经过此处移动到监狱并暂停一轮游戏");
		movexy(29,15);
		printf("“/”表示空地,经过此处无响应");
		movexy(15,16);
		printf("经过起点,消费指数为1领取薪水200,为2领取100,大于等于4无薪水");
		movexy(20,17);
		printf("消费指数每15回合翻倍,实际租金将会是基本租金*消费指数"); 
		movexy(30,18);
		printf("按任意键开始游戏!");
		getch(); 
		Sleep(800);
	}
	while(true)
	{
		draw();
		if(me.stop)
		{
			me.stop=false;
			movexy(27,10);
			printf("你被关进监狱,暂停一轮!");
			goto computer;
		}
		getch();
		Sleep(800);
		x=me.way;
		m=rand()%6+rand()%6;
		if(m==0) m=12;
		else if(m<2) m=7;
		me.mov(m);
		if(x>=24&&me.way<=13)
		{
			if(xf==1) me.money+=200;
			else if(xf==2) me.money+=100;
		}
		move:
		draw();
		movexy(10,12);
		if(me.way==com.way) m2=c2,c2=3;
		if(citys[me.way].ts)
		{
			m=rand()%8;
			if(m<4)
			{
				if(citys[1].a[m]>me.money)
				{
					system("cls");
					system("color 1A");
					movexy(18,0);
					printf("你付税%d元",citys[me.way].a[m]);
					movexy(18,1);
					printf("你破产了!");
					Sleep(2000);
					return 0;
				}
				movexy(18,0);
				printf("你付税%d元",citys[me.way].a[m]);
				me.money-=citys[me.way].a[m];
				Sleep(2000);
			}
			else
			{
				movexy(18,0);
				me.money+=citys[me.way].a[m];
				printf("银行给你%d元",citys[me.way].a[m]);
				Sleep(2000);
			}
		}
		else if(citys[me.way].fate)
		{
			m=rand()%14;
			if(m<8){
				m=rand()%8;
				if(m<4)
				{
					if(citys[1].a[m]>me.money)
					{
						system("cls");
						system("color 1A");
						movexy(18,0);
						printf("你付税%d元",citys[me.way].a[m]);
						movexy(18,1);
						printf("你破产了!");
						Sleep(2000);
						return 0;
					}
					movexy(18,0);
					printf("你付税%d元",citys[me.way].a[m]);
					me.money-=citys[me.way].a[m];
					Sleep(2000);
				}
				else
				{
					movexy(18,0);
					me.money+=citys[me.way].a[m];
					printf("银行给你%d元",citys[me.way].a[m]);
					Sleep(2000);
				}
			}
			else if(m<14)
			{
				m=rand()%5;
				me.go(citys[me.way].t[m]);
				movexy(18,0);
				printf("命运卡:坐飞机到%s",citys[me.way].name);
				Sleep(2000);
				goto move;
			}
			else
			{
				me.mov(-3);
				movexy(18,0);
				printf("命运卡:后退3格");
				Sleep(2000);
				goto move;	
			}
		}
		else if(citys[me.way].jy||me.way==1);
		else if(citys[me.way].gojy)
		{
			me.go();
			if(com.way==11) m2=c2,c2=3;
			movexy(18,0);
			printf("你走到警察局被关进了监狱!");
			Sleep(2000);
		} 
		else if(citys[me.way].shui)
		{
			if(me.money<citys[me.way].a[m])
			{
				system("cls");
				system("color 1A");
				movexy(18,0);
				printf("你付税%d元",citys[me.way].a[m]);
				movexy(18,1);
				printf("你破产了!");
				Sleep(2000);
				return 0;
			}
			me.money-=citys[me.way].smoney;
			movexy(18,0);
			printf("你付税%d元",citys[me.way].smoney);
			Sleep(2000);
		}
		else if(m2==2||(com.way==me.way&&c2==2))
		{
			me.money-=citys[me.way].money*xf;
			com.money+=citys[me.way].money*xf;
			movexy(18,0);
			if(me.money<0)
			{
				system("color 1A");
				system("cls");
				printf("你移动到%s,缴纳租金%d元!",citys[me.way].name,citys[me.way].money*xf);
				movexy(18,11);
				printf("你破产了!");
				Sleep(2000);
				return 0;
			}
			printf("你移动到%s,缴纳租金%d元!",citys[me.way].name,citys[me.way].money*xf);
			Sleep(2000);
		}	
		else if(me.money>=citys[me.way].price/2)
		{
			if(citys[me.way].house==0&&me.money>=citys[me.way].price)
			{
				movexy(18,0);
				printf("为购买%s支付%d元?",citys[me.way].name,citys[me.way].price);
				movexy(18,1);
				printf("租金:%d元",citys[me.way].money);
				movexy(18,2);
				printf("买按下空格键,否则按下任意键");
				if(getch()==' ')
				{
					m2=1;
					me.money-=citys[me.way].price;
					citys[me.way].house++;
					movexy(18,3);
					printf("你花费%d元购买了%s!",citys[me.way].price,citys[me.way].name);
					Sleep(2000);
					draw();
				}
			}
			else if(citys[me.way].house<5&&(!citys[me.way].tsdc))
			{
				movexy(18,0);
				printf("是否花费%d元在%s升级一座房子?",citys[me.way].price/2,citys[me.way].name);
				movexy(18,1);
				printf("升级按下空格键,否则按下任意键");
				if(getch()==' ')
				{
					citys[me.way].money*=2;
					citys[me.way].house++;
					me.money-=citys[me.way].price/2;
					movexy(18,2);
					printf("你花费%d元在%s升级了一栋房子!",citys[me.way].price/2,citys[me.way].name);
					Sleep(2000);
				}
			}
		}
		draw();
		computer:
		Sleep(2000);
		if(com.stop)
		{
			com.stop=false;
			movexy(27,10);
			printf("电脑被关进监狱,暂停一轮!");
			Sleep(2000);
			continue;
		}
		m=rand()%6+rand()%6;
		if(m==0) m=12;
		else if(m<2) m=7;
		x=com.way;
		com.mov(m);
		if(24<=x&&com.way<=13)
		{
			if(xf==1) com.money+=200;
			else if(xf==2) com.money+=100;
		}
		move2:
		draw();
		if(me.way==com.way) c2=m2,m2=4;
		if(citys[com.way].ts)
		{
			m=rand()%8;
			if(m<4)
			{
				if(citys[1].a[m]>com.money)
				{
					system("cls");
					system("color 1A");
					movexy(18,0);
					printf("电脑付税%d元",citys[com.way].a[m]);
					movexy(18,1);
					printf("电脑破产了!");
					Sleep(2000);
					return 0;
				}
				movexy(18,0);
				printf("电脑付税%d元",citys[com.way].a[m]);
				com.money-=citys[com.way].a[m];
				Sleep(2000);
			}
			else
			{
				movexy(18,0);
				printf("银行给电脑%d元",citys[com.way].a[m]);
				com.money+=citys[com.way].a[m];
				Sleep(2000);
			}
		}
		else if(citys[com.way].fate)
		{
			m=rand()%13;
			if(m<8)
			{
				m=rand()%8;
				if(m<4)
				{
					if(citys[1].a[m]>com.money)
					{
						system("cls");
						system("color 1A");
						movexy(18,0);
						printf("电脑付税%d元",citys[com.way].a[m]);
						movexy(18,1);
						printf("电脑破产了!");
						Sleep(2000);
						return 0;
					}
					movexy(18,0);
					printf("电脑付税%d元",citys[com.way].a[m]);
					com.money-=citys[com.way].a[m];
					Sleep(2000);
				}
				else
				{
					movexy(18,0);
					printf("银行给电脑%d元",citys[com.way].a[m]);
					com.money+=citys[com.way].a[m];
					Sleep(2000);
				}
			}
			else if(m<14)
			{
				m=rand()%5;
				com.go(citys[com.way].t[m]);
				movexy(18,0);
				printf("电脑命运卡:坐飞机到%s",citys[com.way].name);
				Sleep(2000);
				goto move2;
			}
			else
			{
				com.mov(-3);
				movexy(18,0);
				printf("电脑命运卡:后退3格");
				Sleep(2000);
				goto move2;	
			}
		}
		else if(com.way==1||citys[com.way].jy);
		else if(citys[com.way].gojy)
		{
			movexy(18,0);
			printf("电脑走到警察局被关进监狱");
			com.go();
			if(me.way==11) c2=m2,m2=4;
		}
		else if(citys[com.way].shui)
		{
			if(com.money<citys[com.way].smoney)
			{
				system("cls");
				system("color 1A");
				movexy(18,0);
				printf("电脑付税%d元",citys[com.way].smoney);
				movexy(18,1);
				printf("电脑破产了!");
				Sleep(2000);
				return 0;
			}
			movexy(18,2);
			printf("电脑付税%d元",citys[com.way].smoney);
			com.money-=citys[com.way].smoney;
			Sleep(2000);
		}
		else if(c2==1||(me.way==com.way&&m2==1))
		{
			com.money-=citys[com.way].money*xf;
			me.money+=citys[com.way].money*xf;
			movexy(18,0);
			if(com.money<0)
			{
				printf("电脑移动到%s,缴纳租金%d元!",citys[com.way].name,citys[com.way].money*xf);
				movexy(18,11); 
				printf("电脑破产了!"); 
				Sleep(2000);
				return 0;
			} 
			printf("电脑移动到%s,缴纳租金%d元!",citys[com.way].name,citys[com.way].money*xf);
			Sleep(2000);
		}
		else if(com.money-300>=citys[com.way].price)
		{
			if(citys[com.way].house==0)
			{
				movexy(18,0);
				printf("电脑花费%d元购买了%s",citys[com.way].price,citys[com.way].name);
				com.money-=citys[com.way].price;
				citys[com.way].house++;
				c2=2;
				Sleep(2000);
			}
			else if(citys[com.way].house<5&&(!citys[com.way].tsdc))
			{
				movexy(18,0);
				citys[com.way].money*=2;
				citys[com.way].house++;
				printf("电脑花费%d元在%s升级了一栋房子!",citys[com.way].price/2,citys[com.way].name);
				Sleep(2000);
			}
		}
		cs++;
	}
}
{{ vote && vote.total.up }}

共 7 条回复

hqiqi

这个字有点eee~~~

chen_zhe 沙雕

无聊是肯定的,毕竟我还处于辣鸡阶段。。。

Duke

大佬,你牛逼UD2L3_9Q_2HS29_075_F6BG.png

xuzihang

真的很无聊

chen_zhe 沙雕

已修复,谢谢

Herobrine 303

其实吧,我是编译错误

chen_zhe 沙雕

欢迎纠正bug!(可能有不少)