#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
模拟实现道具店购物功能
商店暂时只支持一种类型的商品
商品具备名称、价格、库存等属性
模拟玩家购买游戏道具
1.玩家选择要购买的道具
2.玩家同意交易后扣除相应的游戏币
3.对应商品库存-1
4.玩家背包中增加商品或该商品数量+1
*/
//定义结构------------------------------------------------------------------------------------------------------------------------------------
//1.商品结构
typedef struct _prop{
int id; //道具编号
char name[50]; //名称
int price; //单价
int stock; //库存,如果在背包里就表示此商品的叠加数量
char desc[200]; //功能描述
}Prop;
//2.背包结构
typedef struct _bag
{
int playerId; //玩家编号
int count; //当前背包中道具数量
int max; //当前背包的插槽总数--可以rmb购买
Prop props[8]; //当前背包中的道具数组
}Bag;
//3.玩家结构
typedef struct _player
{
int id; //玩家编号
char name[50]; //玩家名称/昵称
char pass[50]; //密码
Bag bag; //玩家背包
double gold; //金钱
double sysee; //元宝数量
}Player;
//-------------------
商城系统的实现---C语言
最新推荐文章于 2022-06-30 23:53:12 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)