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
12cb873f
Commit
12cb873f
authored
Oct 27, 2024
by
wind2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bot won't activate cards in executor
parent
38e1571a
Pipeline
#30747
passed with stage
in 39 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
34 deletions
+59
-34
Game/AI/CardExecutor.cs
Game/AI/CardExecutor.cs
+14
-2
Game/AI/DefaultExecutor.cs
Game/AI/DefaultExecutor.cs
+5
-3
Game/AI/Executor.cs
Game/AI/Executor.cs
+20
-15
Game/GameAI.cs
Game/GameAI.cs
+20
-14
No files found.
Game/AI/CardExecutor.cs
View file @
12cb873f
...
...
@@ -6,13 +6,25 @@ namespace WindBot.Game.AI
{
public
int
CardId
{
get
;
private
set
;
}
public
ExecutorType
Type
{
get
;
private
set
;
}
public
Func
<
bool
>
Func
{
get
;
private
set
;
}
public
Func
<
bool
?
>
Func
{
get
;
private
set
;
}
public
CardExecutor
(
ExecutorType
type
,
int
cardId
,
Func
<
bool
>
func
)
public
CardExecutor
(
ExecutorType
type
,
int
cardId
,
Func
<
bool
?
>
func
)
{
CardId
=
cardId
;
Type
=
type
;
Func
=
func
;
}
public
CardExecutor
(
ExecutorType
type
,
int
cardId
,
Func
<
bool
>
func
)
{
CardId
=
cardId
;
Type
=
type
;
Func
=
ConvertToNullableFunc
(
func
);
}
public
Func
<
bool
?>
ConvertToNullableFunc
(
Func
<
bool
>
func
)
{
return
()
=>
func
();
}
}
}
\ No newline at end of file
Game/AI/DefaultExecutor.cs
View file @
12cb873f
...
...
@@ -239,6 +239,8 @@ namespace WindBot.Game.AI
});
SetFuncFilter
(
ExecutorType
.
Activate
,
()
=>
{
if
(
Card
.
IsMonster
()
||
((
Card
.
Location
&
CardLocation
.
Onfield
)
>
0
&&
Card
.
IsFaceup
()))
return
null
;
if
(
Card
.
IsCode
(
5990062
))
return
Bot
.
HasInSpellZone
(
9373534
);
//[大逆转谜题]只有在自己场上有手里剑覆盖的场合才发动
if
(
Card
.
IsCode
(
3493058
))
return
Enemy
.
GetSpellCount
()
>
0
;
//[骰子旋风]对方玩家场上有魔陷才发动
if
(
Card
.
IsCode
(
22802010
))
//[无差别崩坏]自己场上怪兽少于对方才发动
...
...
@@ -1745,7 +1747,7 @@ namespace WindBot.Game.AI
{
if
(
exec
.
Type
==
ExecutorType
.
Activate
&&
exec
.
CardId
==
Card
.
Id
)
{
if
(
exec
.
Func
==
null
||
exec
.
Func
())
if
(
exec
.
Func
==
null
||
exec
.
Func
()
==
true
)
{
return
true
;
}
...
...
@@ -1755,13 +1757,13 @@ namespace WindBot.Game.AI
return
false
;
}
protected
bool
DefaultGambleCard
()
protected
bool
?
DefaultGambleCard
()
{
int
[]
cardsname
=
new
[]
{
3280747
,
37812118
,
50470982
,
43061293
,
37313786
,
3493058
,
38299233
,
25173686
,
71625222
,
36562627
,
19162134
,
81172176
,
21598948
,
39537362
,
36378044
,
38143903
,
96012004
,
62784717
,
84290642
,
3549275
,
41139112
,
36708764
,
74137509
,
126218
,
93078761
,
76895648
,
22802010
,
83241722
,
84397023
,
31863912
,
39454112
,
59905358
,
5990062
,
9373534
,
58577036
};
if
(
Card
.
IsCode
(
cardsname
))
return
true
;
return
false
;
return
null
;
}
}
}
Game/AI/Executor.cs
View file @
12cb873f
...
...
@@ -13,7 +13,7 @@ namespace WindBot.Game.AI
public
string
Deck
{
get
;
set
;
}
public
Duel
Duel
{
get
;
private
set
;
}
public
IList
<
CardExecutor
>
Executors
{
get
;
private
set
;
}
public
Dictionary
<
ExecutorType
,
Func
<
bool
>
>
FuncFilters
{
get
;
private
set
;
}
public
Dictionary
<
ExecutorType
,
List
<
Func
<
bool
?>>
>
FuncFilters
{
get
;
private
set
;
}
public
GameAI
AI
{
get
;
private
set
;
}
public
AIUtil
Util
{
get
;
private
set
;
}
...
...
@@ -34,14 +34,14 @@ namespace WindBot.Game.AI
AI
=
ai
;
Util
=
new
AIUtil
(
duel
);
Executors
=
new
List
<
CardExecutor
>();
FuncFilters
=
new
Dictionary
<
ExecutorType
,
Func
<
bool
>>();
FuncFilters
.
Add
(
ExecutorType
.
Summon
,
n
ull
);
FuncFilters
.
Add
(
ExecutorType
.
SpSummon
,
n
ull
);
FuncFilters
.
Add
(
ExecutorType
.
MonsterSet
,
null
);
FuncFilters
.
Add
(
ExecutorType
.
Repos
,
null
);
FuncFilters
.
Add
(
ExecutorType
.
SpellSet
,
n
ull
);
FuncFilters
.
Add
(
ExecutorType
.
Activate
,
n
ull
);
FuncFilters
.
Add
(
ExecutorType
.
SummonOrSet
,
n
ull
);
FuncFilters
=
new
Dictionary
<
ExecutorType
,
List
<
Func
<
bool
?>
>>();
FuncFilters
.
Add
(
ExecutorType
.
Summon
,
n
ew
List
<
Func
<
bool
?>>()
);
FuncFilters
.
Add
(
ExecutorType
.
SpSummon
,
n
ew
List
<
Func
<
bool
?>>()
);
FuncFilters
.
Add
(
ExecutorType
.
MonsterSet
,
new
List
<
Func
<
bool
?>>()
);
FuncFilters
.
Add
(
ExecutorType
.
Repos
,
new
List
<
Func
<
bool
?>>()
);
FuncFilters
.
Add
(
ExecutorType
.
SpellSet
,
n
ew
List
<
Func
<
bool
?>>()
);
FuncFilters
.
Add
(
ExecutorType
.
Activate
,
n
ew
List
<
Func
<
bool
?>>()
);
FuncFilters
.
Add
(
ExecutorType
.
SummonOrSet
,
n
ew
List
<
Func
<
bool
?>>()
);
Bot
=
Duel
.
Fields
[
0
];
Enemy
=
Duel
.
Fields
[
1
];
}
...
...
@@ -266,9 +266,9 @@ namespace WindBot.Game.AI
CurrentTiming
=
timing
;
}
public
void
SetFuncFilter
(
ExecutorType
type
,
Func
<
bool
>
func
)
public
void
SetFuncFilter
(
ExecutorType
type
,
Func
<
bool
?
>
func
)
{
FuncFilters
[
type
]
=
func
;
FuncFilters
[
type
]
.
Add
(
func
)
;
}
/// <summary>
...
...
@@ -290,6 +290,11 @@ namespace WindBot.Game.AI
/// <summary>
/// Do the action for every card if func return true.
/// </summary>
public
void
AddExecutor
(
ExecutorType
type
,
Func
<
bool
?>
func
)
{
Executors
.
Add
(
new
CardExecutor
(
type
,
-
1
,
func
));
}
public
void
AddExecutor
(
ExecutorType
type
,
Func
<
bool
>
func
)
{
Executors
.
Add
(
new
CardExecutor
(
type
,
-
1
,
func
));
...
...
Game/GameAI.cs
View file @
12cb873f
...
...
@@ -31,7 +31,7 @@ namespace WindBot.Game
{
foreach
(
CardExecutor
exec
in
Executor
.
Executors
)
{
if
(
exec
.
Type
==
ExecutorType
.
Surrender
&&
exec
.
Func
(
))
if
(
exec
.
Type
==
ExecutorType
.
Surrender
&&
(
exec
.
Func
()
==
true
))
{
_dialogs
.
SendSurrender
();
Game
.
Surrender
();
...
...
@@ -194,11 +194,11 @@ namespace WindBot.Game
Executor
.
SetBattle
(
battle
);
foreach
(
CardExecutor
exec
in
Executor
.
Executors
)
{
if
(
exec
.
Type
==
ExecutorType
.
GoToMainPhase2
&&
battle
.
CanMainPhaseTwo
&&
exec
.
Func
(
))
// check if should enter main phase 2 directly
if
(
exec
.
Type
==
ExecutorType
.
GoToMainPhase2
&&
battle
.
CanMainPhaseTwo
&&
(
exec
.
Func
()
==
true
))
// check if should enter main phase 2 directly
{
return
ToMainPhase2
();
}
if
(
exec
.
Type
==
ExecutorType
.
GoToEndPhase
&&
battle
.
CanEndPhase
&&
exec
.
Func
(
))
// check if should enter end phase directly
if
(
exec
.
Type
==
ExecutorType
.
GoToEndPhase
&&
battle
.
CanEndPhase
&&
(
exec
.
Func
()
==
true
))
// check if should enter end phase directly
{
return
ToEndPhase
();
}
...
...
@@ -442,12 +442,12 @@ namespace WindBot.Game
CheckSurrender
();
foreach
(
CardExecutor
exec
in
Executor
.
Executors
)
{
if
(
exec
.
Type
==
ExecutorType
.
GoToEndPhase
&&
main
.
CanEndPhase
&&
exec
.
Func
(
))
// check if should enter end phase directly
if
(
exec
.
Type
==
ExecutorType
.
GoToEndPhase
&&
main
.
CanEndPhase
&&
(
exec
.
Func
()
==
true
))
// check if should enter end phase directly
{
_dialogs
.
SendEndTurn
();
return
new
MainPhaseAction
(
MainPhaseAction
.
MainAction
.
ToEndPhase
);
}
if
(
exec
.
Type
==
ExecutorType
.
GoToBattlePhase
&&
main
.
CanBattlePhase
&&
exec
.
Func
(
))
// check if should enter battle phase directly
if
(
exec
.
Type
==
ExecutorType
.
GoToBattlePhase
&&
main
.
CanBattlePhase
&&
(
exec
.
Func
()
==
true
))
// check if should enter battle phase directly
{
return
new
MainPhaseAction
(
MainPhaseAction
.
MainAction
.
ToBattlePhase
);
}
...
...
@@ -1174,9 +1174,15 @@ namespace WindBot.Game
}
Func
<
bool
>
Func
=
()
=>
{
if
(
Executor
.
FuncFilters
.
ContainsKey
(
exec
.
Type
)
&&
Executor
.
FuncFilters
[
exec
.
Type
]
!=
null
&&
!
Executor
.
FuncFilters
[
exec
.
Type
]())
return
false
;
return
exec
.
Func
==
null
||
exec
.
Func
();
if
(
Executor
.
FuncFilters
.
ContainsKey
(
exec
.
Type
)
&&
Executor
.
FuncFilters
[
exec
.
Type
]
!=
null
)
{
foreach
(
Func
<
bool
?>
item
in
Executor
.
FuncFilters
[
exec
.
Type
])
{
if
(
item
()
==
true
)
return
true
;
if
(
item
()
==
false
)
return
false
;
}
};
return
exec
.
Func
==
null
||
(
exec
.
Func
()
==
true
);
};
bool
result
=
card
!=
null
&&
exec
.
Type
==
type
&&
(
exec
.
CardId
==
-
1
||
exec
.
CardId
==
card
.
Id
)
&&
Func
();
...
...
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