Road to Coder _Gane


周次


学习时间


新编写代码行数


博客量(篇)


学到知识点

         

第15周


1573


1


再次熟悉项目流程

Game.h (头文件)

#pragma once

#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"hero.h"
#include"windows.h"

#define    CLS        "                                                                "
#define    SEP        "|--------------------------------------------------------------------------------------------------|"
#define    COL                100                            //游戏页面总长
#define MARGIN_X        20                            //左边距
#define    MARGIN_XX        45
#define    MARGIN_10        8
#define    PAGE_TITLE_X    45
#define    PAGE_TITLE_Y    2
#define MAP_START_Y        4
#define    MAP_END_Y        16
#define    INFOR_START_Y    15
#define    INFOR_END_Y        23
#define    SUP_NAME_Y        25
#define    SUP_EXE_Y        27

/*
商品结构:商品编号,商品名称,商品价格,商品数量(库存),商品描述
玩家结构:玩家名称,金钱,身份(平民V0/VIP),【背包】
背包结构:物品【100】(初始容量100),当前道具数量,最大道具数量
*/
typedef enum _stufftype        //道具类型
{
    Weapon=0,Armor=1,Mean=2,con=3    //武器,防具,功法,消耗品
}stufftype;
/*商品结构*/
typedef struct _stuff        //道具
{
    int id;                    //商品编号
    char name[20];            //商品名称
    float price;            //商品单价
    int amoung;                //商品数量
    char desc[500];            //商品描述
    stufftype    type;        //商品种类
    union {                    //联合-多选一
        int minattack;            //武器(或者功法) - 增加攻击力
        int mindefence;        //防具 - 增加防御力
        int    minpower;            //功法(或者道具) - 增加真元
    };
    union {                    //联合-多选一
        int maxattack;            //武器(或者功法) - 增加攻击力
        int maxdefence;        //防具 - 增加防御力
        int    maxpower;            //功法(或者道具) - 增加真元
    };
}Stuff;

/*背包结构*/
typedef struct _bag
{
    Stuff item[10];            //背包内的物品
    int sum;                //当前背包内物品数量
    int summax;                //当前背包内可容纳最大的物品数量
    int specount;            //背包内的物品种类的数量
}Bag;
/*玩家结构*/
typedef struct _player
{
    int id;
    char name[50];            //玩家昵称
    char pass[100];            //玩家的密码
    int  glod;                //玩家的财富(金币)
    int  wealth;            //玩家的点券(通过充值获得)
    char iden[20];            //玩家的身份(VIP or V0)
    Bag bag;                //玩家的背包
    int level;                //玩家的游戏等级
    int exp;                //玩家当前的经验值
    int nextexp;            //玩家升级所需经验
    char achieve[10];        //玩家的境界
    int hp;                    //玩家的血量
    int attack;                //玩家的攻击力
    int defence;            //玩家的防御力
    char mean[20];            //玩家所修功法                                            三个char型名称其实可以去掉,但我懒得删了
    int meanindex;            //所修功法的标记(在背包使用时记住ta的编号)            用stuff[index].name的形式使用
    char weapon[20];        //玩家所装备的武器
    int weaponindex;        //武器标记(在背包使用时记住ta的编号)
    char armor[20];            //玩家所装备的防具
    int armorindex;        //防具标记(在背包使用时记住ta的编号)
}Player;

/*地图结构*/
typedef struct _map
{
    int id;                    //地图编号
    char name[20];            //地图名称
    int minlevel;            //进入最低等级
    //坐标结构
    COORD coord;            //地图的坐标
    char desc[500];            //地图介绍 Introduction
}Map;

/*怪物结构*/
typedef struct _monster
{
    int id;                    //怪物id
    char name[30];            //怪物名称
    int level;                //怪物的等级
    char achieve[10];        //怪物的修为
    int hp;                    //怪物的血量
    int attack;                //怪物的攻击力
    int defence;            //怪物的防御力
    int minmoney;            //杀死怪物后掉落金币最低值
    int maxmoney;            //杀死怪物后掉落金币最高值
    int exp;                //杀死怪物后获得的经验值
    int state;                //怪物的状态  0-死亡  非0表示存活
    //Stuff item;                //杀死怪物后有可能掉落的物品
    COORD coord;            //怪物的坐标
}Monster;

void Exit();
char Umenu();                                //功能大厅
void Uloiinsucceed();                        //登陆成功的动画
void Ulogin();                                //登陆界面
void Newlogn();                                //新用户注册界面
int Uloginmenu();                            //游戏登陆界面
void Uopenstore();                            //打开商城
void Lshowbag(Player *players);                //打开背包
void Ltrade(Player *player, int tradeid);    //交易函数
void Lshowmap(Player *players);                            //打开地图
void showinformation(Player *players);                    //打开个人信息
void LshowInformation();                                //打印信息显示区
void Lrefrush(Player *players);                            //刷新玩家的各种属性
void Lshowmonster(Player *players);                        //显示当前地图上的怪物
void LCombat(int monsterid, Player *players);            //核心:打怪啦

/*******************************************游戏库文件********************************************************/
void init();                                //初始化游戏设置,也就是包含以下函数设置
void SetTitle(char *title);                    //设置游戏窗标题
/*
    0-黑色, 1-蓝色,    2-绿色,    3-浅绿色,        4-红色,    5-紫色,    6-黄色,    7-白色
    8-灰色, 9-浅蓝色,    10-浅绿色,    11-淡浅绿色,    12-淡红色,    13-淡紫色,    14-淡黄色,    15-亮白色
*/
void SetColor(int foreColor,int backColor);    //设置游戏的前景色,背景色
void SetPosition(int x,int y);                //设置光标的坐标(位置)
void ClearInfor();                            //清除信息显示区的消息
void LshowMapInfor(int x, int y);            //在显示区显示地图息信
void Lclearmall();                            //商城清屏函数

Sour.c (源文件)

#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"hero.h"
#include"windows.h"
#include"conio.h"
#include"Game.h"

#pragma warning(disable:4996)

extern Player players[];
extern Stuff stuffs[];
Monster monsters[];
extern int X, Y;

/***************************前言**************************************/
/*当前游戏还有着各种各样的BUG,排版,怪物一大堆问题*/
/*还有我之前调试问题留下的大量注释语句*/

main()
{
    //char ch = getch();
    //players[0].exp++;
    //printf("%d",players[0].exp);
    //getch();
    init();
    //scanf("%s", players[4].name);
    //printf("%s", players[4].name);
    int result;                        //登陆界面得到的结果
    char choice=‘ ‘;                     //选择进入的功能
    do
    {
        int index = 0;                    //返回登陆界面的标记
        result = Uloginmenu();
        if (result == 0)
            Ulogin();

        while (1)
        {
            choice = Umenu();
            switch (choice)
            {
            case ‘1‘:    Lshowbag(players);        break;
            case ‘2‘: Uopenstore();        break;
            case ‘3‘:    Lshowmap(players);        break;
            case ‘4‘:  showinformation(players);  break;
            case ‘8‘:    index = 1;        break;                    //标记,返回登陆界面
            case ‘9‘:    Exit();            break;

            }
            if (index == 1)
                break;
        }
    } while (1);
    getch();
    return 0;
}

Function.c (实现文件)

#include"stdio.h"
#include"stdlib.h"
#include"time.h"
#include"string.h"
#include"hero.h"
#include"windows.h"
#include"conio.h"
#include"Game.h"
#include"math.h"

#pragma warning(disable:4996)

Player players[]={
{0, "TEXT", "123456",50000,0 ,"Vip3",.bag.summax=10,1,1,1,"武道一重天",1000,100,100,},
{1, "hhh", "123456" ,500000,0 ,"Vip0",.bag.summax = 10 ,1,1,10,"武道一重天",100,10,10 , },
{2, "小七699", "123456" ,50000,0 ,"Vip0",.bag.summax = 10,1,1,10,"武道一重天",100,10,10," ",0," " ,0," ",0 },
{3, "何无", "123456",80000000,80000 ,"Vip8",.bag.summax = 10 ,1,1,10,"武道一重天",100,10,10," ",0," " ,0," ",0 }
};
//int Playerlen=sizeof(players)/sizeof(Player);
int playid=4;
int loginid =0;                        //登录标记

Stuff stuffs[] = {
    { 0,"天灵草",8999.0,5,"强大的治愈效果。可以激发传说中的天灵体。",con,.minpower=500,.maxpower=0},
    { 1,"血魂果",11000.0,5,"增加大量肉身之力,使人血肉充足。" ,con,.minpower = 800,.maxpower = 1000 },
    { 2,"生死花",89999.0,1,"由死转生,可以再人刚死那一瞬间将人救回。",con,.minpower = 5000,.maxpower = 10000 },
    { 3,"天尊符昭",150000.0,2,"天尊强大所以可以躲避劫罚,带有天尊气息都符昭可以避劫。" ,con,.mindefence = 500,.maxdefence = 1000 },
    { 4,"真仙魂血",9999999.9,0,"真仙的一滴魂血,蕴含毁天灭地的能量(可遇不可求)。" ,con,.minattack=800,.maxpower = 1000 },
    { 5,"武道精气(金)",88888,3,"相当于100条蓝色等级的武道精气,可使人脱胎换骨。" ,con,.minpower = 500,.maxpower = 1000 },
    { 6,"木剑",1000,30,"入门必备!" ,Weapon,.minattack = 20,.maxattack = 30 },

    { 7,"玄天剑",2000,20,"入门必备!" ,Weapon,.minattack = 20,.maxattack = 50 },
    { 8,"玄天刀",2000,20,"入门必备!" ,Weapon,.minattack = 15,.maxattack = 48 },
    { 9,"绝影枪",5000,10,"抢出如龙,轻掠如火,难知如音!" ,Weapon,.minattack = 20,.maxattack = 60 },
    { 10,"裂天弓",8000,30,"裂天弓!九箭,一箭一生死!" ,Weapon,.minattack = 20,.maxattack = 70 },
    { 11,"血魔拳套",9500,30,"入门必备!" ,Weapon,.minattack = 20,.maxattack = 80 },
    { 12,"玄天盾",3000,10,"入门必备!" ,Armor,.mindefence = 20,.maxdefence = 60 },
    { 13,"玄天袍",3000,10,"入门必备!" ,Armor,.mindefence = 20,.maxdefence = 60 },
    { 14,"荆棘战甲",12000,5,"万年玄铁,九天玄冥刺融合而成的强大战甲!" ,Armor,.mindefence = 20,.maxdefence = 100 },
    { 15,"太极图",10000,30,"入门必备!" ,Weapon,.minattack = 20,.maxattack = 80 },

    { 16,"九转玄阳罡气",500000,1,"圣武顾家最强功法,圣武大陆九大圣阶秘典之一!" ,Mean,.minattack = 200,.maxattack = 850 },
    { 17,"天龙古经",450000,1,"圣武九门-天龙门镇派之秘典,圣武大陆九大圣阶秘典之一!" ,Mean,.minattack = 200,.maxattack = 800 },
    { 18,"太和经",800000,1,"圣武大陆最神奇的功法,熔炼各种功法!" ,Mean,.minattack = 500,.maxattack = 1200 },
    { 19,"魔典",500000,30,"圣武大陆魔道之首魔宫,其主魔帝功力冠绝天下,鲜有敌手!" ,Mean,.minattack = 20,.maxattack = 850 },
    { 20,"血魔手",50000,30,"极品功法!" ,Mean,.minattack = 20,.maxattack = 200 },
    { 21,"烈焰拳!",10000,30,"高级功法!" ,Mean,.minattack = 20,.maxattack = 100 },
    { 22,"七转断山拳",30000,30,"高级功法,无限趋近极品功法!" ,Mean,.minattack = 20,.maxattack = 189 },
    { 23,"剑风决",80000,30,"极品功法!" ,Mean,.minattack = 20,.maxattack = 220 },
    { 24,"九重金身决",100000,30,"绝品功法!" ,Mean,.minattack = 20,.maxattack = 360 },

    { 25,"潜龙药剂",10000,5,"神级药剂!血量永久加300" ,con,.minpower=20,.maxpower = 300 },
    { 26,"玄清丹",6000,1,"神级药剂!经验值加200" ,con,.minpower = 20,.maxpower = 200 },
    { 27,"大力牛魔丹",10000,1,"神级药剂!力量永久加300" ,con,.minpower = 20,.maxpower = 300 },
    { 28,"心魔草",3000,50,"集齐10个可以炼心魔丹" ,con,.minpower = 20,.maxpower = 30 },
    { 29,"武道石",10000,5,"逆天神物" ,con,.minpower = 20,.maxpower = 300 },
    { 30,"武道草",10000,5,"逆天神物" ,con,.minpower = 20,.maxpower = 300 },
    { 31,"龙涎香",30000,1,"神级药剂!血量永久加500" ,con,.minpower = 20,.maxpower = 500 },
    { 32,"经验药剂(小)",1000,50,"神级药剂!经验永久加30" ,con,.minpower = 20,.maxpower = 30 },
    { 33,"经验药剂(大)",10000,5,"神级药剂!血量永久加300" ,con,.minpower = 20,.maxpower = 300 },

    { 34,"三阳烈焰斩",300000,1,"仙域术法" ,Mean,.minattack = 20,.maxattack = 1000 },
    { 35,"纯阳指",310000,1,"仙域术法" ,Mean,.minattack = 20,.maxattack = 1200 },
    { 36,"八荒六合功",500000,1,"仙域术法,准圣功法" ,Mean,.minattack = 20,.maxattack = 3000 },
    { 37,"九千杀伐术",550000,1,"仙域术法,准圣功法" ,Mean,.minattack = 20,.maxattack = 3200 },
    { 38,"神凤焚天印",1000000,1,"真正的圣人功法!梵天灭地" ,Mean,.minattack = 20,.maxattack =5300 },
    { 39,"破灭印",1000000,1,"真正的圣人功法!刚猛霸道,无坚不摧,破坏力难以想象。" ,Mean,.minattack = 20,.maxattack = 5000 },
    { 40,"无极圣元功",9999999,1,"天上地下第一功法!" ,Mean,.minattack = 20,.maxattack = 10000 },
    { 41,"九天惊雷术!",9780000,1,"真仙级功法!召唤灭世天劫" ,Mean,.minattack = 20,.maxattack = 8800 },
    { 42,"吞炼山河",10000000,1,"真正的圣人功法!" ,Mean,.minattack = 20,.maxattack = 9200 },
    //空缺5,6,7栏位的商品
    { 100,"太极图",10000,30,"入门必备!" ,Mean,.minattack = 20,.maxattack = 80 }
};
int Stufflen = sizeof(stuffs) / sizeof(Stuff);
int X = 3;
int Y = 2;
Map mapArray[8][8] = {
    {
        { 1,"顾家花园",1,{ 0.0 },"   顾家一座安静的花园,这里亭台坐落,小桥流水,周围更有有百花争艳,绽放异彩。特别是那一簇又一簇迷人的花色,被清澈如镜的水面映照之下,使得这里流光溢彩,犹若仙境。偶尔,一两只蝴蝶飞过,翅膀上彩霞点点,尤其在明媚的阳光下,更加夺目。" },{ 2,"顾家主殿",1,{ 0.1 },"这里是燕国圣武九门之一的圣武世家,顾家!" },
        { 3,"后山禁地",1,{ 0.2 },"后山禁地,那是一座上古之地,整片天地都笼罩在浩大的上古大阵中,传说里面有着诸多神秘。" },{ 3,"柴房",1,{ 0.3 },"说着,顾风恶狠狠地拎着那管理杂物的管家走向房间,不知道说了些什么。当出来后,顾老八完全变了个样儿,看向雪十三的目光充满了阴厉与蔑视。" },
        { 5,"圣武山",1,{ 0.4 },"顾家所在!" },{ 5,"圣武城",1,{ 0.5 },"圣武城,世间共有九座,分别隶属于圣武九门的九大圣武世家。  眼前顾家的这座城池,更是燕国仅有的唯一一座圣武城,意义非凡!" },
        { 7,"燕国",1,{ 0.6 },"这里是是一切故事开始的地方!" },{ 8,"大永帝国",1,{ 0.7 },"燕国的友邦,两国间的关系一直很好。" }
    },
    {
        { 9,"通天楼",1,{ 1.0 }," 通天楼,这是在燕国赫赫有名的一大势力,他们尤为出名的是情报消息,号称本领通天,无所不知。" },{ 10,"天剑门",1,{ 1.2 },"  " },
        { 11,"雅轩阁",1,{ 1.2 },"拍卖行!" },{ 12,"天魔山",1,{ 1.3 },"魔宫所在,魔宫中的有名强者被划分为:金木水火土五大阎君,其次为青龙、白虎、朱雀、玄武、麒麟五大护法,接着是十大长老,天、地、人三大魔帅,两大魔尊,最后则是……魔宫的宫主,被称为魔帝。" },
        { 13,"银黄殿",1,{ 1.4 },"一座气势磅礴,连绵成片的巨大宫殿群呈现在眼前,仅是门面的雕琢,便充满一股贵气。" },{ 14,"黑龙帝国",1,{ 1.5 },"黑龙帝国内忧外患,随时能够灭国。" },
        { 15,"飞雪山庄",1,{ 1.6 },"飞雪山庄,在整个天下间也是极为有名气的。整个飞雪山庄,最强者是他们的老祖,卡在八重天圆满之境多年,一直不能破入九重天。但是,传说,那是一件被武道神话凌之轩加持过的绝品神器,真正威能比之圣阶神器丝毫不弱,还要更强。" },{ 16,"天山秘境",1,{ 1.7 },"此秘境八百年没有开启了,想必里面各种古药、灵果" }
    },
    {
        { 17,"司徒家",1,{ 2.0 },"圣武九门之一!" },{ 18,"竹屋",1,{ 2.1 },"八百年前的武道神话凌之轩曾经居住过的地方。" },
        { 19,"凤音阁",1,{ 2.2 },"圣武九门之一!" },{ 20,"神宫",1,{ 2.3 },"一个庞大,神秘的势力!" },
        { 21,"血衣门",1,{ 2.4 },"血衣门恶名昭彰,任谁听到名字都要闻风丧胆。" },{ 22,"天龙门",1,{ 2.5 },"圣武世家的威严不可侵犯!" },
        { 23,"天霜门",1,{ 2.6 },"可圣武世家之间是有着盟约的,任何一方敢觊觎对方的圣阶秘典,将遭到所有势力的围攻。" },{ 24,"天云帝国",1,{ 2.7 }," !" }
    },
    {
        { 25,"无量宗",1,{ 3.0 },"“千年之前,圣武九门分成三派,一派是血衣门与魔宫两大邪道,一派是我等名门正派,最后一派则是……无量宗。”" },{ 26,"天灵山",1,{ 3.1 },"妖兽纵横!" },
        { 27,"上古战场",1,{ 3.2 }," 有数百丈大的骸骨横陈,不知是何种异兽,骨骼如今还有些晶莹,散着股让人心惊的气息。" },{ 28,"永生道门",1,{ 3.3 },"此门威力无穷,可上震诸天,下震九幽,倘若能够打开其奥秘,将令人堪破生死,得证长生!只是,这个过程十分危险,须有一往无前的信心,一旦失败,将万劫不复。" },
        { 29,"云岚帝国",1,{ 3.4 },"“此处靠近云岚帝国,听说该国以一套上古残阵而闻名大6,是周围方圆数万里内的巨无霸,比肩一流势力。你们……可是云岚帝国的人?”" },{ 30,"血狼谷",1,{ 3.5 },"血狼谷谷主是风云榜上的强者,位于前列,实力强大恐怖。" },
        { 31,"乱剑山",1,{ 3.6 },"大周帝国的一个强大势力。" },{ 32,"西部冰域李家",1,{ 3.7 },"圣武九门之一!" }
    },
    {
        { 33,"凤鸣谷",1,{ 4.0 }," 凤鸣谷是一片绝世凶地,如果是平常人到此,只会见到外围的那片废墟峡谷,连入口都难以找到。!" },{ 34,"百花宫",1,{ 4.1 },"百花宫皆女子,所有人聚集此处,可谓百花争艳,芳香怡人,让人看得眼花缭乱。" },
        { 35,"穿云宫",1,{ 4.2 },"穿云宫属于一流势力,但其老祖只是一只脚踏入了九重天,并未真正跨入进去。但凭借着穿云宫的震天弓,其攻击力却足以达到九重天的层次。这才使得他们位列一流势力当中。!" },{ 36,"大周帝国",1,{ 4.3 },"大周帝国虽然是一流强国,但在整个天下间,却也并不是特别显眼。!" },
        { 37,"凤阳城",1,{ 4.4 },"凤阳城!" },{ 38,"天星谷",1,{ 4.5 },"不长时间,他们便见到远处一座密林,冒着氤氲灵气,云蒸雾绕,此时天没亮,那边的光芒却映照的璀璨一片,仿佛一片仙家神圣之地!" },
        { 39,"风神宫",1,{ 4.6 },"!" },{ 40,"仙门",1,{ 4.7 },"可以说,要想成就武道神话,就必须跨越圣武九门这九座庞然大物,否则,便是灰飞烟灭的下场。此劫被称为……生死劫!" }
    },
    //以下开始为仙道世界地图
    {
        { 41,"雪神宫",11,{ 5.0 },"这里也是故事开始的地方!" },{ 42,"帝氏一族",11,{ 5.1 },"沧澜界虽然比不上仙道世界那么的浩大辉煌,可毕竟也是一片修仙大世界,资源雄浑。因此,这里早已被仙域中的几大家族占领,统御此处。而帝氏一族,便是其中之一。" },
        { 43,"鬼蜮",11,{ 5.2 },"鬼蜮,据说,那是一片神秘的地域,据说,那里是一群曾经死去的人栖居。!" },{ 44,"万苍圣宫",11,{ 5.3 },"雪十三知道一些这个势力的传说,那万苍圣人的《万苍圣功》无比霸道,一经施展,能将人的一身生机给抽掉。雪十三知道一些这个势力的传说,那万苍圣人的《万苍圣功》无比霸道,一经施展,能将人的一身生机给抽掉。" },
        { 45,"北玄域",11,{ 5.4 },"听闻她们一向与世无争,安静修炼,还不时地救济一些贫苦的修士" },{ 46,"麒麟巢",11,{ 5.5 },"真正的麒麟巢,这里空间比外面还要浩大许多,周围,那龙眼大的珍珠、宝石等,数不胜数,流光溢彩,美轮美奂。!" },
        { 47,"天雷宗",11,{ 5.6 },"!" },{ 48,"北玄域",11,{ 5.7 },"那里各大妖族盘踞,不说万族林立,也差不了多少,最起码有上千个种族。" }
    },
    {
        { 49,"妖域",11,{ 6.0 },"大妖遍地,强势无比!" },{ 50,"万剑宫",11,{ 6.1 },"!" },
        { 51,"金龙拍卖行",11,{ 6.2 },"这个商会无比庞大,分行遍布整个北玄域,据说,在其他几大域中也有势力盘根错节,十分不好惹。 根本原因,是该族有圣人坐镇。!" },{ 52,"玄昆宫",11,{ 6.3 },"那玄昆宫的宫主便到来,一身蓝色锦袍,很年轻,面如刀削,发丝漆黑,眸子若星辰般明亮,整个人的气势浑然天成。!" },
        { 53,"化龙洞",11,{ 6.4 },"毫无疑问,这化龙洞是一场天大的造化,可同时又是一处无比恐怖的地方,就是称为禁地都不过分,太可怕了。这么多年来,进去的人活着出来的不足十分之一,而成功领悟完成蜕变,获得大造化者,却是不足千分之一。" },{ 54,"圣天宫",11,{ 6.5 },"那是圣天宫的殿主,他踏着大印而来,据说那是他的成名法器,以稀有的金属锻造,有山河之重,可一力破万法。!" },
        { 55,"邪域",11,{ 6.6 },"!" },{ 56,"大元殿",11,{ 6.7 },"大元殿殿主的那口神剑,神霞千万,都撕裂虚空了,太恐怖。!" }
    },
    {
        { 57,"天灵观",11,{ 7.0 },"此道观虽非圣人传承,也不是什么名震天下的大势力,可却曾在两万年前现出过仙迹。 传说,这里有真仙留下的一道法印烙印,十分了得,拥有不朽的奥义,参悟后可得长生。!" },{ 58,"天秀宫",11,{ 7.1 },"天秀宫是南玄域一个一流大势力,门派中有化虚层次的强者坐镇,虽然不是圣人传承世家,可存在的岁月古老,底蕴深厚,威震一方。" },
        { 59,"玉剑宫",11,{ 7.2 },"这里是一片山脉,雾霭腾腾,百花盛开,馨香扑鼻,还有鸟兽啼鸣,一片祥和的气息,出尘而宁静,这是一方净土。" },{ 60,"死亡星海",11,{ 7.3 },"这里到处都是毁灭般的气息,根本没有一丝的生机,四周的地面也都是光秃秃的一片,因为被这种气息笼罩,任何植被都无法生长。每一个时代,每一段时空,都被死亡星海贯穿,所有殒落的生灵,破碎的物体,包括星辰世界等,都会被它吸过来。" },
        { 61,"永恒族",11,{ 7.4 },"域外神秘种族!" },{ 62,"杀戮神殿",11,{ 7.5 },"杀戮圣骑士的归属!" },
        { 63,"初始之地",11,{ 7.6 },"混沌!" },{ 64,"天尊传承",20,{ 7.7 },"有几率获得天尊传承!" }
    }
};

Monster monsters[] = {
    //凤鸣谷
    { 1,"守门弟子",1,"武道一重天",150,150,150,10,15,5,1,{0,4}},
    { 2,"外门弟子",3,"武道三重天",300,400,150,20,35,20,1 ,{ 0,4 } },
    { 3,"内门弟子",5,"武道五重天",500,600,30,65,50,1,{ 0, } },
    { 4,"精英弟子",6,"武道六重天",1000,700,250,50,200,100,1,{ 0,4 } },
    { 5,"传承弟子",7,"武道七重天",1000,800,300,200,500,300,1 ,{ 0,4 } },
    { 6,"外门长老",8,"武道八重天",2000,1000,320,500,605,500,1 ,{ 0,4 } },
    { 7,"内门长老",8,"武道八重天",2000,1020,330,500,655,600,1 ,{ 0,4 } },
    { 8,"大长老",9,"武道九重天",3000,1550,350,600,800,800,1 ,{ 0,4 } },
    { 9,"掌门",10,"武道通神",5000,1660,400,1000,3500,1000,1 ,{ 0,4 } },
    //神宫
    { 10,"血袍人",1,"武道一重天",150,150,100,10,15,5,1,{ 3,2 } },
    { 11,"血袍人",3,"武道三重天",300,400,150,20,35,20,1,{ 3,2 } },
    { 12,"血袍人",5,"武道五重天",500,600,200,30,65,50,1,{ 3,2 } },
    { 13,"血袍人",6,"武道六重天",1000,700,250,50,200,100,1,{ 3,2 } },
    { 14,"血袍人",7,"武道七重天",1000,800,300,200,500,300,1 ,{ 3,2 } },
    { 15,"陈皇(少主)",8,"武道八重天",2000,1000,320,500,605,500,1 ,{ 3,2 } },
    { 16,"血袍总管",8,"武道八重天",2000,1030,330,500,655,600,1 ,{ 3,2 } },
    { 17,"血袍大总管",9,"武道九重天",3000,1250,350,600,800,800,1 ,{ 3,2 } },
    { 18,"神宫宫主",10,"武道通神",5200,1680,400,1000,3500,1000,1 ,{ 3,2 } },
    //顾家主殿
    //{ 19,"弟子",1,"武道一重天",150,100,100,10,15,5,1,{ 1,0 } },
    { 20,"弟子",3,"武道三重天",300,150,150,20,35,20,1,{ 1,0 } },
    { 21,"弟子",5,"武道五重天",500,400,200,30,65,50,1,{ 1,0 } },
    { 22,"弟子",6,"武道六重天",1000,650,250,50,200,100,1,{ 1,0 } },
    { 23,"第五供奉",7,"武道七重天",1000,700,300,200,500,300,1 ,{ 1,0 } },
    { 24,"第四供奉",8,"武道八重天",2000,820,320,500,605,500,1 ,{ 1,0 } },
    { 25,"第三供奉",8,"武道八重天",2000,1030,330,500,655,600,1 ,{ 1,0 } },
    { 26,"第二供奉",9,"武道九重天",3000,1350,350,600,800,800,1 ,{ 1,0 } },
    { 27,"第一供奉",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 1,0 } },
    { 28,"剑尊",10,"武道通神",5300,1480,400,1000,3500,1000,1 ,{ 1,0 } },

    //圣武山
    { 29,"弟子",5,"武道五重天",500,600,200,30,65,50,1,{ 4,0 } },
    { 30,"弟子",6,"武道六重天",1000,750,250,50,200,100,1,{ 4,0 } },
    { 31,"第九供奉",7,"武道七重天",1000,1000,300,200,500,300,1 ,{ 4,0 } },
    { 32,"第八供奉",8,"武道八重天",2000,1320,320,500,605,500,1 ,{ 4,0 } },
    { 33,"第七供奉",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 4,0 } },
    { 34,"第六供奉",9,"武道九重天",3000,1650,350,600,800,800,1 ,{ 4,0 } },
    { 35,"二长老",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 4,0 } },
    { 36,"顾西风",10,"武道通神",5300,1500,400,1000,3500,1000,1 ,{ 4,0 } },
    { 37,"顾天霸",10,"武道通神",5300,1800,400,1000,3500,1000,1 ,{ 4,0 } },

    //神宫
    { 10,"血袍人",1,"武道一重天",150,150,100,10,15,5,1,{ 3,2 } },
    { 11,"血袍人",3,"武道三重天",300,400,150,20,35,20,1,{ 3,2 } },
    { 12,"血袍人",5,"武道五重天",500,600,200,30,65,50,1,{ 3,2 } },
    { 13,"血袍人",6,"武道六重天",1000,700,250,50,200,100,1,{ 3,2 } },
    { 14,"血袍人",7,"武道七重天",1000,800,300,200,500,300,1 ,{ 3,2 } },
    { 15,"陈皇(少主)",8,"武道八重天",2000,1000,320,500,605,500,1 ,{ 3,2 } },
    { 16,"血袍总管",8,"武道八重天",2000,1030,330,500,655,600,1 ,{ 3,2 } },
    { 17,"血袍大总管",9,"武道九重天",3000,1250,350,600,800,800,1 ,{ 3,2 } },
    { 18,"神宫宫主",10,"武道通神",5200,1680,400,1000,3500,1000,1 ,{ 3,2 } },
    //顾家主殿
    //{ 19,"弟子",1,"武道一重天",150,100,100,10,15,5,1,{ 1,0 } },
    { 20,"弟子",3,"武道三重天",300,150,150,20,35,20,1,{ 1,0 } },
    { 21,"弟子",5,"武道五重天",500,400,200,30,65,50,1,{ 1,0 } },
    { 22,"弟子",6,"武道六重天",1000,650,250,50,200,100,1,{ 1,0 } },
    { 23,"第五供奉",7,"武道七重天",1000,700,300,200,500,300,1 ,{ 1,0 } },
    { 24,"第四供奉",8,"武道八重天",2000,820,320,500,605,500,1 ,{ 1,0 } },
    { 25,"第三供奉",8,"武道八重天",2000,1030,330,500,655,600,1 ,{ 1,0 } },
    { 26,"第二供奉",9,"武道九重天",3000,1350,350,600,800,800,1 ,{ 1,0 } },
    { 27,"第一供奉",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 1,0 } },
    { 28,"剑尊",10,"武道通神",5300,1480,400,1000,3500,1000,1 ,{ 1,0 } },

    //圣武山
    { 29,"弟子",5,"武道五重天",500,600,200,30,65,50,1,{ 4,0 } },
    { 30,"弟子",6,"武道六重天",1000,750,250,50,200,100,1,{ 4,0 } },
    { 31,"第九供奉",7,"武道七重天",1000,1000,300,200,500,300,1 ,{ 4,0 } },
    { 32,"第八供奉",8,"武道八重天",2000,1320,320,500,605,500,1 ,{ 4,0 } },
    { 33,"第七供奉",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 4,0 } },
    { 34,"第六供奉",9,"武道九重天",3000,1650,350,600,800,800,1 ,{ 4,0 } },
    { 35,"二长老",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 4,0 } },
    { 36,"顾西风",10,"武道通神",5300,1500,400,1000,3500,1000,1 ,{ 4,0 } },
    { 37,"顾天霸",10,"武道通神",5300,1800,400,1000,3500,1000,1 ,{ 4,0 } },
    //天魔山
    { 38,"魔宫弟子",5,"武道五重天",500,600,200,30,65,50,1,{ 3,1 } },
    { 42,"木阎行君",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 3,1 } },
    { 42,"金阎行君",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 3,1 } },
    { 42,"土阎行君",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 3,1 } },
    { 42,"火阎行君",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 3,1 } },
    { 43,"水阎行君",9,"武道九重天",3000,1650,350,600,800,800,1 ,{ 3,1 } },
    { 44,"白魔尊",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 3,1 } },
    { 45,"黑魔尊",10,"武道通神",5300,1500,400,1000,3500,1000,1 ,{ 3,1 } },
    { 46,"魔帝",10,"武道通神",5300,1700,400,1000,3500,1000,1 ,{ 3,1 } },
    //后山禁地
    { 47,"禁地英魂",5,"武道五重天",500,600,200,30,65,50,1,{ 2,0 } },
    { 48,"禁地英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,0 } },
    { 49,"禁地英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,0 } },
    { 50,"禁地英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,0 } },
    { 51,"禁地英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,0 } },
    { 52,"禁地英魂",9,"武道九重天",3000,1650,350,600,800,800,1 ,{ 2,0 } },
    { 53,"禁地英魂",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 2,0 } },
    { 54,"禁地英魂",10,"武道通神",5300,1500,400,1000,3500,1000,1 ,{ 2,0 } },
    { 55,"顾天雄",10,"武道通神",5300,1700,400,1000,3500,1000,1 ,{ 2,0 } },
    //天山秘境
    { 29,"秘境亡魂",5,"武道五重天",500,600,200,30,65,50,1,{ 7,1 } },
    { 30,"秘境亡魂",6,"武道六重天",1000,750,250,50,200,100,1,{ 7,1 } },
    { 31,"秘境亡魂",7,"武道七重天",1000,1000,300,200,500,300,1 ,{ 7,1 } },
    { 32,"秘境亡魂",8,"武道八重天",2000,1320,320,500,605,500,1 ,{ 7,1 } },
    { 33,"秘境亡魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 7,1 } },
    { 34,"秘境亡魂",9,"武道九重天",3000,1650,350,600,800,800,1 ,{ 7,1 } },
    { 35,"秘境亡魂",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 7,1 } },
    { 36,"秘境亡魂",10,"武道通神",5300,1500,400,1000,3500,1000,1 ,{ 7,1 } },
    { 37,"秘境亡魂",10,"武道通神",5300,1600,400,1000,3500,1000,1 ,{ 7,1 } },
        //永生道门
    { 55,"恐怖身影",10,"武道通神",5300,1800,400,1000,3500,1000,1 ,{ 3,3 } },
        //上古战场
    { 47,"上古英魂",5,"武道五重天",500,600,200,30,65,50,1,{ 2,3 } },
    { 48,"上古英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,3 } },
    { 49,"上古英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,3 } },
    { 50,"上古英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,3 } },
    { 51,"上古英魂",8,"武道八重天",2000,1330,330,500,655,600,1 ,{ 2,3 } },
    { 52,"上古英魂",9,"武道九重天",3000,1650,350,600,800,800,1 ,{ 2,3 } },
    { 53,"上古英魂",10,"武道通神",5100,1400,400,1000,3500,1000,1 ,{ 2,3 } },
    { 54,"上古英魂",10,"武道通神",5300,1500,400,1000,3500,1000,1 ,{ 2,3 } },
    { 55,"上古英魂",10,"武道通神",5300,1700,400,1000,3500,1000,1 ,{ 2,3 } },

    { 100,"魔帝",10,"武道通神",5300,1700,400,1000,3500,1000,1 ,{ 3,1 } }
};

int monstercount = sizeof(monsters) / sizeof(Monster);

int Uloginmenu()                    //游戏登陆界面
{
    //getchar();
    system("cls");
    char choice;
    printf("\n");
    printf("\t\t\t\t\t欢迎来到- 仙域天尊 -!\n\n");
    SetPosition(MARGIN_X, 4);
    printf("请选择:\t(1)【老用户登陆】  (2)【新用户注册】  (3)【游客登陆】(暂不开放)\n");
    do {
        printf("\n");
        printf("                                 请输入1 or 2;");
        choice = getchar();
        if (choice == ‘2‘)
        {
            Newlogn();
            printf("\t\t\t\t注册成功!按任意键进入登陆页面.\n");
            getch();
            break;
        }
        else if (choice == ‘1‘)
        {
            break;
        }
    } while (choice != 1 && choice != 2);
    return 0;
}

 void Newlogn()
{
     int a = playid;
     printf("\t\t\t\t请设置用户名/昵称:");
     scanf("%s", players[a].name);
     //gets(players[playid].name);
     //fflush(stdin);
     printf("\t\t\t\t请设置密码:");
     scanf("%s", players[a].pass);
     //gets(players[playid].pass);
     fflush(stdin);
     players[a].id = playid;
     playid++;
     players[a].glod = 50000;
     players[a].wealth = 0;
     strcpy(players[a].iden, "Vip0");
     players[a].bag.summax = 20;
     players[a].level = 1;
     players[a].exp = 1;
     players[a].nextexp = 10;
     strcpy(players[a].achieve, "武道一重天");
     players[a].hp = 100;
     players[a].attack = 10;
     players[a].defence = 10;
     strcpy(players[a].weapon," ");
     strcpy(players[a].armor, " ");
     strcpy(players[a].mean, " ");
}

 void Ulogin()
 {
    int i;
    int wrongcount=0;
    int flag=0;
    char temp[20];
    char pass[20];
    system("cls");
    printf("\n");
    SetPosition(PAGE_TITLE_X, PAGE_TITLE_Y);
    printf("仙域天尊-997工作室\n");
    printf("\n");
    do {
        printf("\t\t\t\t\t请输入用户名/昵称:");
        scanf("%s", temp);
        printf("\t\t\t\t\t请输入密码:");
        scanf("%s", pass);
        //printf("%s\n",players[playid].name);
        //printf("%s\n",temp);
        for (i = 0; i < playid;i++)
        {
            if ((strcmp(temp, players[i].name) == 0) && (strcmp(pass, players[i].pass) == 0))
            {
                flag = 1;
                loginid = i;
            }
        }
        //printf("%d",flag);

        if (flag == 1)
        {
            Uloiinsucceed();
            break;
        }
        else
            wrongcount++;
            printf("                              账号或密码错误,请重新输入!已输入错误%d次,错误3次将退出游戏!\n",wrongcount);
    } while (wrongcount != 3);

    if (wrongcount == 3)
    {
        printf("\n");
        printf("                ");
        printf("输入错误3次,正在退出系统!");
        for (int i = 0; i < 3; i++)
        {
            printf(".");
            Sleep(500);
        }
        exit(0);
    }
}

 void Uloiinsucceed()
 {
    printf("\t\t\t\t\t\t\t\t\t\t|当前用户为:%s(%s)\n", players[loginid].name, players[loginid].iden);
    printf("\t\t\t\t 请选择区服;\n");
    printf("\t\t\t\t 1.测试先驱服1\n\t\t\t\t 2.......\n");
    getchar();
    printf("                        正在进入\n");
    printf("                ");
    for (int i = 0; i < 20; i++)
    {
        printf("□");
        Sleep(300);
    }

}

char Umenu()                            //功能大厅
{
    char choice=‘ ‘;
    system("cls");
    printf("\n");
    printf("                        仙域天尊-功能大厅\n");
    printf("\n");
    //printf("\t\t\t\t\t\t\t|当前用户为:%s(%s)|  金币:%d | 点券:%d |\n", players[loginid].name, players[loginid].iden, players[loginid].glod, players[loginid].wealth);
    printf("\n");
    printf("\t\t1.背包\t\t\t    2.商城\t\t        3.地图\n");
    printf("\t\t4.个人信息\t\t\t8.退出登陆\t\t\t9.退出游戏\n");
    printf("\t\t请输入您的选择:");
    scanf("%c", &choice);
    return choice;
}

void Uopenstore()
{
    getchar();
    char a;                                    //接收是否交易的指令
    int choiceindex = 0;                    //接收需要购买商品的编号
    system("cls");
    printf("\n");
    SetPosition(PAGE_TITLE_X, PAGE_TITLE_Y);
    printf("仙域天尊-游戏商城\n");
    printf("\n");
    printf("\t\t\t\t\t\t\t\t|当前用户为:%s(%s)|  金币:%d | 点券:%d |\n", players[loginid].name, players[loginid].iden, players[loginid].glod, players[loginid].wealth);
    printf("\n");
    printf("   <1>默认\t<2>\t    <3>\t        <4>\t     <5>\t  <6>\t       <7>\t       <8>\n");
    printf("热门商品 | 装备(武道) | 功法(武道) | 物品(武道) | 装备(仙道) | 功法(仙道) | 物品(仙道) | 天地造化(仙域)\n");
    printf("热门商品-->\n");
    printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
    printf("\n");
    //int len;
    int i=0;
    //len = sizeof(stuffs) / sizeof(Stuff);
    printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
    for(i=0;i<7;i++)
    printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n",stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
    printf("\n");
    printf("  d=================================================================================( ̄▽ ̄*)b\n");
        do
        {
            for (i = 0; i < 4; i++)
            {
                SetPosition(0, 24+i);
                printf("                                                                                                                  ");
            }
            SetPosition(80, 23);
            printf("Tps:当前商店;栏位5,6,7暂无物品");
            SetPosition(0, 23);
            printf("请选择商店栏位(按ENTER键直接进入购买或按ESC退出):");
            //scanf("%c", &a);
            a = getch();
            if (a == ‘Y‘ || a == ‘y‘ || a == ‘1‘ || a == ‘2‘ || a == ‘3‘ || a == ‘4‘ || a == ‘5‘ || a == ‘6‘ || a == ‘7‘ || a==13 || a==108 ||a==27 || a==‘8‘)            //暂时只开发圣武大陆
            {
                if (a == 27)
                    break;

                if(a!=13)
                Lclearmall();                                        //商城清屏函数

                if (a == 13)
                {
                    SetPosition(0,25);
                    printf("请输入要购买的商品的编号:");
                    scanf("%d", &choiceindex);
                    Ltrade(&players[loginid], choiceindex);

                }
                else if (a == ‘1‘)
                {
                    SetPosition(0, 8);
                    printf("热门商品-->\n");
                    printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                    printf("\n");
                    //int len;
                    int i = 0;
                    //len = sizeof(stuffs) / sizeof(Stuff);
                    printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
                    for (i = 0; i < 7; i++)
                        printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                    printf("\n");
                    printf("  d=================================================================================( ̄▽ ̄*)b\n");
                }
            else if (a == ‘2‘)
            {
                SetPosition(0, 8);
                printf("装备(武道)-->\n");
                printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                printf("\n");
                //int len;
                int i = 0;
                //len = sizeof(stuffs) / sizeof(Stuff);
                printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
                for (i = 7; i < 16; i++)
                    printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                printf("\n");
                printf("  d=================================================================================( ̄▽ ̄*)b\n");
            }
            else if (a == ‘3‘)
            {
                SetPosition(0, 8);
                printf("功法(武道)-->\n");
                printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                printf("\n");
                //int len;
                int i = 0;
                //len = sizeof(stuffs) / sizeof(Stuff);
                printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
                for (i = 16; i < 25; i++)
                    printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                printf("\n");
                printf("  d=================================================================================( ̄▽ ̄*)b\n");
            }
            else if (a == ‘4‘)
            {
                SetPosition(0, 8);
                printf("物品(武道)-->\n");
                printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                printf("\n");
                //int len;
                int i = 0;
                //len = sizeof(stuffs) / sizeof(Stuff);
                printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
                for (i = 25; i < 34; i++)
                    printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                printf("\n");
                printf("  d=================================================================================( ̄▽ ̄*)b\n");
            }
            else if (a == ‘5‘)
            {
                SetPosition(0, 8);
                printf("装备(仙道)-->\n");
                printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                printf("\n");
                //int len;
                int i = 0;
                //len = sizeof(stuffs) / sizeof(Stuff);
                printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
            /*    for (i = 42; i < 50; i++)
                    printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                printf("\n");
                printf("  d=================================================================================( ̄▽ ̄*)b\n");*/
                printf("抱歉,当前栏位暂无商品!");
            }
            else if (a == ‘6‘)
            {
                SetPosition(0, 8);
                printf("功法(仙道)-->\n");
                printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                printf("\n");
                //int len;
                int i = 0;
                //len = sizeof(stuffs) / sizeof(Stuff);
                printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
                /*    for (i = 42; i < 50; i++)
                printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                printf("\n");
                printf("  d=================================================================================( ̄▽ ̄*)b\n");*/
                printf("抱歉,当前栏位暂无商品!");
            }
            else if (a == ‘7‘)
            {
                SetPosition(0, 8);
                printf("物品(仙道)-->\n");
                printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                printf("\n");
                //int len;
                int i = 0;
                //len = sizeof(stuffs) / sizeof(Stuff);
                printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
                /*    for (i = 42; i < 50; i++)
                printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                printf("\n");
                printf("  d=================================================================================( ̄▽ ̄*)b\n");*/
                printf("抱歉,当前栏位暂无商品!");
            }
            else if (a == ‘8‘)
            {
                SetPosition(0, 8);
                printf("天地造化-->\n");
                printf("ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=ε=(~ ̄▽ ̄)~\n");
                printf("\n");
                //int len;
                int i = 0;
                //len = sizeof(stuffs) / sizeof(Stuff);
                printf("编号\t商品名称\t单价\t\tVIP价格\t\t数量\t物品描述\n");
                for (i = 34; i < 43; i++)
                    printf("%d\t%-12s    %-10.1f\t%-10.1f\t%d\t%s\n", stuffs[i].id, stuffs[i].name, stuffs[i].price, stuffs[i].price*0.8, stuffs[i].amoung, stuffs[i].desc);
                printf("\n");
                printf("  d=================================================================================( ̄▽ ̄*)b\n");
            }

        }
    /*else
    {
        printf("按任意键返回大厅");
        break;
        getch();
    }*/

        } while (1);

}

void Ltrade(Player *player, int tradeid)
{
    int i;
    //printf("请输入要购买的商品编号:");
    //scanf("%d",&choice);

    Stuff *tradestuff=NULL;                    //购买商品的指针

    for (i = 0; i < Stufflen; i++)            //商品数组中遍历选择的那个编号
    {
        if (stuffs[i].id == tradeid)
        {
        //    printf("%d", Stufflen);
            tradestuff = stuffs + i;//tradestuff=&stuffs[i];
            break;
        }
    }
    //满足交易条件后,执行交易操作;
    if (tradestuff->amoung = 0)
    {
        printf("商品库存不足,下次早点来哦!/(ㄒoㄒ)/~~");
        getch();
        Uopenstore();
    }
    if (player->glod <= tradestuff->price)
    {
        printf("您的金币不足,要赚够了钱再来找我哟!(? ?_?)?");
        getch();
        Uopenstore();
    }
    if (player->bag.sum >= player->bag.summax)
    {
        printf("您的金币不足,要赚够了钱再来找我哟!(? ?_?)?");
        getch();
        Uopenstore();
    }

    //购买成功

    //1.商城库存-1
    tradestuff->amoung--;
    //2.玩家的金钱-商品单价
    player->glod -= tradestuff->price;
    //3.玩家的背包增加物品
    for (i = 0; i < player->bag.sum; i++)
    {
        //通过玩家背包中物品的id来判断是否拥有
        if (tradestuff->id == player->bag.item[i].id)    //3.1    判断玩家背包中是否已有该商品
        {
            player->bag.item[i].amoung++;    //3.2    如果有,该商品的数量+1
            player->bag.sum++;
            break;
        }
    }
    if (i == player->bag.sum)    //3.3    如果没有,就向背包里添加该商品
    {
        int newindex = player->bag.sum;
        player->bag.item[newindex].id = tradestuff->id;
        player->bag.item[newindex].price = tradestuff->price;
        player->bag.item[newindex].amoung = 1;
        strcpy(player->bag.item[newindex].name,tradestuff->name);
        strcpy(player->bag.item[newindex].desc, tradestuff->desc);
        //player->bag.specount= tradestuff->id+1;
        player->bag.sum++;
        player->bag.specount++;
        player->bag.item[newindex].type = tradestuff->type;
        switch (players[loginid].bag.item[newindex].type)                //此地有BUG
        {
        case Weapon:    player->bag.item->maxattack=tradestuff->maxattack;    break;
        case Armor:    player->bag.item->maxdefence=tradestuff->maxdefence;    break;
        case Mean:    player->bag.item->maxattack= tradestuff->maxattack;        break;
        case con:    player->bag.item->maxpower += tradestuff->maxpower;        break;
        }
    }
    printf("购买成功!<( ̄︶ ̄)[GO!]\n");
    printf("按任意键返回商城\n");
    getch();
}

 void Exit()
{
     printf("\n");
     printf("                ");
        printf("正在退出系统!");
        for (int i = 0; i < 3; i++)
        {
            printf(".");
            Sleep(500);
        }
        exit(0);
}

 void Lshowbag(Player *players)                    //打开背包
 {
     int i=0;
     char spec[20]=" ";                    //道具类型
     int choice=-1;
     system("cls");
     printf("\n");
     SetPosition(PAGE_TITLE_X,PAGE_TITLE_Y);
     printf("仙域天尊-我的背包\n");
     printf("\n");
     SetPosition(PAGE_TITLE_X+7, MAP_START_Y);
     printf("当前用户为:%s(%s)|  金币:%d | 点券:%d |\n", players[loginid].name, players[loginid].iden, players[loginid].glod, players[loginid].wealth);
     printf("\n");
     printf("\n");

    // printf("%d\n", players[loginid].bag.summax);
     SetPosition(MARGIN_X-10, 6);
     printf("编号\t  物品名称\t拥有数量\t物品类型\t物品描述\n");
     SetPosition(MARGIN_X-10, 7);
     printf(SEP);
     if (players[loginid].bag.sum == 0)
     {
         SetPosition(MARGIN_X - 10, 7);
         printf(SEP);
         SetPosition(MARGIN_XX, 8);
         printf("当前背包暂无物品");
         SetPosition(MARGIN_X - 10, 9);
         printf(SEP);
         SetPosition(MARGIN_X - 10, 10);
         printf("按任意键返回大厅.");
         getch();
         return;
     }
     for ( i = 0; i <players[loginid].bag.specount;i++)
     {

         switch (players[loginid].bag.item[i].type)                //此地有BUG
         {
         case Weapon:    strcpy(spec, "武器");    break;
         case Armor:    strcpy(spec, "防具");    break;
         case Mean:    strcpy(spec, "功法");        break;
         case con:    strcpy(spec, "消耗品");        break;
         }
         SetPosition(MARGIN_X-10, 8+i);
         printf("%d\t  %-12s    %d\t\t%s    \t%s\n", players[loginid].bag.item[i].id, players[loginid].bag.item[i].name, players[loginid].bag.item[i].amoung,spec, players[loginid].bag.item[i].desc);

     }
     SetPosition(MARGIN_X - 10, 7 + i );
     printf(SEP);

     do                                                                //装备武器防具或功法,使用道具等。
     {
         if (choice == 888)
         {
             break;
         }
         SetPosition(MARGIN_X, 12 + i);
         printf("请选择需要使用的装备的编号(按888退出):");
         scanf("%d",&choice);
         for (i = 0; i < players[loginid].bag.specount; i++)
         {                                                                                    

             if (players[loginid].bag.item[i].id == choice)
             {
                 int actualattack = players[loginid].bag.item[i].maxattack;
                 int actualdefence = players[loginid].bag.item[i].maxdefence;
                 /*
                 switch (players[loginid].bag.item[i].type)
                 {
                 case Weapon:strcpy(players[loginid].weapon, players[loginid].bag.item[i].name);
                     players[loginid].weaponattack = actualattack; break;
                 case Armor:strcpy(players[loginid].armor, players[loginid].bag.item[i].name);
                     players[loginid].armordefence = actualdefence; break;
                 case Mean:strcpy(players[loginid].mean, players[loginid].bag.item[i].name);
                     players[loginid].meanattack = players[loginid].bag.item[i].maxattack; break;
                 case con:players[loginid].hp = players[loginid].bag.item[i].maxpower; break;
                 }*/

                 if (players[loginid].bag.item[i].type == Weapon)
                 {
                     strcpy(players[loginid].weapon, players[loginid].bag.item[i].name);
                     players[loginid].weaponindex = choice;
                 }
                 else if (players[loginid].bag.item[i].type == Armor)
                 {
                     strcpy(players[loginid].armor, players[loginid].bag.item[i].name);
                     players[loginid].armorindex = choice;
                 }
                 else if (players[loginid].bag.item[i].type == con)
                 {
                     players[loginid].hp = players[loginid].bag.item[i].maxpower;
                 }
                 else if (players[loginid].bag.item[i].type == Mean)
                 {
                     strcpy(players[loginid].mean , players[loginid].bag.item[i].name);
                     players[loginid].meanindex = choice;
                 }
                 SetPosition(MARGIN_X , 13+i);
                 printf("使用成功!");
                 break;
             }
             else
             {
                 SetPosition(MARGIN_X, 15 + i);
                 printf("当前背包暂无此装备,请到商城购买!");
             }
         }
     } while (1);

     getch();
 }

 void showinformation(Player *players)                //打开个人信息
 {
     Lrefrush(players);
     system("cls");
     printf("\n");
     SetPosition(PAGE_TITLE_X, PAGE_TITLE_Y);
     printf("仙域天尊-个人信息\n");
     printf("\n");
     printf("\t\t\t\t\t\t\t\t|当前用户为:%s(%s)|  金币:%d | 点券:%d |\n", players[loginid].name, players[loginid].iden, players[loginid].glod, players[loginid].wealth);
     printf("\n");
     Lrefrush(players);
     players[loginid].defence = players[loginid].attack;
     SetPosition(MARGIN_X,7);
     printf("血量:%d\t\t攻击力:%d\t\t防御力:%d\t\t真元:∞(嫌麻烦我去掉了蓝条)", players[loginid].hp, players[loginid].attack + stuffs[players[loginid].weaponindex].maxattack + stuffs[players[loginid].meanindex].maxattack, players[loginid].defence+ stuffs[players[loginid].armorindex].maxdefence);
     SetPosition(MARGIN_X, 9);
     printf("等级:%d<%s>\t\t经验值:%d(距离升级还差%d经验)", players[loginid].level, players[loginid].achieve, players[loginid].exp, players[loginid].nextexp- players[loginid].exp);
     SetPosition(MARGIN_X, 11);
     printf("所装备的武器:%s\t\t所装备的防具:%s\t\t所修功法:%s\t\t", players[loginid].weapon, players[loginid].armor, players[loginid].mean);
     SetPosition(45, 15);
     printf("Tps:玩家前五级会有新手保护,HP很高,请在在那之后就靠你们自己了!");
     getch();
 }

 void Lshowmap(Player *players)                    //打开地图
 {
     char key ;

     int i, j;
     system("cls");
     printf("\n");
     SetPosition(PAGE_TITLE_X, PAGE_TITLE_Y-1);
     printf("仙域天尊-地图一-圣武大陆\n"); 

     while (1)
     {
         SetPosition(MARGIN_10, MAP_START_Y - 2);
         printf("%s", SEP);
         for (i = 0; i < 5; i++)
         {
             // printf("\t  |  ");
             SetPosition(MARGIN_10, 3 + i);
             printf("| ");
             for (j = 0; j < 8; j++)
             {
                 if (i == Y && j == X)                    //如果当前地图的索引跟玩家所在的位置一样(通俗点就是玩家来到某个地图)
                 {
                     SetColor(5,15);                    //就改变当前地图的前景色,背景色(这个地图的颜色就变了,让人知道玩家在哪个地图)
                 }
                 printf("%-12s", mapArray[i][j].name);
                 SetColor(1, 7);                        //玩家离开后,将颜色改回之前的颜色(不流痕迹!)
             }
             printf(" |");
             printf("\n");
         }
         printf("\n");
         SetPosition(PAGE_TITLE_X, 9);
         printf("        -地图二-仙道世界\n");
         printf("\n");

         for (i = 5; i < 8; i++)
         {
             // printf("\t  |  ");
             SetPosition(MARGIN_10, 11 + i - 5);
             printf("| ");
             for (j = 0; j < 8; j++)
             {
                 if (i == Y && j == X)
                 {
                     SetColor(5    , 15);
                 }
                 printf("%-12s", mapArray[i][j].name);
                 SetColor(1, 7);
             }
             printf(" |");
             printf("\n");
         }

         SetPosition(MARGIN_10, MAP_END_Y - 2);
         printf("%s\n", SEP);
         LshowInformation();                //打印信息显示区
         LshowMapInfor(Y,X);                    //打印当前地图信息
         SetPosition(PAGE_TITLE_X * 2 - 8, SUP_NAME_Y - 1);
         printf("Tip:按ENTER键进入地图");
         SetPosition(PAGE_TITLE_X * 2 - 8, SUP_NAME_Y);
         printf("Tip:按ESC键退出地图,回到大厅");
         Lrefrush(players);
         SetPosition(MARGIN_10, SUP_NAME_Y);
         printf("【%s】-%s", players[loginid].name, players[loginid].iden);
         SetPosition(MARGIN_10, SUP_NAME_Y + 1);
         printf("LV.%d[%s]", players[loginid].level, players[loginid].achieve);
         SetPosition(MARGIN_10, SUP_EXE_Y);
         printf("                                                                                                               ");
         SetPosition(MARGIN_10, SUP_EXE_Y);
         printf("经验值: %d/%d", players[loginid].exp, players[loginid].nextexp);
         printf("\t\tHP:%d", players[loginid].hp);
         printf("\t\tAttack:%d", players[loginid].attack + stuffs[players[loginid].weaponindex].maxattack + stuffs[players[loginid].meanindex].maxattack);
         printf("\t\tDefence:%d", players[loginid].defence + stuffs[players[loginid].armorindex].maxdefence);
         //SetPosition(11,3);
         fflush(stdin);
         key=getch();
         fflush(stdin);
         if (key == 38 || key == 72)//上键
         {
             Y--;
         }
         if (key == 37 || key == 75)//左键
         {
             X--;
         }
         if (key == 39 || key == 77)//右键
         {
             X++;
         }
         if (key == 40 || key == 80)//下键
         {
             Y++;
         }
         if (key == 13 || key == 108)//ENTER键
         {
             Lshowmonster(players);
         }
         if (key == 27)//ESC键
         {
             break;
         }
         if (X > 7) X = 0;
         if (X < 0)    X = 7;
         if (Y > 7)Y = 0;
         if (Y < 0)    Y = 7;
        // SetPosition(X,Y);
     }

     getch();
 }

 void LshowInformation()                //打印信息显示区
 {
    // SetPosition(MARGIN_10, INFOR_START_Y);
     int i;
     for (i = 0; i < 8; i++)
     {
         SetPosition(MARGIN_10, INFOR_START_Y+i);
         printf("|");
         SetPosition(MARGIN_10+99, INFOR_START_Y+i);
         printf("|");
     }
     SetPosition(MARGIN_10, INFOR_END_Y);
     printf(SEP);
 }

 void Lrefrush(Player *players)                            //刷新玩家的各种属性
 {
     if (players[loginid].exp >= 10  )
     {
         players[loginid].level =2;
     }
     if (players[loginid].exp >= 100 )
     {
         players[loginid].level = 3;
     }
     if (players[loginid].exp >= 1000 )
     {
         players[loginid].level = 4;
     }
      if (players[loginid].exp >= 2000 )
     {
         players[loginid].level = 5;
     }
     if (players[loginid].exp >= 3000 )
     {
         players[loginid].level = 6;
     }
      if (players[loginid].exp >= 500)
     {
         players[loginid].level = 7;
     }
      if (players[loginid].exp >= 7000 )
     {
         players[loginid].level = 8;
     }
    if (players[loginid].exp >= 10000 )
     {
         players[loginid].level = 9;
     }
      if (players[loginid].exp >= 15000)
     {
         players[loginid].level = 10;
     }
          if (players[loginid].exp >= 30000 )
     {
         players[loginid].level =11;
     }
         if (players[loginid].exp >= 50000 )
         {
             players[loginid].level = 12;
         }
        if (players[loginid].exp >= 100000)
         {
             players[loginid].level = 13;
         }
         if (players[loginid].exp >= 200000 )
         {
             players[loginid].level = 14;
         }
         if (players[loginid].exp >= 350000 )
         {
             players[loginid].level = 15;
         }
          if (players[loginid].exp >= 500000)
         {
             players[loginid].level = 16;
         }
          if (players[loginid].exp >= 1000000 )
         {
             players[loginid].level = 17;
         }
         if (players[loginid].exp >= 1800000 )
         {
             players[loginid].level = 18;
         }
         if (players[loginid].exp >= 2000000 )
         {
             players[loginid].level = 19;
         }
          if (players[loginid].exp >= 5000000)
         {
             players[loginid].level = 20;
         }
         if (players[loginid].exp >= 7000000 )
         {
             players[loginid].level = 21;
         }
          if (players[loginid].exp >= 10000000 )
         {
             players[loginid].level = 22;
         }
          if (players[loginid].exp >= 16000000 )
         {
             players[loginid].level = 23;
         }
        if (players[loginid].exp >= 50000000 )
         {
             players[loginid].level = 24;
         }
         if (players[loginid].exp >= 99999999 )
         {
             players[loginid].level = 25;
         }

     switch (players[loginid].level)
     {
     case 1:strcpy(players[loginid].achieve, "武道一重天"); players[loginid].nextexp = 10; players[loginid].hp = 1000; players[loginid].attack = 100; players[loginid].defence= 100; break;
     case 2:strcpy(players[loginid].achieve, "武道二重天"); players[loginid].nextexp = 100; players[loginid].hp = 2000; players[loginid].attack = 200; players[loginid].defence = 200; break;
     case 3:strcpy(players[loginid].achieve, "武道三重天");  players[loginid].nextexp = 1000; players[loginid].hp = 3000; players[loginid].attack = 300; players[loginid].defence= 300; break;
     case 4:strcpy(players[loginid].achieve, "武道四重天"); players[loginid].nextexp = 2000; players[loginid].hp = 3000; players[loginid].attack = 400;  players[loginid].defence= 400; break;
     case 5:strcpy(players[loginid].achieve, "武道五重天");   players[loginid].nextexp = 3000; players[loginid].hp = 3000; players[loginid].attack = 500; players[loginid].defence;  break;
     case 6:strcpy(players[loginid].achieve, "武道六重天");  players[loginid].nextexp = 5000; players[loginid].hp = 500; players[loginid].attack = 600; players[loginid].defence= 600; break;
     case 7:strcpy(players[loginid].achieve, "武道七重天");  players[loginid].nextexp = 7000; players[loginid].hp = 500; players[loginid].attack = 700; players[loginid].defence = 700; break;
     case 8:strcpy(players[loginid].achieve, "武道八重天");  players[loginid].nextexp = 10000; players[loginid].hp = 500; players[loginid].attack = 1000; players[loginid].defence = 1000; break;
     case 9:strcpy(players[loginid].achieve, "武道九重天");  players[loginid].nextexp = 15000; players[loginid].hp = 500; players[loginid].attack = 1500; players[loginid].defence = 1500; break;
     case 10:strcpy(players[loginid].achieve, "武道通神");  players[loginid].nextexp = 30000; players[loginid].hp = 1000; players[loginid].attack = 1600; players[loginid].defence = 1600; break;
     case 11:strcpy(players[loginid].achieve, "武道神话");  players[loginid].nextexp = 50000; players[loginid].hp = 5000; players[loginid].attack = 2000; players[loginid].defence = 2000; break;
     case 12:strcpy(players[loginid].achieve, "道胎境");   players[loginid].nextexp = 100000; players[loginid].hp = 10000; players[loginid].attack = 2100; players[loginid].defence = 2100; break;
     case 13:strcpy(players[loginid].achieve, "一阳境");  players[loginid].nextexp = 200000; players[loginid].hp = 10000; players[loginid].attack = 2200; players[loginid].defence = 2200; break;
     case 14:strcpy(players[loginid].achieve, "凝神境");  players[loginid].nextexp = 350000; players[loginid].hp = 10000; players[loginid].attack = 3000; players[loginid].defence = 3000; break;
     case 15:strcpy(players[loginid].achieve, "灵泉境");  players[loginid].nextexp = 500000; players[loginid].hp = 10000; players[loginid].attack = 4000; players[loginid].defence = 4000; break;
     case 16:strcpy(players[loginid].achieve, "化虚境"); players[loginid].nextexp = 1000000; players[loginid].hp = 10000; players[loginid].attack = 5000; players[loginid].defence = 5000; break;
     case 17:strcpy(players[loginid].achieve, "五龙境");  players[loginid].nextexp = 1800000; players[loginid].hp = 10000; players[loginid].attack = 6000; players[loginid].defence = 6000; break;
     case 18:strcpy(players[loginid].achieve, "准圣境");   players[loginid].nextexp = 2000000; players[loginid].hp = 50000; players[loginid].attack = 8000; players[loginid].defence = 8000; break;
     case 19:strcpy(players[loginid].achieve, "圣人境");  players[loginid].nextexp = 5000000; players[loginid].hp = 50000; players[loginid].attack = 10000; players[loginid].defence = 10000; break;
     case 20:strcpy(players[loginid].achieve, "圣王境");   players[loginid].nextexp = 7000000; players[loginid].hp = 50000; players[loginid].attack = 30000; players[loginid].defence = 30000; break;
     case 21:strcpy(players[loginid].achieve, "伪仙境");  players[loginid].nextexp = 10000000; players[loginid].hp = 50000; players[loginid].attack = 50000; players[loginid].defence = 50000; break;
     case 22:strcpy(players[loginid].achieve, "真仙境");   players[loginid].nextexp = 16000000; players[loginid].hp = 50000; players[loginid].attack = 80000; players[loginid].defence = 80000; break;
     case 23:strcpy(players[loginid].achieve, "战仙境"); players[loginid].nextexp = 50000000; players[loginid].hp = 100000; players[loginid].attack = 100000; players[loginid].defence = 100000; break;
     case 24:strcpy(players[loginid].achieve, "天尊境"); players[loginid].nextexp = 99999999; players[loginid].hp = 500000; players[loginid].attack = 5000000; players[loginid].defence = 500000; break;
     case 25:strcpy(players[loginid].achieve, "主宰境"); players[loginid].nextexp = 999999999; players[loginid].hp = 9999999; players[loginid].attack = 99999999; players[loginid].defence = 99999999; break;
     }
 }

 void LshowMapInfor(int x,int y)                        //在显示区显示地图的信息
 {

     ClearInfor();
     SetPosition(PAGE_TITLE_X,INFOR_START_Y);
     printf("当前玩家所在地图 【%s】",mapArray[x][y].name);
     SetPosition(MARGIN_X, INFOR_START_Y+1);
     char *desc=mapArray[x][y].desc;
     int desclen = strlen(desc);
     int i, j;
     for (i = 0; i < desclen; i++)
     {
         if (i != 0 && i % 76 == 0)
         {
             SetPosition(MARGIN_X -4, INFOR_START_Y + 1+i/76);
         }
         printf("%c",desc[i]);
     }
 }

 void Lshowmonster(Player *players)                                    //显示当前地图上的怪物
 {
     ClearInfor();

     int monstercount = sizeof(monsters)/sizeof(Monster)+1;        //整个游戏的怪物数组的怪物数量
     int currmonsterindex[12];                                    //当前地图的怪物下标
     int currmonstercount = 0;                                    //当前地图的怪物数量
     int i;
     for (i = 0; i < monstercount; i++)
     {
         if (monsters[i].coord.X == X && monsters[i].coord.Y == Y && monsters[i].state != 0)        //暂时未做判定怪物死亡的代码
             currmonsterindex[currmonstercount++] = i;
         if (currmonstercount == 9)
         {
             break;
         }
     }
     //打印怪物
     SetPosition(PAGE_TITLE_X, INFOR_START_Y);
     if (players[loginid].level < mapArray[Y][X].minlevel)
     {
         printf("您当前等级不足,此地图尚未开放!");
         SetPosition(PAGE_TITLE_X, INFOR_START_Y+1);
         printf("当前地图开放等级为:Lv.%d", mapArray[Y][X].minlevel);
     }
     else if (currmonstercount == 0)
     {
         SetPosition(PAGE_TITLE_X, INFOR_START_Y);
         printf("当前地图什么都没有!");
     }
     else
     {

         printf("在当前地图发现了:");
         SetPosition(MARGIN_10 + 3, INFOR_START_Y + 1);
         for (i = 0; i < currmonstercount; i++)
         {
             if (i !=0 && i%3==0)
             {
                 SetPosition(MARGIN_10 + 3, INFOR_START_Y + 1 + i / 3);
             }
             printf("%2d.Lv%-2d %-10s[%-10s]  ",monsters[currmonsterindex[i]].id, monsters[currmonsterindex[i]].level, monsters[currmonsterindex[i]].name, monsters[currmonsterindex[i]].achieve);
             if (i == 12) break;
         }
         do
         {
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 6);
             printf(CLS);
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
             printf(CLS);
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 6);
             printf("请选择要挑战的对象(按0返回):");
             int pkmonsterid = -1;
             scanf("%d", &pkmonsterid);
             if (pkmonsterid == 0)
             {
                 break;
             }
             // SetPosition(MARGIN_10 + 46, INFOR_START_Y + 7);
              //printf("要挑战的编号为:%d",pkmonsterid);
             // printf("%d", monstercount);
             LCombat(pkmonsterid,players);

             SetPosition(MARGIN_10 + 75, INFOR_START_Y + 7);
             printf("按任意键继续挑战.");
             getch();
         } while (1);
         getch();
     }
     getch();
 }

 void LCombat(int monsterid, Player *players)                                                    //核心:打怪啦
 {

     int Attack = players[loginid].attack + stuffs[players[loginid].weaponindex].maxattack + stuffs[players[loginid].meanindex].maxattack;                                        //攻击力=基础攻击力+武器攻击力+功法加成
     int Defence = players[loginid].defence + stuffs[players[loginid].armorindex].maxdefence;
     int Exper= players[loginid].exp;
     int Level= players[loginid].level;
     int combatcount = 0;
     Player currplayer = players[loginid];
     int monsterindex = -1;
     int i;
         for (i = 0; i <= monstercount; i++)
         {
             if (monsters[i].id == monsterid )                    //&& monsters[monsterid].coord.X==X && monsters[monsterid].coord.Y==Y
                                                                //加上此句会有一些怪物显示,挑战不了的问题,已懒得解决
             {
                 monsterindex = i;
                 break;
             }
        // printf("%d", monsters[monsterindex].defence);
         //getch();
         }

         if (monsterindex == -1)
         {
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
             printf("当前地图不存在要此怪物,按任意键继续!");
             return;
         }

         while (1)
         {

             srand(time(NULL));

             monsters[monsterindex].hp -= Attack-monsters[monsterindex].defence/2;                                     //过程
             currplayer.hp -= monsters[monsterindex].attack-currplayer.defence/2;
             combatcount++;
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
             printf(CLS);
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
             printf("当前战斗第%2d回合,  %s:%dHP         %s:%dHP", combatcount, currplayer.name, currplayer.hp, monsters[monsterindex].name, monsters[monsterindex].hp);
             Sleep(1000);

             SetPosition(PAGE_TITLE_X * 2 - 8, SUP_NAME_Y - 1);
             printf("Tip:按ENTER键进入地图");
             SetPosition(PAGE_TITLE_X * 2 - 8, SUP_NAME_Y);
             printf("Tip:按ESC键退出地图,回到大厅");
             Lrefrush(players);
             SetPosition(MARGIN_10, SUP_NAME_Y);
             printf("【%s】-%s", players[loginid].name, players[loginid].iden);
             SetPosition(MARGIN_10, SUP_NAME_Y + 1);
             printf("LV.%d[%s]", currplayer.level, players[loginid].achieve);
             SetPosition(MARGIN_10, SUP_EXE_Y);
             printf("                                                                                                               ");
             SetPosition(MARGIN_10, SUP_EXE_Y);
             printf("经验值: %d/%d", currplayer.exp, players[loginid].nextexp);
             printf("\t\tHP:%d", currplayer.hp);
             printf("\t\tAttack:%d",Attack);
             printf("\t\tDefence:%d", Defence);
             if (monsters[monsterindex].hp <= 0)
             {
                 break;
             }
             if (currplayer.hp <= 0)
             {
                 break;
             }

         }
         if (currplayer.hp <= 0)
         {
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
             printf(CLS);
             SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
             printf("失败,在与%s[%s]的战斗中死亡!", monsters[monsterindex].name, monsters[monsterindex].achieve);
             currplayer.hp = 1;
             return;
         }
         int actualgold = (rand() % (monsters[monsterindex].maxmoney - monsters[monsterindex].minmoney)) + monsters[monsterindex].minmoney;
         SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
         printf(CLS);

         SetPosition(MARGIN_10 + 6, INFOR_START_Y + 7);
         printf("经过艰苦的战斗,您击败了%s!获得了%d点经验,%d金币", monsters[monsterindex].name,monsters[monsterindex].exp, actualgold);
         Exper += monsters[monsterid].exp;
         currplayer.glod += actualgold;
         Lrefrush(players);

         SetPosition(PAGE_TITLE_X * 2 - 8, SUP_NAME_Y - 1);
         printf("Tip:按ENTER键进入地图");
         SetPosition(PAGE_TITLE_X * 2 - 8, SUP_NAME_Y);
         printf("Tip:按ESC键退出地图,回到大厅");

         players[loginid].exp= Exper;
         players[loginid].level= Level;
         Lrefrush(players);
         SetPosition(MARGIN_10, SUP_NAME_Y);
         printf("【%s】-%s", players[loginid].name, players[loginid].iden);
         SetPosition(MARGIN_10, SUP_NAME_Y + 1);
         printf("LV.%d[%s]", currplayer.level, players[loginid].achieve);
         SetPosition(MARGIN_10, SUP_EXE_Y);
         printf("                                                                                                               ");
         SetPosition(MARGIN_10, SUP_EXE_Y);
         printf("经验值: %d/%d", currplayer.exp, players[loginid].nextexp);
         printf("\t\tHP:%d", currplayer.hp);
         printf("\t\tAttack:%d", Attack);
         printf("\t\tDefence:%d", Defence);
 }

 /*******************************************游戏库函数********************************************************/
 /*
 0-黑色, 1-蓝色,    2-绿色,    3-浅绿色,        4-红色,    5-紫色,    6-黄色,    7-白色
 8-灰色, 9-浅蓝色,    10-浅绿色,    11-淡浅绿色,    12-淡红色,    13-淡紫色,    14-淡黄色,    15-亮白色
 */
 void init()                                //初始化游戏设置,也就是包含以下函数设置
 {
     SetTitle("仙域天尊之纵横圣武 1.0    — C语言测试版(Fairy domain Buddha 1.0  -The C language BETA)");
     SetColor(1,7);
 }

 void SetTitle(char *title)                            //设置游戏窗标题
 {

     SetConsoleTitle(title);                        //windows.h 内设置窗口标题的函数
 }

 void SetColor(int foreColor, int backColor)//设置游戏的前景色,背景色
 {
     HANDLE winhandle;                                //handle把手的意思
     winhandle=GetStdHandle(STD_OUTPUT_HANDLE);        //拿到控制台窗口
     //设置文字颜色
     SetConsoleTextAttribute(winhandle,foreColor+backColor * 0x10);
 }
 void SetPosition(int x, int y)                        //设置光标的坐标(位置)
 {
     HANDLE winhandle;                                //handle把手的意思
     COORD pos = { x,y };
     winhandle = GetStdHandle(STD_OUTPUT_HANDLE);    //拿到控制台窗口
     SetConsoleCursorPosition(winhandle,pos);        //参数一:需要设置的对象
                                                    //参数二:坐标
 }

 void ClearInfor()                                    //清除信息显示区的消息
 {
     int i, j;
     for (i = 0; i < 8; i++)
     {
         for (j = 0; j < 98; j++)
         {
             SetPosition(MARGIN_10 + 1+j, INFOR_START_Y + i);
             printf(" ");
         }
     }
 }

 void Lclearmall()                                        //商城清屏函数
 {
     SetPosition(0, 11);
     int i;
     for (i = 0; i < 11; i++)
     {
         SetPosition(0, 11 + i);
         printf("                                                                                                                         ");
     }
 }

原文地址:https://www.cnblogs.com/520-42/p/8491030.html

时间: 2024-10-17 18:36:20

Road to Coder _Gane的相关文章

Road to Coder _指向函数的指针

#include"stdio.h" main(){ int max(int, int); int min(int,int); int add(int,int); int fun(int x, int y, int(*p)(int, int)); int (*p)(int, int); int a, b, c,n; printf("please enter a and b:"); scanf_s("%d%d",&a,&b); pri

Road to Coder _练习

周次 学习时间 新编写代码行数 博客量(篇) 学到知识点           第15周 -0.5h 1 函数'及算法加深 #include"stdio.h"#include"string.h" main(){ char string[20]; char c; int word=0,num=0,i; printf("请输入一个句子:"); gets(string); for(i=0;(c=string[i])!='\0';i++)//结束条件:字符

poj 3204 Ikki&#39;s Story I - Road Reconstruction

Ikki's Story I - Road Reconstruction 题意:有N个顶点和M条边N, M (N ≤ 500, M ≤ 5,000)  ,试图改变图中的一条边使得从0到N-1的流量增加:问这样的边有几条? 思路:刚最大流入门,之后一看就觉得满流的边就是答案..真是太天真了.之后看了题解,发现满流只是前提(即使满流是几次残量的叠加也是一样),还有一个条件是,该路径的最大流量只受该边影响:即可以从S和T遍历到该边的两个端点,这就是为什么之后还要dfs给点涂色的原因:涂色前要对残余网络

hdoj 1596 find the safest road 【dijkstra】

find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9144    Accepted Submission(s): 3225 Problem Description XX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1

HDU4081 Qin Shi Huang&#39;s National Road System【Kruska】【次小生成树】

Qin Shi Huang's National Road System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3979    Accepted Submission(s): 1372 Problem Description During the Warring States Period of ancient China(4

Restoring Road Network

D - Restoring Road Network Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are

AtCoder Regular Contest 083 D:Restoring Road Network

In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network: People traveled between cities only through roads. It was possible to reach

暑假练习赛 003 B Chris and Road

B - Chris and Road Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice _ uDebug Description Input Output Sample Input Sample Output Hint Description And while Mis

HDU 4081 Qin Shi Huang&#39;s National Road System 最小生成树

分析:http://www.cnblogs.com/wally/archive/2013/02/04/2892194.html 这个题就是多一个限制,就是求包含每条边的最小生成树,这个求出原始最小生成树然后查询就好了 然后预处理那个数组是O(n^2)的,这样总时间复杂度是O(n^2+m) 这是因为这个题n比较小,如果n大的时候,就需要路径查询了,比如LCA 或者树链剖分达到O(mlogn) #include <iostream> #include <algorithm> #incl