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
神之吹息
windbot
Commits
c626f14f
Commit
c626f14f
authored
Nov 03, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comment
parent
360bfea5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
8 deletions
+39
-8
Game/AI/Executor.cs
Game/AI/Executor.cs
+30
-0
Game/GameAI.cs
Game/GameAI.cs
+3
-7
Program.cs
Program.cs
+4
-1
README.md
README.md
+2
-0
No files found.
Game/AI/Executor.cs
View file @
c626f14f
...
@@ -50,6 +50,12 @@ namespace WindBot.Game.AI
...
@@ -50,6 +50,12 @@ namespace WindBot.Game.AI
return
Program
.
Rand
.
Next
(
2
)
>
0
;
return
Program
.
Rand
.
Next
(
2
)
>
0
;
}
}
/// <summary>
/// Called when the AI has to decide if it should attack
/// </summary>
/// <param name="attackers">List of monsters that can attcack.</param>
/// <param name="defenders">List of monsters of enemy.</param>
/// <returns>A new BattlePhaseAction containing the action to do.</returns>
public
virtual
BattlePhaseAction
OnBattle
(
IList
<
ClientCard
>
attackers
,
IList
<
ClientCard
>
defenders
)
public
virtual
BattlePhaseAction
OnBattle
(
IList
<
ClientCard
>
attackers
,
IList
<
ClientCard
>
defenders
)
{
{
if
(
attackers
.
Count
==
0
)
if
(
attackers
.
Count
==
0
)
...
@@ -86,6 +92,13 @@ namespace WindBot.Game.AI
...
@@ -86,6 +92,13 @@ namespace WindBot.Game.AI
return
AI
.
ToMainPhase2
();
return
AI
.
ToMainPhase2
();
}
}
/// <summary>
/// Decide whether to declare attack between attacker and defender.
/// Can be overrided to update the RealPower of attacker for cards like Honest.
/// </summary>
/// <param name="attacker">Card that attack.</param>
/// <param name="defender">Card that defend.</param>
/// <returns>true if the attack can be done.</returns>
public
virtual
bool
OnPreBattleBetween
(
ClientCard
attacker
,
ClientCard
defender
)
public
virtual
bool
OnPreBattleBetween
(
ClientCard
attacker
,
ClientCard
defender
)
{
{
if
(
defender
.
IsMonsterInvincible
())
if
(
defender
.
IsMonsterInvincible
())
...
@@ -115,11 +128,13 @@ namespace WindBot.Game.AI
...
@@ -115,11 +128,13 @@ namespace WindBot.Game.AI
public
virtual
IList
<
ClientCard
>
OnSelectCard
(
IList
<
ClientCard
>
cards
,
int
min
,
int
max
,
bool
cancelable
)
public
virtual
IList
<
ClientCard
>
OnSelectCard
(
IList
<
ClientCard
>
cards
,
int
min
,
int
max
,
bool
cancelable
)
{
{
// For overriding
return
null
;
return
null
;
}
}
public
virtual
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
public
virtual
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
{
{
// For overriding
return
null
;
return
null
;
}
}
...
@@ -181,6 +196,9 @@ namespace WindBot.Game.AI
...
@@ -181,6 +196,9 @@ namespace WindBot.Game.AI
Battle
=
battle
;
Battle
=
battle
;
}
}
/// <summary>
/// Set global variables Type, Card, ActivateDescription for Executor
/// </summary>
public
void
SetCard
(
ExecutorType
type
,
ClientCard
card
,
int
description
)
public
void
SetCard
(
ExecutorType
type
,
ClientCard
card
,
int
description
)
{
{
Type
=
type
;
Type
=
type
;
...
@@ -188,21 +206,33 @@ namespace WindBot.Game.AI
...
@@ -188,21 +206,33 @@ namespace WindBot.Game.AI
ActivateDescription
=
description
;
ActivateDescription
=
description
;
}
}
/// <summary>
/// Do the action for the card if func return true.
/// </summary>
public
void
AddExecutor
(
ExecutorType
type
,
int
cardId
,
Func
<
bool
>
func
)
public
void
AddExecutor
(
ExecutorType
type
,
int
cardId
,
Func
<
bool
>
func
)
{
{
Executors
.
Add
(
new
CardExecutor
(
type
,
cardId
,
func
));
Executors
.
Add
(
new
CardExecutor
(
type
,
cardId
,
func
));
}
}
/// <summary>
/// Do the action for the card if available.
/// </summary>
public
void
AddExecutor
(
ExecutorType
type
,
int
cardId
)
public
void
AddExecutor
(
ExecutorType
type
,
int
cardId
)
{
{
Executors
.
Add
(
new
CardExecutor
(
type
,
cardId
,
null
));
Executors
.
Add
(
new
CardExecutor
(
type
,
cardId
,
null
));
}
}
/// <summary>
/// Do the action for every card if func return true.
/// </summary>
public
void
AddExecutor
(
ExecutorType
type
,
Func
<
bool
>
func
)
public
void
AddExecutor
(
ExecutorType
type
,
Func
<
bool
>
func
)
{
{
Executors
.
Add
(
new
CardExecutor
(
type
,
-
1
,
func
));
Executors
.
Add
(
new
CardExecutor
(
type
,
-
1
,
func
));
}
}
/// <summary>
/// Do the action for every card if no other Executor is added to it.
/// </summary>
public
void
AddExecutor
(
ExecutorType
type
)
public
void
AddExecutor
(
ExecutorType
type
)
{
{
Executors
.
Add
(
new
CardExecutor
(
type
,
-
1
,
DefaultNoExecutor
));
Executors
.
Add
(
new
CardExecutor
(
type
,
-
1
,
DefaultNoExecutor
));
...
...
Game/GameAI.cs
View file @
c626f14f
...
@@ -75,6 +75,7 @@ namespace WindBot.Game
...
@@ -75,6 +75,7 @@ namespace WindBot.Game
/// </summary>
/// </summary>
public
void
OnNewTurn
()
public
void
OnNewTurn
()
{
{
Executor
.
OnNewTurn
();
}
}
/// <summary>
/// <summary>
...
@@ -91,7 +92,6 @@ namespace WindBot.Game
...
@@ -91,7 +92,6 @@ namespace WindBot.Game
if
(
Duel
.
Player
==
0
&&
Duel
.
Phase
==
DuelPhase
.
Draw
)
if
(
Duel
.
Player
==
0
&&
Duel
.
Phase
==
DuelPhase
.
Draw
)
{
{
_dialogs
.
SendNewTurn
();
_dialogs
.
SendNewTurn
();
Executor
.
OnNewTurn
();
}
}
}
}
...
@@ -102,10 +102,6 @@ namespace WindBot.Game
...
@@ -102,10 +102,6 @@ namespace WindBot.Game
{
{
_dialogs
.
SendOnDirectAttack
(
card
.
Name
);
_dialogs
.
SendOnDirectAttack
(
card
.
Name
);
}
}
public
void
OnDirectAttack
()
{
_dialogs
.
SendOnDirectAttack
();
}
/// <summary>
/// <summary>
/// Called when a chain is executed.
/// Called when a chain is executed.
...
@@ -369,13 +365,13 @@ namespace WindBot.Game
...
@@ -369,13 +365,13 @@ namespace WindBot.Game
}
}
/// <summary>
/// <summary>
/// Called when the AI has to tribute for a synchro monster.
/// Called when the AI has to tribute for a synchro monster
or ritual monster
.
/// </summary>
/// </summary>
/// <param name="cards">Available cards.</param>
/// <param name="cards">Available cards.</param>
/// <param name="sum">Result of the operation.</param>
/// <param name="sum">Result of the operation.</param>
/// <param name="min">Minimum cards.</param>
/// <param name="min">Minimum cards.</param>
/// <param name="max">Maximum cards.</param>
/// <param name="max">Maximum cards.</param>
/// <param name="mode">True for equal.</param>
/// <param name="mode">True for e
xact e
qual.</param>
/// <returns></returns>
/// <returns></returns>
public
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
public
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
,
bool
mode
)
{
{
...
...
Program.cs
View file @
c626f14f
...
@@ -11,7 +11,7 @@ namespace WindBot
...
@@ -11,7 +11,7 @@ namespace WindBot
{
{
public
class
Program
public
class
Program
{
{
//
i
n safe mode, all errors will be catched instead of causing the program to crash.
//
I
n safe mode, all errors will be catched instead of causing the program to crash.
#if DEBUG
#if DEBUG
public
static
bool
SafeMode
=
false
;
public
static
bool
SafeMode
=
false
;
#else
#else
...
@@ -34,11 +34,13 @@ namespace WindBot
...
@@ -34,11 +34,13 @@ namespace WindBot
if
(
serverMode
)
if
(
serverMode
)
{
{
// Run in server mode, provide a http interface to create bot.
int
serverPort
=
Config
.
GetInt
(
"ServerPort"
,
2399
);
int
serverPort
=
Config
.
GetInt
(
"ServerPort"
,
2399
);
RunAsServer
(
serverPort
);
RunAsServer
(
serverPort
);
}
}
else
else
{
{
// Join the host specified on the command line.
if
(
args
.
Length
==
0
)
if
(
args
.
Length
==
0
)
{
{
Logger
.
WriteLine
(
"=== WARN ==="
);
Logger
.
WriteLine
(
"=== WARN ==="
);
...
@@ -55,6 +57,7 @@ namespace WindBot
...
@@ -55,6 +57,7 @@ namespace WindBot
DecksManager
.
Init
();
DecksManager
.
Init
();
string
absolutePath
=
Path
.
GetFullPath
(
databasePath
);
string
absolutePath
=
Path
.
GetFullPath
(
databasePath
);
if
(!
File
.
Exists
(
absolutePath
))
if
(!
File
.
Exists
(
absolutePath
))
// In case windbot is placed in a folder under ygopro folder
absolutePath
=
Path
.
GetFullPath
(
"../"
+
databasePath
);
absolutePath
=
Path
.
GetFullPath
(
"../"
+
databasePath
);
if
(!
File
.
Exists
(
absolutePath
))
if
(!
File
.
Exists
(
absolutePath
))
Logger
.
WriteErrorLine
(
"Can't find cards database file. Please place cards.cdb next to WindBot.exe ."
);
Logger
.
WriteErrorLine
(
"Can't find cards database file. Please place cards.cdb next to WindBot.exe ."
);
...
...
README.md
View file @
c626f14f
...
@@ -121,6 +121,8 @@ The parameters are same as commandlines, but low cased.
...
@@ -121,6 +121,8 @@ The parameters are same as commandlines, but low cased.
*
`AI.SelectMaterials`
which select a set of cards for F/S/X/L summon
*
`AI.SelectMaterials`
which select a set of cards for F/S/X/L summon
*
`AI.SelectTribute`
*
Better new master rule support
*
Better new master rule support
*
More default common cards executor
*
More default common cards executor
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