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
8f0d12cd
Commit
8f0d12cd
authored
Nov 13, 2017
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'selectunselect' of
https://github.com/IceYGO/windbot
parents
82e5e968
b1017ebc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
3 deletions
+81
-3
Game/GameAI.cs
Game/GameAI.cs
+5
-3
Game/GameBehavior.cs
Game/GameBehavior.cs
+76
-0
No files found.
Game/GameAI.cs
View file @
8f0d12cd
...
@@ -222,9 +222,11 @@ namespace WindBot.Game
...
@@ -222,9 +222,11 @@ namespace WindBot.Game
// Always select the first available cards and choose the minimum.
// Always select the first available cards and choose the minimum.
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
for
(
int
i
=
0
;
i
<
min
;
++
i
)
if
(
cards
.
Count
>=
min
)
selected
.
Add
(
cards
[
i
]);
{
for
(
int
i
=
0
;
i
<
min
;
++
i
)
selected
.
Add
(
cards
[
i
]);
}
return
selected
;
return
selected
;
}
}
...
...
Game/GameBehavior.cs
View file @
8f0d12cd
...
@@ -127,6 +127,9 @@ namespace WindBot.Game
...
@@ -127,6 +127,9 @@ namespace WindBot.Game
_messages
.
Add
(
GameMessage
.
SpSummoning
,
OnSpSummon
);
_messages
.
Add
(
GameMessage
.
SpSummoning
,
OnSpSummon
);
_messages
.
Add
(
GameMessage
.
SpSummoned
,
OnSpSummon
);
_messages
.
Add
(
GameMessage
.
SpSummoned
,
OnSpSummon
);
_messages
.
Add
((
GameMessage
)
190
,
OnSelectUnselectCard
);
// only in edopro
}
}
private
void
OnJoinGame
(
BinaryReader
packet
)
private
void
OnJoinGame
(
BinaryReader
packet
)
...
@@ -719,11 +722,84 @@ namespace WindBot.Game
...
@@ -719,11 +722,84 @@ namespace WindBot.Game
Connection
.
Send
(
reply
);
Connection
.
Send
(
reply
);
}
}
private
void
InternalOnSelectUnselectCard
(
BinaryReader
packet
,
Func
<
IList
<
ClientCard
>,
int
,
int
,
int
,
bool
,
IList
<
ClientCard
>>
func
)
{
packet
.
ReadByte
();
// player
packet
.
ReadByte
();
// buttonok
bool
cancelable
=
packet
.
ReadByte
()
!=
0
;
int
min
=
packet
.
ReadByte
();
int
max
=
packet
.
ReadByte
();
IList
<
ClientCard
>
cards
=
new
List
<
ClientCard
>();
int
count
=
packet
.
ReadByte
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
int
id
=
packet
.
ReadInt32
();
int
player
=
GetLocalPlayer
(
packet
.
ReadByte
());
CardLocation
loc
=
(
CardLocation
)
packet
.
ReadByte
();
int
seq
=
packet
.
ReadByte
();
packet
.
ReadByte
();
// pos
ClientCard
card
;
if
(((
int
)
loc
&
(
int
)
CardLocation
.
Overlay
)
!=
0
)
card
=
new
ClientCard
(
id
,
CardLocation
.
Overlay
);
else
card
=
_duel
.
GetCard
(
player
,
loc
,
seq
);
if
(
card
==
null
)
continue
;
if
(
card
.
Id
==
0
)
card
.
SetId
(
id
);
cards
.
Add
(
card
);
}
int
count2
=
packet
.
ReadByte
();
for
(
int
i
=
0
;
i
<
count2
;
++
i
)
{
int
id
=
packet
.
ReadInt32
();
int
player
=
GetLocalPlayer
(
packet
.
ReadByte
());
CardLocation
loc
=
(
CardLocation
)
packet
.
ReadByte
();
int
seq
=
packet
.
ReadByte
();
packet
.
ReadByte
();
// pos
}
IList
<
ClientCard
>
selected
=
func
(
cards
,
min
,
max
,
_select_hint
,
cancelable
);
_select_hint
=
0
;
if
(
selected
.
Count
==
0
&&
cancelable
)
{
Connection
.
Send
(
CtosMessage
.
Response
,
-
1
);
return
;
}
byte
[]
result
=
new
byte
[
selected
.
Count
+
1
];
result
[
0
]
=
(
byte
)
selected
.
Count
;
for
(
int
i
=
0
;
i
<
selected
.
Count
;
++
i
)
{
int
id
=
0
;
for
(
int
j
=
0
;
j
<
count
;
++
j
)
{
if
(
cards
[
j
]
==
null
)
continue
;
if
(
cards
[
j
].
Equals
(
selected
[
i
]))
{
id
=
j
;
break
;
}
}
result
[
i
+
1
]
=
(
byte
)
id
;
}
BinaryWriter
reply
=
GamePacketFactory
.
Create
(
CtosMessage
.
Response
);
reply
.
Write
(
result
);
Connection
.
Send
(
reply
);
}
private
void
OnSelectCard
(
BinaryReader
packet
)
private
void
OnSelectCard
(
BinaryReader
packet
)
{
{
InternalOnSelectCard
(
packet
,
_ai
.
OnSelectCard
);
InternalOnSelectCard
(
packet
,
_ai
.
OnSelectCard
);
}
}
private
void
OnSelectUnselectCard
(
BinaryReader
packet
)
{
InternalOnSelectUnselectCard
(
packet
,
_ai
.
OnSelectCard
);
}
private
void
OnSelectChain
(
BinaryReader
packet
)
private
void
OnSelectChain
(
BinaryReader
packet
)
{
{
packet
.
ReadByte
();
// player
packet
.
ReadByte
();
// player
...
...
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