mirror of
https://github.com/Fluorohydride/ygopro.git
synced 2026-10-26 11:10:08 +08:00
* Use size_t for length in HandleCTOSPacket Co-authored-by: Copilot <copilot@github.com> * Use uint32_t in deck loading functions Co-authored-by: Copilot <copilot@github.com> * fix Co-authored-by: Copilot <copilot@github.com> * Validate deck update length in SingleDuel and TagDuel Co-authored-by: Copilot <copilot@github.com> * revert --------- Co-authored-by: Copilot <copilot@github.com>
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
#ifndef DECKMANAGER_H
|
|
#define DECKMANAGER_H
|
|
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <sstream>
|
|
#include "deck.h"
|
|
|
|
namespace irr {
|
|
namespace io {
|
|
class IReadFile;
|
|
}
|
|
}
|
|
|
|
namespace ygo {
|
|
|
|
constexpr int DECK_MAX_SIZE = 60;
|
|
constexpr int DECK_MIN_SIZE = 40;
|
|
constexpr int EXTRA_MAX_SIZE = 15;
|
|
constexpr int SIDE_MAX_SIZE = 15;
|
|
constexpr int PACK_MAX_SIZE = 1000;
|
|
|
|
constexpr int MAINC_MAX = 250; // the limit of card_state
|
|
constexpr int SIDEC_MAX = MAINC_MAX;
|
|
|
|
constexpr int DECK_CATEGORY_PACK = 0;
|
|
constexpr int DECK_CATEGORY_BOT = 1;
|
|
constexpr int DECK_CATEGORY_NONE = 2;
|
|
constexpr int DECK_CATEGORY_SEPARATOR = 3;
|
|
constexpr int DECK_CATEGORY_CUSTOM = 4;
|
|
|
|
struct LFList {
|
|
unsigned int hash{};
|
|
std::wstring listName;
|
|
std::unordered_map<uint32_t, int> content;
|
|
};
|
|
|
|
class DeckManager {
|
|
public:
|
|
Deck current_deck;
|
|
std::vector<LFList> _lfList;
|
|
|
|
static constexpr int MAX_YDK_SIZE = 0x10000;
|
|
|
|
void LoadLFListSingle(const char* path);
|
|
void LoadLFList();
|
|
const wchar_t* GetLFListName(unsigned int lfhash);
|
|
const LFList* GetLFList(unsigned int lfhash);
|
|
uint32_t CheckDeck(const Deck& deck, unsigned int lfhash, size_t rule);
|
|
bool LoadCurrentDeck(const wchar_t* file, bool is_packlist = false);
|
|
bool LoadCurrentDeck(int category_index, const wchar_t* category_name, const wchar_t* deckname);
|
|
bool LoadCurrentDeck(std::istringstream& deckStream, bool is_packlist = false);
|
|
|
|
static uint32_t LoadDeck(Deck& deck, uint32_t dbuf[], uint32_t mainc, uint32_t sidec, bool is_packlist = false);
|
|
static uint32_t LoadDeckFromStream(Deck& deck, std::istringstream& deckStream, bool is_packlist = false);
|
|
static bool LoadSide(Deck& deck, uint32_t dbuf[], uint32_t mainc, uint32_t sidec);
|
|
static void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
|
|
static void GetDeckFile(wchar_t* ret, int category_index, const wchar_t* category_name, const wchar_t* deckname);
|
|
static FILE* OpenDeckFile(const wchar_t* file, const char* mode);
|
|
static irr::io::IReadFile* OpenDeckReader(const wchar_t* file);
|
|
static bool SaveDeck(const Deck& deck, const wchar_t* file);
|
|
static void SaveDeck(const Deck& deck, std::stringstream& deckStream);
|
|
static bool DeleteDeck(const wchar_t* file);
|
|
static bool CreateCategory(const wchar_t* name);
|
|
static bool RenameCategory(const wchar_t* oldname, const wchar_t* newname);
|
|
static bool DeleteCategory(const wchar_t* name);
|
|
static bool SaveDeckArray(const DeckArray& deck, const wchar_t* name);
|
|
};
|
|
|
|
extern DeckManager deckManager;
|
|
|
|
}
|
|
|
|
#endif //DECKMANAGER_H
|