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
Tang Xinwei
windbot
Commits
28b42177
Commit
28b42177
authored
Feb 01, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:moecube/windbot
parents
028710cb
d6998ace
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
197 additions
and
10 deletions
+197
-10
Game/AI/Decks/WitchcraftExecutor.cs
Game/AI/Decks/WitchcraftExecutor.cs
+2
-4
Game/AI/Executor.cs
Game/AI/Executor.cs
+11
-0
Game/AI/Opcodes.cs
Game/AI/Opcodes.cs
+19
-0
Game/GameAI.cs
Game/GameAI.cs
+11
-4
Game/GameBehavior.cs
Game/GameBehavior.cs
+150
-2
WindBot.csproj
WindBot.csproj
+4
-0
YGOSharp.OCGWrapper.Enums.dll
YGOSharp.OCGWrapper.Enums.dll
+0
-0
YGOSharp.OCGWrapper.dll
YGOSharp.OCGWrapper.dll
+0
-0
No files found.
Game/AI/Decks/WitchcraftExecutor.cs
View file @
28b42177
...
...
@@ -271,6 +271,7 @@ namespace WindBot.Game.AI.Decks
public
override
void
OnNewTurn
()
{
CrossoutDesignatorTarget
=
0
;
PSYOmega_count
=
0
;
MadameVerreGainedATK
=
false
;
summoned
=
false
;
enemy_activate_MaxxC
=
false
;
...
...
@@ -283,8 +284,7 @@ namespace WindBot.Game.AI.Decks
FirstCheckSS
.
Clear
();
UseSSEffect
.
Clear
();
ActivatedCards
.
Clear
();
int
PSYOmega_count
=
0
;
// CalledbytheGrave refrest
// CalledbytheGrave refresh
List
<
int
>
key_list
=
CalledbytheGraveCount
.
Keys
.
ToList
();
foreach
(
int
dic
in
key_list
)
{
...
...
@@ -976,8 +976,6 @@ namespace WindBot.Game.AI.Decks
// check
bool
have_FiveRainbow
=
false
;
List
<
ClientCard
>
list
=
new
List
<
ClientCard
>();
ClientCard
l
=
null
;
ClientCard
r
=
null
;
if
(
Duel
.
IsNewRule
||
Duel
.
IsNewRule2020
)
{
list
.
Add
(
Enemy
.
SpellZone
[
0
]);
...
...
Game/AI/Executor.cs
View file @
28b42177
...
...
@@ -188,6 +188,17 @@ namespace WindBot.Game.AI
return
false
;
}
/// <summary>
/// Called when bot is going to annouce a card
/// </summary>
/// <param name="avail">Available card's ids.</param>
/// <returns>Card's id to annouce.</returns>
public
virtual
int
OnAnnounceCard
(
IList
<
int
>
avail
)
{
// For overriding
return
0
;
}
public
void
SetMain
(
MainPhase
main
)
{
Main
=
main
;
...
...
Game/AI/Opcodes.cs
0 → 100644
View file @
28b42177
namespace
WindBot.Game.AI
{
public
static
class
Opcodes
{
public
const
int
OPCODE_ADD
=
0x40000000
,
OPCODE_SUB
=
0x40000001
,
OPCODE_MUL
=
0x40000002
,
OPCODE_DIV
=
0x40000003
,
OPCODE_AND
=
0x40000004
,
OPCODE_OR
=
0x40000005
,
OPCODE_NEG
=
0x40000006
,
OPCODE_NOT
=
0x40000007
,
OPCODE_ISCODE
=
0x40000100
,
OPCODE_ISSETCARD
=
0x40000101
,
OPCODE_ISTYPE
=
0x40000102
,
OPCODE_ISRACE
=
0x40000103
,
OPCODE_ISATTRIBUTE
=
0x40000104
;
}
}
\ No newline at end of file
Game/GameAI.cs
View file @
28b42177
...
...
@@ -95,6 +95,7 @@ namespace WindBot.Game
m_materialSelector
=
null
;
m_option
=
-
1
;
m_yesno
=
-
1
;
m_announce
=
0
;
m_place
=
0
;
if
(
Duel
.
Player
==
0
&&
Duel
.
Phase
==
DuelPhase
.
Draw
)
...
...
@@ -734,12 +735,18 @@ namespace WindBot.Game
/// <summary>
/// Called when the AI has to declare a card.
/// </summary>
/// <param name="avail">Available card's ids.</param>
/// <returns>Id of the selected card.</returns>
public
int
OnAnnounceCard
()
public
int
OnAnnounceCard
(
IList
<
int
>
avail
)
{
if
(
m_announce
==
0
)
return
89631139
;
// Blue-eyes white dragon
return
m_announce
;
int
selected
=
Executor
.
OnAnnounceCard
(
avail
);
if
(
avail
.
Contains
(
selected
))
return
selected
;
if
(
avail
.
Contains
(
m_announce
))
return
m_announce
;
else
if
(
m_announce
>
0
)
Logger
.
WriteErrorLine
(
"Pre-announced card cant be used: "
+
m_announce
);
return
avail
[
0
];
}
// _ Others functions _
...
...
Game/GameBehavior.cs
View file @
28b42177
...
...
@@ -1449,8 +1449,156 @@ namespace WindBot.Game
private
void
OnAnnounceCard
(
BinaryReader
packet
)
{
// not fully implemented
Connection
.
Send
(
CtosMessage
.
Response
,
_ai
.
OnAnnounceCard
());
IList
<
int
>
opcodes
=
new
List
<
int
>();
packet
.
ReadByte
();
// player
int
count
=
packet
.
ReadByte
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
opcodes
.
Add
(
packet
.
ReadInt32
());
IList
<
int
>
avail
=
new
List
<
int
>();
IList
<
NamedCard
>
all
=
NamedCardsManager
.
GetAllCards
();
foreach
(
NamedCard
card
in
all
)
{
if
(
card
.
HasType
(
CardType
.
Token
)
||
(
card
.
Alias
>
0
&&
card
.
Id
-
card
.
Alias
<
10
))
continue
;
Stack
<
int
>
stack
=
new
Stack
<
int
>();
for
(
int
i
=
0
;
i
<
opcodes
.
Count
;
i
++)
{
switch
(
opcodes
[
i
])
{
case
Opcodes
.
OPCODE_ADD
:
if
(
stack
.
Count
>=
2
)
{
int
rhs
=
stack
.
Pop
();
int
lhs
=
stack
.
Pop
();
stack
.
Push
(
lhs
+
rhs
);
}
break
;
case
Opcodes
.
OPCODE_SUB
:
if
(
stack
.
Count
>=
2
)
{
int
rhs
=
stack
.
Pop
();
int
lhs
=
stack
.
Pop
();
stack
.
Push
(
lhs
-
rhs
);
}
break
;
case
Opcodes
.
OPCODE_MUL
:
if
(
stack
.
Count
>=
2
)
{
int
rhs
=
stack
.
Pop
();
int
lhs
=
stack
.
Pop
();
stack
.
Push
(
lhs
*
rhs
);
}
break
;
case
Opcodes
.
OPCODE_DIV
:
if
(
stack
.
Count
>=
2
)
{
int
rhs
=
stack
.
Pop
();
int
lhs
=
stack
.
Pop
();
stack
.
Push
(
lhs
/
rhs
);
}
break
;
case
Opcodes
.
OPCODE_AND
:
if
(
stack
.
Count
>=
2
)
{
int
rhs
=
stack
.
Pop
();
int
lhs
=
stack
.
Pop
();
bool
b0
=
rhs
!=
0
;
bool
b1
=
lhs
!=
0
;
if
(
b0
&&
b1
)
stack
.
Push
(
1
);
else
stack
.
Push
(
0
);
}
break
;
case
Opcodes
.
OPCODE_OR
:
if
(
stack
.
Count
>=
2
)
{
int
rhs
=
stack
.
Pop
();
int
lhs
=
stack
.
Pop
();
bool
b0
=
rhs
!=
0
;
bool
b1
=
lhs
!=
0
;
if
(
b0
||
b1
)
stack
.
Push
(
1
);
else
stack
.
Push
(
0
);
}
break
;
case
Opcodes
.
OPCODE_NEG
:
if
(
stack
.
Count
>=
1
)
{
int
rhs
=
stack
.
Pop
();
stack
.
Push
(-
rhs
);
}
break
;
case
Opcodes
.
OPCODE_NOT
:
if
(
stack
.
Count
>=
1
)
{
int
rhs
=
stack
.
Pop
();
bool
b0
=
rhs
!=
0
;
if
(
b0
)
stack
.
Push
(
0
);
else
stack
.
Push
(
1
);
}
break
;
case
Opcodes
.
OPCODE_ISCODE
:
if
(
stack
.
Count
>=
1
)
{
int
code
=
stack
.
Pop
();
bool
b0
=
code
==
card
.
Id
;
if
(
b0
)
stack
.
Push
(
1
);
else
stack
.
Push
(
0
);
}
break
;
case
Opcodes
.
OPCODE_ISSETCARD
:
if
(
stack
.
Count
>=
1
)
{
if
(
card
.
HasSetcode
(
stack
.
Pop
()))
stack
.
Push
(
1
);
else
stack
.
Push
(
0
);
}
break
;
case
Opcodes
.
OPCODE_ISTYPE
:
if
(
stack
.
Count
>=
1
)
{
if
((
stack
.
Pop
()
&
card
.
Type
)
>
0
)
stack
.
Push
(
1
);
else
stack
.
Push
(
0
);
}
break
;
case
Opcodes
.
OPCODE_ISRACE
:
if
(
stack
.
Count
>=
1
)
{
if
((
stack
.
Pop
()
&
card
.
Race
)
>
0
)
stack
.
Push
(
1
);
else
stack
.
Push
(
0
);
}
break
;
case
Opcodes
.
OPCODE_ISATTRIBUTE
:
if
(
stack
.
Count
>=
1
)
{
if
((
stack
.
Pop
()
&
card
.
Attribute
)
>
0
)
stack
.
Push
(
1
);
else
stack
.
Push
(
0
);
}
break
;
default
:
stack
.
Push
(
opcodes
[
i
]);
break
;
}
}
if
(
stack
.
Count
==
1
&&
stack
.
Pop
()
!=
0
)
avail
.
Add
(
card
.
Id
);
}
if
(
avail
.
Count
==
0
)
throw
new
Exception
(
"No avail card found for announce!"
);
Connection
.
Send
(
CtosMessage
.
Response
,
_ai
.
OnAnnounceCard
(
avail
));
}
private
void
OnAnnounceNumber
(
BinaryReader
packet
)
...
...
WindBot.csproj
View file @
28b42177
...
...
@@ -37,6 +37,9 @@
<PropertyGroup>
<ApplicationIcon>
WindBot.ico
</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>
true
</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Mono.Data.Sqlite"
>
<HintPath>
.\Mono.Data.Sqlite.dll
</HintPath>
...
...
@@ -120,6 +123,7 @@
<Compile
Include=
"Game\AI\Enums\InvincibleMonster.cs"
/>
<Compile
Include=
"Game\AI\Enums\Floodgate.cs"
/>
<Compile
Include=
"Game\AI\Executor.cs"
/>
<Compile
Include=
"Game\AI\Opcodes.cs"
/>
<Compile
Include=
"Game\AI\Zones.cs"
/>
<Compile
Include=
"Game\AI\ExecutorType.cs"
/>
<Compile
Include=
"Game\BattlePhase.cs"
/>
...
...
YGOSharp.OCGWrapper.Enums.dll
View file @
28b42177
No preview for this file type
YGOSharp.OCGWrapper.dll
View file @
28b42177
No preview for this file type
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