Commit a0af40c2 authored by Chen Bill's avatar Chen Bill

add DECK_MAX_SIZE, DECK_MIN_SIZE

parent 19908a9a
...@@ -1249,7 +1249,7 @@ void DeckBuilder::GetHoveredCard() { ...@@ -1249,7 +1249,7 @@ void DeckBuilder::GetHoveredCard() {
} else if(y >= 164 && y <= 435) { } else if(y >= 164 && y <= 435) {
int lx = 10, px, py = (y - 164) / 68; int lx = 10, px, py = (y - 164) / 68;
hovered_pos = 1; hovered_pos = 1;
if(deckManager.current_deck.main.size() > 40) if(deckManager.current_deck.main.size() > DECK_MIN_SIZE)
lx = (deckManager.current_deck.main.size() - 41) / 4 + 11; lx = (deckManager.current_deck.main.size() - 41) / 4 + 11;
if(x >= 750) if(x >= 750)
px = lx - 1; px = lx - 1;
...@@ -1757,7 +1757,7 @@ bool DeckBuilder::push_main(code_pointer pointer, int seq) { ...@@ -1757,7 +1757,7 @@ bool DeckBuilder::push_main(code_pointer pointer, int seq) {
if(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) if(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))
return false; return false;
auto& container = deckManager.current_deck.main; auto& container = deckManager.current_deck.main;
int maxc = mainGame->is_siding ? 64 : 60; int maxc = mainGame->is_siding ? 64 : DECK_MAX_SIZE;
if((int)container.size() >= maxc) if((int)container.size() >= maxc)
return false; return false;
if(seq >= 0 && seq < (int)container.size()) if(seq >= 0 && seq < (int)container.size())
...@@ -1772,7 +1772,7 @@ bool DeckBuilder::push_extra(code_pointer pointer, int seq) { ...@@ -1772,7 +1772,7 @@ bool DeckBuilder::push_extra(code_pointer pointer, int seq) {
if(!(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))) if(!(pointer->second.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)))
return false; return false;
auto& container = deckManager.current_deck.extra; auto& container = deckManager.current_deck.extra;
int maxc = mainGame->is_siding ? 20 : 15; int maxc = mainGame->is_siding ? 20 : EXTRA_MAX_SIZE;
if((int)container.size() >= maxc) if((int)container.size() >= maxc)
return false; return false;
if(seq >= 0 && seq < (int)container.size()) if(seq >= 0 && seq < (int)container.size())
...@@ -1785,7 +1785,7 @@ bool DeckBuilder::push_extra(code_pointer pointer, int seq) { ...@@ -1785,7 +1785,7 @@ bool DeckBuilder::push_extra(code_pointer pointer, int seq) {
} }
bool DeckBuilder::push_side(code_pointer pointer, int seq) { bool DeckBuilder::push_side(code_pointer pointer, int seq) {
auto& container = deckManager.current_deck.side; auto& container = deckManager.current_deck.side;
int maxc = mainGame->is_siding ? 20 : 15; int maxc = mainGame->is_siding ? 20 : SIDE_MAX_SIZE;
if((int)container.size() >= maxc) if((int)container.size() >= maxc)
return false; return false;
if(seq >= 0 && seq < (int)container.size()) if(seq >= 0 && seq < (int)container.size())
......
...@@ -86,11 +86,11 @@ int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) { ...@@ -86,11 +86,11 @@ int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
if(!list) if(!list)
return 0; return 0;
int dc = 0; int dc = 0;
if(deck.main.size() < 40 || deck.main.size() > 60) if(deck.main.size() < DECK_MIN_SIZE || deck.main.size() > DECK_MAX_SIZE)
return (DECKERROR_MAINCOUNT << 28) + deck.main.size(); return (DECKERROR_MAINCOUNT << 28) + deck.main.size();
if(deck.extra.size() > 15) if(deck.extra.size() > EXTRA_MAX_SIZE)
return (DECKERROR_EXTRACOUNT << 28) + deck.extra.size(); return (DECKERROR_EXTRACOUNT << 28) + deck.extra.size();
if(deck.side.size() > 15) if(deck.side.size() > SIDE_MAX_SIZE)
return (DECKERROR_SIDECOUNT << 28) + deck.side.size(); return (DECKERROR_SIDECOUNT << 28) + deck.side.size();
const int rule_map[6] = { AVAIL_OCG, AVAIL_TCG, AVAIL_SC, AVAIL_CUSTOM, AVAIL_OCGTCG, 0 }; const int rule_map[6] = { AVAIL_OCG, AVAIL_TCG, AVAIL_SC, AVAIL_CUSTOM, AVAIL_OCGTCG, 0 };
int avail = rule_map[rule]; int avail = rule_map[rule];
...@@ -158,10 +158,10 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p ...@@ -158,10 +158,10 @@ int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_p
continue; continue;
} }
else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) { else if(cd.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)) {
if(deck.extra.size() >= 15) if(deck.extra.size() >= EXTRA_MAX_SIZE)
continue; continue;
deck.extra.push_back(dataManager.GetCodePointer(code)); deck.extra.push_back(dataManager.GetCodePointer(code));
} else if(deck.main.size() < 60) { } else if(deck.main.size() < DECK_MAX_SIZE) {
deck.main.push_back(dataManager.GetCodePointer(code)); deck.main.push_back(dataManager.GetCodePointer(code));
} }
} }
......
...@@ -8,6 +8,10 @@ ...@@ -8,6 +8,10 @@
#include <sstream> #include <sstream>
namespace ygo { 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;
struct LFList { struct LFList {
unsigned int hash{}; unsigned int hash{};
......
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