商城购买修正
This commit is contained in:
@@ -2,78 +2,88 @@
|
||||
#ifndef __GAMEDATAMANAGER_H__
|
||||
#define __GAMEDATAMANAGER_H__
|
||||
|
||||
struct AWARD_ITEM
|
||||
struct CeraShopBonusCodeType
|
||||
{
|
||||
int code_min;
|
||||
int code_max;
|
||||
int code_count;
|
||||
};
|
||||
|
||||
struct CeraShopBonusItemType
|
||||
{
|
||||
|
||||
int item_id;
|
||||
int item_num;
|
||||
bool is_random;
|
||||
};
|
||||
|
||||
|
||||
class CGameDataManager
|
||||
{
|
||||
public:
|
||||
SINGLETON_DEFINE_S(CGameDataManager);
|
||||
|
||||
CGameDataManager() :
|
||||
cera_award_begin_id(0),
|
||||
cera_award_end_id(0)
|
||||
CGameDataManager()
|
||||
{
|
||||
|
||||
cera_shop_bonus_code_array.clear();
|
||||
cera_shop_bonus_item_map.Clear();
|
||||
}
|
||||
~CGameDataManager() {};
|
||||
public:
|
||||
void set_cera_award_begin_id(int id)
|
||||
|
||||
bool is_cera_shop_bonus_code(int code_id, CeraShopBonusCodeType* res = NULL)
|
||||
{
|
||||
cera_award_begin_id = id;
|
||||
}
|
||||
void set_cera_award_end_id(int id)
|
||||
{
|
||||
cera_award_end_id = id;
|
||||
}
|
||||
int get_cera_award_begin_id()
|
||||
{
|
||||
return cera_award_begin_id;
|
||||
}
|
||||
int get_cera_award_end_id()
|
||||
{
|
||||
return cera_award_end_id;
|
||||
}
|
||||
bool add_cera_awarw_item(int count_, int item_id, int item_num)
|
||||
{
|
||||
cera_award_item.Push(count_, { item_id ,item_num });
|
||||
for (size_t i = 0; i < cera_shop_bonus_code_array.size(); i++)
|
||||
{
|
||||
CeraShopBonusCodeType cera_shop_bonus_code_ = cera_shop_bonus_code_array.at(i);
|
||||
if (code_id >= cera_shop_bonus_code_.code_min && code_id <= cera_shop_bonus_code_.code_max)
|
||||
{
|
||||
if (res != NULL) *res = cera_shop_bonus_code_;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Utils::TMap<int, AWARD_ITEM>* get_cera_award_item_map()
|
||||
bool get_rand_cera_shop_bonus_item(CeraShopBonusItemType* res = NULL)
|
||||
{
|
||||
return &cera_award_item;
|
||||
int size = get_random_item_num();
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
int random_value = Utils::Rand(1, size - 1);
|
||||
CeraShopBonusItemType cera_shop_bonusi_temt = cera_shop_bonus_item_map_rand.Map.at(random_value);
|
||||
if (cera_shop_bonusi_temt.is_random == true)
|
||||
{
|
||||
if (res != NULL) *res = cera_shop_bonusi_temt;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void set_cera_award_package_begin_id(int id)
|
||||
int get_random_item_num()
|
||||
{
|
||||
cera_award_package_begin_id = id;
|
||||
}
|
||||
void set_cera_award_package_end_id(int id)
|
||||
{
|
||||
cera_award_package_end_id = id;
|
||||
}
|
||||
int get_cera_award_package_begin_id()
|
||||
{
|
||||
return cera_award_package_begin_id;
|
||||
}
|
||||
int get_cera_award_package_end_id()
|
||||
{
|
||||
return cera_award_package_end_id;
|
||||
return cera_shop_bonus_item_map_rand.Size();
|
||||
}
|
||||
|
||||
bool add_cera_award_package_item(int count_, int item_id, int item_num)
|
||||
bool add_cera_shop_bonus_item(int count_, int item_id, int item_num, bool is_random)
|
||||
{
|
||||
cera_award_package_item.Push(count_, { item_id ,item_num });
|
||||
cera_shop_bonus_item_map.Push(count_, { item_id ,item_num ,is_random });
|
||||
}
|
||||
|
||||
Utils::TMap<int, AWARD_ITEM>* get_cera_award_package_item_map()
|
||||
Utils::TMap<int, CeraShopBonusItemType>* get_cera_shop_bonus_item_map()
|
||||
{
|
||||
return &cera_award_package_item;
|
||||
return &cera_shop_bonus_item_map;
|
||||
}
|
||||
|
||||
std::vector<CeraShopBonusCodeType>* get_cera_shop_bonus_code_array()
|
||||
{
|
||||
return &cera_shop_bonus_code_array;
|
||||
}
|
||||
|
||||
Utils::TMap<int, CeraShopBonusItemType>* get_cera_shop_bonus_item_map_rand()
|
||||
{
|
||||
return &cera_shop_bonus_item_map_rand;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,13 +91,11 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
int cera_award_begin_id; //商城奖励开始id
|
||||
int cera_award_end_id; //商城奖励结束id
|
||||
int cera_award_package_begin_id; //商城礼包奖励开始id
|
||||
int cera_award_package_end_id; //商城礼包奖励结束id
|
||||
|
||||
Utils::TMap<int, AWARD_ITEM> cera_award_item; // 次数 + 数据
|
||||
Utils::TMap<int, AWARD_ITEM> cera_award_package_item; // 次数 + 数据
|
||||
std::vector<CeraShopBonusCodeType> cera_shop_bonus_code_array;
|
||||
|
||||
Utils::TMap<int, CeraShopBonusItemType> cera_shop_bonus_item_map; // ´ÎÊý + Êý¾Ý
|
||||
Utils::TMap<int, CeraShopBonusItemType> cera_shop_bonus_item_map_rand; // ´ÎÊý + Êý¾Ý
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user