Commit 339d756b authored by argon.sun's avatar argon.sun

recon

parent 8d2f4a33
#include "duelclient.h" #include "duelclient.h"
#include client_card.h"
#include "game.h" #include "game.h"
namespace ygo { namespace ygo {
...@@ -138,6 +139,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -138,6 +139,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
unsigned char pktType = BufferIO::ReadUInt8(pdata); unsigned char pktType = BufferIO::ReadUInt8(pdata);
switch(pktType) { switch(pktType) {
case STOC_GAME_MSG: { case STOC_GAME_MSG: {
ClientAnalyze(pdata, len - 1);
break; break;
} }
case STOC_ERROR_MSG: { case STOC_ERROR_MSG: {
...@@ -173,33 +175,46 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -173,33 +175,46 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} }
break; break;
} }
case STOC_SELECT_HAND: {
mainGame->ShowElement(mainGame->wHand);
break;
}
case STOC_SELECT_TP: {
break;
}
case STOC_HAND_RESULT: {
break;
}
case STOC_TP_RESULT: {
break;
}
case STOC_JOIN_GAME: { case STOC_JOIN_GAME: {
STOC_JoinGame* pkt = (STOC_JoinGame*)pdata; STOC_JoinGame* pkt = (STOC_JoinGame*)pdata;
std::wstring str; std::wstring str;
wchar_t msgbuf[256]; wchar_t msgbuf[256];
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1226), deckManager.GetLFListName(pkt->info.lflist)); myswprintf(msgbuf, L" % ls % ls\n", dataManager.GetSysString(1226), deckManager.GetLFListName(pkt->info.lflist));
str.append(msgbuf); str.append(msgbuf);
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1225), dataManager.GetSysString(1240 + pkt->info.rule)); myswprintf(msgbuf, L" % ls % ls\n", dataManager.GetSysString(1225), dataManager.GetSysString(1240 + pkt->info.rule));
str.append(msgbuf); str.append(msgbuf);
myswprintf(msgbuf, L"%ls%ls\n", dataManager.GetSysString(1227), dataManager.GetSysString(1244 + pkt->info.mode)); myswprintf(msgbuf, L" % ls % ls\n", dataManager.GetSysString(1227), dataManager.GetSysString(1244 + pkt->info.mode));
str.append(msgbuf); str.append(msgbuf);
if(pkt->info.enable_priority) { if(pkt->info.enable_priority) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1236)); myswprintf(msgbuf, L"* % ls\n", dataManager.GetSysString(1236));
str.append(msgbuf); str.append(msgbuf);
} }
str.append(L"==========\n"); str.append(L" == == == == == \n");
myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1231), pkt->info.start_lp); myswprintf(msgbuf, L" % ls % d\n", dataManager.GetSysString(1231), pkt->info.start_lp);
str.append(msgbuf); str.append(msgbuf);
myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1232), pkt->info.start_hand); myswprintf(msgbuf, L" % ls % d\n", dataManager.GetSysString(1232), pkt->info.start_hand);
str.append(msgbuf); str.append(msgbuf);
myswprintf(msgbuf, L"%ls%d\n", dataManager.GetSysString(1233), pkt->info.draw_count); myswprintf(msgbuf, L" % ls % d\n", dataManager.GetSysString(1233), pkt->info.draw_count);
str.append(msgbuf); str.append(msgbuf);
if(pkt->info.no_check_deck) { if(pkt->info.no_check_deck) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1229)); myswprintf(msgbuf, L"* % ls\n", dataManager.GetSysString(1229));
str.append(msgbuf); str.append(msgbuf);
} }
if(pkt->info.no_shuffle_deck) { if(pkt->info.no_shuffle_deck) {
myswprintf(msgbuf, L"*%ls\n", dataManager.GetSysString(1230)); myswprintf(msgbuf, L"* % ls\n", dataManager.GetSysString(1230));
str.append(msgbuf); str.append(msgbuf);
} }
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
...@@ -248,6 +263,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -248,6 +263,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->wCardImg->setVisible(true); mainGame->wCardImg->setVisible(true);
mainGame->wInfos->setVisible(true); mainGame->wInfos->setVisible(true);
mainGame->device->setEventReceiver(&mainGame->dField);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
} }
...@@ -289,7 +305,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -289,7 +305,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} else if(state == PLAYERCHANGE_OBSERVE) { } else if(state == PLAYERCHANGE_OBSERVE) {
watching++; watching++;
wchar_t watchbuf[32]; wchar_t watchbuf[32];
myswprintf(watchbuf, L"%ls %d", dataManager.GetSysString(1253), watching); myswprintf(watchbuf, L" % ls % d", dataManager.GetSysString(1253), watching);
mainGame->stHostSingleDuelist[pos]->setText(L""); mainGame->stHostSingleDuelist[pos]->setText(L"");
mainGame->chkHostSingleReady[pos]->setChecked(false); mainGame->chkHostSingleReady[pos]->setChecked(false);
mainGame->stHostSingleOB->setText(watchbuf); mainGame->stHostSingleOB->setText(watchbuf);
...@@ -301,13 +317,1915 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -301,13 +317,1915 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
STOC_HS_WatchChange* pkt = (STOC_HS_WatchChange*)pdata; STOC_HS_WatchChange* pkt = (STOC_HS_WatchChange*)pdata;
watching = pkt->watch_count; watching = pkt->watch_count;
wchar_t watchbuf[32]; wchar_t watchbuf[32];
myswprintf(watchbuf, L"%ls %d", dataManager.GetSysString(1253), watching); myswprintf(watchbuf, L" % ls % d", dataManager.GetSysString(1253), watching);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->stHostSingleOB->setText(watchbuf); mainGame->stHostSingleOB->setText(watchbuf);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
} }
} }
int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
char* pbuf = msg;
wchar_t textBuffer[256];
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
mainGame->wCmdMenu->setVisible(false);
if(mainGame->dInfo.curMsg != MSG_WAITING && mainGame->dInfo.curMsg != MSG_CARD_SELECTED) {
mainGame->waitFrame = -1;
mainGame->stHintMsg->setVisible(false);
if(mainGame->wCardSelect->isVisible()) {
mainGame->HideElement(mainGame->wCardSelect);
mainGame->WaitFrameSignal(10);
}
}
switch(mainGame->dInfo.curMsg) {
case MSG_RETRY: {
mainGame->stACMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wACMessage, 100);
mainGame->WaitFrameSignal(120);
if(!mainGame->dField.is_replaying) {
pdInfo->isStarted = false;
mainGame->localResponse.Set();
}
return false;
}
case MSG_HINT: {
int type = BufferIO::ReadInt8(pbuf);
int player = BufferIO::ReadInt8(pbuf);
int data = BufferIO::ReadInt32(pbuf);
switch (type) {
case HINT_EVENT: {
myswprintf(pdInfo->strEvent, L" % ls", dataManager.GetDesc(data));
break;
}
case HINT_MESSAGE: {
mainGame->stMessage->setText(dataManager.GetDesc(data));
mainGame->PopupElement(mainGame->wMessage);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
break;
}
case HINT_SELECTMSG: {
mainGame->dInfo.selectHint = data;
break;
}
case HINT_OPSELECTED: {
myswprintf(textBuffer, L"对方选择了:[ % ls]", dataManager.GetDesc(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
break;
}
case HINT_EFFECT: {
mainGame->showcardcode = data;
mainGame->showcarddif = 0;
mainGame->showcard = 1;
mainGame->WaitFrameSignal(30);
break;
}
case HINT_RACE: {
myswprintf(textBuffer, L"对方宣言了:[ % ls]", dataManager.FormatRace(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
break;
}
case HINT_ATTRIB: {
myswprintf(textBuffer, L"对方宣言了:[ % ls]", dataManager.FormatAttribute(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
break;
}
case HINT_CODE: {
myswprintf(textBuffer, L"对方宣言了:[ % ls]", dataManager.GetName(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(data);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
break;
}
case HINT_NUMBER: {
myswprintf(textBuffer, L"对方选择了:[ % d]", data);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
break;
}
case HINT_CARD: {
mainGame->showcardcode = data;
mainGame->showcarddif = 0;
mainGame->showcard = 1;
mainGame->WaitFrameSignal(30);
break;
}
}
break;
}
case MSG_WIN: {
int player = BufferIO::ReadInt8(pbuf);
int type = BufferIO::ReadInt8(pbuf);
if(player == 2)
myswprintf(textBuffer, L"Draw Game.\n原因: % ls", dataManager.GetVictoryString(type));
else if(mainGame->LocalPlayer(player) == 0) {
if(!mainGame->dField.is_replaying) {
if(type == 1 || type == 2)
myswprintf(textBuffer, L"You Win!\n原因: % ls % ls", mainGame->LocalName(1), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"You Win!\n原因: % ls", dataManager.GetVictoryString(type));
} else {
if(type == 1 || type == 2)
myswprintf(textBuffer, L" % ls Win!\n原因: % ls % ls", mainGame->LocalName(0), mainGame->LocalName(1), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L" % ls Win!\n原因: % ls", mainGame->LocalName(0), dataManager.GetVictoryString(type));
}
} else {
if(!mainGame->dField.is_replaying) {
if(type == 1 || type == 2)
myswprintf(textBuffer, L"You Lose!\n原因: % ls % ls", mainGame->LocalName(0), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L"You Lose!\n原因: % ls", dataManager.GetVictoryString(type));
} else {
if(type == 1 || type == 2)
myswprintf(textBuffer, L" % ls Win!\n原因: % ls % ls", mainGame->LocalName(1), mainGame->LocalName(0), dataManager.GetVictoryString(type));
else myswprintf(textBuffer, L" % ls Win!\n原因: % ls", mainGame->LocalName(1), dataManager.GetVictoryString(type));
}
}
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 100);
mainGame->WaitFrameSignal(120);
if(mainGame->dInfo.is_local_host)
mainGame->localResponse.Set();
break;
}
case MSG_DUEL_END: {
pdInfo->isStarted = false;
mainGame->localResponse.Set();
return false;
}
case MSG_REPLAY: {
pbuf -= 3;
int size = BufferIO::ReadInt16(pbuf);
pbuf++;
memcpy(&mainGame->lastReplay.pheader, pbuf, sizeof(ReplayHeader));
pbuf += sizeof(ReplayHeader);
memcpy(mainGame->lastReplay.comp_data, pbuf, size - sizeof(ReplayHeader) - 1);
mainGame->lastReplay.comp_size = size - sizeof(ReplayHeader) - 1;
mainGame->PopupElement(mainGame->wReplaySave);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
break;
}
case MSG_WAITING: {
mainGame->waitFrame = 0;
mainGame->gMutex.Lock();
mainGame->stHintMsg->setText(L"等待对方行动中...");
mainGame->stHintMsg->setVisible(true);
mainGame->gMutex.Unlock();
return true;
}
case MSG_START: {
mainGame->gMutex.Lock();
pdInfo->is_first_turn = BufferIO::ReadInt32(pbuf) ? false : true;
pdInfo->lp[mainGame->LocalPlayer(0)] = BufferIO::ReadInt32(pbuf);
pdInfo->lp[mainGame->LocalPlayer(1)] = BufferIO::ReadInt32(pbuf);
myswprintf(pdInfo->strLP[0], L" % d", pdInfo->lp[0]);
myswprintf(pdInfo->strLP[1], L" % d", pdInfo->lp[1]);
int deckc = BufferIO::ReadInt32(pbuf);
int extrac = BufferIO::ReadInt32(pbuf);
mainGame->dField.Initial(mainGame->LocalPlayer(0), deckc, extrac);
deckc = BufferIO::ReadInt32(pbuf);
extrac = BufferIO::ReadInt32(pbuf);
mainGame->dField.Initial(mainGame->LocalPlayer(1), deckc, extrac);
pdInfo->turn = 0;
pdInfo->strTurn[0] = 0;
pdInfo->is_shuffling = false;
mainGame->gMutex.Unlock();
return true;
}
case MSG_UPDATE_DATA: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int location = BufferIO::ReadInt8(pbuf);
mainGame->gMutex.Lock();
mainGame->dField.UpdateFieldCard(player, location, pbuf);
mainGame->gMutex.Unlock();
if (location == LOCATION_HAND && pdInfo->is_shuffling) {
pdInfo->is_shuffling = false;
for(int i = 0; i < mainGame->dField.hand[0].size(); ++i) {
mainGame->dField.hand[0][i]->is_hovered = false;
mainGame->dField.MoveCard(mainGame->dField.hand[0][i], 5);
}
mainGame->WaitFrameSignal(5);
}
return true;
}
case MSG_UPDATE_CARD: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int loc = BufferIO::ReadInt8(pbuf);
int seq = BufferIO::ReadInt8(pbuf);
mainGame->gMutex.Lock();
mainGame->dField.UpdateCard(player, loc, seq, pbuf);
mainGame->gMutex.Unlock();
break;
}
case MSG_SELECT_BATTLECMD: {
int selecting_player = BufferIO::ReadInt8(pbuf);
int code, desc, count, con, loc, seq, diratt;
ClientCard* pcard;
mainGame->dField.activatable_cards.clear();
mainGame->dField.activatable_descs.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
desc = BufferIO::ReadInt32(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.activatable_cards.push_back(pcard);
mainGame->dField.activatable_descs.push_back(desc);
pcard->cmdFlag |= COMMAND_ACTIVATE;
if (pcard->location == LOCATION_GRAVE)
mainGame->dField.grave_act = true;
if (pcard->location == LOCATION_REMOVED)
mainGame->dField.remove_act = true;
}
mainGame->dField.attackable_cards.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
diratt = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.attackable_cards.push_back(pcard);
pcard->cmdFlag |= COMMAND_ATTACK;
}
mainGame->gMutex.Lock();
if(BufferIO::ReadInt8(pbuf)) {
mainGame->btnM2->setVisible(true);
mainGame->btnM2->setEnabled(true);
mainGame->btnM2->setPressed(false);
}
if(BufferIO::ReadInt8(pbuf)) {
mainGame->btnEP->setVisible(true);
mainGame->btnEP->setEnabled(true);
mainGame->btnEP->setPressed(false);
}
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearCommandFlag();
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_IDLECMD: {
int selecting_player = BufferIO::ReadInt8(pbuf);
int code, desc, count, con, loc, seq;
ClientCard* pcard;
mainGame->dField.summonable_cards.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.summonable_cards.push_back(pcard);
pcard->cmdFlag |= COMMAND_SUMMON;
}
mainGame->dField.spsummonable_cards.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.spsummonable_cards.push_back(pcard);
pcard->cmdFlag |= COMMAND_SPSUMMON;
if (pcard->location == LOCATION_DECK) {
pcard->SetCode(code);
mainGame->dField.deck_act = true;
}
if (pcard->location == LOCATION_GRAVE)
mainGame->dField.grave_act = true;
if (pcard->location == LOCATION_REMOVED)
mainGame->dField.remove_act = true;
if (pcard->location == LOCATION_EXTRA)
mainGame->dField.extra_act = true;
}
mainGame->dField.reposable_cards.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.reposable_cards.push_back(pcard);
pcard->cmdFlag |= COMMAND_REPOS;
}
mainGame->dField.msetable_cards.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.msetable_cards.push_back(pcard);
pcard->cmdFlag |= COMMAND_MSET;
}
mainGame->dField.ssetable_cards.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.ssetable_cards.push_back(pcard);
pcard->cmdFlag |= COMMAND_SSET;
}
mainGame->dField.activatable_cards.clear();
mainGame->dField.activatable_descs.clear();
count = BufferIO::ReadInt8(pbuf);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
con = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
loc = BufferIO::ReadInt8(pbuf);
seq = BufferIO::ReadInt8(pbuf);
desc = BufferIO::ReadInt32(pbuf);
pcard = mainGame->dField.GetCard(con, loc, seq);
mainGame->dField.activatable_cards.push_back(pcard);
mainGame->dField.activatable_descs.push_back(desc);
pcard->cmdFlag |= COMMAND_ACTIVATE;
if (pcard->location == LOCATION_GRAVE)
mainGame->dField.grave_act = true;
if (pcard->location == LOCATION_REMOVED)
mainGame->dField.remove_act = true;
}
if(BufferIO::ReadInt8(pbuf)) {
mainGame->btnBP->setVisible(true);
mainGame->btnBP->setEnabled(true);
mainGame->btnBP->setPressed(false);
}
if(BufferIO::ReadInt8(pbuf)) {
mainGame->btnEP->setVisible(true);
mainGame->btnEP->setEnabled(true);
mainGame->btnEP->setPressed(false);
}
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearCommandFlag();
mainGame->btnBP->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_EFFECTYN: {
int selecting_player = BufferIO::ReadInt8(pbuf);
int code = BufferIO::ReadInt32(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(c, l, s);
if (pcard->code != code)
pcard->SetCode(code);
BufferIO::ReadInt8(pbuf);
myswprintf(textBuffer, L"是否在[ % ls]发动[ % ls]的效果?", dataManager.FormatLocation(l), dataManager.GetName(code));
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_YESNO: {
int selecting_player = BufferIO::ReadInt8(pbuf);
int desc = BufferIO::ReadInt32(pbuf);
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(desc));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_OPTION: {
int selecting_player = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_options.clear();
for (int i = 0; i < count; ++i)
mainGame->dField.select_options.push_back(BufferIO::ReadInt32(pbuf));
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stOptions, 310, mainGame->textFont,
(wchar_t*)dataManager.GetDesc(mainGame->dField.select_options[0]));
mainGame->btnOptionp->setVisible(false);
if(count > 1)
mainGame->btnOptionn->setVisible(true);
else mainGame->btnOptionn->setVisible(false);
mainGame->dField.selected_option = 0;
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
else myswprintf(textBuffer, L"请选择一个选项:");
mainGame->dInfo.selectHint = 0;
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_CARD: {
int selecting_player = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_cards.clear();
mainGame->dField.selected_cards.clear();
int c, l, s, ss, code;
bool panelmode = false;
mainGame->dField.select_ready = false;
ClientCard* pcard;
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
ss = BufferIO::ReadInt8(pbuf);
if ((l & LOCATION_OVERLAY) > 0)
pcard = mainGame->dField.GetCard(c, l & 0x7f, s)->overlayed[ss];
else
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->select_seq = i;
mainGame->dField.selectable_cards.push_back(pcard);
pcard->is_selectable = true;
pcard->is_selected = false;
if (l & 0xf1)
panelmode = true;
}
std::sort(mainGame->dField.selectable_cards.begin(), mainGame->dField.selectable_cards.end(), ClientCard::client_card_sort);
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls( % d - % d)", dataManager.GetDesc(mainGame->dInfo.selectHint),
mainGame->dField.select_min, mainGame->dField.select_max);
else myswprintf(textBuffer, L"请选择卡:( % d - % d)", mainGame->dField.select_min, mainGame->dField.select_max);
mainGame->dInfo.selectHint = 0;
if (panelmode) {
mainGame->gMutex.Lock();
mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard();
mainGame->gMutex.Unlock();
} else {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
}
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_CHAIN: {
int selecting_player = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
int specount = BufferIO::ReadInt8(pbuf);
int hint0 = BufferIO::ReadInt32(pbuf);
int hint1 = BufferIO::ReadInt32(pbuf);
int c, l, s, code, desc;
ClientCard* pcard;
mainGame->dField.activatable_cards.clear();
mainGame->dField.activatable_descs.clear();
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
desc = BufferIO::ReadInt32(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
mainGame->dField.activatable_cards.push_back(pcard);
mainGame->dField.activatable_descs.push_back(desc);
pcard->is_selectable = true;
pcard->is_selected = false;
pcard->cmdFlag |= COMMAND_ACTIVATE;
if (pcard->location == LOCATION_GRAVE)
mainGame->dField.grave_act = true;
if (pcard->location == LOCATION_REMOVED)
mainGame->dField.remove_act = true;
}
if(mainGame->ignore_chain || ((count == 0 || specount == 0) && !mainGame->always_chain)) {
mainGame->dInfo.responseI = -1;
mainGame->SetResponseI();
mainGame->dField.ClearChainSelect();
if(mainGame->chkWaitChain->isChecked()) {
mainGame->WaitFrameSignal(mainGame->rnd.real() * 20 + 20);
}
mainGame->localResponse.Set();
return true;
}
mainGame->gMutex.Lock();
if(count == 0)
myswprintf(textBuffer, L"此时没有可以发动的效果\n是否要确认场上的情况?");
else
myswprintf(textBuffer, L" % ls\n是否进行连锁?", pdInfo->strEvent);
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)textBuffer);
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearChainSelect();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_PLACE:
case MSG_SELECT_DISFIELD: {
int selecting_player = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_field = ~BufferIO::ReadInt32(pbuf);
mainGame->dField.selected_field = 0;
if (mainGame->dInfo.curMsg == MSG_SELECT_PLACE && mainGame->chkAutoPos->isChecked()) {
int filter;
if (mainGame->dField.selectable_field & 0x1f) {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 0 : 1;
mainGame->dInfo.responseB[1] = 0x4;
filter = mainGame->dField.selectable_field & 0x1f;
} else if (mainGame->dField.selectable_field & 0x1f00) {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 0 : 1;
mainGame->dInfo.responseB[1] = 0x8;
filter = (mainGame->dField.selectable_field >> 8) & 0x1f;
} else if (mainGame->dField.selectable_field & 0x1f0000) {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 1 : 0;
mainGame->dInfo.responseB[1] = 0x4;
filter = (mainGame->dField.selectable_field >> 16) & 0x1f;
} else {
mainGame->dInfo.responseB[0] = mainGame->dInfo.is_first_turn ? 1 : 0;
mainGame->dInfo.responseB[1] = 0x8;
filter = (mainGame->dField.selectable_field >> 24) & 0x1f;
}
if(mainGame->chkRandomPos->isChecked()) {
mainGame->dInfo.responseB[2] = mainGame->rnd.real() * 5;
while(!(filter & (1 << mainGame->dInfo.responseB[2])))
mainGame->dInfo.responseB[2] = mainGame->rnd.real() * 5;
} else {
if (filter & 0x4) mainGame->dInfo.responseB[2] = 2;
else if (filter & 0x2) mainGame->dInfo.responseB[2] = 1;
else if (filter & 0x8) mainGame->dInfo.responseB[2] = 3;
else if (filter & 0x1) mainGame->dInfo.responseB[2] = 0;
else if (filter & 0x10) mainGame->dInfo.responseB[2] = 4;
}
mainGame->dField.selectable_field = 0;
mainGame->SetResponseB(3);
mainGame->localResponse.Set();
return true;
}
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_POSITION: {
int selecting_player = BufferIO::ReadInt8(pbuf);
int code = BufferIO::ReadInt32(pbuf);
int positions = BufferIO::ReadInt8(pbuf);
if (positions == 0x1 || positions == 0x2 || positions == 0x4 || positions == 0x8) {
mainGame->dInfo.responseI = positions;
mainGame->SetResponseI();
return true;
}
int count = 0, filter = 0x1, startpos;
while(filter != 0x10) {
if(positions & filter) count++;
filter <<= 1;
}
if(count == 4) startpos = 10;
else if(count == 3) startpos = 82;
else startpos = 155;
if(positions & 0x1) {
mainGame->imageLoading.insert(std::make_pair(mainGame->btnPSAU, code));
mainGame->btnPSAU->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSAU->setVisible(true);
startpos += 145;
} else mainGame->btnPSAU->setVisible(false);
if(positions & 0x2) {
mainGame->btnPSAD->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSAD->setVisible(true);
startpos += 145;
} else mainGame->btnPSAD->setVisible(false);
if(positions & 0x4) {
mainGame->imageLoading.insert(std::make_pair(mainGame->btnPSDU, code));
mainGame->btnPSDU->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSDU->setVisible(true);
startpos += 145;
} else mainGame->btnPSDU->setVisible(false);
if(positions & 0x8) {
mainGame->btnPSDD->setRelativePosition(rect<s32>(startpos, 45, startpos + 140, 185));
mainGame->btnPSDD->setVisible(true);
startpos += 145;
} else mainGame->btnPSDD->setVisible(false);
mainGame->PopupElement(mainGame->wPosSelect);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_TRIBUTE: {
int selecting_player = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_cancelable = BufferIO::ReadInt8(pbuf) ? true : false;
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_cards.clear();
mainGame->dField.selected_cards.clear();
int c, l, s, t, code;
ClientCard* pcard;
mainGame->dField.select_ready = false;
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
t = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
if (code && pcard->code != code)
pcard->SetCode(code);
mainGame->dField.selectable_cards.push_back(pcard);
pcard->opParam = t;
pcard->select_seq = i;
pcard->is_selectable = true;
}
mainGame->stHintMsg->setText(L"请选择上级召唤用需要解放的怪兽:");
mainGame->stHintMsg->setVisible(false);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_COUNTER: {
int selecting_player = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_counter_type = BufferIO::ReadInt16(pbuf);
mainGame->dField.select_counter_count = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_cards.clear();
int c, l, s, t, code;
ClientCard* pcard;
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
t = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
mainGame->dField.selectable_cards.push_back(pcard);
pcard->opParam = t;
pcard->select_seq = i;
pcard->is_selectable = true;
mainGame->dInfo.responseB[i] = 0;
}
myswprintf(textBuffer, L"请移除 % d个[ % ls]: ", mainGame->dField.select_counter_count, dataManager.GetCounterName(mainGame->dField.select_counter_type));
mainGame->gMutex.Lock();
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
return true;
}
case MSG_SELECT_SUM: {
mainGame->dField.select_mode = BufferIO::ReadInt8(pbuf);
int selecting_player = BufferIO::ReadInt8(pbuf);
mainGame->dField.select_max = BufferIO::ReadInt32(pbuf);
mainGame->dField.select_min = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectsum_all.clear();
mainGame->dField.selected_cards.clear();
mainGame->dField.selectsum_cards.clear();
int c, l, s, code;
bool panelmode = false;
ClientCard* pcard;
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->opParam = BufferIO::ReadInt32(pbuf);
pcard->select_seq = i;
mainGame->dField.selectsum_all.push_back(pcard);
if ((l & 0xe) == 0)
panelmode = true;
}
std::sort(mainGame->dField.selectsum_all.begin(), mainGame->dField.selectsum_all.end(), ClientCard::client_card_sort);
mainGame->dField.CheckSelectSum();
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L"
% ls( % d)", dataManager.GetDesc(mainGame->dInfo.selectHint), mainGame->dField.select_max);
else myswprintf(textBuffer, L"请选择卡:( % d)", mainGame->dField.select_max);
mainGame->dInfo.selectHint = 0;
if (panelmode) {
mainGame->wCardSelect->setText(textBuffer);
mainGame->dField.ShowSelectCard();
} else {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
}
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->dField.ClearSelect();
mainGame->localResponse.Set();
return true;
}
case MSG_SORT_CARD:
case MSG_SORT_CHAIN: {
int player = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
mainGame->dField.selectable_cards.clear();
mainGame->dField.selected_cards.clear();
mainGame->dField.sort_list.clear();
int c, l, s, code;
ClientCard* pcard;
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
mainGame->dField.selectable_cards.push_back(pcard);
pcard->select_seq = i;
mainGame->dField.sort_list.push_back(0);
}
if (mainGame->chkAutoChain->isChecked() && pdInfo->curMsg == MSG_SORT_CHAIN) {
mainGame->dInfo.responseI = -1;
mainGame->SetResponseI();
mainGame->localResponse.Set();
return true;
}
if(pdInfo->curMsg == MSG_SORT_CHAIN)
mainGame->wCardSelect->setText(L"请选择连锁顺序:");
else
mainGame->wCardSelect->setText(L"请选择排列顺序:");
mainGame->dField.select_min = 0;
mainGame->dField.select_max = count;
mainGame->dField.ShowSelectCard();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_CONFIRM_DECKTOP: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
int code, c, l, s;
ClientCard* pcard;
myswprintf(textBuffer, L"翻开卡组上方 % d张卡:", count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->dField.selectable_cards.clear();
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0)
pcard->SetCode(code);
myswprintf(textBuffer, L" % d [ % ls]", i, dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
float shift = -0.15f;
if (player == 1) shift = 0.15f;
pcard->dPos = irr::core::vector3df(shift, 0, 0);
pcard->dRot = irr::core::vector3df(0, 3.14159f / 5.0f, 0);
pcard->is_moving = true;
pcard->aniFrame = 5;
mainGame->WaitFrameSignal(45);
mainGame->dField.MoveCard(pcard, 5);
mainGame->WaitFrameSignal(5);
}
return true;
}
case MSG_CONFIRM_CARDS: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
int code, c, l, s;
std::vector<ClientCard*> field_confirm;
ClientCard* pcard;
myswprintf(textBuffer, L"确认 % d张卡:", count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
if (code != 0)
pcard->SetCode(code);
myswprintf(textBuffer, L" % d [ % ls]", i, dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
if (l & 0x41) {
float shift = -0.15f;
if ((c == 0 && l == 0x40) || (c == 1 && l == 0x1)) shift = 0.15f;
pcard->dPos = irr::core::vector3df(shift, 0, 0);
pcard->dRot = irr::core::vector3df(0, 3.14159f / 5.0f, 0);
pcard->is_moving = true;
pcard->aniFrame = 5;
mainGame->WaitFrameSignal(45);
mainGame->dField.MoveCard(pcard, 5);
mainGame->WaitFrameSignal(5);
} else
field_confirm.push_back(pcard);
}
if (field_confirm.size() > 0) {
for(int i = 0; i < field_confirm.size(); ++i) {
pcard = field_confirm[i];
c = pcard->controler;
l = pcard->location;
if (l == LOCATION_HAND) {
mainGame->dField.MoveCard(pcard, 5);
} else if (l == LOCATION_MZONE) {
if (pcard->position & POS_FACEUP)
continue;
pcard->dPos = irr::core::vector3df(0, 0, 0);
if (pcard->position == POS_FACEDOWN_ATTACK)
pcard->dRot = irr::core::vector3df(0, 3.14159f / 5.0f, 0);
else
pcard->dRot = irr::core::vector3df(3.14159f / 5.0f, 0, 0);
pcard->is_moving = true;
pcard->aniFrame = 5;
} else if (l == LOCATION_SZONE) {
if (pcard->position & POS_FACEUP)
continue;
pcard->dPos = irr::core::vector3df(0, 0, 0);
pcard->dRot = irr::core::vector3df(0, 3.14159f / 5.0f, 0);
pcard->is_moving = true;
pcard->aniFrame = 5;
}
}
mainGame->WaitFrameSignal(45);
for(int i = 0; i < field_confirm.size(); ++i) {
if (pcard->location != LOCATION_HAND)
mainGame->dField.MoveCard(pcard, 5);
}
mainGame->WaitFrameSignal(5);
}
return true;
}
case MSG_SHUFFLE_DECK: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
std::vector<ClientCard*>::iterator cit;
for (int i = 0; i < mainGame->dField.deck[player].size(); ++i)
mainGame->dField.deck[player][i]->code = 0;
for (int i = 0; i < 5; ++i) {
for (cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) {
(*cit)->dPos = irr::core::vector3df(rand() * 0.4f / RAND_MAX - 0.2f, 0, 0);
(*cit)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true;
(*cit)->aniFrame = 3;
}
mainGame->WaitFrameSignal(3);
for (cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit)
mainGame->dField.MoveCard(*cit, 3);
mainGame->WaitFrameSignal(3);
}
return true;
}
case MSG_SHUFFLE_HAND: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
std::vector<ClientCard*>::iterator cit;
mainGame->WaitFrameSignal(5);
if(player == 1) {
bool flip = false;
for (cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit)
if((*cit)->code) {
(*cit)->dPos = irr::core::vector3df(0, 0, 0);
(*cit)->dRot = irr::core::vector3df(1.322f / 5, 3.1415926f / 5, 0);
(*cit)->is_moving = true;
(*cit)->is_hovered = false;
(*cit)->aniFrame = 5;
flip = true;
}
if(flip)
mainGame->WaitFrameSignal(5);
}
for (cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit) {
(*cit)->dPos = irr::core::vector3df((3.9f - (*cit)->curPos.X) / 5, 0, 0);
(*cit)->dRot = irr::core::vector3df(0, 0, 0);
(*cit)->is_moving = true;
(*cit)->is_hovered = false;
(*cit)->aniFrame = 5;
}
mainGame->WaitFrameSignal(20);
for (cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit)
(*cit)->SetCode(0);
if (player == 0)
mainGame->dInfo.is_shuffling = true;
else {
for (cit = mainGame->dField.hand[player].begin(); cit != mainGame->dField.hand[player].end(); ++cit) {
(*cit)->is_hovered = false;
mainGame->dField.MoveCard(*cit, 5);
}
mainGame->WaitFrameSignal(5);
}
return true;
}
case MSG_REFRESH_DECK: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
return true;
}
case MSG_SWAP_GRAVE_DECK: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
std::vector<ClientCard*>::iterator cit;
mainGame->gMutex.Lock();
mainGame->dField.grave[player].swap(mainGame->dField.deck[player]);
for (cit = mainGame->dField.grave[player].begin(); cit != mainGame->dField.grave[player].end(); ++cit) {
(*cit)->location = LOCATION_GRAVE;
mainGame->dField.MoveCard(*cit, 10);
}
for (cit = mainGame->dField.deck[player].begin(); cit != mainGame->dField.deck[player].end(); ++cit) {
(*cit)->location = LOCATION_DECK;
mainGame->dField.MoveCard(*cit, 10);
}
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(10);
return true;
}
case MSG_SHUFFLE_SET_CARD: {
std::vector<ClientCard*>::iterator cit;
int count = BufferIO::ReadInt8(pbuf);
ClientCard* mc[5];
ClientCard* swp;
int c, l, s, ps;
for (int i = 0; i < count; ++i) {
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
mc[i] = mainGame->dField.mzone[c][s];
mc[i]->dPos = irr::core::vector3df((3.95f - mc[i]->curPos.X) / 10, 0, 0.05f);
mc[i]->dRot = irr::core::vector3df(0, 0, 0);
mc[i]->is_moving = true;
mc[i]->aniFrame = 10;
}
mainGame->WaitFrameSignal(20);
for (int i = 0; i < count; ++i) {
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
l = BufferIO::ReadInt8(pbuf);
s = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
ps = mc[i]->sequence;
if (l > 0) {
swp = mainGame->dField.mzone[c][s];
mainGame->dField.mzone[c][ps] = swp;
mainGame->dField.mzone[c][s] = mc[i];
mc[i]->sequence = s;
swp->sequence = ps;
}
}
for (int i = 0; i < count; ++i) {
mainGame->dField.MoveCard(mc[i], 10);
for (cit = mc[i]->overlayed.begin(); cit != mc[i]->overlayed.end(); ++cit)
mainGame->dField.MoveCard(*cit, 10);
}
mainGame->WaitFrameSignal(10);
return true;
}
case MSG_NEW_TURN: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->dInfo.turn++;
myswprintf(mainGame->dInfo.strTurn, L"Turn:
% d", mainGame->dInfo.turn);
myswprintf(textBuffer, L" % ls的回合", mainGame->LocalName(player));
mainGame->gMutex.Lock();
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(40);
return true;
}
case MSG_NEW_PHASE: {
int phase = (unsigned char)BufferIO::ReadInt8(pbuf);
mainGame->gMutex.Lock();
mainGame->btnDP->setVisible(false);
mainGame->btnSP->setVisible(false);
mainGame->btnM1->setVisible(false);
mainGame->btnBP->setVisible(false);
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
switch (phase) {
case PHASE_DRAW:
mainGame->btnDP->setVisible(true);
myswprintf(textBuffer, L"进入【抽卡阶段】");
break;
case PHASE_STANDBY:
mainGame->btnSP->setVisible(true);
myswprintf(textBuffer, L"进入【准备阶段】");
break;
case PHASE_MAIN1:
mainGame->btnM1->setVisible(true);
myswprintf(textBuffer, L"进入【主要阶段1】");
break;
case PHASE_BATTLE:
mainGame->btnBP->setVisible(true);
mainGame->btnBP->setPressed(true);
mainGame->btnBP->setEnabled(false);
myswprintf(textBuffer, L"进入【战斗阶段】");
break;
case PHASE_MAIN2:
mainGame->btnM2->setVisible(true);
mainGame->btnM2->setPressed(true);
mainGame->btnM2->setEnabled(false);
myswprintf(textBuffer, L"进入【主要阶段2】");
break;
case PHASE_END:
mainGame->btnEP->setVisible(true);
mainGame->btnEP->setPressed(true);
mainGame->btnEP->setEnabled(false);
myswprintf(textBuffer, L"进入【结束阶段】");
break;
}
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(40);
return true;
}
case MSG_MOVE: {
int code = BufferIO::ReadInt32(pbuf);
int pc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int pl = BufferIO::ReadUInt8(pbuf);
int ps = BufferIO::ReadInt8(pbuf);
int pp = BufferIO::ReadInt8(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadUInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
int reason = BufferIO::ReadInt32(pbuf);
if (pl == 0) {
ClientCard* pcard = new ClientCard();
pcard->position = cp;
pcard->SetCode(code);
mainGame->gMutex.Lock();
mainGame->dField.AddCard(pcard, cc, cl, cs);
mainGame->gMutex.Unlock();
mainGame->dField.GetCardLocation(pcard, &pcard->curPos, &pcard->curRot);
pcard->mTransform.setTranslation(pcard->curPos);
pcard->mTransform.setRotationRadians(pcard->curRot);
pcard->curAlpha = 5;
mainGame->dField.FadeCard(pcard, 255, 20);
mainGame->WaitFrameSignal(20);
} else if (cl == 0) {
ClientCard* pcard = mainGame->dField.GetCard(pc, pl, ps);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->ClearTarget();
mainGame->dField.FadeCard(pcard, 5, 20);
mainGame->WaitFrameSignal(20);
mainGame->gMutex.Lock();
mainGame->dField.RemoveCard(pc, pl, ps);
mainGame->gMutex.Unlock();
if(pcard == mainGame->dField.hovered_card)
mainGame->dField.hovered_card = 0;
delete pcard;
} else {
if (!(pl & 0x80) && !(cl & 0x80)) {
ClientCard* pcard = mainGame->dField.GetCard(pc, pl, ps);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
if((pl & LOCATION_ONFIELD) && (cl != pl))
pcard->counters.clear();
if(cl != pl)
pcard->ClearTarget();
mainGame->gMutex.Lock();
mainGame->dField.RemoveCard(pc, pl, ps);
pcard->position = cp;
mainGame->dField.AddCard(pcard, cc, cl, cs);
mainGame->gMutex.Unlock();
if (pl == cl && pc == cc && (cl & 0x71)) {
pcard->dPos = irr::core::vector3df(-0.2f, 0, 0);
pcard->dRot = irr::core::vector3df(0, 0, 0);
if (pc == 1) pcard->dPos.X = 0.2f;
pcard->is_moving = true;
pcard->aniFrame = 5;
mainGame->WaitFrameSignal(5);
mainGame->dField.MoveCard(pcard, 5);
mainGame->WaitFrameSignal(5);
} else {
if (cl == 0x4 && pcard->overlayed.size() > 0) {
mainGame->gMutex.Lock();
for (int i = 0; i < pcard->overlayed.size(); ++i)
mainGame->dField.MoveCard(pcard->overlayed[i], 10);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(5);
}
if (cl == 0x2) {
mainGame->gMutex.Lock();
for (int i = 0; i < mainGame->dField.hand[cc].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[cc][i], 10);
mainGame->gMutex.Unlock();
} else {
mainGame->gMutex.Lock();
mainGame->dField.MoveCard(pcard, 10);
if (pl == 0x2)
for (int i = 0; i < mainGame->dField.hand[pc].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[pc][i], 10);
mainGame->gMutex.Unlock();
}
mainGame->WaitFrameSignal(5);
}
} else if (!(pl & 0x80)) {
ClientCard* pcard = mainGame->dField.GetCard(pc, pl, ps);
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
if((pl & LOCATION_ONFIELD) && (cl != pl))
pcard->counters.clear();
if(cl != pl)
pcard->ClearTarget();
ClientCard* olcard = mainGame->dField.GetCard(cc, cl & 0x7f, cs);
mainGame->gMutex.Lock();
mainGame->dField.RemoveCard(pc, pl, ps);
olcard->overlayed.push_back(pcard);
mainGame->dField.overlay_cards.insert(pcard);
mainGame->gMutex.Unlock();
pcard->overlayTarget = olcard;
pcard->location = 0x80;
pcard->sequence = olcard->overlayed.size() - 1;
if (olcard->location == 0x4) {
mainGame->gMutex.Lock();
mainGame->dField.MoveCard(pcard, 10);
if (pl == 0x2)
for (int i = 0; i < mainGame->dField.hand[pc].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[pc][i], 10);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(5);
}
} else if (!(cl & 0x80)) {
ClientCard* olcard = mainGame->dField.GetCard(pc, pl & 0x7f, ps);
ClientCard* pcard = olcard->overlayed[pp];
mainGame->gMutex.Lock();
olcard->overlayed.erase(olcard->overlayed.begin() + pcard->sequence);
pcard->overlayTarget = 0;
pcard->position = cp;
mainGame->dField.AddCard(pcard, cc, cl, cs);
mainGame->dField.overlay_cards.erase(pcard);
for (int i = 0; i < olcard->overlayed.size(); ++i) {
olcard->overlayed[i]->sequence = i;
mainGame->dField.MoveCard(olcard->overlayed[i], 2);
}
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(5);
mainGame->gMutex.Lock();
mainGame->dField.MoveCard(pcard, 10);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(5);
} else {
ClientCard* olcard1 = mainGame->dField.GetCard(pc, pl & 0x7f, ps);
ClientCard* pcard = olcard1->overlayed[pp];
ClientCard* olcard2 = mainGame->dField.GetCard(cc, cl & 0x7f, cs);
mainGame->gMutex.Lock();
olcard1->overlayed.erase(olcard1->overlayed.begin() + pcard->sequence);
olcard2->overlayed.push_back(pcard);
pcard->sequence = olcard2->overlayed.size() - 1;
pcard->location = 0x80;
pcard->overlayTarget = olcard2;
for (int i = 0; i < olcard1->overlayed.size(); ++i) {
olcard1->overlayed[i]->sequence = i;
mainGame->dField.MoveCard(olcard1->overlayed[i], 2);
}
mainGame->dField.MoveCard(pcard, 10);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(5);
}
}
return true;
}
case MSG_POS_CHANGE: {
int code = BufferIO::ReadInt32(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int pp = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(cc, cl, cs);
if((pp & POS_FACEUP) && (cp & POS_FACEDOWN)) {
pcard->counters.clear();
pcard->ClearTarget();
}
if (code != 0 && pcard->code != code)
pcard->SetCode(code);
pcard->position = cp;
myswprintf(pdInfo->strEvent, L"卡片改变了表示形式");
mainGame->dField.MoveCard(pcard, 10);
mainGame->WaitFrameSignal(10);
return true;
}
case MSG_SET: {
int code = BufferIO::ReadInt32(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"放置了卡片");
return true;
}
case MSG_SWAP: {
int code1 = BufferIO::ReadInt32(pbuf);
int c1 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l1 = BufferIO::ReadInt8(pbuf);
int s1 = BufferIO::ReadInt8(pbuf);
int p1 = BufferIO::ReadInt8(pbuf);
int code2 = BufferIO::ReadInt32(pbuf);
int c2 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l2 = BufferIO::ReadInt8(pbuf);
int s2 = BufferIO::ReadInt8(pbuf);
int p2 = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"卡的控制权改变了");
ClientCard* pc1 = mainGame->dField.GetCard(c1, l1, s1);
ClientCard* pc2 = mainGame->dField.GetCard(c2, l2, s2);
mainGame->gMutex.Lock();
mainGame->dField.RemoveCard(c1, l1, s1);
mainGame->dField.RemoveCard(c2, l2, s2);
mainGame->dField.AddCard(pc1, c2, l2, s2);
mainGame->dField.AddCard(pc2, c1, l1, s1);
mainGame->dField.MoveCard(pc1, 10);
mainGame->dField.MoveCard(pc2, 10);
for (int i = 0; i < pc1->overlayed.size(); ++i)
mainGame->dField.MoveCard(pc1->overlayed[i], 10);
for (int i = 0; i < pc2->overlayed.size(); ++i)
mainGame->dField.MoveCard(pc2->overlayed[i], 10);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(10);
return true;
}
case MSG_FIELD_DISABLED: {
int disabled = BufferIO::ReadInt32(pbuf);
if (!mainGame->dInfo.is_first_turn)
disabled = (disabled >> 16) | (disabled << 16);
mainGame->dField.disabled_field = disabled;
return true;
}
case MSG_SUMMONING: {
int code = BufferIO::ReadInt32(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"[ % ls]召唤中...", dataManager.GetName(code));
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcard = 4;
mainGame->WaitFrameSignal(30);
mainGame->showcard = 0;
mainGame->WaitFrameSignal(10);
return true;
}
case MSG_SUMMONED: {
myswprintf(pdInfo->strEvent, L"怪兽召唤成功");
return true;
}
case MSG_SPSUMMONING: {
int code = BufferIO::ReadInt32(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
myswprintf(pdInfo->strEvent, L"[ % ls]特殊召唤中...", dataManager.GetName(code));
myswprintf(pdInfo->strEvent, L"[ % ls]召唤中...", dataManager.GetName(code));
mainGame->showcardcode = code;
mainGame->showcarddif = 1;
mainGame->showcard = 5;
mainGame->WaitFrameSignal(30);
mainGame->showcard = 0;
mainGame->WaitFrameSignal(10);
return true;
}
case MSG_SPSUMMONED: {
myswprintf(pdInfo->strEvent, L"怪兽特殊召唤成功");
return true;
}
case MSG_FLIPSUMMONING: {
int code = BufferIO::ReadInt32(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int cp = BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(cc, cl, cs);
pcard->SetCode(code);
pcard->position = cp;
myswprintf(pdInfo->strEvent, L"[ % ls]反转召唤中...", dataManager.GetName(code));
mainGame->dField.MoveCard(pcard, 10);
mainGame->WaitFrameSignal(10);
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcard = 4;
mainGame->WaitFrameSignal(30);
mainGame->showcard = 0;
mainGame->WaitFrameSignal(10);
return true;
}
case MSG_FLIPSUMMONED: {
myswprintf(pdInfo->strEvent, L"怪兽反转召唤成功");
return true;
}
case MSG_CHAINING: {
int code = BufferIO::ReadInt32(pbuf);
int pcc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int pcl = BufferIO::ReadInt8(pbuf);
int pcs = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
int cc = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cl = BufferIO::ReadInt8(pbuf);
int cs = BufferIO::ReadInt8(pbuf);
int desc = BufferIO::ReadInt32(pbuf);
int ct = BufferIO::ReadInt8(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(pcc, pcl, pcs);
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcard = 1;
pcard->is_highlighting = true;
mainGame->WaitFrameSignal(30);
pcard->is_highlighting = false;
mainGame->dField.current_chain.chain_card = pcard;
mainGame->dField.current_chain.code = code;
mainGame->dField.current_chain.desc = desc;
mainGame->dField.current_chain.controler = cc;
mainGame->dField.current_chain.location = cl;
mainGame->dField.current_chain.sequence = cs;
mainGame->dField.GetChainLocation(cc, cl, cs, &mainGame->dField.current_chain.chain_pos);
mainGame->dField.current_chain.solved = false;
int chc = 0;
for(int i = 0; i < mainGame->dField.chains.size(); ++i) {
if (cl == 0x10 || cl == 0x20) {
if (mainGame->dField.chains[i].controler == cc && mainGame->dField.chains[i].location == cl)
chc++;
} else {
if (mainGame->dField.chains[i].controler == cc && mainGame->dField.chains[i].location == cl && mainGame->dField.chains[i].sequence == cs)
chc++;
}
}
if(cl == LOCATION_HAND)
mainGame->dField.current_chain.chain_pos.X += 0.35;
else
mainGame->dField.current_chain.chain_pos.Y += chc * 0.25f;
return true;
}
case MSG_CHAINED: {
int ct = BufferIO::ReadInt8(pbuf);
myswprintf(mainGame->dInfo.strEvent, L"[ % ls]的效果发动", dataManager.GetName(mainGame->dField.current_chain.code));
mainGame->gMutex.Lock();
mainGame->dField.chains.push_back(mainGame->dField.current_chain);
mainGame->gMutex.Unlock();
if (ct > 1)
mainGame->WaitFrameSignal(20);
mainGame->dField.last_chain = true;
return true;
}
case MSG_CHAIN_SOLVING: {
int ct = BufferIO::ReadInt8(pbuf);
if (mainGame->dField.chains.size() > 1) {
if (mainGame->dField.last_chain)
mainGame->WaitFrameSignal(10);
for(int i = 0; i < 5; ++i) {
mainGame->dField.chains[ct - 1].solved = false;
mainGame->WaitFrameSignal(3);
mainGame->dField.chains[ct - 1].solved = true;
mainGame->WaitFrameSignal(3);
}
}
mainGame->dField.last_chain = false;
return true;
}
case MSG_CHAIN_SOLVED: {
int ct = BufferIO::ReadInt8(pbuf);
return true;
}
case MSG_CHAIN_END: {
mainGame->dField.chains.clear();
return true;
}
case MSG_CHAIN_INACTIVATED:
case MSG_CHAIN_DISABLED: {
int ct = BufferIO::ReadInt8(pbuf);
mainGame->showcardcode = mainGame->dField.chains[ct - 1].code;
mainGame->showcarddif = 0;
mainGame->showcard = 3;
mainGame->WaitFrameSignal(30);
mainGame->showcard = 0;
return true;
}
case MSG_CARD_SELECTED: {
return true;
}
case MSG_RANDOM_SELECTED: {
int player = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
ClientCard* pcards[10];
for (int i = 0; i < count; ++i) {
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
int ss = BufferIO::ReadInt8(pbuf);
if ((l & 0x80) > 0)
pcards[i] = mainGame->dField.GetCard(c, l & 0x7f, s)->overlayed[ss];
else
pcards[i] = mainGame->dField.GetCard(c, l, s);
pcards[i]->is_highlighting = true;
}
mainGame->WaitFrameSignal(30);
for(int i = 0; i < count; ++i)
pcards[i]->is_highlighting = false;
return true;
}
case MSG_BECOME_TARGET: {
int count = BufferIO::ReadInt8(pbuf);
ClientCard* pcard;
for (int i = 0; i < count; ++i) {
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
int ss = BufferIO::ReadInt8(pbuf);
pcard = mainGame->dField.GetCard(c, l, s);
pcard->is_highlighting = true;
if(pcard->location & LOCATION_ONFIELD) {
for (int j = 0; j < 3; ++j) {
mainGame->dField.FadeCard(pcard, 5, 5);
mainGame->WaitFrameSignal(5);
mainGame->dField.FadeCard(pcard, 255, 5);
mainGame->WaitFrameSignal(5);
}
} else
mainGame->WaitFrameSignal(30);
myswprintf(textBuffer, L"[ % ls]( % ls, % d)成为对象", dataManager.GetName(pcard->code), dataManager.FormatLocation(l), s);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(pcard->code);
pcard->is_highlighting = false;
}
return true;
}
case MSG_DRAW: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
ClientCard* pcard;
for (int i = 0; i < count; ++i) {
int code = BufferIO::ReadInt32(pbuf);
mainGame->gMutex.Lock();
pcard = mainGame->dField.GetCard(player, LOCATION_DECK, mainGame->dField.deck[player].size() - 1);
pcard->SetCode(code);
mainGame->dField.deck[player].erase(mainGame->dField.deck[player].end() - 1);
mainGame->dField.AddCard(pcard, player, LOCATION_HAND, 0);
for(int i = 0; i < mainGame->dField.hand[player].size(); ++i)
mainGame->dField.MoveCard(mainGame->dField.hand[player][i], 10);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(5);
}
if (player == 0)
myswprintf(pdInfo->strEvent, L"我方抽了 % d张卡", count);
else myswprintf(pdInfo->strEvent, L"对手抽了 % d张卡", count);
return true;
}
case MSG_DAMAGE: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int val = BufferIO::ReadInt32(pbuf);
int final = mainGame->dInfo.lp[player] - val;
if (final < 0)
final = 0;
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
if (player == 0)
myswprintf(pdInfo->strEvent, L"我方受到 % d伤害", val);
else
myswprintf(pdInfo->strEvent, L"对方受到 % d伤害", val);
mainGame->lpccolor = 0xffff0000;
mainGame->lpplayer = player;
myswprintf(textBuffer, L" - % d", val);
mainGame->lpcstring = textBuffer;
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(10);
mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock();
myswprintf(mainGame->dInfo.strLP[player], L" % d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock();
return true;
}
case MSG_RECOVER: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int val = BufferIO::ReadInt32(pbuf);
int final = mainGame->dInfo.lp[player] + val;
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
if (player == 0)
myswprintf(pdInfo->strEvent, L"我方回复 % dLP", val);
else
myswprintf(pdInfo->strEvent, L"对方回复 % dLP", val);
mainGame->lpccolor = 0xff00ff00;
mainGame->lpplayer = player;
myswprintf(textBuffer, L" + % d", val);
mainGame->lpcstring = textBuffer;
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(10);
mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock();
myswprintf(mainGame->dInfo.strLP[player], L" % d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock();
return true;
}
case MSG_EQUIP: {
int c1 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l1 = BufferIO::ReadInt8(pbuf);
int s1 = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
int c2 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l2 = BufferIO::ReadInt8(pbuf);
int s2 = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
ClientCard* pc1 = mainGame->dField.GetCard(c1, l1, s1);
ClientCard* pc2 = mainGame->dField.GetCard(c2, l2, s2);
mainGame->gMutex.Lock();
pc1->equipTarget = pc2;
pc2->equipped.insert(pc1);
if (mainGame->dField.hovered_card == pc1)
pc2->is_showequip = true;
else if (mainGame->dField.hovered_card == pc2)
pc1->is_showequip = true;
mainGame->gMutex.Unlock();
return true;
}
case MSG_LPUPDATE: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int val = BufferIO::ReadInt32(pbuf);
mainGame->lpd = (val - mainGame->dInfo.lp[player]) / 10;
mainGame->lpplayer = player;
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(10);
mainGame->dInfo.lp[player] = val;
mainGame->gMutex.Lock();
myswprintf(mainGame->dInfo.strLP[player], L" % d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock();
return true;
}
case MSG_UNEQUIP: {
int c1 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l1 = BufferIO::ReadInt8(pbuf);
int s1 = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
ClientCard* pc = mainGame->dField.GetCard(c1, l1, s1);
mainGame->gMutex.Lock();
if (mainGame->dField.hovered_card == pc)
pc->equipTarget->is_showequip = false;
else if (mainGame->dField.hovered_card == pc->equipTarget)
pc->is_showequip = false;
pc->equipTarget->equipped.erase(pc);
pc->equipTarget = 0;
mainGame->gMutex.Unlock();
return true;
}
case MSG_CARD_TARGET: {
int c1 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l1 = BufferIO::ReadInt8(pbuf);
int s1 = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
int c2 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l2 = BufferIO::ReadInt8(pbuf);
int s2 = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
ClientCard* pc1 = mainGame->dField.GetCard(c1, l1, s1);
ClientCard* pc2 = mainGame->dField.GetCard(c2, l2, s2);
mainGame->gMutex.Lock();
pc1->cardTarget.insert(pc2);
pc2->ownerTarget.insert(pc1);
if (mainGame->dField.hovered_card == pc1)
pc2->is_showtarget = true;
else if (mainGame->dField.hovered_card == pc2)
pc1->is_showtarget = true;
mainGame->gMutex.Unlock();
break;
}
case MSG_CANCEL_TARGET: {
int c1 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l1 = BufferIO::ReadInt8(pbuf);
int s1 = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
int c2 = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l2 = BufferIO::ReadInt8(pbuf);
int s2 = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
ClientCard* pc1 = mainGame->dField.GetCard(c1, l1, s1);
ClientCard* pc2 = mainGame->dField.GetCard(c2, l2, s2);
mainGame->gMutex.Lock();
pc1->cardTarget.erase(pc2);
pc2->ownerTarget.erase(pc1);
if (mainGame->dField.hovered_card == pc1)
pc2->is_showtarget = false;
else if (mainGame->dField.hovered_card == pc2)
pc1->is_showtarget = false;
mainGame->gMutex.Unlock();
break;
}
case MSG_PAY_LPCOST: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int cost = BufferIO::ReadInt32(pbuf);
int final = mainGame->dInfo.lp[player] - cost;
if (final < 0)
final = 0;
mainGame->lpd = (mainGame->dInfo.lp[player] - final) / 10;
mainGame->lpccolor = 0xff0000ff;
mainGame->lpplayer = player;
myswprintf(textBuffer, L" - % d", cost);
mainGame->lpcstring = textBuffer;
mainGame->WaitFrameSignal(30);
mainGame->lpframe = 10;
mainGame->WaitFrameSignal(10);
mainGame->lpcstring = 0;
mainGame->dInfo.lp[player] = final;
mainGame->gMutex.Lock();
myswprintf(mainGame->dInfo.strLP[player], L" % d", mainGame->dInfo.lp[player]);
mainGame->gMutex.Unlock();
return true;
}
case MSG_ADD_COUNTER: {
int type = BufferIO::ReadInt16(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
ClientCard* pc = mainGame->dField.GetCard(c, l, s);
if (pc->counters.count(type))
pc->counters[type] += count;
else pc->counters[type] = count;
myswprintf(textBuffer, L"[ % ls]放置了 % d个[ % ls]", dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true;
mainGame->gMutex.Lock();
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(40);
pc->is_highlighting = false;
return true;
}
case MSG_REMOVE_COUNTER: {
int type = BufferIO::ReadInt16(pbuf);
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
int count = BufferIO::ReadInt8(pbuf);
ClientCard* pc = mainGame->dField.GetCard(c, l, s);
pc->counters[type] -= count;
if (pc->counters[type] <= 0)
pc->counters.erase(type);
myswprintf(textBuffer, L"[ % ls]移除了 % d个[ % ls]", dataManager.GetName(pc->code), count, dataManager.GetCounterName(type));
pc->is_highlighting = true;
mainGame->gMutex.Lock();
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
mainGame->WaitFrameSignal(40);
pc->is_highlighting = false;
return true;
}
case MSG_ATTACK: {
int ca = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int la = BufferIO::ReadInt8(pbuf);
int sa = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
mainGame->dField.attacker = mainGame->dField.GetCard(ca, la, sa);
int cd = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int ld = BufferIO::ReadInt8(pbuf);
int sd = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
float sy;
if (ld != 0) {
mainGame->dField.attack_target = mainGame->dField.GetCard(cd, ld, sd);
myswprintf(pdInfo->strEvent, L"[ % ls]攻击[ % ls]", dataManager.GetName(mainGame->dField.attacker->code),
dataManager.GetName(mainGame->dField.attack_target->code));
float xa = mainGame->dField.attacker->curPos.X;
float ya = mainGame->dField.attacker->curPos.Y;
float xd = mainGame->dField.attack_target->curPos.X;
float yd = mainGame->dField.attack_target->curPos.Y;
sy = (float)sqrt((xa - xd) * (xa - xd) + (ya - yd) * (ya - yd)) / 2;
mainGame->atk_t = vector3df((xa + xd) / 2, (ya + yd) / 2, 0);
if (ca == 0)
mainGame->atk_r = vector3df(0, 0, -atan((xd - xa) / (yd - ya)));
else
mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
} else {
myswprintf(pdInfo->strEvent, L"[ % ls]直接攻击", dataManager.GetName(mainGame->dField.attacker->code));
float xa = mainGame->dField.attacker->curPos.X;
float ya = mainGame->dField.attacker->curPos.Y;
float xd = 3.95f;
float yd = 3.5f;
if (ca == 0)
yd = -3.5f;
sy = (float)sqrt((xa - xd) * (xa - xd) + (ya - yd) * (ya - yd)) / 2;
mainGame->atk_t = vector3df((xa + xd) / 2, (ya + yd) / 2, 0);
if (ca == 0)
mainGame->atk_r = vector3df(0, 0, -atan((xd - xa) / (yd - ya)));
else
mainGame->atk_r = vector3df(0, 0, 3.1415926 - atan((xd - xa) / (yd - ya)));
}
mainGame->matManager.GenArrow(sy);
mainGame->attack_sv = 0;
mainGame->is_attacking = true;
mainGame->WaitFrameSignal(40);
mainGame->is_attacking = false;
return true;
}
case MSG_BATTLE: {
int ca = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int la = BufferIO::ReadInt8(pbuf);
int sa = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
int va = BufferIO::ReadInt32(pbuf);
int da = BufferIO::ReadInt8(pbuf);
int cd = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int ld = BufferIO::ReadInt8(pbuf);
int sd = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
int vd = BufferIO::ReadInt32(pbuf);
int dd = BufferIO::ReadInt8(pbuf);
return true;
}
case MSG_ATTACK_DISABLED: {
myswprintf(pdInfo->strEvent, L"攻击被无效", dataManager.GetName(mainGame->dField.attacker->code));
return true;
}
case MSG_DAMAGE_STEP_START: {
return true;
}
case MSG_DAMAGE_STEP_END: {
return true;
}
case MSG_MISSED_EFFECT: {
BufferIO::ReadInt32(pbuf);
int code = BufferIO::ReadInt32(pbuf);
myswprintf(textBuffer, L"[ % ls]错过时点", dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
return true;
}
case MSG_TOSS_COIN: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
textBuffer[0] = 0;
wcscat(textBuffer, L"投掷硬币结果:");
for (int i = 0; i < count; ++i) {
int res = BufferIO::ReadInt8(pbuf);
wcscat(textBuffer, res ? L"[正面]" : L"[反面]");
}
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
return true;
}
case MSG_TOSS_DICE: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
textBuffer[0] = 0;
wcscat(textBuffer, L"投掷骰子结果:");
wchar_t* p = &textBuffer[7];
for (int i = 0; i < count; ++i) {
int res = BufferIO::ReadInt8(pbuf);
*p++ = L'[';
*p++ = L'0' + res;
*p++ = L']';
}
*p = 0;
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
return true;
}
case MSG_ANNOUNCE_RACE: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->dField.announce_count = BufferIO::ReadInt8(pbuf);
int available = BufferIO::ReadInt32(pbuf);
for(int i = 0, filter = 0x1; i < 22; ++i, filter <<= 1) {
mainGame->chkRace[i]->setChecked(false);
if(filter & available)
mainGame->chkRace[i]->setVisible(true);
else mainGame->chkRace[i]->setVisible(false);
}
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
else myswprintf(textBuffer, L"请宣言种族");
mainGame->dInfo.selectHint = 0;
mainGame->wANRace->setText(textBuffer);
mainGame->PopupElement(mainGame->wANRace);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_ANNOUNCE_ATTRIB: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->dField.announce_count = BufferIO::ReadInt8(pbuf);
int available = BufferIO::ReadInt32(pbuf);
for(int i = 0, filter = 0x1; i < 7; ++i, filter <<= 1) {
mainGame->chkAttribute[i]->setChecked(false);
if(filter & available)
mainGame->chkAttribute[i]->setVisible(true);
else mainGame->chkAttribute[i]->setVisible(false);
}
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
else myswprintf(textBuffer, L"请宣言属性");
mainGame->dInfo.selectHint = 0;
mainGame->wANAttribute->setText(textBuffer);
mainGame->PopupElement(mainGame->wANAttribute);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_ANNOUNCE_CARD: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
mainGame->ebANCard->setText(L"");
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
else myswprintf(textBuffer, L"请宣言卡名");
mainGame->dInfo.selectHint = 0;
mainGame->wANCard->setText(textBuffer);
mainGame->PopupElement(mainGame->wANCard);
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_ANNOUNCE_NUMBER: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int count = BufferIO::ReadInt8(pbuf);
mainGame->gMutex.Lock();
mainGame->cbANNumber->clear();
for (int i = 0; i < count; ++i) {
int value = BufferIO::ReadInt32(pbuf);
myswprintf(textBuffer, L" % d", value);
mainGame->cbANNumber->addItem(textBuffer, value);
}
mainGame->cbANNumber->setSelected(0);
if(mainGame->dInfo.selectHint)
myswprintf(textBuffer, L" % ls", dataManager.GetDesc(mainGame->dInfo.selectHint));
else myswprintf(textBuffer, L"请宣言数字");
mainGame->dInfo.selectHint = 0;
mainGame->wANNumber->setText(textBuffer);
mainGame->PopupElement(mainGame->wANNumber);
mainGame->gMutex.Unlock();
mainGame->localAction.Reset();
mainGame->localAction.Wait();
mainGame->localResponse.Set();
return true;
}
case MSG_COUNT_TURN: {
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
int l = BufferIO::ReadInt8(pbuf);
int s = BufferIO::ReadInt8(pbuf);
BufferIO::ReadInt8(pbuf);
int ct = BufferIO::ReadInt16(pbuf);
ClientCard* pcard = mainGame->dField.GetCard(c, l, s);
pcard->turnCounter = ct;
if(ct == 0)
return true;
if(pcard->location & LOCATION_ONFIELD)
pcard->is_selectable = true;
mainGame->showcardcode = pcard->code;
mainGame->showcarddif = 0;
mainGame->showcardp = ct - 1;
mainGame->showcard = 6;
mainGame->WaitFrameSignal(30);
pcard->is_selectable = false;
mainGame->showcard = 0;
return true;
}
}
return true;
}
void DuelClient::SetResponseI(int respI) { void DuelClient::SetResponseI(int respI) {
*((int*)response_buf) = respI; *((int*)response_buf) = respI;
is_responseB = false; is_responseB = false;
......
...@@ -24,6 +24,8 @@ private: ...@@ -24,6 +24,8 @@ private:
static char duel_client_read[0x2000]; static char duel_client_read[0x2000];
static char duel_client_write[0x2000]; static char duel_client_write[0x2000];
static bool is_closing; static bool is_closing;
static int select_hint;
static wchar_t event_string[128];
public: public:
static bool StartClient(unsigned int ip, unsigned short port, bool create_game = true); static bool StartClient(unsigned int ip, unsigned short port, bool create_game = true);
static void StopClient(bool is_exiting = false); static void StopClient(bool is_exiting = false);
...@@ -31,6 +33,7 @@ public: ...@@ -31,6 +33,7 @@ public:
static void ClientEvent(bufferevent *bev, short events, void *ctx); static void ClientEvent(bufferevent *bev, short events, void *ctx);
static int ClientThread(void* param); static int ClientThread(void* param);
static void HandleSTOCPacketLan(char* data, unsigned int len); static void HandleSTOCPacketLan(char* data, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len);
static void SetResponseI(int respI); static void SetResponseI(int respI);
static void SetResponseB(unsigned char* respB, unsigned char len); static void SetResponseB(unsigned char* respB, unsigned char len);
static void SendPacketToServer(unsigned char proto) { static void SendPacketToServer(unsigned char proto) {
......
...@@ -1265,9 +1265,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1265,9 +1265,6 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case irr::EET_USER_EVENT: {
break;
}
} }
return false; return false;
} }
......
...@@ -161,23 +161,28 @@ bool Game::Initialize() { ...@@ -161,23 +161,28 @@ bool Game::Initialize() {
imgCard = env->addImage(rect<s32>(9, 9, 187, 262), wCardImg); imgCard = env->addImage(rect<s32>(9, 9, 187, 262), wCardImg);
imgCard->setUseAlphaChannel(true); imgCard->setUseAlphaChannel(true);
//phase //phase
btnDP = env->addButton(rect<s32>(475, 310, 525, 330), 0, -1, L"DP"); wPhase = env->addWindow(rect<s32>(475, 310, 850, 330), false, L"");
wPhase->setDraggable(false);
wPhase->getCloseButton()->setVisible(false);
wPhase->setDrawBackground(false);
wPhase->setVisible(false);
btnDP = env->addButton(rect<s32>(0, 0, 50, 20), wPhase, -1, L"DP");
btnDP->setEnabled(false); btnDP->setEnabled(false);
btnDP->setPressed(true); btnDP->setPressed(true);
btnDP->setVisible(false); btnDP->setVisible(false);
btnSP = env->addButton(rect<s32>(540, 310, 590, 330), 0, -1, L"SP"); btnSP = env->addButton(rect<s32>(65, 0, 115, 20), wPhase, -1, L"SP");
btnSP->setEnabled(false); btnSP->setEnabled(false);
btnSP->setPressed(true); btnSP->setPressed(true);
btnSP->setVisible(false); btnSP->setVisible(false);
btnM1 = env->addButton(rect<s32>(605, 310, 655, 330), 0, -1, L"M1"); btnM1 = env->addButton(rect<s32>(130, 0, 180, 20), wPhase, -1, L"M1");
btnM1->setEnabled(false); btnM1->setEnabled(false);
btnM1->setPressed(true); btnM1->setPressed(true);
btnM1->setVisible(false); btnM1->setVisible(false);
btnBP = env->addButton(rect<s32>(670, 310, 720, 330), 0, BUTTON_BP, L"BP"); btnBP = env->addButton(rect<s32>(195, 0, 245, 20), wPhase, BUTTON_BP, L"BP");
btnBP->setVisible(false); btnBP->setVisible(false);
btnM2 = env->addButton(rect<s32>(735, 310, 785, 330), 0, BUTTON_M2, L"M2"); btnM2 = env->addButton(rect<s32>(260, 0, 310, 20), wPhase, BUTTON_M2, L"M2");
btnM2->setVisible(false); btnM2->setVisible(false);
btnEP = env->addButton(rect<s32>(800, 310, 850, 330), 0, BUTTON_EP, L"EP"); btnEP = env->addButton(rect<s32>(325, 0, 375, 20), wPhase, BUTTON_EP, L"EP");
btnEP->setVisible(false); btnEP->setVisible(false);
//tab //tab
wInfos = env->addTabControl(rect<s32>(1, 275, 301, 639), 0, true); wInfos = env->addTabControl(rect<s32>(1, 275, 301, 639), 0, true);
......
...@@ -24,28 +24,14 @@ struct Config { ...@@ -24,28 +24,14 @@ struct Config {
struct DuelInfo { struct DuelInfo {
bool isStarted; bool isStarted;
bool is_shuffling; bool is_shuffling;
bool netError;
bool is_host_player[2];
bool is_first_turn; bool is_first_turn;
bool is_local_host;
bool is_responsed;
int resPlayer;
int lp[2]; int lp[2];
int engFlag;
int engLen;
int engType;
int msgLen;
int msgType;
int turn; int turn;
short curMsg; short curMsg;
short preMsg;
int selectHint;
wchar_t hostname[20]; wchar_t hostname[20];
wchar_t clientname[20]; wchar_t clientname[20];
wchar_t pass[20];
wchar_t strLP[2][16]; wchar_t strLP[2][16];
wchar_t strTurn[8]; wchar_t strTurn[8];
wchar_t strEvent[64];
}; };
class Game { class Game {
...@@ -279,6 +265,7 @@ public: ...@@ -279,6 +265,7 @@ public:
irr::gui::IGUIButton* btnAttack; irr::gui::IGUIButton* btnAttack;
irr::gui::IGUIButton* btnShowList; irr::gui::IGUIButton* btnShowList;
//phase button //phase button
irr::gui::IGUIWindow* wPhase;
irr::gui::IGUIButton* btnDP; irr::gui::IGUIButton* btnDP;
irr::gui::IGUIButton* btnSP; irr::gui::IGUIButton* btnSP;
irr::gui::IGUIButton* btnM1; irr::gui::IGUIButton* btnM1;
......
...@@ -266,55 +266,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -266,55 +266,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case irr::EET_USER_EVENT: {
switch(event.UserEvent.UserData1) {
case UEVENT_EXIT: {
if(mainGame->guiFading) {
mainGame->guiFading->setVisible(false);
mainGame->guiNext = 0;
}
mainGame->ShowElement(mainGame->wMessage, 60);
if(event.UserEvent.UserData2 == 1)
mainGame->exit_window = mainGame->wLanWindow;
else if(event.UserEvent.UserData2 == 2)
;
else if(event.UserEvent.UserData2 == 3)
;
break;
}
case UEVENT_TOWINDOW: {
mainGame->exit_window = 0;
mainGame->wMessage->setVisible(false);
mainGame->wACMessage->setVisible(false);
mainGame->wQuery->setVisible(false);
mainGame->wOptions->setVisible(false);
mainGame->wPosSelect->setVisible(false);
mainGame->wCardSelect->setVisible(false);
mainGame->wANNumber->setVisible(false);
mainGame->wANCard->setVisible(false);
mainGame->wANAttribute->setVisible(false);
mainGame->wANRace->setVisible(false);
mainGame->wCmdMenu->setVisible(false);
mainGame->wReplaySave->setVisible(false);
mainGame->btnDP->setVisible(false);
mainGame->btnSP->setVisible(false);
mainGame->btnM1->setVisible(false);
mainGame->btnBP->setVisible(false);
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->wCardImg->setVisible(false);
mainGame->wInfos->setVisible(false);
mainGame->stHintMsg->setVisible(false);
mainGame->stTip->setVisible(false);
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->dField.Clear();
mainGame->ShowElement(mainGame->exit_window);
break;
}
break;
}
break;
}
} }
return false; return false;
} }
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -1216,7 +1216,9 @@ int32 scriptlib::duel_get_chain_info(lua_State *L) { ...@@ -1216,7 +1216,9 @@ int32 scriptlib::duel_get_chain_info(lua_State *L) {
lua_pushinteger(L, ch->chain_id); lua_pushinteger(L, ch->chain_id);
break; break;
case CHAININFO_TYPE: case CHAININFO_TYPE:
lua_pushinteger(L, (ch->chain_type & 0x7)); if((ch->chain_type & 0x7) == (TYPE_TRAP | TYPE_MONSTER))
lua_pushinteger(L, TYPE_MONSTER);
else lua_pushinteger(L, (ch->chain_type & 0x7));
break; break;
case CHAININFO_EXTTYPE: case CHAININFO_EXTTYPE:
lua_pushinteger(L, ch->chain_type); lua_pushinteger(L, ch->chain_type);
......
...@@ -3539,8 +3539,6 @@ int32 field::add_chain(uint16 step) { ...@@ -3539,8 +3539,6 @@ int32 field::add_chain(uint16 step) {
if(!(peffect->flag & EFFECT_FLAG_FIELD_ONLY) && peffect->handler->is_affected_by_effect(EFFECT_DISABLE_EFFECT)) if(!(peffect->flag & EFFECT_FLAG_FIELD_ONLY) && peffect->handler->is_affected_by_effect(EFFECT_DISABLE_EFFECT))
clit->flag |= CHAIN_DISABLE_EFFECT; clit->flag |= CHAIN_DISABLE_EFFECT;
clit->chain_type = peffect->handler->get_type(); clit->chain_type = peffect->handler->get_type();
if(clit->chain_type == TYPE_MONSTER + TYPE_TRAP)
clit->chain_type = TYPE_MONSTER;
clit->chain_count = core.current_chain.size() + 1; clit->chain_count = core.current_chain.size() + 1;
clit->target_cards = 0; clit->target_cards = 0;
clit->target_player = PLAYER_NONE; clit->target_player = PLAYER_NONE;
......
...@@ -4,7 +4,7 @@ function c2067935.initial_effect(c) ...@@ -4,7 +4,7 @@ function c2067935.initial_effect(c)
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(2067935,0)) e1:SetDescription(aux.Stringid(2067935,0))
e1:SetCategory(CATEGORY_REMOVE) e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCode(EVENT_SPSUMMON_SUCCESS)
e1:SetCondition(c2067935.rmcon) e1:SetCondition(c2067935.rmcon)
......
...@@ -26,7 +26,7 @@ function c21768554.cfilter(c) ...@@ -26,7 +26,7 @@ function c21768554.cfilter(c)
return c:IsFaceup() and c:IsSetCard(0xc) return c:IsFaceup() and c:IsSetCard(0xc)
end end
function c21768554.condition(e,tp,eg,ep,ev,re,r,rp) function c21768554.condition(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(c21768554.cfilter,tp,0,LOCATION_MZONE,1,nil) return Duel.IsExistingMatchingCard(c21768554.cfilter,tp,LOCATION_MZONE,0,1,nil)
end end
function c21768554.filter(c) function c21768554.filter(c)
return c:GetCounter(0xe)>0 and c:IsControlerCanBeChanged() return c:GetCounter(0xe)>0 and c:IsControlerCanBeChanged()
......
...@@ -10,20 +10,17 @@ function c24694698.initial_effect(c) ...@@ -10,20 +10,17 @@ function c24694698.initial_effect(c)
e1:SetTarget(c24694698.target) e1:SetTarget(c24694698.target)
e1:SetOperation(c24694698.operation) e1:SetOperation(c24694698.operation)
c:RegisterEffect(e1) c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e2)
--draw --draw
local e3=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(24694698,1)) e2:SetDescription(aux.Stringid(24694698,1))
e3:SetCategory(CATEGORY_DRAW) e2:SetCategory(CATEGORY_DRAW)
e3:SetType(EFFECT_TYPE_IGNITION) e2:SetType(EFFECT_TYPE_IGNITION)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e3:SetRange(LOCATION_MZONE) e2:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1) e2:SetCountLimit(1)
e3:SetTarget(c24694698.drtg) e2:SetTarget(c24694698.drtg)
e3:SetOperation(c24694698.drop) e2:SetOperation(c24694698.drop)
c:RegisterEffect(e3) c:RegisterEffect(e2)
end end
function c24694698.tgfilter(c) function c24694698.tgfilter(c)
return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x2a) and c:IsAbleToGrave() return c:IsType(TYPE_MONSTER) and c:IsSetCard(0x2a) and c:IsAbleToGrave()
......
...@@ -20,9 +20,12 @@ end ...@@ -20,9 +20,12 @@ end
function c43385557.reccon(e,tp,eg,ep,ev,re,r,rp) function c43385557.reccon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetTurnPlayer()==tp return Duel.GetTurnPlayer()==tp
end end
function c43385557.filter(c)
return c:IsFaceup() and c:IsRace(RACE_PSYCHO)
end
function c43385557.rectg(e,tp,eg,ep,ev,re,r,rp,chk) function c43385557.rectg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end if chk==0 then return true end
local ct=Duel.GetMatchingGroupCount(Card.IsRace,tp,LOCATION_MZONE,0,nil,RACE_PSYCHO) local ct=Duel.GetMatchingGroupCount(c43385557.filter,tp,LOCATION_MZONE,0,nil)
Duel.SetTargetPlayer(tp) Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(ct*600) Duel.SetTargetParam(ct*600)
Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,ct*600) Duel.SetOperationInfo(0,CATEGORY_RECOVER,nil,0,tp,ct*600)
......
...@@ -28,12 +28,12 @@ function c52971944.target1(e,tp,eg,ep,ev,re,r,rp,chk,chkc) ...@@ -28,12 +28,12 @@ function c52971944.target1(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCAITON_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end if chkc then return chkc:IsLocation(LOCAITON_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end
if chk==0 then return true end if chk==0 then return true end
if Duel.IsExistingMatchingCard(c52971944.cfilter,tp,LOCATION_GRAVE,0,1,nil) if Duel.IsExistingMatchingCard(c52971944.cfilter,tp,LOCATION_GRAVE,0,1,nil)
and Duel.IsExistingTarget(Card.IsAbleToRemoveAs,tp,0,LOCATION_GRAVE,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(52971944,0)) then and Duel.IsExistingTarget(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(52971944,0)) then
e:SetProperty(EFFECT_FLAG_CARD_TARGET) e:SetProperty(EFFECT_FLAG_CARD_TARGET)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local cg=Duel.SelectMatchingCard(tp,c52971944.cfilter,tp,LOCATION_GRAVE,0,1,1,nil) local cg=Duel.SelectMatchingCard(tp,c52971944.cfilter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.Remove(cg,POS_FACEUP,REASON_COST) Duel.Remove(cg,POS_FACEUP,REASON_COST)
local g=Duel.SelectTarget(tp,Card.IsAbleToRemoveAs,tp,0,LOCATION_GRAVE,1,1,nil) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0)
e:GetHandler():RegisterFlagEffect(52971944,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) e:GetHandler():RegisterFlagEffect(52971944,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
else e:SetProperty(0) end else e:SetProperty(0) end
...@@ -47,8 +47,8 @@ end ...@@ -47,8 +47,8 @@ end
function c52971944.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c52971944.target2(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCAITON_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end if chkc then return chkc:IsLocation(LOCAITON_GRAVE) and chkc:IsControler(1-tp) and chkc:IsAbleToRemove() end
if chk==0 then return e:GetHandler():GetFlagEffect(52971944)==0 if chk==0 then return e:GetHandler():GetFlagEffect(52971944)==0
and Duel.IsExistingTarget(Card.IsAbleToRemoveAs,tp,0,LOCATION_GRAVE,1,nil) end and Duel.IsExistingTarget(Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,nil) end
local g=Duel.SelectTarget(tp,Card.IsAbleToRemoveAs,tp,0,LOCATION_GRAVE,1,1,nil) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,0,LOCATION_GRAVE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0)
e:GetHandler():RegisterFlagEffect(52971944,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) e:GetHandler():RegisterFlagEffect(52971944,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1)
end end
......
...@@ -13,7 +13,7 @@ function c53540729.initial_effect(c) ...@@ -13,7 +13,7 @@ function c53540729.initial_effect(c)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c53540729.filter(c) function c53540729.filter(c)
return c:IsFaceup() and c:IsSetCard(0x58) return c:IsFaceup() and c:IsSetCard(0x58) and c:IsLevelAbove(1)
end end
function c53540729.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c53540729.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c24920410.filter(chkc) end if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c24920410.filter(chkc) end
......
...@@ -19,7 +19,7 @@ function c56769674.initial_effect(c) ...@@ -19,7 +19,7 @@ function c56769674.initial_effect(c)
end end
function c56769674.target(e,tp,eg,ep,ev,re,r,rp,chk) function c56769674.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,0) Duel.Hint(HINT_SELECTMSG,tp,562)
local rc=Duel.AnnounceAttribute(tp,1,0xffff) local rc=Duel.AnnounceAttribute(tp,1,0xffff)
e:GetLabelObject():SetLabel(rc) e:GetLabelObject():SetLabel(rc)
end end
......
...@@ -53,7 +53,7 @@ end ...@@ -53,7 +53,7 @@ end
function c66957584.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c66957584.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c66957584.filter(chkc,e,tp) end if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c66957584.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c66957584.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end and Duel.IsExistingTarget(c66957584.filter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end
local ct=Duel.GetLocationCount(tp,LOCATION_MZONE) local ct=Duel.GetLocationCount(tp,LOCATION_MZONE)
if ct>2 then ct=2 end if ct>2 then ct=2 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
......
...@@ -11,7 +11,7 @@ function c73262676.initial_effect(c) ...@@ -11,7 +11,7 @@ function c73262676.initial_effect(c)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c73262676.filter(c) function c73262676.filter(c)
return c:GetCounter(0xe)>0 and c:GetLevel()>0 and c:IsDestructable() return c:IsFaceup() and c:IsSetCard(0xc) and c:GetLevel()>0 and c:IsDestructable()
end end
function c73262676.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c73262676.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c73262676.filter(chkc) end if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c73262676.filter(chkc) end
......
...@@ -18,7 +18,7 @@ function c74701381.initial_effect(c) ...@@ -18,7 +18,7 @@ function c74701381.initial_effect(c)
end end
function c74701381.target(e,tp,eg,ep,ev,re,r,rp,chk) function c74701381.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,0) Duel.Hint(HINT_SELECTMSG,tp,563)
local rc=Duel.AnnounceRace(tp,1,0xffffff) local rc=Duel.AnnounceRace(tp,1,0xffffff)
e:GetLabelObject():SetLabel(rc) e:GetLabelObject():SetLabel(rc)
end end
......
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