-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugcard.cpp
More file actions
79 lines (70 loc) · 2.63 KB
/
debugcard.cpp
File metadata and controls
79 lines (70 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "common/macros.h"
#include "common/nndef.h"
#include "gameroot.h"
#include "logic/roomlogic/core/debugcard.h"
#include "context/context.h"
#include "Comm/ITableGame.h"
#include "config/gameconfig.h"
#include "utils/tarslog.h"
#include "process/process.h"
#include "context/context.h"
using namespace nndef;
namespace majong
{
namespace logic
{
namespace roomlogic
{
int DebugCard(void const *p, GameRoot *root)
{
PERFSTATS_ENTRY();
__TRY__
using namespace RoomSo;
using namespace context;
TGAME_DebugCard const *nnrs = static_cast<TGAME_DebugCard const *>(p);
DLOG_TRACE("roomid:"<<root->roomid()<<", "<<"DebugCard: " << printTars(*nnrs));
root->con->clearDebugCards();
std::set<string> sdebugcard;
auto vCommDebugCard = tars::TC_Common::sepstr<string>(nnrs->comm_debug_card, ",");
for(auto card : vCommDebugCard)
{
if(checkCard(card, sdebugcard))
{
root->con->addDebugCard(-1, atoi(card.c_str()));
DLOG_TRACE("roomid:"<<root->roomid()<<", "<<"DebugCard. cid: -1, card: " << card);
}
}
for(auto cardItem : nnrs->seat_debug_card)
{
auto vSeatDebugCard = tars::TC_Common::sepstr<string>(cardItem.second, ",");
for(auto card : vSeatDebugCard)
{
if(checkCard(card, sdebugcard))
{
root->con->addDebugCard(cardItem.first, atoi(card.c_str()));
DLOG_TRACE("roomid:"<<root->roomid()<<", "<<"DebugCard. cid: "<< cardItem.first <<", card: " << card);
}
}
}
__CATCH__
PERFSTATS_EXIT();
return 0;
}
bool checkCard(string card, std::set<string>& sdebugcard)
{
int pre_card_count = sdebugcard.size();
sdebugcard.insert(card);
if(sdebugcard.size() - pre_card_count != 1)
{
return false;
}
int trancard = atoi(card.c_str());
if(trancard < 0 || 71 < trancard)
{
return false;
}
return true;
}
}
}
}