跳到正文

休闲·娱乐

Generals.io C++修改版(单机版)

SL789约 84 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年7月27日
篇幅
约 84 分钟
获赞
1

版本

  1. v1当前

Generals将军棋 2023.8.9初发布

上次更新:新增了撤回操作,修复了铁路建造的bug

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define N 45
using namespace std;
//--------------------*变量*----------------------
int dec8X[8] {1,1,1,0,-1,-1,-1,0};
int dec8Y[8] {1,0,-1,-1,-1,0,1,1};
int dec4X[4] {1,0,-1,0};
int dec4Y[4] {0,1,0,-1};
//----------
//基础相关 [num]为数量,[Plus]为增加量
char Mapstate[N][N];
string Rec_str[N],MapSeed,Seed_output;
int Mapsize=15,Barrier_num=20,City_num=16,Mainhp_Plus=2,Landhp_Plus=10;
int hp[N][N],Counts,Cursor_X,Cursor_Y;
int FuLL;
//金钱相关 [limit]为上限 [consume]为消耗
bool Pit[N][N],Pitstate;
int City_limit=300,Pit_num,A_money,B_money,Moneysingle;
int Fly_consume=1000,Train_consume=100,A_Tra=100,B_Tra=100;
int A_Train_num,B_Train_num,Train_Map[N][N];
//平衡相关
int Treapstate,City_B,City_A,Army_A,Army_B;
//随机相关
int Randomstate;
string Random_str;
int Floodstate;
int Ran_map[N][N];
//迷雾相关
int Dark_map[N][N],Dark;
//--------------------*函数*------------------------
void Start_screen();//开始
void vInit();//生成地图
void vMoveNum(int dx,int dy,char A);
void vDiv(int dx,int dy,char A);
void vPlus();//每回合数值增加,计算army和land
void vChange(int x,int y);//刷新屏幕上指定坐标的数
void vMain2();
void vEnd();//判断游戏结束
void cot(string In_string);//输出换行
void Set_num();//修改配置
void vFly(int dx,int dy);//空降
void vRec(int rec_kind,int dx,int dy,char A);//历史记录栏
void vBuild(int bu_num,int dx,int dy);//建造铁路
void vDestroy(int dx,int dy);//拆除铁路
void vRandom();//随机
//---------------------*类*-------------------------
class Operate {
	private:
		 char cmd[255];
    public:
        void operate_window(int dx,int dy) {//修改窗口大小,dx为行数,dy为列数
            sprintf(cmd,"mode con cols=%d lines=%d",dx,dy);
            system(cmd);
        }
        void gotoxy(int dx,int dy) {//指定输出位置
            COORD c;
			c.X=dy;
            c.Y=dx;
            SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
        }
        void color(int text,int back) {//修改输出颜色
            SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),text+back*16);
        }
} oper;
class Output {
    public:
        void putline(string In_string) {
            for(int i=0; i<In_string.size(); i++) {
                cout<<In_string[i];
                Sleep(20);
            }
            cout<<endl;
            Sleep(400);
        }
        void putLen(string In_string,int Len) {
            for(int i=0; i<Len; i++) cout<<In_string[i];
        }
} op;
class Help {
    public:
        void playerhelp() {//Help
            oper.operate_window(60,22);
            oper.color(15,0);
            op.putline("Welcome! ");
            op.putline("欢迎来到教程 ,");
            op.putline("有关游戏更多细节请查看 About Us ");
            system("pause");
            system("cls");
            op.putline("游戏模式分为经典模式与自定义模式 ,");
            op.putline("在经典模式下 , 我们将使用游戏内预设好的设置进行游戏 ,");
            op.putline("上手简单 , 适合新手游玩 ,");
            op.putline("在对游戏有一定的理解与经验后 ,");
            op.putline("可以尝试游玩自定义模式 , ");
            op.putline("根据自己的喜好修改游戏内的设置 ,");
            op.putline("充分体验游戏的特色 ,");
            cot(" ");
            op.putline("# 那么请问你是 :");
            cot(" ");
            op.putline("#A 我是新人(观看经典模式教程)");
            op.putline("#S 我有过一点点游玩经验(观看自定义模式教程)");
            op.putline("#D 我全都会!(跳过教程)");
            int In=getch();
            while(In!='a'&&In!='s'&&In!='d') In=getch();
            system("cls");
            if(In=='d') {
                system("cls");
                op.putline("# 希望了解更多吗 ?");
                op.putline("");
                op.putline("#A 不了 (返回主页)");
                op.putline("#S 未完待续...");
                In=' ';
                In=getch();
                while(In!='a') In=getch();
                system("cls");
                Start_screen();
            }
            if(In=='a') {
                op.putline("欢迎来到经典模式教程 ,");
                op.putline("经典模式源代码 洛谷 @ ForeverCC ");
                op.putline("Blog地址: https://yydcc.blog.luogu.org/");
                op.putline("经典模式的地图大小 , 障碍数量以及城市数量是预设好的 ,");
                op.putline("不可进行手动修改 ,");
                op.putline("其中包含3个主要元素 ,");
                op.putline("主要城市 , 中立城市 , 障碍物");
                op.putline("# 主要城市 是指地图上左上角以及右下角的城市 ,");
                op.putline("分别代表红方及蓝方的主要城市 ,");
                op.putline("游戏的最终目标就是攻破对方的主城 ,");
                op.putline("# 中立城市 是指初始地图上各处散落的数字 ,");
                op.putline("不会自行扩张 , 可以被占领作为自己的城市 , ");
                op.putline("# 障碍物 是指地图上的 X (山脉) , ");
                op.putline("障碍物会阻碍士兵的前进 ,");
                op.putline("合理运用地形可以让你赢得游戏胜利 ,");
                op.putline(" ");
                op.putline("# 明白了吗 ?");
                op.putline(" ");
                op.putline("#A 我明白了 (跳过教程)");
                op.putline("#S 说说如何移动 (观看操作教程)");
                In=' ';
                In=getch();
                while(In!='a'&&In!='s') In=getch();
                system("cls");
                if(In=='a') {
                    system("cls");
                    op.putline("# 希望了解更多吗 ?");
                    op.putline("");
                    op.putline("#A 不了 (返回主页)");
                    op.putline("#S 未完待续...");
                    In=' ';
                    In=getch();
                    while(In!='a') In=getch();
                    system("cls");
                    Start_screen();
                }
                op.putline("游戏为双人游戏 , 回合制 ,");
                op.putline("移动总共分为 3 步 ,");
                op.putline("#1 将地图上的光标移动到需移动格子的右方 ,");
                op.putline("红方使用 W,A,S,D 进行操作 ,");
                op.putline("蓝方使用方向键进行操作 ,");
                op.putline("#2 红方按下 Z/X 进行半数或全部士兵的移动 ,");
                op.putline("蓝方按下 N/M 同理 ,");
                op.putline("#3 再次按下方向键 ,");
                op.putline("此时 , 指定格子内的一半或全部兵力便会移动到目标格子中 ,");
                op.putline("");
                op.putline("# 下一页 ?");
                op.putline("");
                op.putline("#A 是");
                In=' ';
                In=getch();
                while(In!='a'&&In!='s') In=getch();
                system("cls");
                op.putline("如图 , 标有数字 5 的便是城市 , 分别为红方与蓝方的城市 ,");
                op.putline("标有 1 的便是移动到其他格子上的士兵 ,");
                cout<<"     ";
                oper.color(15,5),cout<<"5 ";
                oper.color(15,0),cout<<" ";
                oper.color(15,4),cout<<"1 ";
                oper.color(15,0),cout<<" ";
                oper.color(15,4),cout<<"1 ";
                oper.color(15,0),cout<<"     ";
                oper.color(15,3),cout<<"5 ";
                oper.color(15,0),cout<<" ";
                oper.color(15,1),cout<<"1 ";
                oper.color(15,0),cout<<" ";
                oper.color(15,1),cout<<"1 ";
                oper.color(15,0),cout<<" "<<endl;
                op.putline("城市与其他格子都会按照一定速度增加兵力 ,");
                op.putline("经典模式下 , 城市的增长较迅速 , 每回合增加 2 点兵力 ,");
                op.putline("其他格子的增长速度较为缓慢 , 每 10 回合增加 1 点兵力 ,");
                op.putline("格子内的兵力移动时碰上对方的士兵时 ,");
                op.putline("如果己方的士兵数量比对方至少多 2 , 便会消灭对方并占领 , ");
                op.putline("否则进攻无效 ,");
                op.putline("格子里的士兵数量在过大 (>100) 时会显示缩写 ,");
                op.putline("当数量大于 100 且小于 1000 时 , 会显示 X e ,");
                op.putline("当数量大于 1000 且小于 10000 时 , 会显示 X k ,");
                op.putline("当数量大于 1000 且小于 100000 时 , 会显示 X w ,");
                op.putline("当数量大于 100000 时 , 会显示 >w ,");
                op.putline("");
                op.putline("# 明白了吗 ?");
                op.putline("");
                op.putline("#A 我明白了 (跳过教程)");
                op.putline("#S 我还想了解更多 (观看自定义模式教程)");
                In=' ';
                In=getch();
                while(In!='a'&&In!='s') In=getch();
                system("cls");
            }
            if(In=='s') {
                op.putline("欢迎来到自定义模式教程 ,");
                op.putline("自定义模式代码创作 洛谷 @ SL789");
                op.putline("自定义模式的自由度较高 ,");
                op.putline("有许多元素需要去了解和掌握 ,");
                op.putline("");
                op.putline("# 所以你想看 ?");
                op.putline("#A 和矿井有关 (观看矿井介绍)");
                op.putline("#S 和Random事件有关 (观看Random介绍)");
                op.putline("#D 和平衡模式有关 (观看平衡模式简介)");
                op.putline("#F 了解更多 (...)");
                In=' ';
                In=getch();
                while(In!='a'&&In!='s'&&In!='d'&&In!='f') In=getch();
                while(In=='a'||In=='s'||In=='d') {
                    system("cls");
                    if(In=='a') {
                        op.putline("欢迎来到矿井介绍 ,");
                        op.putline("矿井是自定义模式中特有的一个元素 ,");
                        op.putline("可在自定义中选择开启或关闭 ,");
                        op.putline("开启后 , 地图上会随机生成矿井 ($) ,");
						op.putline("矿井在地图上等效于障碍物 , 士兵不可穿过 ,");
						op.putline("将士兵移动到矿井周围 4 个格子便可以缓慢地获取金钱 ,");
						cout<<"         ";
						oper.color(15,1),cout<<"1 ";
						oper.color(15,0),cot(" ");
						cout<<"      ";
						oper.color(15,1),cout<<"1 ";
						oper.color(15,0),cout<<" $ ";
                        oper.color(15,1),cout<<"1 ";
                        oper.color(15,0),cot(" ");
                        cout<<"         ";
                        oper.color(15,1),cout<<"1 ";
                        oper.color(15,0),cot(" ");
                        op.putline("如图 , 蓝色的四个格子便是可获取金钱的位置 ,");
                        op.putline("金钱的存储是有上限的 ,");
                        op.putline("可在  自定义钱数消耗  中进行修改 ,");
                        op.putline("当占领城市时会增加对应的存储上限 ,");
                        op.putline("丢失城市时则会减少对应的存储上限 ,");
                        op.putline("超出上限的部分会直接消失 ,");
                        op.putline("");
                        op.putline("# 下一页 ?");
                        op.putline("");
                        op.putline("#A 是");
                        In=' ';
                        In=getch();
                        while(In!='a'&&In!='s'&&In!='d'&&In!='f') In=getch();
                        system("cls");
                        op.putline("金钱可以用于进行多种操作 ,");
                        op.putline("#1 空降 可以消耗金钱在指定的格子上生成 1e 士兵 ,");
                        op.putline("红方在将光标移动到指定格子上后使用 q 键进行空降 ,");
                        op.putline("蓝方使用 P 键同理 ,");
                        op.putline("空降只能对自己已经占领的格子使用 ,");
                        op.putline("初始设置为 1000 金钱 / 次 ,");
                        op.putline("#2 铁路 可以消耗金钱建造铁路 ,");
                        op.putline("红方在将光标移动到指定格子上后使用 E 键建造铁路 ,");
                        op.putline("蓝方使用 O 键同理 ,");
                        op.putline("若移动到已建造铁路的格子上并按下建造则会拆除铁路 ,");
                        op.putline("并返还初始价格一半的金钱 ,");
                        op.putline("士兵在铁路上走时 , 会直接移动到铁路在该方向上的末端 ,");
                        op.putline("若铁路末端下一格是城市则会直接移动到城市内 ,");
                        op.putline("铁路只能在自己的格子上建造 , 城市不可建造铁路 ,");
                        op.putline("铁路的价格会随现有铁路条数的增加而增加 ,");
                        op.putline("初始设置为 1000 金钱 / 条 ,");
                        op.putline("都可在  自定义钱数消耗  中进行修改 ,");
                    } else if(In=='s') {
                        op.putline("欢迎来到Random事件介绍 ,");
                        op.putline("Random事件是自定义模式中的一种特殊模式 ,");
                        op.putline("可在自定义中选择开启或关闭");
                        op.putline("开启后 , 每过一段时间便会触发一次随机事件 ,");
                        op.putline("随机事件有好有坏 ,");
                        op.putline("并且可能会对游戏结果产生决定性的影响 ,");
                        op.putline("下面是Random事件列表 ,");
                        op.putline("# 随机减少 , 约50% ,");
                        op.putline("# 随机增加 , 约35% ,");
                        op.putline("# 矿井坍塌 / 山体滑坡 , 约8% ,");
                        op.putline("# 狂风 , 约4% ,");
                        op.putline("# 陨石 , 约2% ,");
                        op.putline("# 洪水 , 约1% ,");
                        op.putline("");
                        op.putline("# 下一页 ?");
                        op.putline("");
                        op.putline("#A 是");
                        In=' ';
                        In=getch();
                        while(In!='a'&&In!='s'&&In!='d'&&In!='f') In=getch();
                        system("cls");
                        op.putline("#1 随机减少 在地图上随机选取一格并减少一定兵力 ,");
                        op.putline("最大不超过格子内原数值 ,");
                        op.putline("#2 随机增加 在地图上随机选取一格并增加一定兵力");
                        op.putline("最大不超过 100 ,");
                        op.putline("#3 矿井坍塌 / 山体滑坡 ,");
                        op.putline("若开启矿井模式 , 则随机一个矿井坍塌 ,");
                        op.putline("否则随机一个障碍物发生山体滑坡 ,");
                        op.putline("周围 4 格的兵力全部归零 ,");
                        op.putline("#4 狂风 随机选取一行或一列 , ");
                        op.putline("将路径上的所有非城市的兵力重置为 1 ,");
                        op.putline("城市兵力则减半 ,");
                        op.putline("#5 陨石 随机选取一个陨石中心 ,");
                        op.putline("将所有与中心之间的曼哈顿距离小于等于 2 的格子清零 ,");
                        op.putline("#6 洪水 , 不明");
                    } else {
                        op.putline("欢迎来到平衡模式简介 ,");
                        op.putline("平衡模式对城市与矿井的生成制定了限制 ,");
                        op.putline("使得资源的分配趋近于平衡 ,");
                        op.putline("建议游玩时开启 ,");
                        op.putline("能有效提高游戏体验 ,");
                    }
                    op.putline("");
                    op.putline("# 所以你还想看 ?");
                    op.putline("#A 和矿井有关 (观看矿井介绍)");
                    op.putline("#S 和Random事件有关 (观看Random介绍)");
                    op.putline("#D 和平衡模式有关 (观看平衡模式简介)");
                    op.putline("#F 了解更多 (...)");
                    In=' ';
                    In=getch();
                    while(In!='a'&&In!='s'&&In!='d'&&In!='f') In=getch();
                }
            }
            system("cls");
            op.putline("# 希望了解更多吗 ?");
            op.putline("");
            op.putline("#A 不了 (返回主页)");
            op.putline("#S 未完待续...");
            In=' ';
            In=getch();
            while(In!='a') In=getch();
            system("cls");
            Start_screen();
        }
        void detail() {//About Us
            oper.operate_window(52,20);
            op.putline("游戏原作: @ generals.io");
            op.putline("c++版原源代码作者:洛谷 @ ForeverCC");
            op.putline("c++代码修改版:洛谷 @ SL789");
            op.putline("          Bilibili @ 带火锌的木条");
            op.putline("感谢支持!");
            op.putline(" ");
            op.putline("更新日志:");
            op.putline("2023.8.9   修改版Generals初版发布在洛谷博客上");
            op.putline("2023.8.9   修复了建造铁路后钱数可以为负的bug");
            op.putline("2023.8.9   修复了光标移动到铁路上直接跳过回合的bug");
            op.putline("2023.8.10  工厂正式更名为矿井");
            op.putline("2023.8.10  重置了教程 , 教程更加详细与具体 ,");
            op.putline("2023.8.10  修复了离城市最近的铁路会残留兵力的bug");
            op.putline("2023.8.11  新增了迷雾模式");
            op.putline("2023.8.18  新增了UI");
            op.putline("2023.8.19  修复了被对方占领的城市会错乱的bug");
            op.putline("2023.4.28  修复了铁路建造与摧毁异常的bug");
            system("pause");
            return;
        }
} hel;
class Refresh {
    private:
        int val;
        void single(int dx,int dy) {
            oper.color(15,0),oper.gotoxy(dx,dy*3);
            if(Dark_map[dx][dy]==1) {
                oper.color(0,7);
                cout<<" ?";
                return;
            }
            if(Pit[dx][dy]==1) {
                cout<<" $";
				return;
			}
			if(Mapstate[dx][dy]=='X') {
				cout<<" X";
				return;
			}
			char cm=Mapstate[dx][dy];
			if(Ran_map[dx][dy]==1) oper.color(0,14);
			if(Mapstate[dx][dy]==0) {
				cout<<"   ";
				return;
			}
			if(Mapstate[dx][dy]=='A') oper.color(15,5);
			if(Mapstate[dx][dy]=='a') oper.color(15,4);
			if(Mapstate[dx][dy]=='B') oper.color(15,3);
			if(Mapstate[dx][dy]=='b') oper.color(15,1);
			if(Mapstate[dx][dy]=='C') oper.color(15,0);
			if(Ran_map[dx][dy]==1) oper.color(0,14);
			if(cm=='a'&&Train_Map[dx][dy]==1) oper.color(4,7);
			if(cm=='b'&&Train_Map[dx][dy]==2) oper.color(1,7);
			val=hp[dx][dy];
			if(val<10) cout<<" "<<val;
			else if(val<100) cout<<val;
			else if(val<1000) cout<<val/100<<"e";
			else if(val<10000) cout<<val/1000<<"k";
			else if(val<100000) cout<<val/10000<<"w";
			else cout<<">w";
			oper.color(15,0);
		}
	public:
		void modifyS(int dx,int dy) {
			single(dx,dy);
		}
		void modifyA() {
			for(int i=0; i<Mapsize; i++) {
				for(int j=0; j<Mapsize; j++) {
					single(i,j);
				}
			}
		}
} refr;
class Smog {
	public:
		void smog_renew() {//迷雾重置
			for(int i=0; i<Mapsize; i++) {
				for(int j=0; j<Mapsize; j++) {
					if(Mapstate[i][j]=='a'||Mapstate[i][j]=='A') continue;
					if(Mapstate[i][j]=='b'||Mapstate[i][j]=='B') continue;
					int f=1;
					for(int l=0; l<8; l++) {
						int cx=i+dec8X[l],cy=j+dec8Y[l];
						if(cx<0||cy<0||cx>=Mapsize||cy>=Mapsize) continue;
						if(Mapstate[cx][cy]=='a'||Mapstate[cx][cy]=='b') f=0;
						if(Mapstate[cx][cy]=='A'||Mapstate[cx][cy]=='B') f=0;
					}
					Dark_map[i][j]=f;
					refr.modifyS(i,j);
				}
			}
		}
} smog;
class Moveevent {
	private:
	public:
		void move_cursor(int dx,int dy) {//移动光标
			oper.color(15,0);
			if(dx<0||dx>=Mapsize||dy<0||dy>=Mapsize) return;
			oper.gotoxy(Cursor_X,Cursor_Y*3+2);
			cout<<" ";
			Cursor_X=dx,Cursor_Y=dy;
			oper.gotoxy(Cursor_X,Cursor_Y*3+2);
			cout<<"<";
			oper.gotoxy(Mapsize+2,0);
			if(Dark_map[dx][dy]==1) cout<<"Mapstate= "<<"?"<<" , HP="<<"?"<<"    ";
			else cout<<"Mapstate= "<<Mapstate[dx][dy]<<" , HP="<<hp[dx][dy]<<"    ";
		}
} mov;
class Player {
	private:
		int In;
		char a,b,B;
	public:
		bool PlayerTurn(char A,int U,int D,int L,int R,int Fly,int Tra,int All,int Hal,int Cancel,int dx,int dy) {//键位映射
			oper.color(15,0);
			mov.move_cursor(dx-1,dy-1);
			a=A-'A'+'a',B=(A=='A')?'B':'A',b=B-'A'+'a';
			In=0;
			while(In!=All&&In!=Hal&&In!=' ') {
				In=getch();
				if(In==224) In=getch();
				if(In==U) mov.move_cursor(Cursor_X-1,Cursor_Y);
				if(In==D) mov.move_cursor(Cursor_X+1,Cursor_Y);
				if(In==L) mov.move_cursor(Cursor_X,Cursor_Y-1);
				if(In==R) mov.move_cursor(Cursor_X,Cursor_Y+1);
				if(In==Fly&&(A=='A'?A_money>=Fly_consume:B_money>=Fly_consume)&&(Mapstate[Cursor_X][Cursor_Y]==a||Mapstate[Cursor_X][Cursor_Y]==A)) break;
				if(In==Tra&&((Mapstate[Cursor_X][Cursor_Y]==a&&(A=='A'?A_money>=A_Tra:B_money>=B_Tra))||Train_Map[Cursor_X][Cursor_Y]==A-'A'+1)) break;
			}
			if(In==All) {
                while(In!=224&&In!=U&&In!=D&&In!=L&&In!=R&&In!=Cancel) In=getch();
				if(In==224) In=getch();
				if(In==Cancel) return 0;
				if(In==U) vRec(3,Cursor_X+1,Cursor_Y+1,A),vMoveNum(-1,0,A);
				if(In==D) vRec(4,Cursor_X+1,Cursor_Y+1,A),vMoveNum(1,0,A);
				if(In==L) vRec(2,Cursor_X+1,Cursor_Y+1,A),vMoveNum(0,-1,A);
				if(In==R) vRec(1,Cursor_X+1,Cursor_Y+1,A),vMoveNum(0,1,A);
			} else if(In==Hal) {
                while(In!=224&&In!=U&&In!=D&&In!=L&&In!=R&&In!=Cancel) In=getch();
				if(In==224) In=getch();
				if(In==Cancel) return 0;
				if(In==U) vRec(7,Cursor_X+1,Cursor_Y+1,A),vDiv(-1,0,A);
				if(In==D) vRec(8,Cursor_X+1,Cursor_Y+1,A),vDiv(1,0,A);
				if(In==L) vRec(6,Cursor_X+1,Cursor_Y+1,A),vDiv(0,-1,A);
				if(In==R) vRec(5,Cursor_X+1,Cursor_Y+1,A),vDiv(0,1,A);
			} else if(In==Fly) {
				vFly(Cursor_X,Cursor_Y);
				(A=='A')?A_money-=Fly_consume:B_money-=Fly_consume;
			} else if(In==' ') {
				vRec(11,0,0,A);
			} else if(In==Tra) {
				if(Train_Map[Cursor_X][Cursor_Y]==A-'A'+1) {
					vDestroy(Cursor_X,Cursor_Y);
					(A=='A')?A_money+=Train_consume/2:B_money+=Train_consume/2;
					(A=='A')?A_Train_num--:B_Train_num--;
				} else {
					Train_Map[Cursor_X][Cursor_Y]=A-'A'+1;
					vBuild(A-'A'+1,Cursor_X,Cursor_Y);
					(A=='A')?A_money-=A_Tra:B_money-=B_Tra;
				}
			}
			if(Dark) smog.smog_renew();
			return 1;
		}
} pla;
class Animation {
	private:
		const int show[10][31] {
			{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
			{1,0,0,1,1,2,2,1,0,0,1,1,2,2,1,0,0,1,1,2,2,1,0,1,1,1,2,2,2,1},
			{0,1,1,1,2,1,1,2,0,1,0,2,1,1,2,0,1,0,2,1,1,2,0,1,1,2,1,1,1,1},
			{0,1,0,0,2,2,2,1,0,1,0,2,2,2,1,0,1,1,2,1,1,2,0,1,1,1,2,2,1,1},
			{0,1,1,0,2,1,1,1,0,1,0,2,1,1,1,0,1,1,2,1,2,2,0,1,0,1,1,1,2,1},
			{1,0,0,0,1,2,2,2,0,1,0,1,2,2,2,0,1,1,1,2,1,2,2,0,1,2,2,2,1,0},
			{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1},
			{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3},
			{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,1,3},
			{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,3,3,3}
		};
		int a,b;
	public:
		void ani_begin() {
			for(int k=2; k<=43; k++) {
				for(int i=1; i<=10; i++) {
					int j=k-i;
					if(j<=0||j>30) continue;
					a=i-1,b=j-1;
					oper.gotoxy(a,b*2),oper.color(15,0),cout<<"■";
				}
				for(int i=1; i<=10; i++) {
					int j=(k-3)-i;
					if(j>30||j<=0) continue;
					a=i-1,b=j-1;
					if(show[a][b]==1) oper.gotoxy(a,b*2),oper.color(15,0),cout<<"  ";
					if(show[a][b]==0) oper.gotoxy(a,b*2),oper.color(3,0),cout<<"■";
					if(show[a][b]==2) oper.gotoxy(a,b*2),oper.color(4,0),cout<<"■";
					if(show[a][b]==3) oper.gotoxy(a,b*2),oper.color(14,0),cout<<"■";
				}
				Sleep(12);
			}
			oper.color(15,0);
		}
} ani;


//--------------------*Main*------------------------
int main() {
	oper.color(15,0);
	system("cls");
	oper.operate_window(60,20);
	SetConsoleTitle("Generals Test @ SL789");
	Start_screen();
	return 0;
}
void Start_screen() {
	string Start_str[4];
	char C[16];
	sprintf(C,"#1 Classic mode "),Start_str[0]=C;
	sprintf(C,"#2 custom mode  "),Start_str[1]=C;
	sprintf(C,"#3 Help         "),Start_str[2]=C;
	sprintf(C,"#4 About Us     "),Start_str[3]=C;
	oper.operate_window(60,20);
	ani.ani_begin();
	oper.color(0,14);
	oper.gotoxy(11,2);
	op.putLen(Start_str[0],15);
	oper.color(15,0);
	oper.gotoxy(13,2),op.putLen(Start_str[1],15);
	oper.gotoxy(15,2),op.putLen(Start_str[2],15);
	oper.gotoxy(17,2),op.putLen(Start_str[3],15);
	oper.gotoxy(0,0);
	int in=0,p=0;
	while(in!=' '&&in!=13) {
		in=getch();
		if(in=='w') oper.gotoxy(p*2+11,2),oper.color(15,0),op.putLen(Start_str[p],15),p--;
		if(in=='s') oper.gotoxy(p*2+11,2),oper.color(15,0),op.putLen(Start_str[p],15),p++;
		p=(p+4)%4;
		oper.gotoxy(p*2+11,2),oper.color(0,14),op.putLen(Start_str[p],15);
	}
	oper.color(15,0),system("cls");
	switch(p) {
		case 0:
			vMain2();
			break;
		case 1:
			Set_num();
			vMain2();
			break;
		case 2:
			hel.playerhelp();
			break;
		case 3:
			hel.detail();
			break;
	}
}
void vMain2() {
	oper.operate_window(60,20);
	vInit();
	bool pass=0;
	for(Counts=0;; Counts++) {
		vPlus();
		oper.gotoxy(Mapsize,0);
		cout<<"(回合) count="<<Counts;
		oper.gotoxy(Mapsize+1,0);
		oper.color(15,4);
		cout<<"red  ";
		while(!pass){
			pass=pla.PlayerTurn('A','w','s','a','d','q','e','x','z','r',1,1);
		}pass=0;
		vRec(0,0,0,0);
		vEnd();
		oper.gotoxy(Mapsize+1,0),oper.color(15,1);
		cout<<"blue ";
		while(!pass){
			pass=pla.PlayerTurn('B',72,80,75,77,'p','o','m','n','l',Mapsize,Mapsize);
		}pass=0;
		if(Randomstate==1) vRandom();
		vRec(0,0,0,0);
	}
}
void vRandom() {
	int Ran=rand()%max(4,40-Counts/3);
	if(Ran!=0) return;
	Ran=rand()%120;
	if(Floodstate==1) Ran=0;
	char C[N];
	if(Ran==0) { //----------洪水---------
		if(Floodstate==0) {
			Floodstate=1;
			sprintf(C,"It Seems That...    ");
			Random_str=C;
			vRec(20,0,0,0);
			vRec(0,0,0,0);
			Sleep(1000);
			return;
		} else {
			for(int i=0; i<Mapsize; i++) {
				for(int j=0; j<Mapsize; j++) {
					if(Mapstate[i][j]=='C') continue;
					if(Mapstate[i][j]=='X') continue;
					if(Mapstate[i][j]=='A'||Mapstate[i][j]=='B') {
						hp[i][j]=min(100,hp[i][j]/5);
						Ran_map[i][j]=1;
					} else {
						hp[i][j]=0;
						Mapstate[i][j]=0;
						Train_Map[i][j]=0;
						Ran_map[i][j]=1;
					}
				}
				Floodstate=0;
			}
			refr.modifyA();
			if(Dark) smog.smog_renew();
			sprintf(C,"Flood is Coming !!!  ");
		}
	} else if(Ran==1||Ran==2) { //----------陨石----------
		int dx=rand()%Mapsize;
		int dy=rand()%Mapsize;
		for(int i=0; i<Mapsize; i++) {
			for(int j=0; j<Mapsize; j++) {
				if(abs(i-dx)+abs(j-dy)<=2) {
					if(Mapstate[i][j]=='a'||Mapstate[i][j]=='b') {
						hp[i][j]=0;
						Mapstate[i][j]=0;
						Ran_map[i][j]=1;
						refr.modifyS(i,j);
					}
					if(Mapstate[i][j]=='A'||Mapstate[i][j]=='B') {
						hp[i][j]/=2;
						Ran_map[i][j]=1;
						refr.modifyS(i,j);
					}
				}
			}
		}
		if(Dark) smog.smog_renew();
		sprintf(C,"[%d,%d] Meteorute!!  ",dx,dy);
	} else if(Ran>=3&&Ran<=5) { //----------狂风----------
		int dec=rand()%2+1;
		if(dec==1) {
			int dy=rand()%Mapsize;
			for(int i=0; i<Mapsize; i++) {
				if(Mapstate[i][dy]=='a'||Mapstate[i][dy]=='b') {
					hp[i][dy]=1;
					Ran_map[i][dy]=1;
					refr.modifyS(i,dy);
				}
				if(Mapstate[i][dy]=='A'||Mapstate[i][dy]=='B') {
					hp[i][dy]/=2;
					Ran_map[i][dy]=1;
					refr.modifyS(i,dy);
				}
			}
		}
		if(dec==2) {
			int dx=rand()%Mapsize;
			for(int i=0; i<Mapsize; i++) {
				if(Mapstate[dx][i]=='a'||Mapstate[dx][i]=='b') {
					hp[dx][i]=1;
					Ran_map[dx][i]=1;
					refr.modifyS(dx,i);
				}
				if(Mapstate[dx][i]=='A'||Mapstate[dx][i]=='B') {
					hp[dx][i]/=2;
					Ran_map[dx][i]=1;
					refr.modifyS(dx,i);
				}
			}
		}
		sprintf(C,"Wind Blows Heavily !  ");
	} else if(Ran>=5&&Ran<=10) { //-----矿洞坍塌 \ 山体滑坡-----
		int dx=rand()%Mapsize;
		int dy=rand()%Mapsize;
		if(Pitstate==1) {
			while(Pit[dx][dy]==0) {
				dx=rand()%Mapsize;
				dy=rand()%Mapsize;
			}
			for(int i=max(0,dx-1); i<=dx+1; i++) {
				for(int j=max(0,dy-1); j<=dy+1; j++) {
					if(abs(i-dx)+abs(j-dy)==1) {
						hp[i][j]=0;
						if(Mapstate[i][j]=='a'||Mapstate[i][j]=='b') {
							Mapstate[i][j]=0;
							Ran_map[i][j]=1;
							refr.modifyS(i,j);
						}
					}
				}
			}
			sprintf(C,"[%d,%d] Collapse !   ",dx,dy);
		} else {
			while(Mapstate[dx][dy]!='X') {
				dx=rand()%Mapsize;
				dy=rand()%Mapsize;
			}
			for(int i=max(0,dx-1); i<=dx+1; i++) {
				for(int j=max(0,dy-1); j<=dy+1; j++) {
					if(abs(i-dx)+abs(j-dy)==1) {
						hp[i][j]=0;
						if(Mapstate[i][j]=='a'||Mapstate[i][j]=='b') {
							Mapstate[i][j]=0;
							Ran_map[i][j]=1;
							refr.modifyS(i,j);
						}
					}
				}
			}
			sprintf(C,"[%d,%d] Landslide !  ",dx,dy);
		}
	} else if(Ran>=11&&Ran<=55) { //----------随机增加----------
		int dx=rand()%Mapsize;
		int dy=rand()%Mapsize;
		int T=Mapsize*Mapsize;
		while(1) {
			if(Mapstate[dx][dy]=='a'&&Army_A<=Army_B) break;
			if(Mapstate[dx][dy]=='b'&&Army_B<=Army_A) break;
			dx=rand()%Mapsize;
			dy=rand()%Mapsize;
			T--;
			if(T==0) return;
		}
		int s=rand()%min(80,10+Counts)+20;
		hp[dx][dy]+=s;
		Ran_map[dx][dy]=1;
		refr.modifyS(dx,dy);
		sprintf(C,"[%d,%d] Hp + %d      ",dx,dy,s);
	} else if(Ran>55) { //----------随机减少----------
		int dx=rand()%Mapsize;
		int dy=rand()%Mapsize;
		while(Mapstate[dx][dy]=='C'||Mapstate[dx][dy]==0||Mapstate[dx][dy]=='X') {
			if(Mapstate[dx][dy]=='a'&&Army_A>=Army_B&&hp[dx][dy]>=min(80,Counts/2)) break;
			if(Mapstate[dx][dy]=='b'&&Army_B>=Army_A&&hp[dx][dy]>=min(80,Counts/2)) break;
			if(Mapstate[dx][dy]=='A'&&Army_A>=Army_B) break;
			if(Mapstate[dx][dy]=='B'&&Army_B>=Army_A) break;
			dx=rand()%Mapsize;
			dy=rand()%Mapsize;
		}
		int s=rand()%min(80,Counts/2)+20;
		if(hp[dx][dy]>s) hp[dx][dy]-=s;
		else {
			s=hp[dx][dy]-1;
			hp[dx][dy]=1;
		}
		Ran_map[dx][dy]=1;
		refr.modifyS(dx,dy);
		sprintf(C,"[%d,%d] HP - %d     ",dx,dy,s);
	}
	Random_str=C;
	vRec(20,0,0,0);
	vRec(0,0,0,0);
	Sleep(1000);
}
void vDestroy(int dx,int dy) {
	Train_Map[dx][dy]=0;
	vRec(16,dx+1,dy+1,0);
	refr.modifyS(dx,dy);
}
void vBuild(int bu_num,int dx,int dy) {
	if(bu_num==1) {
		A_Train_num++;
		oper.gotoxy(dx,dy*3);
		oper.color(4,7);
		int val=hp[dx][dy];
		if(val<10) cout<<" "<<val;
		else if(val<100) cout<<val;
		else if(val<1000) cout<<val/100<<"e";
		else if(val<10000) cout<<val/1000<<"k";
		else if(val<100000) cout<<val/10000<<"w";
		else cout<<">w";
		Train_Map[dx][dy]=1;
		vRec(13,dx+1,dy+1,'A');
	} else {
		B_Train_num++;
		oper.gotoxy(dx,dy*3);
		oper.color(1,7);
		int val=hp[dx][dy];
		if(val<10) cout<<" "<<val;
		else if(val<100) cout<<val;
		else if(val<1000) cout<<val/100<<"e";
		else if(val<10000) cout<<val/1000<<"k";
		else if(val<100000) cout<<val/10000<<"w";
		else cout<<">w";
		Train_Map[dx][dy]=2;
		vRec(13,dx+1,dy+1,'B');
	}
}
void vFly(int dx,int dy) {
	hp[dx][dy]+=100;
	refr.modifyS(dx,dy);
	if(Mapstate[dx][dy]=='a'||Mapstate[dx][dy]=='A') vRec(14,dx,dy,'A');
	else vRec(14,dx,dy,'B');
}
void vInit() {
	for(int i=1; i<=10; i++) Rec_str[i]=' ';
	Random_str="NULL                ";
	int i,j,x,y;
	unsigned int Seed_out=12345678;
	op.putline("注:相同设置下相同种子生成相同地图");
	cout<<"In_seed:";
	cin>>MapSeed;
	Seed_output=MapSeed;
	system("cls");
	oper.operate_window(Mapsize*3+30,Mapsize+12);
	for(i=1; i<MapSeed.size(); i++) Seed_out=Seed_out*(int)(MapSeed[0])+MapSeed[i];
	srand(Seed_out);
	Mapstate[0][0]='A';
	Mapstate[Mapsize-1][Mapsize-1]='B';
	hp[0][0]=1;
	hp[Mapsize-1][Mapsize-1]=1;
	refr.modifyS(0,0);
	refr.modifyS(Mapsize-1,Mapsize-1);
	if(Dark==1) {
		for(int i=0; i<Mapsize; i++) {
			for(int j=0; j<Mapsize; j++) {
				Dark_map[i][j]=1;
			}
		}
		Dark_map[0][0]=0;
		Dark_map[1][1]=0;
		Dark_map[0][1]=0;
		Dark_map[1][0]=0;
		Dark_map[Mapsize-1][Mapsize-1]=0;
		Dark_map[Mapsize-2][Mapsize-2]=0;
		Dark_map[Mapsize-1][Mapsize-2]=0;
		Dark_map[Mapsize-2][Mapsize-1]=0;
	}
	if(City_num%2==1) {
		City_num--;
		Mapstate[Mapsize/2][Mapsize/2]='C';
		hp[Mapsize/2][Mapsize/2]=60;
		refr.modifyS(Mapsize/2,Mapsize/2);
	}
	for(i=1; i<=Barrier_num; i++) {
		x=rand()%Mapsize;
		y=rand()%Mapsize;
		if(Mapstate[x][y]!=0||x==0||y==0||x==Mapsize-1||y==Mapsize-1) i--;
		else {
			Mapstate[x][y]='X';
			oper.gotoxy(x,y*3);
			oper.color(15,0);
			cout<<" X";
		}
	}
	City_A=City_B=0;
	for(i=1; i<=City_num; i++) {
		x=rand()%Mapsize;
		y=rand()%Mapsize;
		if(Mapstate[x][y]!=0) {
			i--;
			continue;
		}
		if(Treapstate) {
			int f=1;
			for(int l=0; l<4; l++) {
				int x_to=x+dec4X[l],y_to=y+dec4Y[l];
				if(x<0||y<0||x>=Mapsize||y>=Mapsize) continue;
				if(Mapstate[x_to][y_to]=='C') f=0;
			}
			if(!f) {
				i--;
				continue;
			}
			if(x+y>=Mapsize-2&&x+y<=Mapsize) {
				i--;
				continue;
			}
			if(x+y<Mapsize) {
				if(City_A>=City_num/2) {
					i--;
					continue;
				}
				City_A++;
			}
			if(x+y>Mapsize) {
				if(City_B>=City_num/2) {
					i--;
					continue;
				}
				City_B++;
			}
		}
		Mapstate[x][y]='C';
		hp[x][y]=20+rand()%60;
		refr.modifyS(x,y);
	}
	if(Pitstate==1) {
		for(i=1; i<=Pit_num; i++) {
			x=rand()%Mapsize;
			y=rand()%Mapsize;
			if(Mapstate[x][y]!=0) {
				i--;
				continue;
			}
			if(Treapstate) if(x+y<=Mapsize*4/7-1||x+y>=2*Mapsize-Mapsize*4/7+1) {
					i--;
					continue;
				}
			Pit[x][y]=1;
			Mapstate[x][y]='X';
			oper.gotoxy(x,y*3);
			oper.color(15,0);
			cout<<" $";
        }
    }
    Cursor_X=Cursor_Y=0;
    oper.gotoxy(0,2);
    oper.color(15,0);
    cout<<"<";
    A_Tra=B_Tra=Train_consume;
    for(int i=0; i<Mapsize; i++) {
        for(int j=0; j<Mapsize; j++) {
            refr.modifyS(i,j);
        }
    }
}
void vMoveNum(int dx,int dy,char A) {
	//参数:[dx]移动后x坐标[dy]移动后y坐标[A]我方符号
    char a,B,b;
    a=A-'A'+'a',B=(A=='A')?'B':'A',b=B-'A'+'a';//代表敌方[B]和我方[A]
    if(Mapstate[Cursor_X][Cursor_Y]!=a&&Mapstate[Cursor_X][Cursor_Y]!=A) return;//不可移动非我方
    dx+=Cursor_X,dy+=Cursor_Y;
    if(!(dx>=0&&dx<Mapsize&&dy>=0&&dy<Mapsize&&Mapstate[dx][dy]!='X')) {//不合法位置
        vRec(12,0,0,A);
        return;
    }
    char &cd=Mapstate[dx][dy];
    int &hd=hp[dx][dy],&hs=hp[Cursor_X][Cursor_Y];
    if(cd!=a&&cd!=A&&hd>=hs-1) {//进攻失败
        vRec(17,Cursor_X+1,Cursor_Y+1,A);
        vRec(0,0,0,0);
        return;
    }
    if(cd==0) {//空地
        cd=a;
        hp[dx][dy]=hp[Cursor_X][Cursor_Y]-1;
    } else if(cd==A||cd==a) {
        if(Train_Map[dx][dy]==a-'a'+1) {
            int cx,cy;
            cx=dx-Cursor_X;
            cy=dy-Cursor_Y;
            while(Train_Map[dx][dy]==a-'a'+1&&dx>=0&&dx<Mapsize&&dy>=0&&dy<Mapsize) {
                hs+=hp[dx][dy]-1;
                hp[dx][dy]=1;
                refr.modifyS(dx,dy);
                dx+=cx;
                dy+=cy;
            }
            dx-=cx;
            dy-=cy;
            if(Mapstate[dx+cx][dy+cy]==A) {
                hs+=hp[dx][dy]-1;
                hp[dx][dy]=1;
                dx+=cx;
                dy+=cy;
            }
            hp[dx][dy]+=hs-1;
        } else{
        	hp[dx][dy]+=hp[Cursor_X][Cursor_Y]-1;
        	hp[Cursor_X][Cursor_Y]=1;
        }
    } else if(cd==B||cd==b) {
        cd==B?vRec(19,Cursor_X+1,Cursor_Y+1,A):vRec(18,Cursor_X+1,Cursor_Y+1,A);
        if(Train_Map[dx][dy]!=0) {
            Train_Map[dx][dy]=0;
            vRec(16,dx+1,dy+1,0);
            (A=='A')?B_Train_num--:A_Train_num--;
        }
        (A=='A')?cd--:cd++;
        hd=hs-1-hd;
    } else {
        cd=A;
        hd=hs-1-hd;
        vRec(19,Cursor_X+1,Cursor_Y+1,A);
    }
    hs=1;
    vRec(0,0,0,0);
    refr.modifyS(dx,dy);
    refr.modifyS(Cursor_X,Cursor_Y);
    mov.move_cursor(Cursor_X+dx,Cursor_Y+dy);
}
void vDiv(int dx,int dy,char A) {
    char a,B,b;
    a=A-'A'+'a';
    B=(A=='A')?'B':'A';
    b=B-'A'+'a';
    if(Mapstate[Cursor_X][Cursor_Y]!=a&&Mapstate[Cursor_X][Cursor_Y]!=A) return;
    dx+=Cursor_X;
    dy+=Cursor_Y;
    if(!(dx>=0&&dx<Mapsize&&dy>=0&&dy<Mapsize&&Mapstate[dx][dy]!='X')) {
        vRec(12,0,0,A);
        return;
    }
    char &cd=Mapstate[dx][dy];
    int &hd=hp[dx][dy],&hs=hp[Cursor_X][Cursor_Y],tmp=hs/2;
    if(tmp==0) return;
    if(cd!=a&&cd!=A&&hd>=tmp-1) return;
    if(cd==0) {
        cd=a;
        hd=tmp;
    } else if(cd==A||cd==a) {
        hd+=tmp;
    } else if(cd==B||cd==b) {
        (cd==B)?vRec(19,Cursor_X+1,Cursor_Y+1,A):vRec(18,Cursor_X+1,Cursor_Y+1,A);
        if(Train_Map[dx][dy]!=0) {
            Train_Map[dx][dy]=0;
            vRec(16,dx+1,dy+1,0);
            (A=='A')?B_Train_num--:A_Train_num--;
        }
        (A=='A')?cd--:cd++;
        hd=tmp-hd;
    } else {
        cd=A;
        hd=tmp-hd;
        vRec(19,Cursor_X+1,Cursor_Y+1,A);
    }
    hs-=tmp;
    vRec(0,0,0,0);
    refr.modifyS(dx,dy);
    refr.modifyS(Cursor_X,Cursor_Y);
    mov.move_cursor(dx,dy);
}
void vPlus() {
    int i,j,A_army=0,B_army=0,A_land=0,B_land=0,A_mon=0,B_mon=0,A_city=0,B_city=0;
    if(Counts%Landhp_Plus==0) {
        for(i=0; i<Mapsize; i++) {
            for(j=0; j<Mapsize; j++) {
                if(Mapstate[i][j]=='a'||Mapstate[i][j]=='b') {
                    hp[i][j]++;
                    refr.modifyS(i,j);
                }
            }
        }
    }
    for(i=0; i<Mapsize; i++) {
        for(j=0; j<Mapsize; j++) {
            if(Ran_map[i][j]==1) {
                Ran_map[i][j]=0;
                refr.modifyS(i,j);
            }
            if(Mapstate[i][j]=='A'||Mapstate[i][j]=='B') {
                hp[i][j]+=Mainhp_Plus;
                refr.modifyS(i,j);
            }
            if(Pit[i][j]==1) {
                for(int l=0; l<4; l++) {
                    int x=i+dec4X[l],y=j+dec4Y[l];
                    if(x<0||y<0||x>=Mapsize||y>=Mapsize) continue;
                    if(Mapstate[x][y]=='a'||Mapstate[x][y]=='A') A_mon+=Moneysingle;
                    if(Mapstate[x][y]=='b'||Mapstate[x][y]=='B') B_mon+=Moneysingle;
                }
            }
            if(Mapstate[i][j]=='A'||Mapstate[i][j]=='a') A_land++,A_army+=hp[i][j];
            if(Mapstate[i][j]=='B'||Mapstate[i][j]=='b') B_land++,B_army+=hp[i][j];
            if(Mapstate[i][j]=='A') A_city++;
            if(Mapstate[i][j]=='B') B_city++;
        }
    }
    A_money=min(A_money+A_mon,A_city*City_limit);
    B_money=min(B_money+B_mon,B_city*City_limit);
    A_Tra=Train_consume+Train_consume*(A_Train_num/(Mapsize/2));
    B_Tra=Train_consume+Train_consume*(B_Train_num/(Mapsize/2));
    oper.color(15,0);
    oper.gotoxy(Mapsize+3,0);
    Army_A=A_army;
    Army_B=B_army;
    cout<<"(红HP总数)Red army:"<<A_army<<"   "<<endl;
    cout<<"(红地皮总数)Red land:"<<A_land<<"   "<<endl;
    if(Pitstate==1) cout<<"(红方金钱总数)Red money(max):"<<A_money<<"("<<A_city*City_limit<<")"<<"   "<<endl;
    cout<<"(蓝HP总数)Blue army:"<<B_army<<"   "<<endl;
    cout<<"(蓝地皮总数)Blue land:"<<B_land<<"   "<<endl;
    if(Pitstate==1) cout<<"(蓝方金钱总数)Blue money(max):"<<B_money<<"("<<B_city*City_limit<<")"<<"   "<<endl;
    cout<<"Seed:"<<Seed_output<<endl;
    if(Pitstate==1) {
        oper.color(15,0);
        oper.gotoxy(Mapsize+1,40);
        cout<<"空降消耗:"<<Fly_consume<<"(/次)";
        oper.gotoxy(Mapsize+2,40);
        cout<<"红方铁路造价:"<<A_Tra<<"(/条)";
        oper.gotoxy(Mapsize+3,40);
        cout<<"蓝方铁路造价:"<<B_Tra<<"(/条)";
        oper.gotoxy(Mapsize+4,40);
        cout<<"红方铁路条数:"<<A_Train_num;
        oper.gotoxy(Mapsize+5,40);
        cout<<"蓝方铁路条数:"<<B_Train_num;
    }
    if(Randomstate==1) {
        oper.gotoxy(Mapsize+6,40);
        cout<<"Random事件状态:开启";
        oper.gotoxy(Mapsize+7,40);
        cout<<"上次事件:";
        oper.gotoxy(Mapsize+8,40);
        oper.color(0,14);
        op.putLen(Random_str,20);
        oper.color(15,0);
    }
    vEnd();
}
void vEnd() {
    if(Mapstate[0][0]=='B') {
        vRec(15,0,0,'B');
        Sleep(1000);
        vRec(0,0,0,0);
    }
    if(Mapstate[Mapsize-1][Mapsize-1]=='A') {
        vRec(15,0,0,'A');
        Sleep(1000);
        vRec(0,0,0,0);
    }
}
void cot(string In_string) {
    cout<<In_string<<endl;
}
void Set_num() {
    oper.operate_window(60,20);
    int p;
    system("cls");
    cout<<"地图大小:(9<Mapsize<40)";
    cin>>Mapsize;
    Mapsize=min(Mapsize,40);
    Mapsize=max(Mapsize,9);
    cout<<"障碍数量:(0<x<"<<(int)pow(Mapsize-2,2)/2<<")";
    cin>>Barrier_num;
    Barrier_num=min(Barrier_num,(int)pow(Mapsize-2,2));
    Barrier_num=max(Barrier_num,0);
    cout<<"城市数量:(0<x<"<<(int)(pow(Mapsize,2)-Barrier_num)/4<<")";
    cin>>City_num;
    City_num=max(City_num,0);
    City_num=min(City_num,(int)(pow(Mapsize,2)-Barrier_num)/2);
    cout<<"城市每回合增加HP:(1<x<"<<Mapsize<<")";
    cin>>Mainhp_Plus;
    Mainhp_Plus=max(Mainhp_Plus,0);
    Mainhp_Plus=min(Mainhp_Plus,Mapsize);
    cout<<"地皮每增加1HP所需回合:(1<x<500)";
    cin>>Landhp_Plus;
    Landhp_Plus=max(Landhp_Plus,0);
    Landhp_Plus=min(Landhp_Plus,500);
    cout<<"是否开启矿井:(0/1)";
    cin>>Pitstate;
    Pitstate=(Pitstate==0)?0:1;
    if(Pitstate==1) {
        cout<<"    请输入矿井数量:(1<x<"<<(int)(pow(Mapsize-2,2)-Barrier_num)/4<<")";
        cin>>Pit_num;
        Pit_num=max(1,Pit_num);
        Pit_num=min((int)(pow(Mapsize-2,2)-Barrier_num)/4,Pit_num);
        cout<<"    请输入矿井每回合产出钱数:(1<x<100)";
        cin>>Moneysingle;
        Moneysingle=max(1,Moneysingle);
        cout<<"    是否自定义钱数消耗:(0/1)";
        cin>>p;
        p=(p==0)?0:1;
        if(p==1) {
            cout<<"        请输入城市存储上限:(100<x)";
            cin>>City_limit;
            City_limit=max(0,City_limit);
            cout<<"        请输入空降消耗钱数:(100<x<"<<City_limit*City_num/2<<")";
            cin>>Fly_consume;
            Fly_consume=max(Fly_consume,100);
            Fly_consume=min(Fly_consume,City_limit*City_num/2);
            cout<<"        请输入建造铁路(/条)钱数:(10<x<"<<City_limit*City_num/10<<")";
            cin>>Train_consume;
            Train_consume=max(Train_consume,10);
            Train_consume=min(Train_consume,City_limit*City_num/10);
        }
    }
    cout<<"是否启用随机(Random)事件:(0/1)";
    cin>>Randomstate;
    Randomstate=(Randomstate==0)?0:1;
    cout<<"是否启用平衡模式:(0/1)";
    cin>>Treapstate;
    Treapstate=(Treapstate==0)?0:1;
    cout<<"是否启用迷雾模式:(0/1)";
    cin>>Dark;
    Dark=(Dark==0)?0:1;
    for(int i=0; i<=10; i++) {
        system("cls");
        int j;
        cot("修改中:");
        for(j=1; j<=i; j++) cout<<"■";
        for(; j<=10; j++) cout<<"□";
        cout<<i*10<<"%";
        Sleep(200);
    }
    system("cls");
    cot("修改完成");
    Sleep(1000);
    system("cls");
}
void vRec(int rec_kind,int dx,int dy,char A) {
    char C[N];
    if(rec_kind==0) {
        for(int i=1; i<=10; i++) {
            if(Rec_str[i][0]==' ') break;
            oper.gotoxy(i-1,Mapsize*3+4);
            if(Rec_str[i][0]=='A') oper.color(15,4);
            if(Rec_str[i][0]=='B') oper.color(15,1);
            if((Rec_str[i][10]=='C'||Rec_str[i][2]=='S'||Rec_str[i][2]=='B')&&Rec_str[i][0]=='A') oper.color(15,5);
            if((Rec_str[i][10]=='C'||Rec_str[i][2]=='S'||Rec_str[i][2]=='B')&&Rec_str[i][0]=='B') oper.color(15,3);
            if(Rec_str[i][0]=='[') oper.color(15,7);
            if(Rec_str[i][0]=='R') oper.color(0,14);
            op.putLen(Rec_str[i],20);
        }
        oper.color(15,0);
        return;
    }
    switch(rec_kind) {
        case 1:
            sprintf(C,"%c [%d,%d] Right All  ",A,dx,dy);
            break;
        case 2:
            sprintf(C,"%c [%d,%d] Left All   ",A,dx,dy);
            break;
        case 3:
            sprintf(C,"%c [%d,%d] Up All     ",A,dx,dy);
            break;
        case 4:
            sprintf(C,"%c [%d,%d] Down All   ",A,dx,dy);
            break;
        case 5:
            sprintf(C,"%c [%d,%d] Right Half    ",A,dx,dy);
            break;
        case 6:
            sprintf(C,"%c [%d,%d] Left Half   ",A,dx,dy);
            break;
        case 7:
            sprintf(C,"%c [%d,%d] Up Half    ",A,dx,dy);
            break;
        case 8:
            sprintf(C,"%c [%d,%d] Down Half   ",A,dx,dy);
            break;
        case 11:
            sprintf(C,"%c skip               ",A);
            break;
        case 12:
            sprintf(C,"%c Illegal Action     ",A);
            break;
        case 13:
            sprintf(C,"%c Build At[%d,%d]    ",A,dx,dy);
            break;
        case 14:
            sprintf(C,"%c Sent At [%d,%d]    ",A,dx,dy);
            break;
        case 15:
            sprintf(C,"%c Win                ",A);
            break;
        case 16:
            sprintf(C,"[%d,%d]is Destoryed   ",dx,dy);
            break;
        case 17:
            sprintf(C,"%c attack[%d,%d] False",A,dx,dy);
            break;
        case 18:
            sprintf(C,"%c attack[%d,%d] True ",A,dx,dy);
            break;
        case 19:
            sprintf(C,"%c attack [City] True ",A);
            break;
        case 20:
            sprintf(C,"Random                ");
            break;
    }
    FuLL++;
    Rec_str[FuLL]=C;
    if(FuLL>10) {
        for(int i=1; i<=10; i++) Rec_str[i]=Rec_str[i+1];
        FuLL--;
    }
}
原文
抓取于
  1. chenwenzhan

    你简介倒是写清楚点呀