Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
W
windbot
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
windbot
Commits
5f585012
Commit
5f585012
authored
May 29, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add verbose debug log for card movement
(some credits to Wind2009-Louse & handsomekiwi)
parent
31097d94
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
4 deletions
+57
-4
Game/GameBehavior.cs
Game/GameBehavior.cs
+49
-2
Game/GameClient.cs
Game/GameClient.cs
+2
-1
Program.cs
Program.cs
+4
-0
WindBotInfo.cs
WindBotInfo.cs
+2
-1
No files found.
Game/GameBehavior.cs
View file @
5f585012
...
...
@@ -25,6 +25,7 @@ namespace WindBot.Game
private
Room
_room
;
private
Duel
_duel
;
private
int
_hand
;
private
bool
_debug
;
private
int
_select_hint
;
public
GameBehavior
(
GameClient
game
)
...
...
@@ -32,7 +33,7 @@ namespace WindBot.Game
Game
=
game
;
Connection
=
game
.
Connection
;
_hand
=
game
.
Hand
;
_debug
=
game
.
Debug
;
_packets
=
new
Dictionary
<
StocMessage
,
Action
<
BinaryReader
>>();
_messages
=
new
Dictionary
<
GameMessage
,
Action
<
BinaryReader
>>();
RegisterPackets
();
...
...
@@ -351,6 +352,8 @@ namespace WindBot.Game
{
int
player
=
GetLocalPlayer
(
packet
.
ReadByte
());
int
count
=
packet
.
ReadByte
();
if
(
_debug
)
Logger
.
WriteLine
(
"("
+
player
.
ToString
()
+
" draw "
+
count
.
ToString
()
+
" card)"
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
...
...
@@ -422,6 +425,17 @@ namespace WindBot.Game
private
void
OnNewPhase
(
BinaryReader
packet
)
{
_duel
.
Phase
=
(
DuelPhase
)
packet
.
ReadInt16
();
if
(
_debug
&&
_duel
.
Phase
==
DuelPhase
.
Standby
)
{
Logger
.
WriteLine
(
"*********Bot Hand*********"
);
foreach
(
ClientCard
card
in
_duel
.
Fields
[
0
].
Hand
)
{
Logger
.
WriteLine
(
card
.
Name
);
}
Logger
.
WriteLine
(
"*********Bot Hand*********"
);
}
if
(
_debug
)
Logger
.
WriteLine
(
"(Go to "
+
(
_duel
.
Phase
.
ToString
())
+
")"
);
_duel
.
LastSummonPlayer
=
-
1
;
_duel
.
Fields
[
0
].
BattlingMonster
=
null
;
_duel
.
Fields
[
1
].
BattlingMonster
=
null
;
...
...
@@ -433,6 +447,8 @@ namespace WindBot.Game
int
player
=
GetLocalPlayer
(
packet
.
ReadByte
());
int
final
=
_duel
.
Fields
[
player
].
LifePoints
-
packet
.
ReadInt32
();
if
(
final
<
0
)
final
=
0
;
if
(
_debug
)
Logger
.
WriteLine
(
"("
+
player
.
ToString
()
+
" got damage , LifePoint left= "
+
final
.
ToString
()
+
")"
);
_duel
.
Fields
[
player
].
LifePoints
=
final
;
}
...
...
@@ -462,13 +478,16 @@ namespace WindBot.Game
packet
.
ReadInt32
();
// reason
ClientCard
card
=
_duel
.
GetCard
(
previousControler
,
(
CardLocation
)
previousLocation
,
previousSequence
);
if
((
previousLocation
&
(
int
)
CardLocation
.
Overlay
)
!=
0
)
{
previousLocation
=
previousLocation
&
0x7f
;
card
=
_duel
.
GetCard
(
previousControler
,
(
CardLocation
)
previousLocation
,
previousSequence
);
if
(
card
!=
null
)
{
if
(
_debug
)
Logger
.
WriteLine
(
"("
+
previousControler
.
ToString
()
+
" 's "
+
(
card
.
Name
??
"UnKnowCard"
)
+
" deattach "
+
(
NamedCard
.
Get
(
cardId
)?.
Name
)
+
")"
);
card
.
Overlays
.
Remove
(
cardId
);
}
previousLocation
=
0
;
// the card is removed when it go to overlay, so here we treat it as a new card
}
else
...
...
@@ -479,14 +498,29 @@ namespace WindBot.Game
currentLocation
=
currentLocation
&
0x7f
;
card
=
_duel
.
GetCard
(
currentControler
,
(
CardLocation
)
currentLocation
,
currentSequence
);
if
(
card
!=
null
)
{
if
(
_debug
)
Logger
.
WriteLine
(
"("
+
previousControler
.
ToString
()
+
" 's "
+
(
card
.
Name
??
"UnKnowCard"
)
+
" overlay "
+
(
NamedCard
.
Get
(
cardId
)?.
Name
)
+
")"
);
card
.
Overlays
.
Add
(
cardId
);
}
}
else
{
if
(
previousLocation
==
0
)
{
if
(
_debug
)
Logger
.
WriteLine
(
"("
+
previousControler
.
ToString
()
+
" 's "
+
(
NamedCard
.
Get
(
cardId
)?.
Name
)
+
" appear in "
+
(
CardLocation
)
currentLocation
+
")"
);
_duel
.
AddCard
((
CardLocation
)
currentLocation
,
cardId
,
currentControler
,
currentSequence
,
currentPosition
);
}
else
{
_duel
.
AddCard
((
CardLocation
)
currentLocation
,
card
,
currentControler
,
currentSequence
,
currentPosition
,
cardId
);
if
(
_debug
&&
card
!=
null
)
Logger
.
WriteLine
(
"("
+
previousControler
.
ToString
()
+
" 's "
+
(
card
.
Name
??
"UnKnowCard"
)
+
" from "
+
(
CardLocation
)
previousLocation
+
" move to "
+
(
CardLocation
)
currentLocation
+
")"
);
}
}
}
...
...
@@ -503,6 +537,11 @@ namespace WindBot.Game
ClientCard
attackcard
=
_duel
.
GetCard
(
ca
,
(
CardLocation
)
la
,
sa
);
ClientCard
defendcard
=
_duel
.
GetCard
(
cd
,
(
CardLocation
)
ld
,
sd
);
if
(
_debug
)
{
if
(
defendcard
==
null
)
Logger
.
WriteLine
(
"("
+
(
attackcard
.
Name
??
"UnKnowCard"
)
+
" direct attack!!)"
);
else
Logger
.
WriteLine
(
"("
+
ca
.
ToString
()
+
" 's "
+
(
attackcard
.
Name
??
"UnKnowCard"
)
+
" attack "
+
cd
.
ToString
()
+
" 's "
+
(
defendcard
.
Name
??
"UnKnowCard"
)
+
")"
);
}
_duel
.
Fields
[
attackcard
.
Controller
].
BattlingMonster
=
attackcard
;
_duel
.
Fields
[
1
-
attackcard
.
Controller
].
BattlingMonster
=
defendcard
;
...
...
@@ -522,7 +561,11 @@ namespace WindBot.Game
int
cp
=
packet
.
ReadSByte
();
ClientCard
card
=
_duel
.
GetCard
(
pc
,
(
CardLocation
)
pl
,
ps
);
if
(
card
!=
null
)
{
card
.
Position
=
cp
;
if
(
_debug
)
Logger
.
WriteLine
(
"("
+
(
card
.
Name
??
"UnKnowCard"
)
+
" change position to "
+
(
CardPosition
)
cp
+
")"
);
}
}
private
void
OnChaining
(
BinaryReader
packet
)
...
...
@@ -534,6 +577,8 @@ namespace WindBot.Game
int
subs
=
packet
.
ReadSByte
();
ClientCard
card
=
_duel
.
GetCard
(
pcc
,
pcl
,
pcs
,
subs
);
int
cc
=
GetLocalPlayer
(
packet
.
ReadByte
());
if
(
_debug
)
if
(
card
!=
null
)
Logger
.
WriteLine
(
"("
+
cc
.
ToString
()
+
" 's "
+
(
card
.
Name
??
"UnKnowCard"
)
+
" activate effect)"
);
_ai
.
OnChaining
(
card
,
cc
);
_duel
.
ChainTargets
.
Clear
();
_duel
.
LastSummonPlayer
=
-
1
;
...
...
@@ -669,6 +714,8 @@ namespace WindBot.Game
/*int sseq = */
packet
.
ReadByte
();
ClientCard
card
=
_duel
.
GetCard
(
player
,
(
CardLocation
)
loc
,
seq
);
if
(
card
==
null
)
continue
;
if
(
_debug
)
Logger
.
WriteLine
(
"("
+
(
CardLocation
)
loc
+
" 's "
+
(
card
.
Name
??
"UnKnowCard"
)
+
" become target)"
);
_duel
.
ChainTargets
.
Add
(
card
);
}
}
...
...
Game/GameClient.cs
View file @
5f585012
...
...
@@ -14,7 +14,7 @@ namespace WindBot.Game
public
string
Deck
;
public
string
Dialog
;
public
int
Hand
;
public
bool
Debug
;
public
bool
_chat
;
private
string
_serverHost
;
private
int
_serverPort
;
...
...
@@ -30,6 +30,7 @@ namespace WindBot.Game
Deck
=
Info
.
Deck
;
Dialog
=
Info
.
Dialog
;
Hand
=
Info
.
Hand
;
Debug
=
Info
.
Debug
;
_chat
=
Info
.
Chat
;
_serverHost
=
Info
.
Host
;
_serverPort
=
Info
.
Port
;
...
...
Program.cs
View file @
5f585012
...
...
@@ -74,6 +74,7 @@ namespace WindBot
Info
.
HostInfo
=
Config
.
GetString
(
"HostInfo"
,
Info
.
HostInfo
);
Info
.
Version
=
Config
.
GetInt
(
"Version"
,
Info
.
Version
);
Info
.
Hand
=
Config
.
GetInt
(
"Hand"
,
Info
.
Hand
);
Info
.
Debug
=
Config
.
GetBool
(
"Debug"
,
Info
.
Debug
);
Info
.
Chat
=
Config
.
GetBool
(
"Chat"
,
Info
.
Chat
);
Run
(
Info
);
}
...
...
@@ -115,6 +116,9 @@ namespace WindBot
string
hand
=
HttpUtility
.
ParseQueryString
(
RawUrl
).
Get
(
"hand"
);
if
(
hand
!=
null
)
Info
.
Hand
=
Int32
.
Parse
(
hand
);
string
debug
=
HttpUtility
.
ParseQueryString
(
RawUrl
).
Get
(
"debug"
);
if
(
debug
!=
null
)
Info
.
Debug
=
bool
.
Parse
(
debug
);
string
chat
=
HttpUtility
.
ParseQueryString
(
RawUrl
).
Get
(
"chat"
);
if
(
chat
!=
null
)
Info
.
Chat
=
bool
.
Parse
(
chat
);
...
...
WindBotInfo.cs
View file @
5f585012
...
...
@@ -12,7 +12,7 @@ namespace WindBot
public
string
HostInfo
{
get
;
set
;
}
public
int
Version
{
get
;
set
;
}
public
int
Hand
{
get
;
set
;
}
public
bool
Debug
{
get
;
set
;
}
public
bool
Chat
{
get
;
set
;
}
public
WindBotInfo
()
{
...
...
@@ -24,6 +24,7 @@ namespace WindBot
HostInfo
=
""
;
Version
=
0x1343
;
Hand
=
0
;
Debug
=
false
;
Chat
=
true
;
}
}
...
...
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