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
8adbd20b
Commit
8adbd20b
authored
Jun 24, 2016
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix and update
parent
9b7de117
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
178 additions
and
8 deletions
+178
-8
Game/AI/AIFunctions.cs
Game/AI/AIFunctions.cs
+19
-0
Game/AI/CardContainer.cs
Game/AI/CardContainer.cs
+10
-0
Game/AI/Decks/ZexalWeaponsExecutor.cs
Game/AI/Decks/ZexalWeaponsExecutor.cs
+2
-2
Game/AI/Enums/DangerousMonster.cs
Game/AI/Enums/DangerousMonster.cs
+3
-1
Game/AI/Enums/InvincibleMonster.cs
Game/AI/Enums/InvincibleMonster.cs
+2
-1
Game/AI/Executor.cs
Game/AI/Executor.cs
+10
-0
Game/ClientField.cs
Game/ClientField.cs
+57
-0
Game/Duel.cs
Game/Duel.cs
+2
-0
Game/GameAI.cs
Game/GameAI.cs
+49
-2
Game/GameBehavior.cs
Game/GameBehavior.cs
+24
-2
No files found.
Game/AI/AIFunctions.cs
View file @
8adbd20b
...
@@ -84,5 +84,24 @@ namespace WindBot.Game.AI
...
@@ -84,5 +84,24 @@ namespace WindBot.Game.AI
}
}
return
!
nomonster
;
return
!
nomonster
;
}
}
public
ClientCard
GetOneEnnemyBetterThanValue
(
int
value
,
bool
onlyatk
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
ClientCard
card
=
Duel
.
Fields
[
1
].
MonsterZone
[
i
];
if
(
card
==
null
)
continue
;
if
(
onlyatk
&&
card
.
IsDefense
())
continue
;
int
ennemyValue
=
card
.
GetDefensePower
();
if
(
ennemyValue
>=
value
)
return
card
;
}
return
null
;
}
public
int
GetStringId
(
int
id
,
int
option
)
{
return
id
*
16
+
option
;
}
}
}
}
}
\ No newline at end of file
Game/AI/CardContainer.cs
View file @
8adbd20b
...
@@ -145,6 +145,16 @@ namespace WindBot.Game.AI
...
@@ -145,6 +145,16 @@ namespace WindBot.Game.AI
return
null
;
return
null
;
}
}
public
static
ClientCard
GetDangerousMonster
(
this
IEnumerable
<
ClientCard
>
cards
)
{
foreach
(
ClientCard
card
in
cards
)
{
if
(
card
!=
null
&&
card
.
IsMonsterDangerous
())
return
card
;
}
return
null
;
}
public
static
ClientCard
GetNegateAttackSpell
(
this
IEnumerable
<
ClientCard
>
cards
)
public
static
ClientCard
GetNegateAttackSpell
(
this
IEnumerable
<
ClientCard
>
cards
)
{
{
foreach
(
ClientCard
card
in
cards
)
foreach
(
ClientCard
card
in
cards
)
...
...
Game/AI/Decks/ZexalWeaponsExecutor.cs
View file @
8adbd20b
...
@@ -117,9 +117,9 @@ namespace DevBot.Game.AI.Decks
...
@@ -117,9 +117,9 @@ namespace DevBot.Game.AI.Decks
private
bool
ZwLionArms
()
private
bool
ZwLionArms
()
{
{
if
(
ActivateDescription
==
(
int
)
CardId
.
ZwLionArms
*
16
+
0
)
if
(
ActivateDescription
==
AI
.
Utils
.
GetStringId
((
int
)
CardId
.
ZwLionArms
,
0
)
)
return
true
;
return
true
;
if
(
ActivateDescription
==
(
int
)
CardId
.
ZwLionArms
*
16
+
1
)
if
(
ActivateDescription
==
AI
.
Utils
.
GetStringId
((
int
)
CardId
.
ZwLionArms
,
1
)
)
return
!
Card
.
IsDisabled
();
return
!
Card
.
IsDisabled
();
return
false
;
return
false
;
}
}
...
...
Game/AI/Enums/DangerousMonster.cs
View file @
8adbd20b
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
Yubel
=
78371393
,
Yubel
=
78371393
,
YubelIncarnate
=
4779091
,
YubelIncarnate
=
4779091
,
YubelNightmare
=
31764700
,
YubelNightmare
=
31764700
,
MetaionTheTimelord
=
74530899
MetaionTheTimelord
=
74530899
,
Number39Utopia
=
84013237
,
NumberS39UtopiatheLightning
=
56832966
}
}
}
}
Game/AI/Enums/InvincibleMonster.cs
View file @
8adbd20b
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
MaskedHeroDivineWind
=
22093873
,
MaskedHeroDivineWind
=
22093873
,
DarknessNeosphere
=
60417395
,
DarknessNeosphere
=
60417395
,
MetaionTheTimelord
=
74530899
,
MetaionTheTimelord
=
74530899
,
CastleGate
=
36931229
CastleGate
=
36931229
,
Number39Utopia
=
84013237
}
}
}
}
Game/AI/Executor.cs
View file @
8adbd20b
...
@@ -86,11 +86,21 @@ namespace WindBot.Game.AI
...
@@ -86,11 +86,21 @@ namespace WindBot.Game.AI
CurrentChain
.
Clear
();
CurrentChain
.
Clear
();
}
}
public
virtual
void
OnNewTurn
()
{
// Some AI need do something on new turn
}
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
)
{
{
return
null
;
return
null
;
}
}
public
virtual
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
)
{
return
null
;
}
public
virtual
bool
OnSelectYesNo
(
int
desc
)
public
virtual
bool
OnSelectYesNo
(
int
desc
)
{
{
return
true
;
return
true
;
...
...
Game/ClientField.cs
View file @
8adbd20b
...
@@ -88,10 +88,30 @@ namespace WindBot.Game
...
@@ -88,10 +88,30 @@ namespace WindBot.Game
return
HasInCards
(
Hand
,
cardId
);
return
HasInCards
(
Hand
,
cardId
);
}
}
public
bool
HasInHand
(
List
<
int
>
cardId
)
{
return
HasInCards
(
Hand
,
cardId
);
}
public
bool
HasInGraveyard
(
int
cardId
)
public
bool
HasInGraveyard
(
int
cardId
)
{
{
return
HasInCards
(
Graveyard
,
cardId
);
return
HasInCards
(
Graveyard
,
cardId
);
}
}
public
bool
HasInGraveyard
(
List
<
int
>
cardId
)
{
return
HasInCards
(
Graveyard
,
cardId
);
}
public
bool
HasInBanished
(
int
cardId
)
{
return
HasInCards
(
Banished
,
cardId
);
}
public
bool
HasInBanished
(
List
<
int
>
cardId
)
{
return
HasInCards
(
Banished
,
cardId
);
}
public
bool
HasAttackingMonster
()
public
bool
HasAttackingMonster
()
{
{
...
@@ -120,6 +140,11 @@ namespace WindBot.Game
...
@@ -120,6 +140,11 @@ namespace WindBot.Game
return
HasInCards
(
MonsterZone
,
cardId
);
return
HasInCards
(
MonsterZone
,
cardId
);
}
}
public
bool
HasInMonstersZone
(
List
<
int
>
cardId
)
{
return
HasInCards
(
MonsterZone
,
cardId
);
}
public
bool
HasInSpellZone
(
int
cardId
)
public
bool
HasInSpellZone
(
int
cardId
)
{
{
return
HasInCards
(
SpellZone
,
cardId
);
return
HasInCards
(
SpellZone
,
cardId
);
...
@@ -151,6 +176,28 @@ namespace WindBot.Game
...
@@ -151,6 +176,28 @@ namespace WindBot.Game
return
count
;
return
count
;
}
}
public
int
GetCountCardInZone
(
IEnumerable
<
ClientCard
>
cards
,
int
cardId
)
{
int
count
=
0
;
foreach
(
ClientCard
card
in
cards
)
{
if
(
card
!=
null
&&
card
.
Id
==
cardId
)
count
++;
}
return
count
;
}
public
int
GetCountCardInZone
(
IEnumerable
<
ClientCard
>
cards
,
List
<
int
>
cardId
)
{
int
count
=
0
;
foreach
(
ClientCard
card
in
cards
)
{
if
(
card
!=
null
&&
cardId
.
Contains
(
card
.
Id
))
count
++;
}
return
count
;
}
private
static
List
<
ClientCard
>
GetCards
(
IEnumerable
<
ClientCard
>
cards
,
CardType
type
)
private
static
List
<
ClientCard
>
GetCards
(
IEnumerable
<
ClientCard
>
cards
,
CardType
type
)
{
{
List
<
ClientCard
>
nCards
=
new
List
<
ClientCard
>();
List
<
ClientCard
>
nCards
=
new
List
<
ClientCard
>();
...
@@ -182,5 +229,15 @@ namespace WindBot.Game
...
@@ -182,5 +229,15 @@ namespace WindBot.Game
}
}
return
false
;
return
false
;
}
}
private
static
bool
HasInCards
(
IEnumerable
<
ClientCard
>
cards
,
List
<
int
>
cardId
)
{
foreach
(
ClientCard
card
in
cards
)
{
if
(
card
!=
null
&&
cardId
.
Contains
(
card
.
Id
))
return
true
;
}
return
false
;
}
}
}
}
}
\ No newline at end of file
Game/Duel.cs
View file @
8adbd20b
...
@@ -15,6 +15,7 @@ namespace WindBot.Game
...
@@ -15,6 +15,7 @@ namespace WindBot.Game
public
DuelPhase
Phase
{
get
;
set
;
}
public
DuelPhase
Phase
{
get
;
set
;
}
public
MainPhase
MainPhase
{
get
;
set
;
}
public
MainPhase
MainPhase
{
get
;
set
;
}
public
BattlePhase
BattlePhase
{
get
;
set
;
}
public
BattlePhase
BattlePhase
{
get
;
set
;
}
public
IList
<
ClientCard
>
ChainTargets
{
get
;
set
;
}
public
Duel
()
public
Duel
()
{
{
...
@@ -22,6 +23,7 @@ namespace WindBot.Game
...
@@ -22,6 +23,7 @@ namespace WindBot.Game
Fields
=
new
ClientField
[
2
];
Fields
=
new
ClientField
[
2
];
Fields
[
0
]
=
new
ClientField
();
Fields
[
0
]
=
new
ClientField
();
Fields
[
1
]
=
new
ClientField
();
Fields
[
1
]
=
new
ClientField
();
ChainTargets
=
new
List
<
ClientCard
>();
}
}
public
ClientCard
GetCard
(
int
player
,
CardLocation
loc
,
int
index
)
public
ClientCard
GetCard
(
int
player
,
CardLocation
loc
,
int
index
)
...
...
Game/GameAI.cs
View file @
8adbd20b
...
@@ -64,7 +64,10 @@ namespace WindBot.Game
...
@@ -64,7 +64,10 @@ namespace WindBot.Game
m_option
=
-
1
;
m_option
=
-
1
;
m_position
=
CardPosition
.
FaceUpAttack
;
m_position
=
CardPosition
.
FaceUpAttack
;
if
(
Duel
.
Player
==
0
&&
Duel
.
Phase
==
DuelPhase
.
Draw
)
if
(
Duel
.
Player
==
0
&&
Duel
.
Phase
==
DuelPhase
.
Draw
)
{
_dialogs
.
SendNewTurn
();
_dialogs
.
SendNewTurn
();
Executor
.
OnNewTurn
();
}
}
}
/// <summary>
/// <summary>
...
@@ -341,13 +344,57 @@ namespace WindBot.Game
...
@@ -341,13 +344,57 @@ namespace WindBot.Game
/// <returns></returns>
/// <returns></returns>
public
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
)
public
IList
<
ClientCard
>
OnSelectSum
(
IList
<
ClientCard
>
cards
,
int
sum
,
int
min
,
int
max
)
{
{
// Always return one card. The first available.
IList
<
ClientCard
>
selected
=
new
List
<
ClientCard
>();
selected
=
Executor
.
OnSelectSum
(
cards
,
sum
,
min
,
max
);
if
(
selected
!=
null
)
{
return
selected
;
}
selected
=
new
List
<
ClientCard
>();
int
trysum
=
0
;
foreach
(
ClientCard
card
in
cards
)
{
// try level add
if
(
trysum
+
card
.
Level
>
sum
)
{
continue
;
}
selected
.
Add
(
card
);
trysum
+=
card
.
Level
;
//Logger.WriteLine(card.Id + "");
//Logger.WriteLine(trysum + " selected " + sum);
if
(
trysum
==
sum
)
{
return
selected
;
}
}
IList
<
ClientCard
>
selected2
=
new
List
<
ClientCard
>();
foreach
(
ClientCard
card
in
selected
)
{
// clone
selected2
.
Add
(
card
);
}
foreach
(
ClientCard
card
in
selected
)
{
// try level sub
selected2
.
Remove
(
card
);
trysum
-=
card
.
Level
;
//Logger.WriteLine(card.Id + "");
//Logger.WriteLine(trysum + " selected2 " + sum);
if
(
trysum
==
sum
)
{
return
selected2
;
}
}
foreach
(
ClientCard
card
in
cards
)
foreach
(
ClientCard
card
in
cards
)
{
{
// try level equal
if
(
card
.
Level
==
sum
)
if
(
card
.
Level
==
sum
)
{
return
new
[]
{
card
};
return
new
[]
{
card
};
}
}
}
//
However return everything, that may work.
//
try all
return
cards
;
return
cards
;
}
}
...
...
Game/GameBehavior.cs
View file @
8adbd20b
...
@@ -93,7 +93,7 @@ namespace WindBot.Game
...
@@ -93,7 +93,7 @@ namespace WindBot.Game
_messages
.
Add
(
GameMessage
.
SortChain
,
OnChainSorting
);
_messages
.
Add
(
GameMessage
.
SortChain
,
OnChainSorting
);
_messages
.
Add
(
GameMessage
.
UpdateCard
,
OnUpdateCard
);
_messages
.
Add
(
GameMessage
.
UpdateCard
,
OnUpdateCard
);
_messages
.
Add
(
GameMessage
.
UpdateData
,
OnUpdateData
);
_messages
.
Add
(
GameMessage
.
UpdateData
,
OnUpdateData
);
_messages
.
Add
(
GameMessage
.
BecomeTarget
,
OnBecomeTarget
);
_messages
.
Add
(
GameMessage
.
SelectBattleCmd
,
OnSelectBattleCmd
);
_messages
.
Add
(
GameMessage
.
SelectBattleCmd
,
OnSelectBattleCmd
);
_messages
.
Add
(
GameMessage
.
SelectCard
,
OnSelectCard
);
_messages
.
Add
(
GameMessage
.
SelectCard
,
OnSelectCard
);
_messages
.
Add
(
GameMessage
.
SelectChain
,
OnSelectChain
);
_messages
.
Add
(
GameMessage
.
SelectChain
,
OnSelectChain
);
...
@@ -398,11 +398,13 @@ namespace WindBot.Game
...
@@ -398,11 +398,13 @@ namespace WindBot.Game
ClientCard
card
=
_duel
.
GetCard
(
pcc
,
pcl
,
pcs
,
subs
);
ClientCard
card
=
_duel
.
GetCard
(
pcc
,
pcl
,
pcs
,
subs
);
int
cc
=
GetLocalPlayer
(
packet
.
ReadByte
());
int
cc
=
GetLocalPlayer
(
packet
.
ReadByte
());
_ai
.
OnChaining
(
card
,
cc
);
_ai
.
OnChaining
(
card
,
cc
);
_duel
.
ChainTargets
.
Clear
();
}
}
private
void
OnChainEnd
(
BinaryReader
packet
)
private
void
OnChainEnd
(
BinaryReader
packet
)
{
{
_ai
.
OnChainEnd
();
_ai
.
OnChainEnd
();
//_duel.ChainTargets.Clear();
}
}
private
void
OnChainSorting
(
BinaryReader
packet
)
private
void
OnChainSorting
(
BinaryReader
packet
)
...
@@ -468,6 +470,21 @@ namespace WindBot.Game
...
@@ -468,6 +470,21 @@ namespace WindBot.Game
}
}
}
}
private
void
OnBecomeTarget
(
BinaryReader
packet
)
{
int
count
=
packet
.
ReadByte
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
int
player
=
GetLocalPlayer
(
packet
.
ReadByte
());
int
loc
=
packet
.
ReadByte
();
int
seq
=
packet
.
ReadByte
();
/*int sseq = */
packet
.
ReadByte
();
ClientCard
card
=
_duel
.
GetCard
(
player
,
(
CardLocation
)
loc
,
seq
);
if
(
card
==
null
)
continue
;
_duel
.
ChainTargets
.
Add
(
card
);
}
}
private
void
OnSelectBattleCmd
(
BinaryReader
packet
)
private
void
OnSelectBattleCmd
(
BinaryReader
packet
)
{
{
packet
.
ReadByte
();
// player
packet
.
ReadByte
();
// player
...
@@ -667,7 +684,7 @@ namespace WindBot.Game
...
@@ -667,7 +684,7 @@ namespace WindBot.Game
Connection
.
Send
(
CtosMessage
.
Response
,
0
);
Connection
.
Send
(
CtosMessage
.
Response
,
0
);
return
;
return
;
}
}
if
(
card
.
Id
==
0
)
card
.
SetId
(
cardId
);
if
(
card
.
Id
==
0
)
card
.
SetId
(
cardId
);
int
reply
=
_ai
.
OnSelectEffectYn
(
card
)
?
(
1
)
:
(
0
);
int
reply
=
_ai
.
OnSelectEffectYn
(
card
)
?
(
1
)
:
(
0
);
...
@@ -874,6 +891,11 @@ namespace WindBot.Game
...
@@ -874,6 +891,11 @@ namespace WindBot.Game
}
}
}
}
for
(
int
k
=
0
;
k
<
mandatoryCards
.
Count
;
++
k
)
{
sumval
-=
mandatoryCards
[
k
].
Level
;
}
IList
<
ClientCard
>
selected
=
_ai
.
OnSelectSum
(
cards
,
sumval
,
min
,
max
);
IList
<
ClientCard
>
selected
=
_ai
.
OnSelectSum
(
cards
,
sumval
,
min
,
max
);
byte
[]
result
=
new
byte
[
mandatoryCards
.
Count
+
selected
.
Count
+
1
];
byte
[]
result
=
new
byte
[
mandatoryCards
.
Count
+
selected
.
Count
+
1
];
...
...
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