Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
W
Windbot-408
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
神之吹息
Windbot-408
Commits
e29d534d
Commit
e29d534d
authored
May 25, 2018
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add Executor.OnCardSorting
parent
5cfb5b78
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
2 deletions
+68
-2
Game/AI/Executor.cs
Game/AI/Executor.cs
+6
-0
Game/GameAI.cs
Game/GameAI.cs
+20
-0
Game/GameBehavior.cs
Game/GameBehavior.cs
+42
-2
No files found.
Game/AI/Executor.cs
View file @
e29d534d
...
@@ -146,6 +146,12 @@ namespace WindBot.Game.AI
...
@@ -146,6 +146,12 @@ namespace WindBot.Game.AI
return
null
;
return
null
;
}
}
public
virtual
IList
<
ClientCard
>
OnCardSorting
(
IList
<
ClientCard
>
cards
)
{
// For overriding
return
null
;
}
public
virtual
bool
OnSelectYesNo
(
int
desc
)
public
virtual
bool
OnSelectYesNo
(
int
desc
)
{
{
return
true
;
return
true
;
...
...
Game/GameAI.cs
View file @
e29d534d
...
@@ -329,6 +329,26 @@ namespace WindBot.Game
...
@@ -329,6 +329,26 @@ namespace WindBot.Game
return
used
;
return
used
;
}
}
/// <summary>
/// Called when the AI has to sort cards.
/// </summary>
/// <param name="cards">Cards to sort.</param>
/// <returns>List of sorted cards.</returns>
public
IList
<
ClientCard
>
OnCardSorting
(
IList
<
ClientCard
>
cards
)
{
IList
<
ClientCard
>
result
=
Executor
.
OnCardSorting
(
cards
);
if
(
result
!=
null
)
return
result
;
result
=
new
List
<
ClientCard
>();
// TODO: use selector
for
(
int
i
=
0
;
i
<
cards
.
Count
;
i
++)
{
result
.
Add
(
cards
[
i
]);
}
return
result
;
}
/// <summary>
/// <summary>
/// Called when the AI has to choose to activate or not an effect.
/// Called when the AI has to choose to activate or not an effect.
/// </summary>
/// </summary>
...
...
Game/GameBehavior.cs
View file @
e29d534d
...
@@ -552,8 +552,48 @@ namespace WindBot.Game
...
@@ -552,8 +552,48 @@ namespace WindBot.Game
private
void
OnCardSorting
(
BinaryReader
packet
)
private
void
OnCardSorting
(
BinaryReader
packet
)
{
{
/*BinaryWriter writer =*/
GamePacketFactory
.
Create
(
CtosMessage
.
Response
);
/*int player =*/
GetLocalPlayer
(
packet
.
ReadByte
());
Connection
.
Send
(
CtosMessage
.
Response
,
-
1
);
IList
<
ClientCard
>
originalCards
=
new
List
<
ClientCard
>();
IList
<
ClientCard
>
cards
=
new
List
<
ClientCard
>();
int
count
=
packet
.
ReadByte
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
int
id
=
packet
.
ReadInt32
();
int
controler
=
GetLocalPlayer
(
packet
.
ReadByte
());
CardLocation
loc
=
(
CardLocation
)
packet
.
ReadByte
();
int
seq
=
packet
.
ReadByte
();
ClientCard
card
;
if
(((
int
)
loc
&
(
int
)
CardLocation
.
Overlay
)
!=
0
)
card
=
new
ClientCard
(
id
,
CardLocation
.
Overlay
);
else
card
=
_duel
.
GetCard
(
controler
,
loc
,
seq
);
if
(
card
==
null
)
continue
;
if
(
id
!=
0
)
card
.
SetId
(
id
);
originalCards
.
Add
(
card
);
cards
.
Add
(
card
);
}
IList
<
ClientCard
>
selected
=
_ai
.
OnCardSorting
(
cards
);
byte
[]
result
=
new
byte
[
count
];
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
int
id
=
0
;
for
(
int
j
=
0
;
j
<
count
;
++
j
)
{
if
(
selected
[
j
]
==
null
)
continue
;
if
(
selected
[
j
].
Equals
(
originalCards
[
i
]))
{
id
=
j
;
break
;
}
}
result
[
i
]
=
(
byte
)
id
;
}
BinaryWriter
reply
=
GamePacketFactory
.
Create
(
CtosMessage
.
Response
);
reply
.
Write
(
result
);
Connection
.
Send
(
reply
);
}
}
private
void
OnChainSorting
(
BinaryReader
packet
)
private
void
OnChainSorting
(
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