Commit 7b34d6b5 authored by nanahira's avatar nanahira

add cards

parent ce812267
......@@ -16,8 +16,36 @@ SingleDuel::SingleDuel(bool is_match) {
for(int i = 0; i < 2; ++i) {
players[i] = 0;
ready[i] = false;
is_skystriker[i] = false;
}
duel_count = 0;
skystrikers.insert(33331231);
skystrikers.insert(34456146);
skystrikers.insert(96795312);
skystrikers.insert(22790910);
skystrikers.insert(26077387);
skystrikers.insert(37351133);
skystrikers.insert(96084564);
skystrikers.insert(63166095);
skystrikers.insert(99550630);
skystrikers.insert(25955749);
skystrikers.insert(21623008);
skystrikers.insert(46271408);
skystrikers.insert(52340444);
skystrikers.insert(98338152);
skystrikers.insert(25733157);
skystrikers.insert(51227866);
skystrikers.insert(9726840);
skystrikers.insert(24010609);
skystrikers.insert(97616504);
skystrikers.insert(50005218);
skystrikers.insert(75147529);
skystrikers.insert(98462037);
skystrikers.insert(63013339);
skystrikers.insert(63288573);
skystrikers.insert(90673288);
skystrikers.insert(8491308);
skystrikers.insert(12421694);
memset(match_result, 0, 3);
#ifdef YGOPRO_SERVER_MODE
cache_recorder = 0;
......@@ -395,6 +423,31 @@ void SingleDuel::PlayerKick(DuelPlayer* dp, unsigned char pos) {
return;
LeaveGame(players[pos]);
}
bool SingleDuel::IsSkyStriker(unsigned int code) {
return skystrikers.find(code) != skystrikers.end();
}
void SingleDuel::CheckSkyStriker(unsigned char player_id) {
if((int32)pdeck[0].main.size() > 41) {
is_skystriker[player_id] = false;
return;
}
unsigned short skystricker_count = 0;
for(int32 i = (int32)pdeck[0].main.size() - 1; i >= 0; --i) {
if(IsSkyStriker(pdeck[0].main[i]->first))
skystricker_count++;
}
for(int32 i = (int32)pdeck[0].extra.size() - 1; i >= 0; --i) {
if(IsSkyStriker(pdeck[0].extra[i]->first))
skystricker_count++;
}
is_skystriker[player_id] = skystricker_count >= 23;
}
void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
if(dp->type > 1 || ready[dp->type])
return;
......@@ -412,8 +465,12 @@ void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
}
if(duel_count == 0) {
deck_error[dp->type] = deckManager.LoadDeck(pdeck[dp->type], (int*)deckbuf, mainc, sidec);
if(!deck_error[dp->type]) {
CheckSkyStriker(dp->type);
}
} else {
if(deckManager.LoadSide(pdeck[dp->type], (int*)deckbuf, mainc, sidec)) {
CheckSkyStriker(dp->type);
ready[dp->type] = true;
NetServer::SendPacketToPlayer(dp, STOC_DUEL_START);
if(ready[0] && ready[1]) {
......@@ -595,6 +652,17 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
new_card(pduel, pdeck[1].extra[i]->first, 1, 1, LOCATION_EXTRA, 0, POS_FACEDOWN_DEFENSE);
last_replay.WriteInt32(pdeck[1].extra[i]->first, false);
}
for (int32 p = 0; p < 2; ++p) {
if (is_skystriker[p]) {
// add sky striker cards
// add 10 fireballs with code 46130346
new_card(pduel, 46130346, p, p, LOCATION_GRAVE, 0, POS_FACEDOWN_DEFENSE);
// add 5 effect veilers with code 97268402
new_card(pduel, 97268402, p, p, LOCATION_GRAVE, 0, POS_FACEDOWN_DEFENSE);
}
}
last_replay.Flush();
char startbuf[32], *pbuf = startbuf;
BufferIO::WriteInt8(pbuf, MSG_START);
......
......@@ -52,6 +52,8 @@ public:
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
#endif
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
bool IsSkyStriker(unsigned int code);
void CheckSkyStriker(unsigned char player_id);
static int MessageHandler(intptr_t fduel, int type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg);
......@@ -61,6 +63,8 @@ protected:
DuelPlayer* pplayer[2];
bool ready[2];
Deck pdeck[2];
bool is_skystriker[2];
std::set<unsigned int> skystrikers;
int deck_error[2];
unsigned char hand_result[2];
unsigned char last_response;
......
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