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
List
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
HiiragiGuardians
windbot
Commits
6ea84fe7
Commit
6ea84fe7
authored
Mar 13, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add buildUpdateDeck
parent
59c84707
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
Game/GameBehavior.cs
Game/GameBehavior.cs
+21
-20
No files found.
Game/GameBehavior.cs
View file @
6ea84fe7
...
@@ -28,6 +28,7 @@ namespace WindBot.Game
...
@@ -28,6 +28,7 @@ namespace WindBot.Game
private
bool
_debug
;
private
bool
_debug
;
private
int
_select_hint
;
private
int
_select_hint
;
private
GameMessage
_lastMessage
;
private
GameMessage
_lastMessage
;
private
int
lastDuelResult
;
public
GameBehavior
(
GameClient
game
)
public
GameBehavior
(
GameClient
game
)
{
{
...
@@ -47,6 +48,7 @@ namespace WindBot.Game
...
@@ -47,6 +48,7 @@ namespace WindBot.Game
Deck
=
Deck
.
Load
(
Game
.
DeckFile
??
_ai
.
Executor
.
Deck
);
Deck
=
Deck
.
Load
(
Game
.
DeckFile
??
_ai
.
Executor
.
Deck
);
_select_hint
=
0
;
_select_hint
=
0
;
lastDuelResult
=
2
;
}
}
public
int
GetLocalPlayer
(
int
player
)
public
int
GetLocalPlayer
(
int
player
)
...
@@ -144,6 +146,19 @@ namespace WindBot.Game
...
@@ -144,6 +146,19 @@ namespace WindBot.Game
_messages
.
Add
(
GameMessage
.
FlipSummoned
,
OnSummoned
);
_messages
.
Add
(
GameMessage
.
FlipSummoned
,
OnSummoned
);
}
}
private
BinaryWriter
buildUpdateDeck
(
Deck
targetDeck
)
{
BinaryWriter
deck
=
GamePacketFactory
.
Create
(
CtosMessage
.
UpdateDeck
);
deck
.
Write
(
targetDeck
.
Cards
.
Count
+
targetDeck
.
ExtraCards
.
Count
);
deck
.
Write
(
targetDeck
.
SideCards
.
Count
);
foreach
(
NamedCard
card
in
targetDeck
.
Cards
)
deck
.
Write
(
card
.
Id
);
foreach
(
NamedCard
card
in
targetDeck
.
ExtraCards
)
deck
.
Write
(
card
.
Id
);
foreach
(
NamedCard
card
in
targetDeck
.
SideCards
)
deck
.
Write
(
card
.
Id
);
return
deck
;
}
private
void
OnJoinGame
(
BinaryReader
packet
)
private
void
OnJoinGame
(
BinaryReader
packet
)
{
{
/*int lflist = (int)*/
packet
.
ReadUInt32
();
/*int lflist = (int)*/
packet
.
ReadUInt32
();
...
@@ -152,30 +167,14 @@ namespace WindBot.Game
...
@@ -152,30 +167,14 @@ namespace WindBot.Game
int
duel_rule
=
packet
.
ReadByte
();
int
duel_rule
=
packet
.
ReadByte
();
_ai
.
Duel
.
IsNewRule
=
(
duel_rule
>=
4
);
_ai
.
Duel
.
IsNewRule
=
(
duel_rule
>=
4
);
_ai
.
Duel
.
IsNewRule2020
=
(
duel_rule
>=
5
);
_ai
.
Duel
.
IsNewRule2020
=
(
duel_rule
>=
5
);
BinaryWriter
deck
=
GamePacketFactory
.
Create
(
CtosMessage
.
UpdateDeck
);
BinaryWriter
deck
=
buildUpdateDeck
(
Deck
);
deck
.
Write
(
Deck
.
Cards
.
Count
+
Deck
.
ExtraCards
.
Count
);
deck
.
Write
(
Deck
.
SideCards
.
Count
);
foreach
(
NamedCard
card
in
Deck
.
Cards
)
deck
.
Write
(
card
.
Id
);
foreach
(
NamedCard
card
in
Deck
.
ExtraCards
)
deck
.
Write
(
card
.
Id
);
foreach
(
NamedCard
card
in
Deck
.
SideCards
)
deck
.
Write
(
card
.
Id
);
Connection
.
Send
(
deck
);
Connection
.
Send
(
deck
);
_ai
.
OnJoinGame
();
_ai
.
OnJoinGame
();
}
}
private
void
OnChangeSide
(
BinaryReader
packet
)
private
void
OnChangeSide
(
BinaryReader
packet
)
{
{
BinaryWriter
deck
=
GamePacketFactory
.
Create
(
CtosMessage
.
UpdateDeck
);
BinaryWriter
deck
=
buildUpdateDeck
(
Deck
);
deck
.
Write
(
Deck
.
Cards
.
Count
+
Deck
.
ExtraCards
.
Count
);
deck
.
Write
(
Deck
.
SideCards
.
Count
);
foreach
(
NamedCard
card
in
Deck
.
Cards
)
deck
.
Write
(
card
.
Id
);
foreach
(
NamedCard
card
in
Deck
.
ExtraCards
)
deck
.
Write
(
card
.
Id
);
foreach
(
NamedCard
card
in
Deck
.
SideCards
)
deck
.
Write
(
card
.
Id
);
Connection
.
Send
(
deck
);
Connection
.
Send
(
deck
);
_ai
.
OnJoinGame
();
_ai
.
OnJoinGame
();
}
}
...
@@ -359,7 +358,7 @@ namespace WindBot.Game
...
@@ -359,7 +358,7 @@ namespace WindBot.Game
extra
=
packet
.
ReadInt16
();
extra
=
packet
.
ReadInt16
();
_duel
.
Fields
[
GetLocalPlayer
(
1
)].
Init
(
deck
,
extra
);
_duel
.
Fields
[
GetLocalPlayer
(
1
)].
Init
(
deck
,
extra
);
Logger
.
Debug
WriteLine
(
"Duel started: "
+
_room
.
Names
[
0
]
+
" versus "
+
_room
.
Names
[
1
]);
Logger
.
WriteLine
(
"Duel started: "
+
_room
.
Names
[
0
]
+
" versus "
+
_room
.
Names
[
1
]);
_ai
.
OnStart
();
_ai
.
OnStart
();
}
}
...
@@ -367,9 +366,11 @@ namespace WindBot.Game
...
@@ -367,9 +366,11 @@ namespace WindBot.Game
{
{
int
result
=
GetLocalPlayer
(
packet
.
ReadByte
());
int
result
=
GetLocalPlayer
(
packet
.
ReadByte
());
lastDuelResult
=
result
;
string
otherName
=
_room
.
Position
==
0
?
_room
.
Names
[
1
]
:
_room
.
Names
[
0
];
string
otherName
=
_room
.
Position
==
0
?
_room
.
Names
[
1
]
:
_room
.
Names
[
0
];
string
textResult
=
(
result
==
2
?
"Draw"
:
result
==
0
?
"Win"
:
"Lose"
);
string
textResult
=
(
result
==
2
?
"Draw"
:
result
==
0
?
"Win"
:
"Lose"
);
Logger
.
Debug
WriteLine
(
"Duel finished against "
+
otherName
+
", result: "
+
textResult
);
Logger
.
WriteLine
(
"Duel finished against "
+
otherName
+
", result: "
+
textResult
);
}
}
private
void
OnDraw
(
BinaryReader
packet
)
private
void
OnDraw
(
BinaryReader
packet
)
...
...
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