Commit dccbce5e authored by nanahira's avatar nanahira

5 spells check

parent 4700ce30
......@@ -150,8 +150,21 @@ int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
if(it != list->end() && dc > it->second)
return (DECKERROR_LFLIST << 28) + cit->first;
}
int spellcount = CheckSpellCount(deck);
if (spellcount > 5) {
return (DECKERROR_MAINCOUNT << 28) + spellcount;
}
return 0;
}
int DeckManager::CheckSpellCount(Deck& deck) {
int spellcount = 0;
CardData cd;
for (auto cit : deck.main) {
if (cit->second.type & TYPE_SPELL)
spellcount++;
}
return spellcount;
}
int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec) {
deck.clear();
int code;
......@@ -228,6 +241,8 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
if(cdit->second != pcount[cdit->first])
return false;
#endif
if (CheckSpellCount(ndeck) > 5)
return false;
deck = ndeck;
return true;
}
......
......@@ -40,7 +40,8 @@ public:
const wchar_t* GetLFListName(int lfhash);
const std::unordered_map<int, int>* GetLFListContent(int lfhash);
int CheckDeck(Deck& deck, int lfhash, int rule);
int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec);
int CheckSpellCount(Deck& deck);
int LoadDeck(Deck &deck, int *dbuf, int mainc, int sidec);
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
#ifndef YGOPRO_SERVER_MODE
void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment