-
Notifications
You must be signed in to change notification settings - Fork 1
/
OxsyPlayMode.cpp
110 lines (89 loc) · 2.58 KB
/
OxsyPlayMode.cpp
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "OxsyLibrary.h"
#include "OxsyPlayMode.h"
#include "OxsyClassPointers.h"
#include "OxsyInfo.h"
#include "OxsyScoreInfo.h"
#include "OxsyStatics.h"
COxsyPlayMode::COxsyPlayMode(COxsyClassPointers *pClassPointers)
{
m_pClassPointers = pClassPointers;
m_PlayModeInfo.play_mode_time = 0;
m_PlayModeInfo.play_mode = PM_before_kick_off;
}
COxsyPlayMode::~COxsyPlayMode()
{
m_PlayModeInfoArray.clear();
}
void COxsyPlayMode::analyze_play_mode(char *strRefereeMessage, int nRefereeMessageTime)
{
COxsyInfo *pInfo = m_pClassPointers->GetInfoPointer();
COxsyScoreInfo *pScoreInfo = m_pClassPointers->GetScoreInfoPointer();
ScoreInfo scoreInfo;
m_PlayModeInfo.play_mode_time = nRefereeMessageTime;
m_PlayModeInfo.play_mode = get_play_mode(strRefereeMessage);
if (m_PlayModeInfo.play_mode == PM_Unknown)
{
if (strlen(strRefereeMessage) > 5 && !strncmp(strRefereeMessage, "goal_", 5))
{
if (strRefereeMessage[5] == 'l')
{
m_PlayModeInfo.play_mode = PM_goal_l;
scoreInfo = pScoreInfo->get_score_info();
if (pInfo->get_init_side() == S_Left)
{
scoreInfo.our_score_time = nRefereeMessageTime;
scoreInfo.our_score = atoi(strRefereeMessage + 7);
}
else
{
scoreInfo.opp_score_time = nRefereeMessageTime;
scoreInfo.opp_score = atoi(strRefereeMessage + 7);
}
pScoreInfo->set_score_info(scoreInfo);
}
else
if (strRefereeMessage[5] == 'r')
{
m_PlayModeInfo.play_mode = PM_goal_r;
scoreInfo = pScoreInfo->get_score_info();
if (pInfo->get_init_side() == S_Right)
{
scoreInfo.our_score_time = nRefereeMessageTime;
scoreInfo.our_score = atoi(strRefereeMessage + 7);
}
else
{
scoreInfo.opp_score_time = nRefereeMessageTime;
scoreInfo.opp_score = atoi(strRefereeMessage + 7);
}
pScoreInfo->set_score_info(scoreInfo);
}
}
}
else
if (m_PlayModeInfo.play_mode == PM_before_kick_off)
{
pInfo->init_player_state();
pInfo->inc_match_state();
}
if (m_PlayModeInfoArray.size() > 0)
{
if (m_PlayModeInfoArray[0].play_mode_time != m_PlayModeInfo.play_mode_time)
{
m_PlayModeInfoArray.clear();
}
}
m_PlayModeInfoArray.push_back(m_PlayModeInfo);
}
PlayMode COxsyPlayMode::get_play_mode(char *strPlayMode)
{
int i;
for (i = 0; COxsyStatics::playModeTable[i].strPlayMode != NULL; i++)
{
if (!strcmp(strPlayMode, COxsyStatics::playModeTable[i].strPlayMode))
{
return COxsyStatics::playModeTable[i].playMode;
}
}
return PM_Unknown;
}