Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-2pick
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-2pick
Commits
c6d7d016
Commit
c6d7d016
authored
Dec 25, 2017
by
mercury233
Committed by
nanahira
Dec 25, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add_bot
parent
883b16af
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
245 additions
and
31 deletions
+245
-31
gframe/config.h
gframe/config.h
+1
-0
gframe/duelclient.cpp
gframe/duelclient.cpp
+71
-21
gframe/event_handler.cpp
gframe/event_handler.cpp
+6
-1
gframe/game.cpp
gframe/game.cpp
+67
-6
gframe/game.h
gframe/game.h
+23
-1
gframe/gframe.cpp
gframe/gframe.cpp
+2
-1
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+72
-1
strings.conf
strings.conf
+3
-0
No files found.
gframe/config.h
View file @
c6d7d016
...
...
@@ -80,5 +80,6 @@ extern int enable_log;
extern
bool
exit_on_return
;
extern
bool
open_file
;
extern
wchar_t
open_file_name
[
256
];
extern
bool
bot_mode
;
#endif
gframe/duelclient.cpp
View file @
c6d7d016
...
...
@@ -69,8 +69,12 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Lock
();
if
(
!
mainGame
->
wLanWindow
->
isVisible
())
if
(
bot_mode
&&
!
mainGame
->
wSinglePlay
->
isVisible
())
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
if
(
!
bot_mode
&&
!
mainGame
->
wLanWindow
->
isVisible
())
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1400
));
mainGame
->
gMutex
.
Unlock
();
...
...
@@ -110,18 +114,34 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
SendPacketToServer
(
CTOS_PLAYER_INFO
,
cspi
);
if
(
create_game
)
{
CTOS_CreateGame
cscg
;
BufferIO
::
CopyWStr
(
mainGame
->
ebServerName
->
getText
(),
cscg
.
name
,
20
);
BufferIO
::
CopyWStr
(
mainGame
->
ebServerPass
->
getText
(),
cscg
.
pass
,
20
);
cscg
.
info
.
rule
=
mainGame
->
cbRule
->
getSelected
();
cscg
.
info
.
mode
=
mainGame
->
cbMatchMode
->
getSelected
();
cscg
.
info
.
start_hand
=
_wtoi
(
mainGame
->
ebStartHand
->
getText
());
cscg
.
info
.
start_lp
=
_wtoi
(
mainGame
->
ebStartLP
->
getText
());
cscg
.
info
.
draw_count
=
_wtoi
(
mainGame
->
ebDrawCount
->
getText
());
cscg
.
info
.
time_limit
=
_wtoi
(
mainGame
->
ebTimeLimit
->
getText
());
cscg
.
info
.
lflist
=
mainGame
->
cbLFlist
->
getItemData
(
mainGame
->
cbLFlist
->
getSelected
());
cscg
.
info
.
duel_rule
=
mainGame
->
cbDuelRule
->
getSelected
()
+
1
;
cscg
.
info
.
no_check_deck
=
mainGame
->
chkNoCheckDeck
->
isChecked
();
cscg
.
info
.
no_shuffle_deck
=
mainGame
->
chkNoShuffleDeck
->
isChecked
();
if
(
bot_mode
)
{
BufferIO
::
CopyWStr
(
L"Bot Game"
,
cscg
.
name
,
20
);
BufferIO
::
CopyWStr
(
L""
,
cscg
.
pass
,
20
);
cscg
.
info
.
rule
=
2
;
cscg
.
info
.
mode
=
0
;
cscg
.
info
.
start_hand
=
5
;
cscg
.
info
.
start_lp
=
8000
;
cscg
.
info
.
draw_count
=
1
;
cscg
.
info
.
time_limit
=
0
;
cscg
.
info
.
lflist
=
0
;
cscg
.
info
.
duel_rule
=
mainGame
->
chkBotOldRule
->
isChecked
()
?
DEFAULT_DUEL_RULE
-
1
:
DEFAULT_DUEL_RULE
;
cscg
.
info
.
no_check_deck
=
mainGame
->
chkBotNoCheckDeck
->
isChecked
();
cscg
.
info
.
no_shuffle_deck
=
mainGame
->
chkBotNoShuffleDeck
->
isChecked
();
}
else
{
BufferIO
::
CopyWStr
(
mainGame
->
ebServerName
->
getText
(),
cscg
.
name
,
20
);
BufferIO
::
CopyWStr
(
mainGame
->
ebServerPass
->
getText
(),
cscg
.
pass
,
20
);
cscg
.
info
.
rule
=
mainGame
->
cbRule
->
getSelected
();
cscg
.
info
.
mode
=
mainGame
->
cbMatchMode
->
getSelected
();
cscg
.
info
.
start_hand
=
_wtoi
(
mainGame
->
ebStartHand
->
getText
());
cscg
.
info
.
start_lp
=
_wtoi
(
mainGame
->
ebStartLP
->
getText
());
cscg
.
info
.
draw_count
=
_wtoi
(
mainGame
->
ebDrawCount
->
getText
());
cscg
.
info
.
time_limit
=
_wtoi
(
mainGame
->
ebTimeLimit
->
getText
());
cscg
.
info
.
lflist
=
mainGame
->
cbLFlist
->
getItemData
(
mainGame
->
cbLFlist
->
getSelected
());
cscg
.
info
.
duel_rule
=
mainGame
->
cbDuelRule
->
getSelected
()
+
1
;
cscg
.
info
.
no_check_deck
=
mainGame
->
chkNoCheckDeck
->
isChecked
();
cscg
.
info
.
no_shuffle_deck
=
mainGame
->
chkNoShuffleDeck
->
isChecked
();
}
SendPacketToServer
(
CTOS_CREATE_GAME
,
cscg
);
}
else
{
CTOS_JoinGame
csjg
;
...
...
@@ -139,8 +159,12 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Lock
();
if
(
!
mainGame
->
wLanWindow
->
isVisible
())
if
(
bot_mode
&&
!
mainGame
->
wSinglePlay
->
isVisible
())
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
if
(
!
bot_mode
&&
!
mainGame
->
wLanWindow
->
isVisible
())
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1400
));
mainGame
->
gMutex
.
Unlock
();
...
...
@@ -149,9 +173,14 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Lock
();
mainGame
->
HideElement
(
mainGame
->
wHostPrepare
);
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
if
(
bot_mode
)
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
wChat
->
setVisible
(
false
);
if
(
events
&
BEV_EVENT_EOF
)
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1401
));
...
...
@@ -163,6 +192,8 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeSignal
.
Set
();
...
...
@@ -171,7 +202,10 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
is_building
=
false
;
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
if
(
bot_mode
)
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
gMutex
.
Unlock
();
}
}
...
...
@@ -203,6 +237,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Lock
();
if
(
pkt
->
code
==
0
)
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1403
));
...
...
@@ -276,6 +312,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
gMutex
.
Lock
();
wchar_t
msgbuf
[
256
];
myswprintf
(
msgbuf
,
dataManager
.
GetSysString
(
1411
),
pkt
->
code
>>
12
,
(
pkt
->
code
>>
4
)
&
0xff
,
pkt
->
code
&
0xf
);
...
...
@@ -425,8 +463,10 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
cbDeckSelect
->
setEnabled
(
true
);
if
(
mainGame
->
wCreateHost
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wCreateHost
);
else
if
(
mainGame
->
wLanWindow
->
isVisible
())
else
if
(
mainGame
->
wLanWindow
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wLanWindow
);
else
if
(
mainGame
->
wSinglePlay
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wSinglePlay
);
mainGame
->
ShowElement
(
mainGame
->
wHostPrepare
);
mainGame
->
wChat
->
setVisible
(
true
);
mainGame
->
gMutex
.
Unlock
();
...
...
@@ -600,9 +640,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
if
(
bot_mode
)
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
gMutex
.
Unlock
();
event_base_loopbreak
(
client_base
);
if
(
exit_on_return
)
...
...
@@ -823,9 +868,14 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
if
(
bot_mode
)
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
gMutex
.
Unlock
();
event_base_loopbreak
(
client_base
);
if
(
exit_on_return
)
...
...
@@ -3680,8 +3730,8 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
if
(
pHP
->
host
.
draw_count
==
1
&&
pHP
->
host
.
start_hand
==
5
&&
pHP
->
host
.
start_lp
==
8000
&&
!
pHP
->
host
.
no_check_deck
&&
!
pHP
->
host
.
no_shuffle_deck
&&
pHP
->
host
.
duel_rule
==
DEFAULT_DUEL_RULE
)
hoststr
.
append
(
dataManager
.
GetSysString
(
12
80
));
else
hoststr
.
append
(
dataManager
.
GetSysString
(
12
81
));
hoststr
.
append
(
dataManager
.
GetSysString
(
12
47
));
else
hoststr
.
append
(
dataManager
.
GetSysString
(
12
48
));
hoststr
.
append
(
L"]"
);
wchar_t
gamename
[
20
];
BufferIO
::
CopyWStr
(
pHP
->
name
,
gamename
,
20
);
...
...
gframe/event_handler.cpp
View file @
c6d7d016
...
...
@@ -125,7 +125,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
if
(
bot_mode
)
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
}
else
{
DuelClient
::
SendPacketToServer
(
CTOS_SURRENDER
);
}
...
...
gframe/game.cpp
View file @
c6d7d016
...
...
@@ -118,7 +118,7 @@ bool Game::Initialize() {
wMainMenu
=
env
->
addWindow
(
rect
<
s32
>
(
370
,
200
,
650
,
415
),
false
,
strbuf
);
wMainMenu
->
getCloseButton
()
->
setVisible
(
false
);
btnLanMode
=
env
->
addButton
(
rect
<
s32
>
(
10
,
30
,
270
,
60
),
wMainMenu
,
BUTTON_LAN_MODE
,
dataManager
.
GetSysString
(
1200
));
btnS
erver
Mode
=
env
->
addButton
(
rect
<
s32
>
(
10
,
65
,
270
,
95
),
wMainMenu
,
BUTTON_SINGLE_MODE
,
dataManager
.
GetSysString
(
1201
));
btnS
ingle
Mode
=
env
->
addButton
(
rect
<
s32
>
(
10
,
65
,
270
,
95
),
wMainMenu
,
BUTTON_SINGLE_MODE
,
dataManager
.
GetSysString
(
1201
));
btnReplayMode
=
env
->
addButton
(
rect
<
s32
>
(
10
,
100
,
270
,
130
),
wMainMenu
,
BUTTON_REPLAY_MODE
,
dataManager
.
GetSysString
(
1202
));
// btnTestMode = env->addButton(rect<s32>(10, 135, 270, 165), wMainMenu, BUTTON_TEST_MODE, dataManager.GetSysString(1203));
btnDeckEdit
=
env
->
addButton
(
rect
<
s32
>
(
10
,
135
,
270
,
165
),
wMainMenu
,
BUTTON_DECK_EDIT
,
dataManager
.
GetSysString
(
1204
));
...
...
@@ -585,12 +585,27 @@ bool Game::Initialize() {
wSinglePlay
=
env
->
addWindow
(
rect
<
s32
>
(
220
,
100
,
800
,
520
),
false
,
dataManager
.
GetSysString
(
1201
));
wSinglePlay
->
getCloseButton
()
->
setVisible
(
false
);
wSinglePlay
->
setVisible
(
false
);
lstSinglePlayList
=
env
->
addListBox
(
rect
<
s32
>
(
10
,
30
,
350
,
400
),
wSinglePlay
,
LISTBOX_SINGLEPLAY_LIST
,
true
);
irr
::
gui
::
IGUITabControl
*
wSingle
=
env
->
addTabControl
(
rect
<
s32
>
(
0
,
20
,
579
,
419
),
wSinglePlay
,
true
);
if
(
gameConf
.
enable_bot_mode
)
{
irr
::
gui
::
IGUITab
*
tabBot
=
wSingle
->
addTab
(
dataManager
.
GetSysString
(
1380
));
lstBotList
=
env
->
addListBox
(
rect
<
s32
>
(
10
,
10
,
350
,
350
),
tabBot
,
LISTBOX_BOT_LIST
,
true
);
lstBotList
->
setItemHeight
(
18
);
btnStartBot
=
env
->
addButton
(
rect
<
s32
>
(
459
,
301
,
569
,
326
),
tabBot
,
BUTTON_BOT_START
,
dataManager
.
GetSysString
(
1211
));
btnBotCancel
=
env
->
addButton
(
rect
<
s32
>
(
459
,
331
,
569
,
356
),
tabBot
,
BUTTON_CANCEL_SINGLEPLAY
,
dataManager
.
GetSysString
(
1210
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1382
),
rect
<
s32
>
(
360
,
10
,
550
,
30
),
false
,
true
,
tabBot
);
stBotInfo
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
360
,
40
,
560
,
160
),
false
,
true
,
tabBot
);
chkBotOldRule
=
env
->
addCheckBox
(
false
,
rect
<
s32
>
(
360
,
170
,
560
,
190
),
tabBot
,
CHECKBOX_BOT_OLD_RULE
,
dataManager
.
GetSysString
(
1383
));
chkBotHand
=
env
->
addCheckBox
(
false
,
rect
<
s32
>
(
360
,
200
,
560
,
220
),
tabBot
,
-
1
,
dataManager
.
GetSysString
(
1384
));
chkBotNoCheckDeck
=
env
->
addCheckBox
(
false
,
rect
<
s32
>
(
360
,
230
,
560
,
250
),
tabBot
,
-
1
,
dataManager
.
GetSysString
(
1229
));
chkBotNoShuffleDeck
=
env
->
addCheckBox
(
false
,
rect
<
s32
>
(
360
,
260
,
560
,
280
),
tabBot
,
-
1
,
dataManager
.
GetSysString
(
1230
));
}
irr
::
gui
::
IGUITab
*
tabSingle
=
wSingle
->
addTab
(
dataManager
.
GetSysString
(
1381
));
lstSinglePlayList
=
env
->
addListBox
(
rect
<
s32
>
(
10
,
10
,
350
,
350
),
tabSingle
,
LISTBOX_SINGLEPLAY_LIST
,
true
);
lstSinglePlayList
->
setItemHeight
(
18
);
btnLoadSinglePlay
=
env
->
addButton
(
rect
<
s32
>
(
4
60
,
355
,
570
,
380
),
wSinglePlay
,
BUTTON_LOAD_SINGLEPLAY
,
dataManager
.
GetSysString
(
1211
));
btnSinglePlayCancel
=
env
->
addButton
(
rect
<
s32
>
(
4
60
,
385
,
570
,
410
),
wSinglePlay
,
BUTTON_CANCEL_SINGLEPLAY
,
dataManager
.
GetSysString
(
1210
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1352
),
rect
<
s32
>
(
360
,
30
,
570
,
50
),
false
,
true
,
wSinglePlay
);
stSinglePlayInfo
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
360
,
60
,
570
,
350
),
false
,
true
,
wSinglePlay
);
btnLoadSinglePlay
=
env
->
addButton
(
rect
<
s32
>
(
4
59
,
301
,
569
,
326
),
tabSingle
,
BUTTON_LOAD_SINGLEPLAY
,
dataManager
.
GetSysString
(
1211
));
btnSinglePlayCancel
=
env
->
addButton
(
rect
<
s32
>
(
4
59
,
331
,
569
,
356
),
tabSingle
,
BUTTON_CANCEL_SINGLEPLAY
,
dataManager
.
GetSysString
(
1210
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1352
),
rect
<
s32
>
(
360
,
10
,
550
,
30
),
false
,
true
,
tabSingle
);
stSinglePlayInfo
=
env
->
addStaticText
(
L""
,
rect
<
s32
>
(
360
,
40
,
550
,
280
),
false
,
true
,
tabSingle
);
//replay save
wReplaySave
=
env
->
addWindow
(
rect
<
s32
>
(
510
,
200
,
820
,
320
),
false
,
dataManager
.
GetSysString
(
1340
));
wReplaySave
->
getCloseButton
()
->
setVisible
(
false
);
...
...
@@ -932,6 +947,46 @@ void Game::RefreshSingleplay() {
closedir
(
dir
);
#endif
}
void
Game
::
RefreshBot
()
{
if
(
!
gameConf
.
enable_bot_mode
)
return
;
botInfo
.
clear
();
FILE
*
fp
=
fopen
(
"bot.conf"
,
"r"
);
char
linebuf
[
256
];
char
strbuf
[
256
];
if
(
fp
)
{
while
(
fgets
(
linebuf
,
256
,
fp
))
{
if
(
linebuf
[
0
]
==
'#'
)
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
BotInfo
newinfo
;
sscanf
(
linebuf
,
"!%240[^
\n
]"
,
strbuf
);
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
name
);
fgets
(
linebuf
,
256
,
fp
);
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
);
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
command
);
fgets
(
linebuf
,
256
,
fp
);
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
);
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
desc
);
fgets
(
linebuf
,
256
,
fp
);
newinfo
.
support_master_rule_3
=
!!
strstr
(
linebuf
,
"SUPPORT_MASTER_RULE_3"
);
newinfo
.
support_new_master_rule
=
!!
strstr
(
linebuf
,
"SUPPORT_NEW_MASTER_RULE"
);
if
((
chkBotOldRule
->
isChecked
()
&&
newinfo
.
support_master_rule_3
)
||
(
!
chkBotOldRule
->
isChecked
()
&&
newinfo
.
support_new_master_rule
))
botInfo
.
push_back
(
newinfo
);
continue
;
}
}
fclose
(
fp
);
}
lstBotList
->
clear
();
stBotInfo
->
setText
(
L""
);
for
(
unsigned
int
i
=
0
;
i
<
botInfo
.
size
();
++
i
)
{
lstBotList
->
addItem
(
botInfo
[
i
].
name
);
}
if
(
botInfo
.
size
()
==
0
)
SetStaticText
(
stBotInfo
,
200
,
guiFont
,
dataManager
.
GetSysString
(
1385
));
}
void
Game
::
LoadConfig
()
{
FILE
*
fp
=
fopen
(
"system.conf"
,
"r"
);
if
(
!
fp
)
...
...
@@ -969,6 +1024,7 @@ void Game::LoadConfig() {
gameConf
.
auto_search_limit
=
-
1
;
gameConf
.
chkIgnoreDeckChanges
=
0
;
gameConf
.
defaultOT
=
1
;
gameConf
.
enable_bot_mode
=
0
;
while
(
fgets
(
linebuf
,
256
,
fp
))
{
sscanf
(
linebuf
,
"%s = %s"
,
strbuf
,
valbuf
);
if
(
!
strcmp
(
strbuf
,
"antialias"
))
{
...
...
@@ -1029,6 +1085,10 @@ void Game::LoadConfig() {
gameConf
.
chkIgnoreDeckChanges
=
atoi
(
valbuf
);
}
else
if
(
!
strcmp
(
strbuf
,
"default_ot"
))
{
gameConf
.
defaultOT
=
atoi
(
valbuf
);
}
else
if
(
!
strcmp
(
strbuf
,
"enable_bot_mode"
))
{
#ifdef _WIN32
gameConf
.
enable_bot_mode
=
atoi
(
valbuf
);
#endif
}
else
{
// options allowing multiple words
sscanf
(
linebuf
,
"%s = %240[^
\n
]"
,
strbuf
,
valbuf
);
...
...
@@ -1088,6 +1148,7 @@ void Game::SaveConfig() {
fprintf
(
fp
,
"auto_search_limit = %d
\n
"
,
gameConf
.
auto_search_limit
);
fprintf
(
fp
,
"ignore_deck_changes = %d
\n
"
,
((
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
?
1
:
0
));
fprintf
(
fp
,
"default_ot = %d
\n
"
,
gameConf
.
defaultOT
);
fprintf
(
fp
,
"enable_bot_mode = %d
\n
"
,
gameConf
.
enable_bot_mode
);
fclose
(
fp
);
}
void
Game
::
ShowCardInfo
(
int
code
)
{
...
...
gframe/game.h
View file @
c6d7d016
...
...
@@ -46,6 +46,7 @@ struct Config {
int
auto_search_limit
;
int
chkIgnoreDeckChanges
;
int
defaultOT
;
int
enable_bot_mode
;
};
struct
DuelInfo
{
...
...
@@ -73,6 +74,14 @@ struct DuelInfo {
unsigned
short
time_left
[
2
];
};
struct
BotInfo
{
wchar_t
name
[
256
];
wchar_t
command
[
256
];
wchar_t
desc
[
256
];
bool
support_master_rule_3
;
bool
support_new_master_rule
;
};
struct
FadingUnit
{
bool
signalAction
;
bool
isFadein
;
...
...
@@ -103,6 +112,7 @@ public:
void
RefreshDeck
(
irr
::
gui
::
IGUIComboBox
*
cbDeck
);
void
RefreshReplay
();
void
RefreshSingleplay
();
void
RefreshBot
();
void
DrawSelectionLine
(
irr
::
video
::
S3DVertex
*
vec
,
bool
strip
,
int
width
,
float
*
cv
);
void
DrawBackGround
();
void
DrawLinkedZones
(
ClientCard
*
pcard
);
...
...
@@ -153,6 +163,7 @@ public:
std
::
list
<
FadingUnit
>
fadingList
;
std
::
vector
<
int
>
logParam
;
std
::
wstring
chatMsg
[
8
];
std
::
vector
<
BotInfo
>
botInfo
;
int
hideChatTimer
;
bool
hideChat
;
...
...
@@ -233,7 +244,7 @@ public:
//main menu
irr
::
gui
::
IGUIWindow
*
wMainMenu
;
irr
::
gui
::
IGUIButton
*
btnLanMode
;
irr
::
gui
::
IGUIButton
*
btnS
erver
Mode
;
irr
::
gui
::
IGUIButton
*
btnS
ingle
Mode
;
irr
::
gui
::
IGUIButton
*
btnReplayMode
;
irr
::
gui
::
IGUIButton
*
btnTestMode
;
irr
::
gui
::
IGUIButton
*
btnDeckEdit
;
...
...
@@ -288,6 +299,14 @@ public:
irr
::
gui
::
IGUIEditBox
*
ebRepStartTurn
;
//single play
irr
::
gui
::
IGUIWindow
*
wSinglePlay
;
irr
::
gui
::
IGUIListBox
*
lstBotList
;
irr
::
gui
::
IGUIStaticText
*
stBotInfo
;
irr
::
gui
::
IGUIButton
*
btnStartBot
;
irr
::
gui
::
IGUIButton
*
btnBotCancel
;
irr
::
gui
::
IGUICheckBox
*
chkBotOldRule
;
irr
::
gui
::
IGUICheckBox
*
chkBotHand
;
irr
::
gui
::
IGUICheckBox
*
chkBotNoCheckDeck
;
irr
::
gui
::
IGUICheckBox
*
chkBotNoShuffleDeck
;
irr
::
gui
::
IGUIListBox
*
lstSinglePlayList
;
irr
::
gui
::
IGUIStaticText
*
stSinglePlayInfo
;
irr
::
gui
::
IGUIButton
*
btnLoadSinglePlay
;
...
...
@@ -582,6 +601,9 @@ extern HostInfo game_info;
#define BUTTON_REPLAY_SWAP 325
#define BUTTON_REPLAY_SAVE 330
#define BUTTON_REPLAY_CANCEL 331
#define BUTTON_BOT_START 340
#define LISTBOX_BOT_LIST 341
#define CHECKBOX_BOT_OLD_RULE 342
#define LISTBOX_SINGLEPLAY_LIST 350
#define BUTTON_LOAD_SINGLEPLAY 351
#define BUTTON_CANCEL_SINGLEPLAY 352
...
...
gframe/gframe.cpp
View file @
c6d7d016
...
...
@@ -11,6 +11,7 @@ int enable_log = 0;
bool
exit_on_return
=
false
;
bool
open_file
=
false
;
wchar_t
open_file_name
[
256
]
=
L""
;
bool
bot_mode
=
false
;
void
GetParameter
(
char
*
param
,
const
char
*
arg
)
{
#ifdef _WIN32
...
...
@@ -200,7 +201,7 @@ int main(int argc, char* argv[]) {
open_file
=
true
;
GetParameterW
(
open_file_name
,
&
argv
[
i
+
1
][
0
]);
}
ClickButton
(
ygo
::
mainGame
->
btnS
erver
Mode
);
ClickButton
(
ygo
::
mainGame
->
btnS
ingle
Mode
);
if
(
open_file
)
ClickButton
(
ygo
::
mainGame
->
btnLoadSinglePlay
);
break
;
...
...
gframe/menu_handler.cpp
View file @
c6d7d016
...
...
@@ -46,6 +46,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
}
case
BUTTON_JOIN_HOST
:
{
bot_mode
=
false
;
char
ip
[
20
];
const
wchar_t
*
pstr
=
mainGame
->
ebJoinHost
->
getText
();
BufferIO
::
CopyWStr
(
pstr
,
ip
,
16
);
...
...
@@ -103,6 +104,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
}
case
BUTTON_HOST_CONFIRM
:
{
bot_mode
=
false
;
BufferIO
::
CopyWStr
(
mainGame
->
ebServerName
->
getText
(),
mainGame
->
gameConf
.
gamename
,
20
);
if
(
!
NetServer
::
StartServer
(
mainGame
->
gameConf
.
serverport
))
break
;
...
...
@@ -167,8 +169,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
mainGame
->
btnStartBot
->
setEnabled
(
true
);
mainGame
->
btnBotCancel
->
setEnabled
(
true
);
mainGame
->
HideElement
(
mainGame
->
wHostPrepare
);
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
if
(
bot_mode
)
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
else
mainGame
->
ShowElement
(
mainGame
->
wLanWindow
);
mainGame
->
wChat
->
setVisible
(
false
);
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
...
...
@@ -185,6 +192,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
HideElement
(
mainGame
->
wMainMenu
);
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
mainGame
->
RefreshSingleplay
();
mainGame
->
RefreshBot
();
break
;
}
case
BUTTON_LOAD_REPLAY
:
{
...
...
@@ -227,6 +235,58 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
ShowElement
(
mainGame
->
wMainMenu
);
break
;
}
case
BUTTON_BOT_START
:
{
int
sel
=
mainGame
->
lstBotList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
bot_mode
=
true
;
#ifdef _WIN32
if
(
!
NetServer
::
StartServer
(
mainGame
->
gameConf
.
serverport
))
break
;
if
(
!
DuelClient
::
StartClient
(
0x7f000001
,
mainGame
->
gameConf
.
serverport
))
{
NetServer
::
StopServer
();
break
;
}
STARTUPINFO
si
;
PROCESS_INFORMATION
pi
;
ZeroMemory
(
&
si
,
sizeof
(
si
));
si
.
cb
=
sizeof
(
si
);
ZeroMemory
(
&
pi
,
sizeof
(
pi
));
wchar_t
*
cmd
=
new
wchar_t
[
MAX_PATH
];
int
flag
=
0
;
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
myswprintf
(
cmd
,
L"Bot.exe
\"
%ls
\"
%d %d"
,
mainGame
->
botInfo
[
sel
].
command
,
flag
,
mainGame
->
gameConf
.
serverport
);
if
(
!
CreateProcessW
(
NULL
,
cmd
,
NULL
,
NULL
,
FALSE
,
0
,
NULL
,
NULL
,
&
si
,
&
pi
))
{
NetServer
::
StopServer
();
break
;
}
#else
if
(
fork
()
==
0
)
{
usleep
(
100000
);
char
arg1
[
512
];
BufferIO
::
EncodeUTF8
(
mainGame
->
botInfo
[
sel
].
command
,
arg1
);
int
flag
=
0
;
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
char
arg2
[
8
];
sprintf
(
arg2
,
"%d"
,
flag
);
char
arg3
[
8
];
sprintf
(
arg3
,
"%d"
,
mainGame
->
gameConf
.
serverport
);
execl
(
"./bot"
,
"bot"
,
arg1
,
arg2
,
arg3
,
NULL
);
exit
(
0
);
}
else
{
if
(
!
NetServer
::
StartServer
(
mainGame
->
gameConf
.
serverport
))
break
;
if
(
!
DuelClient
::
StartClient
(
0x7f000001
,
mainGame
->
gameConf
.
serverport
))
{
NetServer
::
StopServer
();
break
;
}
}
#endif
mainGame
->
btnStartBot
->
setEnabled
(
false
);
mainGame
->
btnBotCancel
->
setEnabled
(
false
);
break
;
}
case
BUTTON_LOAD_SINGLEPLAY
:
{
if
(
!
open_file
&&
mainGame
->
lstSinglePlayList
->
getSelected
()
==
-
1
)
break
;
...
...
@@ -317,6 +377,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
SetStaticText
(
mainGame
->
stReplayInfo
,
180
,
mainGame
->
guiFont
,
(
wchar_t
*
)
repinfo
.
c_str
());
break
;
}
case
LISTBOX_BOT_LIST
:
{
int
sel
=
mainGame
->
lstBotList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
SetStaticText
(
mainGame
->
stBotInfo
,
200
,
mainGame
->
guiFont
,
mainGame
->
botInfo
[
sel
].
desc
);
break
;
}
}
break
;
}
...
...
@@ -341,6 +408,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break
;
}
case
CHECKBOX_BOT_OLD_RULE
:
{
mainGame
->
RefreshBot
();
break
;
}
}
break
;
}
...
...
strings.conf
View file @
c6d7d016
...
...
@@ -301,9 +301,12 @@
!
system
1276
自动排列连锁顺序
!
system
1277
没有可连锁的卡时延迟回应
!
system
1278
自动选择魔陷卡片位置
<<<<<<<
HEAD
!
system
1279
开启音效
!
system
1280
开启音乐
!
system
1281
按场景切换音乐
=======
>>>>>>>
d269645
...
add
bot
mode
(
#2059)
!
system
1290
忽略对方发言
!
system
1291
忽略观战者发言
!
system
1292
忽略时点
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment