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
c1a1e4fb
Commit
c1a1e4fb
authored
Jun 18, 2016
by
IceYGO
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the latest YGOSharp.Network to improve performances
parent
2241def4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
108 additions
and
81 deletions
+108
-81
Game/ClientCard.cs
Game/ClientCard.cs
+2
-1
Game/GameAI.cs
Game/GameAI.cs
+0
-3
Game/GameBehavior.cs
Game/GameBehavior.cs
+64
-63
Game/GameClient.cs
Game/GameClient.cs
+21
-13
Game/GamePacketFactory.cs
Game/GamePacketFactory.cs
+15
-0
Program.cs
Program.cs
+2
-1
WindBot.csproj
WindBot.csproj
+4
-0
YGOSharp.Network.dll
YGOSharp.Network.dll
+0
-0
No files found.
Game/ClientCard.cs
View file @
c1a1e4fb
using
OCGWrapper
;
using
OCGWrapper
;
using
OCGWrapper.Enums
;
using
OCGWrapper.Enums
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
YGOSharp.Network
;
using
YGOSharp.Network
;
namespace
WindBot.Game
namespace
WindBot.Game
...
@@ -54,7 +55,7 @@ namespace WindBot.Game
...
@@ -54,7 +55,7 @@ namespace WindBot.Game
Name
=
Data
.
Name
;
Name
=
Data
.
Name
;
}
}
public
void
Update
(
GamePacket
Reader
packet
,
Duel
duel
)
public
void
Update
(
Binary
Reader
packet
,
Duel
duel
)
{
{
int
flag
=
packet
.
ReadInt32
();
int
flag
=
packet
.
ReadInt32
();
if
((
flag
&
(
int
)
Query
.
Code
)
!=
0
)
if
((
flag
&
(
int
)
Query
.
Code
)
!=
0
)
...
...
Game/GameAI.cs
View file @
c1a1e4fb
using
OCGWrapper.Enums
;
using
OCGWrapper.Enums
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
WindBot.Game.AI
;
using
WindBot.Game.AI
;
using
YGOSharp.Network
;
namespace
WindBot.Game
namespace
WindBot.Game
{
{
public
class
GameAI
public
class
GameAI
{
{
public
GameClient
Game
{
get
;
private
set
;
}
public
GameClient
Game
{
get
;
private
set
;
}
public
CoreClient
Connection
{
get
;
private
set
;
}
public
Duel
Duel
{
get
;
private
set
;
}
public
Duel
Duel
{
get
;
private
set
;
}
public
Executor
Executor
{
get
;
set
;
}
public
Executor
Executor
{
get
;
set
;
}
public
AIFunctions
Utils
{
get
;
private
set
;
}
public
AIFunctions
Utils
{
get
;
private
set
;
}
...
@@ -18,7 +16,6 @@ namespace WindBot.Game
...
@@ -18,7 +16,6 @@ namespace WindBot.Game
public
GameAI
(
GameClient
game
,
Duel
duel
)
public
GameAI
(
GameClient
game
,
Duel
duel
)
{
{
Game
=
game
;
Game
=
game
;
Connection
=
game
.
Connection
;
Duel
=
duel
;
Duel
=
duel
;
Utils
=
new
AIFunctions
(
duel
);
Utils
=
new
AIFunctions
(
duel
);
...
...
Game/GameBehavior.cs
View file @
c1a1e4fb
This diff is collapsed.
Click to expand it.
Game/GameClient.cs
View file @
c1a1e4fb
using
System.Text
;
using
System.IO
;
using
System.Net
;
using
System.Text
;
using
YGOSharp.Network
;
using
YGOSharp.Network
;
using
YGOSharp.Network.Enums
;
using
YGOSharp.Network.Enums
;
using
YGOSharp.Network.Utils
;
namespace
WindBot.Game
namespace
WindBot.Game
{
{
public
class
GameClient
public
class
GameClient
{
{
public
Core
Client
Connection
{
get
;
private
set
;
}
public
YGO
Client
Connection
{
get
;
private
set
;
}
public
string
Username
;
public
string
Username
;
public
string
Deck
;
public
string
Deck
;
...
@@ -27,40 +30,45 @@ namespace WindBot.Game
...
@@ -27,40 +30,45 @@ namespace WindBot.Game
public
void
Start
()
public
void
Start
()
{
{
Connection
=
new
CoreClient
(
_serverHost
,
_serverPort
);
Connection
=
new
YGOClient
();
Connection
.
MessageReceived
+=
OnMessageReceived
;
_behavior
=
new
GameBehavior
(
this
);
_behavior
=
new
GameBehavior
(
this
);
GamePacketWriter
packet
=
new
GamePacketWriter
(
CtosMessage
.
PlayerInfo
);
Connection
.
Connected
+=
OnConnected
;
packet
.
Write
(
Username
,
20
);
Connection
.
PacketReceived
+=
OnPacketReceived
;
Connection
.
Connect
(
IPAddress
.
Parse
(
_serverHost
),
_serverPort
);
}
private
void
OnConnected
()
{
BinaryWriter
packet
=
GamePacketFactory
.
Create
(
CtosMessage
.
PlayerInfo
);
packet
.
WriteUnicode
(
Username
,
Program
.
PlayerNameSize
);
Connection
.
Send
(
packet
);
Connection
.
Send
(
packet
);
byte
[]
junk
=
{
0xCC
,
0xCC
,
0x00
,
0x00
,
0x00
,
0x00
};
byte
[]
junk
=
{
0xCC
,
0xCC
,
0x00
,
0x00
,
0x00
,
0x00
};
packet
=
new
GamePacketWriter
(
CtosMessage
.
JoinGame
);
packet
=
GamePacketFactory
.
Create
(
CtosMessage
.
JoinGame
);
packet
.
Write
(
Program
.
ProVersion
);
packet
.
Write
(
Program
.
ProVersion
);
packet
.
Write
(
junk
);
packet
.
Write
(
junk
);
packet
.
Write
(
_roomInfos
,
30
);
packet
.
Write
Unicode
(
_roomInfos
,
30
);
Connection
.
Send
(
packet
);
Connection
.
Send
(
packet
);
}
}
public
void
Tick
()
public
void
Tick
()
{
{
Connection
.
UpdateNetwork
();
Connection
.
Update
();
Connection
.
Update
();
}
}
public
void
Chat
(
string
message
)
public
void
Chat
(
string
message
)
{
{
byte
[]
content
=
Encoding
.
Unicode
.
GetBytes
(
message
+
"\0"
);
byte
[]
content
=
Encoding
.
Unicode
.
GetBytes
(
message
+
"\0"
);
GamePacketWriter
chat
=
new
GamePacketWriter
(
CtosMessage
.
Chat
);
BinaryWriter
chat
=
GamePacketFactory
.
Create
(
CtosMessage
.
Chat
);
chat
.
Write
(
content
);
chat
.
Write
(
content
);
Connection
.
Send
(
chat
);
Connection
.
Send
(
chat
);
}
}
private
void
On
MessageReceived
(
object
sender
,
MessageEventArgs
e
)
private
void
On
PacketReceived
(
BinaryReader
reader
)
{
{
_behavior
.
OnPacket
(
e
.
Message
);
_behavior
.
OnPacket
(
reader
);
}
}
}
}
}
}
\ No newline at end of file
Game/GamePacketFactory.cs
0 → 100644
View file @
c1a1e4fb
using
System.IO
;
using
YGOSharp.Network.Enums
;
namespace
WindBot.Game
{
public
class
GamePacketFactory
{
public
static
BinaryWriter
Create
(
CtosMessage
message
)
{
BinaryWriter
writer
=
new
BinaryWriter
(
new
MemoryStream
());
writer
.
Write
((
byte
)
message
);
return
writer
;
}
}
}
Program.cs
View file @
c1a1e4fb
...
@@ -9,7 +9,8 @@ namespace WindBot
...
@@ -9,7 +9,8 @@ namespace WindBot
{
{
public
class
Program
public
class
Program
{
{
public
const
short
ProVersion
=
0x1338
;
public
static
short
ProVersion
=
0x1330
;
public
static
int
PlayerNameSize
=
20
;
internal
static
Random
Rand
;
internal
static
Random
Rand
;
...
...
WindBot.csproj
View file @
c1a1e4fb
...
@@ -31,6 +31,9 @@
...
@@ -31,6 +31,9 @@
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<CodeAnalysisRuleSet>
MinimumRecommendedRules.ruleset
</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>
MinimumRecommendedRules.ruleset
</CodeAnalysisRuleSet>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup>
<StartupObject
/>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"Mono.Data.Sqlite"
>
<Reference
Include=
"Mono.Data.Sqlite"
>
<HintPath>
.\Mono.Data.Sqlite.dll
</HintPath>
<HintPath>
.\Mono.Data.Sqlite.dll
</HintPath>
...
@@ -80,6 +83,7 @@
...
@@ -80,6 +83,7 @@
<Compile
Include=
"Game\GameAI.cs"
/>
<Compile
Include=
"Game\GameAI.cs"
/>
<Compile
Include=
"Game\GameBehavior.cs"
/>
<Compile
Include=
"Game\GameBehavior.cs"
/>
<Compile
Include=
"Game\GameClient.cs"
/>
<Compile
Include=
"Game\GameClient.cs"
/>
<Compile
Include=
"Game\GamePacketFactory.cs"
/>
<Compile
Include=
"Game\MainPhase.cs"
/>
<Compile
Include=
"Game\MainPhase.cs"
/>
<Compile
Include=
"Game\MainPhaseAction.cs"
/>
<Compile
Include=
"Game\MainPhaseAction.cs"
/>
<Compile
Include=
"Game\Room.cs"
/>
<Compile
Include=
"Game\Room.cs"
/>
...
...
YGOSharp.Network.dll
View file @
c1a1e4fb
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