Commit fac7ce69 authored by sidschingis's avatar sidschingis

shuffle

added the option for the turn player to manually shuffle his hand, when
he has priority ( max. 5 times per turn)
parent 0377af14
...@@ -1043,6 +1043,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -1043,6 +1043,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnEP->setEnabled(true); mainGame->btnEP->setEnabled(true);
mainGame->btnEP->setPressed(false); mainGame->btnEP->setPressed(false);
} }
if (BufferIO::ReadInt8(pbuf)) {
mainGame->canShuffle = true;
}
else {
mainGame->canShuffle = false;
}
return false; return false;
} }
case MSG_SELECT_EFFECTYN: { case MSG_SELECT_EFFECTYN: {
......
...@@ -983,7 +983,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -983,7 +983,19 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
ShowMenu(command_flag, x, y); ShowMenu(command_flag, x, y);
break; break;
} }
case LOCATION_HAND: case LOCATION_HAND: {
if (!clicked_card)
break;
int command_flag = clicked_card->cmdFlag;
if (clicked_card->overlayed.size())
command_flag |= COMMAND_LIST;
list_command = 0;
if (hovered_location & LOCATION_HAND && mainGame->canShuffle
&& mainGame->dInfo.curMsg == MSG_SELECT_IDLECMD)
command_flag |= COMMAND_SHUFFLE;
ShowMenu(command_flag, x, y);
break;
}
case LOCATION_MZONE: case LOCATION_MZONE:
case LOCATION_SZONE: { case LOCATION_SZONE: {
if(!clicked_card) if(!clicked_card)
...@@ -1675,6 +1687,12 @@ void ClientField::ShowMenu(int flag, int x, int y) { ...@@ -1675,6 +1687,12 @@ void ClientField::ShowMenu(int flag, int x, int y) {
return; return;
} }
int height = 1; int height = 1;
if (flag & COMMAND_SHUFFLE) {
mainGame->btnShuffle->setVisible(true);
mainGame->btnShuffle->setRelativePosition(position2di(1, height));
height += 21;
}
else mainGame->btnShuffle->setVisible(false);
if(flag & COMMAND_ACTIVATE) { if(flag & COMMAND_ACTIVATE) {
mainGame->btnActivate->setVisible(true); mainGame->btnActivate->setVisible(true);
mainGame->btnActivate->setRelativePosition(position2di(1, height)); mainGame->btnActivate->setRelativePosition(position2di(1, height));
......
...@@ -355,6 +355,7 @@ bool Game::Initialize() { ...@@ -355,6 +355,7 @@ bool Game::Initialize() {
btnRepos = env->addButton(rect<s32>(1, 106, 99, 126), wCmdMenu, BUTTON_CMD_REPOS, dataManager.GetSysString(1154)); btnRepos = env->addButton(rect<s32>(1, 106, 99, 126), wCmdMenu, BUTTON_CMD_REPOS, dataManager.GetSysString(1154));
btnAttack = env->addButton(rect<s32>(1, 127, 99, 147), wCmdMenu, BUTTON_CMD_ATTACK, dataManager.GetSysString(1157)); btnAttack = env->addButton(rect<s32>(1, 127, 99, 147), wCmdMenu, BUTTON_CMD_ATTACK, dataManager.GetSysString(1157));
btnShowList = env->addButton(rect<s32>(1, 148, 99, 168), wCmdMenu, BUTTON_CMD_SHOWLIST, dataManager.GetSysString(1158)); btnShowList = env->addButton(rect<s32>(1, 148, 99, 168), wCmdMenu, BUTTON_CMD_SHOWLIST, dataManager.GetSysString(1158));
btnShuffle = env->addButton(rect<s32>(1, 169, 99, 189), wCmdMenu, BUTTON_CMD_SHUFFLE, dataManager.GetSysString(1307));
//deck edit //deck edit
wDeckEdit = env->addStaticText(L"", rect<s32>(309, 8, 605, 130), true, false, 0, -1, true); wDeckEdit = env->addStaticText(L"", rect<s32>(309, 8, 605, 130), true, false, 0, -1, true);
wDeckEdit->setVisible(false); wDeckEdit->setVisible(false);
......
...@@ -112,6 +112,7 @@ public: ...@@ -112,6 +112,7 @@ public:
std::vector<int> logParam; std::vector<int> logParam;
std::wstring chatMsg[8]; std::wstring chatMsg[8];
bool canShuffle;
int hideChatTimer; int hideChatTimer;
bool hideChat; bool hideChat;
int chatTiming[8]; int chatTiming[8];
......
...@@ -27,6 +27,7 @@ field::field(duel* pduel) { ...@@ -27,6 +27,7 @@ field::field(duel* pduel) {
this->pduel = pduel; this->pduel = pduel;
infos.field_id = 1; infos.field_id = 1;
infos.copy_id = 1; infos.copy_id = 1;
infos.shuffle_count = 0;
infos.turn_id = 0; infos.turn_id = 0;
infos.card_id = 1; infos.card_id = 1;
infos.phase = 0; infos.phase = 0;
......
...@@ -114,6 +114,7 @@ struct field_info { ...@@ -114,6 +114,7 @@ struct field_info {
uint8 phase; uint8 phase;
uint8 turn_player; uint8 turn_player;
uint8 priorities[2]; uint8 priorities[2];
uint8 shuffle_count;
}; };
struct lpcost { struct lpcost {
int32 count; int32 count;
......
...@@ -139,11 +139,15 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -139,11 +139,15 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
pduel->write_buffer8(1); pduel->write_buffer8(1);
else else
pduel->write_buffer8(0); pduel->write_buffer8(0);
if(infos.shuffle_count <5 && player[(uint32)playerid].list_hand.size() > 1)
pduel->write_buffer8(1);
else
pduel->write_buffer8(0);
return FALSE; return FALSE;
} else { } else {
uint32 t = returns.ivalue[0] & 0xffff; uint32 t = returns.ivalue[0] & 0xffff;
uint32 s = returns.ivalue[0] >> 16; uint32 s = returns.ivalue[0] >> 16;
if(t < 0 || t > 7 || s < 0 if(t < 0 || t > 8 || s < 0
|| (t == 0 && s >= core.summonable_cards.size()) || (t == 0 && s >= core.summonable_cards.size())
|| (t == 1 && s >= core.spsummonable_cards.size()) || (t == 1 && s >= core.spsummonable_cards.size())
|| (t == 2 && s >= core.repositionable_cards.size()) || (t == 2 && s >= core.repositionable_cards.size())
...@@ -151,7 +155,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) { ...@@ -151,7 +155,8 @@ int32 field::select_idle_command(uint16 step, uint8 playerid) {
|| (t == 4 && s >= core.ssetable_cards.size()) || (t == 4 && s >= core.ssetable_cards.size())
|| (t == 5 && s >= core.select_chains.size()) || (t == 5 && s >= core.select_chains.size())
|| (t == 6 && (infos.phase != PHASE_MAIN1 || !core.to_bp)) || (t == 6 && (infos.phase != PHASE_MAIN1 || !core.to_bp))
|| (t == 7 && !core.to_ep)) { || (t == 7 && !core.to_ep)
|| (t == 8 && !(infos.shuffle_count <5 && player[(uint32)playerid].list_hand.size() > 1))) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
......
...@@ -2701,6 +2701,11 @@ int32 field::process_idle_command(uint16 step) { ...@@ -2701,6 +2701,11 @@ int32 field::process_idle_command(uint16 step) {
} else if(ctype == 4) { } else if(ctype == 4) {
core.units.begin()->step = 8; core.units.begin()->step = 8;
return FALSE; return FALSE;
} else if (ctype == 8) {
core.units.begin()->step = -1;
shuffle(infos.turn_player, LOCATION_HAND);
infos.shuffle_count++;
return FALSE;
} else { } else {
core.units.begin()->step = 9; core.units.begin()->step = 9;
pduel->write_buffer8(MSG_HINT); pduel->write_buffer8(MSG_HINT);
...@@ -2789,6 +2794,7 @@ int32 field::process_idle_command(uint16 step) { ...@@ -2789,6 +2794,7 @@ int32 field::process_idle_command(uint16 step) {
} }
case 11: { case 11: {
returns.ivalue[0] = core.units.begin()->arg1; returns.ivalue[0] = core.units.begin()->arg1;
infos.shuffle_count = 0;
return TRUE; return TRUE;
} }
case 12: { case 12: {
......
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