2022-09-13 22:47:38 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
|
#ifndef __GAMEDATAMANAGER_H__
|
|
|
|
|
|
#define __GAMEDATAMANAGER_H__
|
|
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
struct CeraShopBonusCodeType
|
2022-09-13 22:47:38 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
int code_min;
|
|
|
|
|
|
int code_max;
|
|
|
|
|
|
int code_count;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct CeraShopBonusItemType
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2022-09-13 22:47:38 +08:00
|
|
|
|
int item_id;
|
|
|
|
|
|
int item_num;
|
2022-09-21 16:28:11 +08:00
|
|
|
|
bool is_random;
|
2022-09-13 22:47:38 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
|
2022-09-13 22:47:38 +08:00
|
|
|
|
class CGameDataManager
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
SINGLETON_DEFINE_S(CGameDataManager);
|
|
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
CGameDataManager()
|
2022-09-13 22:47:38 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
cera_shop_bonus_code_array.clear();
|
|
|
|
|
|
cera_shop_bonus_item_map.Clear();
|
2022-09-13 22:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
~CGameDataManager() {};
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
bool is_cera_shop_bonus_code(int code_id, CeraShopBonusCodeType* res = NULL)
|
2022-09-13 22:47:38 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
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;
|
2022-09-13 22:47:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
bool get_rand_cera_shop_bonus_item(CeraShopBonusItemType* res = NULL)
|
2022-09-15 13:07:01 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
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;
|
2022-09-15 13:07:01 +08:00
|
|
|
|
}
|
2022-09-21 16:28:11 +08:00
|
|
|
|
|
|
|
|
|
|
int get_random_item_num()
|
2022-09-15 13:07:01 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
return cera_shop_bonus_item_map_rand.Size();
|
2022-09-15 13:07:01 +08:00
|
|
|
|
}
|
2022-09-21 16:28:11 +08:00
|
|
|
|
|
|
|
|
|
|
bool add_cera_shop_bonus_item(int count_, int item_id, int item_num, bool is_random)
|
2022-09-15 13:07:01 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
cera_shop_bonus_item_map.Push(count_, { item_id ,item_num ,is_random });
|
2022-09-15 13:07:01 +08:00
|
|
|
|
}
|
2022-09-21 16:28:11 +08:00
|
|
|
|
|
|
|
|
|
|
Utils::TMap<int, CeraShopBonusItemType>* get_cera_shop_bonus_item_map()
|
2022-09-15 13:07:01 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
return &cera_shop_bonus_item_map;
|
2022-09-15 13:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
std::vector<CeraShopBonusCodeType>* get_cera_shop_bonus_code_array()
|
2022-09-15 13:07:01 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
return &cera_shop_bonus_code_array;
|
2022-09-15 13:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
Utils::TMap<int, CeraShopBonusItemType>* get_cera_shop_bonus_item_map_rand()
|
2022-09-15 13:07:01 +08:00
|
|
|
|
{
|
2022-09-21 16:28:11 +08:00
|
|
|
|
return &cera_shop_bonus_item_map_rand;
|
2022-09-15 13:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-09-13 22:47:38 +08:00
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2022-09-15 13:07:01 +08:00
|
|
|
|
|
2022-09-21 16:28:11 +08:00
|
|
|
|
std::vector<CeraShopBonusCodeType> cera_shop_bonus_code_array;
|
|
|
|
|
|
|
|
|
|
|
|
Utils::TMap<int, CeraShopBonusItemType> cera_shop_bonus_item_map; // <20><><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD>
|
|
|
|
|
|
Utils::TMap<int, CeraShopBonusItemType> cera_shop_bonus_item_map_rand; // <20><><EFBFBD><EFBFBD> + <20><><EFBFBD><EFBFBD>
|
2022-09-13 22:47:38 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __GAMEDATAMANAGER_H__
|
|
|
|
|
|
|