Commit ed3dde3a authored by mercury233's avatar mercury233 Committed by GitHub

add basic support for cant check grave (#2319)

parent 07972be9
......@@ -29,6 +29,7 @@ ClientField::ClientField() {
conti_act = false;
deck_reversed = false;
conti_selecting = false;
cant_check_grave = false;
for(int p = 0; p < 2; ++p) {
mzone[p].resize(7, 0);
szone[p].resize(8, 0);
......@@ -93,6 +94,7 @@ void ClientField::Clear() {
pzone_act[1] = false;
conti_act = false;
deck_reversed = false;
cant_check_grave = false;
}
void ClientField::Initial(int player, int deckc, int extrac) {
ClientCard* pcard;
......@@ -384,6 +386,18 @@ void ClientField::ClearChainSelect() {
}
// needs to be synchronized with EGET_SCROLL_BAR_CHANGED
void ClientField::ShowSelectCard(bool buttonok, bool chain) {
if(cant_check_grave) {
bool has_card_in_grave = false;
for(size_t i = 0; i < selectable_cards.size(); ++i) {
if(selectable_cards[i]->location == LOCATION_GRAVE) {
has_card_in_grave = true;
break;
}
}
if(has_card_in_grave) {
std::random_shuffle(selectable_cards.begin(), selectable_cards.end());
}
}
int startpos;
size_t ct;
if(selectable_cards.size() <= 5) {
......@@ -410,6 +424,8 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
wchar_t formatBuffer[2048];
if(conti_selecting)
myswprintf(formatBuffer, L"%ls", DataManager::unknown_string);
else if(cant_check_grave && selectable_cards[i]->location == LOCATION_GRAVE)
myswprintf(formatBuffer, L"%ls", dataManager.FormatLocation(selectable_cards[i]->location, 0));
else if(selectable_cards[i]->location == LOCATION_OVERLAY)
myswprintf(formatBuffer, L"%ls[%d](%d)",
dataManager.FormatLocation(selectable_cards[i]->overlayTarget->location, selectable_cards[i]->overlayTarget->sequence),
......
......@@ -81,6 +81,7 @@ public:
bool last_chain;
bool deck_reversed;
bool conti_selecting;
bool cant_check_grave;
ClientField();
void Clear();
......@@ -150,5 +151,6 @@ public:
//special cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define CARD_QUESTION 38723936
#endif //CLIENT_FIELD_H
......@@ -408,7 +408,7 @@ void Game::DrawShadowText(CGUITTFont * font, const core::stringw & text, const c
void Game::DrawMisc() {
static irr::core::vector3df act_rot(0, 0, 0);
int rule = (dInfo.duel_rule >= 4) ? 1 : 0;
irr::core::matrix4 im, ic, it;
irr::core::matrix4 im, ic, it, ig;
act_rot.Z += 0.02f;
im.setRotationRadians(act_rot);
matManager.mTexture.setTexture(0, imageManager.tAct);
......@@ -492,6 +492,18 @@ void Game::DrawMisc() {
driver->drawVertexPrimitiveList(matManager.vChainNum, 4, matManager.iRectangle, 2);
}
}
if(dField.cant_check_grave) {
matManager.mTexture.setTexture(0, imageManager.tNegated);
driver->setMaterial(matManager.mTexture);
ig.setTranslation(vector3df((matManager.vFieldGrave[0][rule][0].Pos.X + matManager.vFieldGrave[0][rule][1].Pos.X) / 2,
(matManager.vFieldGrave[0][rule][0].Pos.Y + matManager.vFieldGrave[0][rule][2].Pos.Y) / 2, dField.grave[0].size() * 0.01f + 0.02f));
driver->setTransform(irr::video::ETS_WORLD, ig);
driver->drawVertexPrimitiveList(matManager.vNegate, 4, matManager.iRectangle, 2);
ig.setTranslation(vector3df((matManager.vFieldGrave[1][rule][0].Pos.X + matManager.vFieldGrave[1][rule][1].Pos.X) / 2,
(matManager.vFieldGrave[1][rule][0].Pos.Y + matManager.vFieldGrave[1][rule][2].Pos.Y) / 2, dField.grave[1].size() * 0.01f + 0.02f));
driver->setTransform(irr::video::ETS_WORLD, ig);
driver->drawVertexPrimitiveList(matManager.vNegate, 4, matManager.iRectangle, 2);
}
//finish button
if(btnCancelOrFinish->isVisible() && dField.select_ready)
DrawSelectionLine(btnCancelOrFinish, 2, 0xffffff00);
......
......@@ -3625,7 +3625,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int chtype = BufferIO::ReadInt8(pbuf);
int value = BufferIO::ReadInt32(pbuf);
auto& player_desc_hints = mainGame->dField.player_desc_hints[player];
if(chtype == PHINT_DESC_ADD) {
if(value == CARD_QUESTION && player == 0) {
if(chtype == PHINT_DESC_ADD) {
mainGame->dField.cant_check_grave = true;
} else if(chtype == PHINT_DESC_REMOVE) {
mainGame->dField.cant_check_grave = false;
}
}
else if(chtype == PHINT_DESC_ADD) {
player_desc_hints[value]++;
} else if(chtype == PHINT_DESC_REMOVE) {
player_desc_hints[value]--;
......
......@@ -889,6 +889,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} else {
if(conti_selecting)
myswprintf(formatBuffer, L"%ls", DataManager::unknown_string);
else if(cant_check_grave && selectable_cards[i]->location == LOCATION_GRAVE)
myswprintf(formatBuffer, L"%ls", dataManager.FormatLocation(selectable_cards[i]->location, 0));
else if(selectable_cards[i + pos]->location == LOCATION_OVERLAY)
myswprintf(formatBuffer, L"%ls[%d](%d)",
dataManager.FormatLocation(selectable_cards[i + pos]->overlayTarget->location, selectable_cards[i + pos]->overlayTarget->sequence),
......@@ -1189,6 +1191,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case LOCATION_GRAVE: {
if(grave[hovered_controler].size() == 0)
break;
if(cant_check_grave)
break;
ShowMenu(COMMAND_LIST, x, y);
break;
}
......@@ -1239,6 +1243,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
int command_flag = 0;
if(grave[hovered_controler].size() == 0)
break;
if(cant_check_grave)
break;
for(size_t i = 0; i < grave[hovered_controler].size(); ++i)
command_flag |= grave[hovered_controler][i]->cmdFlag;
command_flag |= COMMAND_LIST;
......@@ -1731,6 +1737,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
display_cards.clear();
switch(event.KeyInput.Key) {
case irr::KEY_F1:
if(cant_check_grave)
break;
loc_id = 1004;
for(auto it = grave[0].rbegin(); it != grave[0].rend(); ++it)
display_cards.push_back(*it);
......@@ -1755,6 +1763,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
break;
case irr::KEY_F5:
if(cant_check_grave)
break;
loc_id = 1004;
for(auto it = grave[1].rbegin(); it != grave[1].rend(); ++it)
display_cards.push_back(*it);
......
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