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
alstroemeria-silentlove
windbot
Commits
665f58a3
Commit
665f58a3
authored
Sep 19, 2017
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add hand param
parent
cb1e5433
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
2 deletions
+30
-2
Game/AI/Executor.cs
Game/AI/Executor.cs
+5
-0
Game/GameAI.cs
Game/GameAI.cs
+10
-1
Game/GameBehavior.cs
Game/GameBehavior.cs
+8
-1
Game/GameClient.cs
Game/GameClient.cs
+2
-0
Program.cs
Program.cs
+3
-0
WindBotInfo.cs
WindBotInfo.cs
+2
-0
No files found.
Game/AI/Executor.cs
View file @
665f58a3
...
@@ -40,6 +40,11 @@ namespace WindBot.Game.AI
...
@@ -40,6 +40,11 @@ namespace WindBot.Game.AI
Enemy
=
Duel
.
Fields
[
1
];
Enemy
=
Duel
.
Fields
[
1
];
}
}
public
virtual
int
OnRockPaperScissors
()
{
return
Program
.
Rand
.
Next
(
1
,
4
);
}
public
virtual
bool
OnSelectHand
()
public
virtual
bool
OnSelectHand
()
{
{
return
Program
.
Rand
.
Next
(
2
)
>
0
;
return
Program
.
Rand
.
Next
(
2
)
>
0
;
...
...
Game/GameAI.cs
View file @
665f58a3
...
@@ -52,10 +52,19 @@ namespace WindBot.Game
...
@@ -52,10 +52,19 @@ namespace WindBot.Game
_dialogs
.
SendDuelStart
();
_dialogs
.
SendDuelStart
();
}
}
/// <summary>
/// Called when the AI do the rock-paper-scissors.
/// </summary>
/// <returns>1 for Scissors, 2 for Rock, 3 for Paper.</returns>
public
int
OnRockPaperScissors
()
{
return
Executor
.
OnRockPaperScissors
();
}
/// <summary>
/// <summary>
/// Called when the AI won the rock-paper-scissors.
/// Called when the AI won the rock-paper-scissors.
/// </summary>
/// </summary>
/// <returns>True if the AI should begin, false otherwise.</returns>
/// <returns>True if the AI should begin
first
, false otherwise.</returns>
public
bool
OnSelectHand
()
public
bool
OnSelectHand
()
{
{
return
Executor
.
OnSelectHand
();
return
Executor
.
OnSelectHand
();
...
...
Game/GameBehavior.cs
View file @
665f58a3
...
@@ -24,11 +24,13 @@ namespace WindBot.Game
...
@@ -24,11 +24,13 @@ namespace WindBot.Game
private
Room
_room
;
private
Room
_room
;
private
Duel
_duel
;
private
Duel
_duel
;
private
int
_hand
;
public
GameBehavior
(
GameClient
game
)
public
GameBehavior
(
GameClient
game
)
{
{
Game
=
game
;
Game
=
game
;
Connection
=
game
.
Connection
;
Connection
=
game
.
Connection
;
_hand
=
game
.
Hand
;
_packets
=
new
Dictionary
<
StocMessage
,
Action
<
BinaryReader
>>();
_packets
=
new
Dictionary
<
StocMessage
,
Action
<
BinaryReader
>>();
_messages
=
new
Dictionary
<
GameMessage
,
Action
<
BinaryReader
>>();
_messages
=
new
Dictionary
<
GameMessage
,
Action
<
BinaryReader
>>();
...
@@ -207,7 +209,12 @@ namespace WindBot.Game
...
@@ -207,7 +209,12 @@ namespace WindBot.Game
private
void
OnSelectHand
(
BinaryReader
packet
)
private
void
OnSelectHand
(
BinaryReader
packet
)
{
{
Connection
.
Send
(
CtosMessage
.
HandResult
,
(
byte
)
Program
.
Rand
.
Next
(
1
,
4
));
int
result
;
if
(
_hand
>
0
)
result
=
_hand
;
else
result
=
_ai
.
OnRockPaperScissors
();
Connection
.
Send
(
CtosMessage
.
HandResult
,
(
byte
)
result
);
}
}
private
void
OnSelectTp
(
BinaryReader
packet
)
private
void
OnSelectTp
(
BinaryReader
packet
)
...
...
Game/GameClient.cs
View file @
665f58a3
...
@@ -13,6 +13,7 @@ namespace WindBot.Game
...
@@ -13,6 +13,7 @@ namespace WindBot.Game
public
string
Username
;
public
string
Username
;
public
string
Deck
;
public
string
Deck
;
public
string
Dialog
;
public
string
Dialog
;
public
int
Hand
;
private
string
_serverHost
;
private
string
_serverHost
;
private
int
_serverPort
;
private
int
_serverPort
;
...
@@ -27,6 +28,7 @@ namespace WindBot.Game
...
@@ -27,6 +28,7 @@ namespace WindBot.Game
Username
=
Info
.
Name
;
Username
=
Info
.
Name
;
Deck
=
Info
.
Deck
;
Deck
=
Info
.
Deck
;
Dialog
=
Info
.
Dialog
;
Dialog
=
Info
.
Dialog
;
Hand
=
Info
.
Hand
;
_serverHost
=
Info
.
Host
;
_serverHost
=
Info
.
Host
;
_serverPort
=
Info
.
Port
;
_serverPort
=
Info
.
Port
;
_roomInfo
=
Info
.
HostInfo
;
_roomInfo
=
Info
.
HostInfo
;
...
...
Program.cs
View file @
665f58a3
...
@@ -162,6 +162,9 @@ namespace WindBot
...
@@ -162,6 +162,9 @@ namespace WindBot
string
password
=
HttpUtility
.
ParseQueryString
(
RawUrl
).
Get
(
"password"
);
string
password
=
HttpUtility
.
ParseQueryString
(
RawUrl
).
Get
(
"password"
);
if
(
password
!=
null
)
if
(
password
!=
null
)
Info
.
HostInfo
=
password
;
Info
.
HostInfo
=
password
;
string
hand
=
HttpUtility
.
ParseQueryString
(
RawUrl
).
Get
(
"hand"
);
if
(
hand
!=
null
)
Info
.
Hand
=
Int32
.
Parse
(
hand
);
if
(
Info
.
Name
==
null
||
Info
.
Host
==
null
||
port
==
null
)
if
(
Info
.
Name
==
null
||
Info
.
Host
==
null
||
port
==
null
)
{
{
...
...
WindBotInfo.cs
View file @
665f58a3
...
@@ -11,6 +11,7 @@ namespace WindBot
...
@@ -11,6 +11,7 @@ namespace WindBot
public
int
Port
{
get
;
set
;
}
public
int
Port
{
get
;
set
;
}
public
string
HostInfo
{
get
;
set
;
}
public
string
HostInfo
{
get
;
set
;
}
public
int
Version
{
get
;
set
;
}
public
int
Version
{
get
;
set
;
}
public
int
Hand
{
get
;
set
;
}
public
WindBotInfo
()
public
WindBotInfo
()
{
{
...
@@ -21,6 +22,7 @@ namespace WindBot
...
@@ -21,6 +22,7 @@ namespace WindBot
Port
=
7911
;
Port
=
7911
;
HostInfo
=
""
;
HostInfo
=
""
;
Version
=
0x233C
;
Version
=
0x233C
;
Hand
=
0
;
}
}
}
}
}
}
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