Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro2
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
nanahira
ygopro2
Commits
0a379347
Commit
0a379347
authored
May 15, 2019
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test mycard
parent
2e11fb67
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
328 deletions
+84
-328
Assets/SibylSystem/MonoHelpers/TcpHelper.cs
Assets/SibylSystem/MonoHelpers/TcpHelper.cs
+1
-1
Assets/SibylSystem/MyCard/MyCard.cs
Assets/SibylSystem/MyCard/MyCard.cs
+82
-326
Assets/SibylSystem/Ocgcore/Ocgcore.cs
Assets/SibylSystem/Ocgcore/Ocgcore.cs
+1
-1
No files found.
Assets/SibylSystem/MonoHelpers/TcpHelper.cs
View file @
0a379347
...
@@ -206,7 +206,7 @@ public static class TcpHelper
...
@@ -206,7 +206,7 @@ public static class TcpHelper
{
{
if
(
Program
.
I
().
menu
.
isShowed
==
false
)
if
(
Program
.
I
().
menu
.
isShowed
==
false
)
{
{
Program
.
I
().
shiftToServant
(
Program
.
I
().
mycard
.
isMatching
WithMyCard
?
Program
.
I
().
mycard
:
Program
.
I
().
selectServer
);
Program
.
I
().
shiftToServant
(
Program
.
I
().
mycard
.
isMatching
?
Program
.
I
().
mycard
:
Program
.
I
().
selectServer
);
}
}
if
(!
roomListChecking
)
if
(!
roomListChecking
)
{
{
...
...
Assets/SibylSystem/MyCard/MyCard.cs
View file @
0a379347
...
@@ -6,279 +6,58 @@ using System.Threading;
...
@@ -6,279 +6,58 @@ using System.Threading;
public
class
MyCard
:
WindowServantSP
public
class
MyCard
:
WindowServantSP
{
{
public
bool
isMatchingWithMyCard
=
false
;
public
bool
isMatching
=
false
;
UIPopupList
list
;
public
bool
isRequesting
;
UIPopupList
serversList
;
const
string
mycard_ip
=
"tiramisu.mycard.moe"
;
const
string
athletic_port
=
"8911"
;
UIInput
inputIP
;
const
string
entertain_port
=
"7911"
;
UIInput
inputPort
;
Thread
requestThread
=
null
;
MyCardHelper
helper
;
UIInput
inputUsername
;
UIInput
inputPsw
;
UIInput
inputPsw
;
UIInput
inputVersion
;
UISprite
inputIP_
;
UISprite
inputPort_
;
public
override
void
initialize
()
public
override
void
initialize
()
{
{
createWindow
(
Program
.
I
().
new_ui_
selectServer
);
createWindow
(
Program
.
I
().
new_ui_
mycard
);
UIHelper
.
registEvent
(
gameObject
,
"exit_"
,
onClickExit
);
UIHelper
.
registEvent
(
gameObject
,
"exit_"
,
onClickExit
);
UIHelper
.
registEvent
(
gameObject
,
"face_"
,
onClickFace
);
UIHelper
.
registEvent
(
gameObject
,
"joinAthletic"
,
onJoinAthletic
);
UIHelper
.
registEvent
(
gameObject
,
"join_"
,
onClickJoin
);
UIHelper
.
registEvent
(
gameObject
,
"joinEntertain"
,
onJoinEntertain
);
UIHelper
.
registEvent
(
gameObject
,
"clearPsw_"
,
onClearPsw
);
UIHelper
.
registEvent
(
gameObject
,
"database"
,
onClickDatabase
);
serversList
=
UIHelper
.
getByName
<
UIPopupList
>(
gameObject
,
"server"
);
UIHelper
.
registEvent
(
gameObject
,
"community"
,
onClickCommunity
);
//serversList.fontSize = 30;
inputUsername
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"nameLine"
);
if
(
Application
.
systemLanguage
==
SystemLanguage
.
Chinese
||
Application
.
systemLanguage
==
SystemLanguage
.
ChineseSimplified
||
Application
.
systemLanguage
==
SystemLanguage
.
ChineseTraditional
)
inputPsw
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"pswLine"
);
{
helper
=
new
MyCardHelper
();
serversList
.
value
=
Config
.
Get
(
"serversPicker"
,
"[自定义]"
);
loadUser
();
}
else
{
serversList
.
value
=
Config
.
Get
(
"serversPicker"
,
"[Custom]"
);
}
UIHelper
.
registEvent
(
gameObject
,
"server"
,
pickServer
);
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"name_"
).
value
=
Config
.
Get
(
"name"
,
"YGOPro2 User"
);
list
=
UIHelper
.
getByName
<
UIPopupList
>(
gameObject
,
"history_"
);
list
.
enabled
=
true
;
UIHelper
.
registEvent
(
gameObject
,
"history_"
,
onSelected
);
name
=
Config
.
Get
(
"name"
,
"YGOPro2 User"
);
inputIP
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
);
inputPort
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
);
inputPsw
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"psw_"
);
inputIP_
=
UIHelper
.
getByName
<
UISprite
>(
gameObject
,
"ip_"
);
inputPort_
=
UIHelper
.
getByName
<
UISprite
>(
gameObject
,
"port_"
);
//inputVersion = UIHelper.getByName<UIInput>(gameObject, "version_");
set_version
(
"0x"
+
String
.
Format
(
"{0:X}"
,
Config
.
ClientVersion
));
//方便免修改 [selectServerWithRoomlist.prefab]
serversList
.
items
.
Add
(
"[OCG]Koishi"
);
serversList
.
items
.
Add
(
"[OCG]Mercury233"
);
serversList
.
items
.
Add
(
"[TCG]Koishi"
);
serversList
.
items
.
Add
(
"[轮抽服]2Pick"
);
//serversList.items.Add("[DIY]YGOPro 222DIY");
serversList
.
items
.
Add
(
"[AI]Doom Bots of Doom"
);
//serversList.items.Add("[OCG&TCG]한국서버");
//serversList.items.Add("[OCG&TCG]YGOhollow (JP)");
if
(
Application
.
systemLanguage
==
SystemLanguage
.
Chinese
||
Application
.
systemLanguage
==
SystemLanguage
.
ChineseSimplified
||
Application
.
systemLanguage
==
SystemLanguage
.
ChineseTraditional
)
{
serversList
.
items
.
Add
(
"[自定义]"
);
}
else
{
serversList
.
items
.
Add
(
"[Custom]"
);
}
SetActiveFalse
();
SetActiveFalse
();
}
}
private
void
pickServer
()
void
saveUser
()
{
{
Config
.
Set
(
"mycard_username"
,
inputUsername
.
value
);
string
server
=
serversList
.
value
;
Config
.
Set
(
"mycard_password"
,
inputPsw
.
value
);
switch
(
server
)
{
case
"[OCG]Koishi"
:
{
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
).
value
=
"koishi.moecube.com"
;
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
).
value
=
"7210"
;
Config
.
Set
(
"serversPicker"
,
"[OCG]Koishi"
);
inputIP_
.
enabled
=
true
;
inputPort_
.
enabled
=
false
;
break
;
}
case
"[OCG]Mercury233"
:
{
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
).
value
=
"s1.ygo233.com"
;
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
).
value
=
"233"
;
Config
.
Set
(
"serversPicker"
,
"[OCG]Mercury233"
);
inputIP_
.
enabled
=
true
;
inputPort_
.
enabled
=
false
;
break
;
}
case
"[TCG]Koishi"
:
{
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
).
value
=
"koishi.moecube.com"
;
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
).
value
=
"1311"
;
Config
.
Set
(
"serversPicker"
,
"[TCG]Koishi"
);
inputIP_
.
enabled
=
false
;
inputPort_
.
enabled
=
false
;
break
;
}
case
"[轮抽服]2Pick"
:
{
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
).
value
=
"2pick.mycard.moe"
;
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
).
value
=
"765"
;
Config
.
Set
(
"serversPicker"
,
"[轮抽服]2Pick"
);
inputIP_
.
enabled
=
false
;
inputPort_
.
enabled
=
false
;
break
;
}
/*case "[DIY]YGOPro 222DIY":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "koishi.moecube.com";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "222";
Config.Set("serversPicker", "[DIY]YGOPro 222DIY");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
} */
case
"[AI]Doom Bots of Doom"
:
{
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
).
value
=
"koishi.moecube.com"
;
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
).
value
=
"573"
;
Config
.
Set
(
"serversPicker"
,
"[AI]Doom Bots of Doom"
);
inputIP_
.
enabled
=
false
;
inputPort_
.
enabled
=
false
;
break
;
}
/*case "[OCG&TCG]한국서버":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "cygopro.fun25.co.kr";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "17225";
Config.Set("serversPicker", "[OCG&TCG]한국서버 (KR)");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
}
case "[OCG&TCG]YGOhollow (JP)":
{
UIHelper.getByName<UIInput>(gameObject, "ip_").value = "ygosvrjp.tk";
UIHelper.getByName<UIInput>(gameObject, "port_").value = "7911";
Config.Set("serversPicker", "[OCG&TCG]YGOhollow (JP)");
inputIP_.enabled = false;
inputPort_.enabled = false;
break;
} */
default
:
{
if
(
Application
.
systemLanguage
==
SystemLanguage
.
Chinese
||
Application
.
systemLanguage
==
SystemLanguage
.
ChineseSimplified
||
Application
.
systemLanguage
==
SystemLanguage
.
ChineseTraditional
)
{
Config
.
Set
(
"serversPicker"
,
"[自定义]"
);
}
else
{
Config
.
Set
(
"serversPicker"
,
"[Custom]"
);
}
inputIP_
.
enabled
=
true
;
inputPort_
.
enabled
=
true
;
break
;
}
}
}
void
loadUser
()
{
inputUsername
.
value
=
Config
.
Get
(
"mycard_username"
,
"MyCard"
);
inputPsw
.
value
=
Config
.
Get
(
"mycard_password"
,
""
);
}
}
void
onSelecte
d
()
public
void
terminateThrea
d
()
{
{
if
(
list
!
=
null
)
if
(
!
isRequesting
&&
requestThread
=
null
)
{
{
readString
(
list
.
value
);
return
;
}
}
private
void
readString
(
string
str
)
{
/*
str = str.Substring(1, str.Length - 1);
string version = "", remain = "";
string[] splited;
splited = str.Split(")");
try
{
version = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(":");
string ip = "";
try
{
ip = splited[0];
remain = splited[1];
}
catch (Exception)
{
}
splited = remain.Split(" ");
string psw = "", port = "";
try
{
port = splited[0];
psw = splited[1];
}
catch (Exception)
{
}
if (EditIpAndPort)
{
inputIP.value = ip;
inputPort.value = port;
}
inputPsw.value = psw;
*/
//确保密码为空时,退出后密码依旧保持为空
str
=
str
.
Substring
(
5
,
str
.
Length
-
5
);
inputPsw
.
value
=
str
;
//inputVersion.value = version;
}
void
onClearPsw
()
{
string
PswString
=
File
.
ReadAllText
(
"config/passwords.conf"
);
string
[]
lines
=
PswString
.
Replace
(
"\r"
,
""
).
Split
(
"\n"
);
for
(
int
i
=
0
;
i
<
lines
.
Length
;
i
++)
{
list
.
RemoveItem
(
lines
[
i
]);
//清空list
}
FileStream
stream
=
new
FileStream
(
"config/passwords.conf"
,
FileMode
.
Truncate
,
FileAccess
.
ReadWrite
);
//清空文件内容
stream
.
Close
();
inputPsw
.
value
=
""
;
Program
.
PrintToChat
(
InterString
.
Get
(
"房间密码已清空"
));
}
public
override
void
show
()
{
base
.
show
();
Program
.
I
().
room
.
RMSshow_clear
();
printFile
(
true
);
Program
.
charge
();
}
public
override
void
preFrameFunction
()
{
base
.
preFrameFunction
();
Menu
.
checkCommend
();
}
void
printFile
(
bool
first
)
{
list
.
Clear
();
if
(
File
.
Exists
(
"config/passwords.conf"
)
==
false
)
{
File
.
Create
(
"config/passwords.conf"
).
Close
();
}
string
txtString
=
File
.
ReadAllText
(
"config/passwords.conf"
);
string
[]
lines
=
txtString
.
Replace
(
"\r"
,
""
).
Split
(
"\n"
);
for
(
int
i
=
0
;
i
<
lines
.
Length
;
i
++)
{
if
(
i
==
0
)
{
if
(
first
)
{
readString
(
lines
[
i
]);
}
}
list
.
AddItem
(
lines
[
i
]);
}
}
requestThread
.
Abort
();
requestThread
=
null
;
}
}
void
onClickExit
()
void
onClickExit
()
{
{
Program
.
I
().
shiftToServant
(
Program
.
I
().
menu
);
Program
.
I
().
shiftToServant
(
Program
.
I
().
menu
);
if
(
TcpHelper
.
tcpClient
!=
null
)
if
(
TcpHelper
.
tcpClient
!=
null
)
{
{
if
(
isRequesting
)
{
terminateThread
();
}
if
(
TcpHelper
.
tcpClient
.
Connected
)
if
(
TcpHelper
.
tcpClient
.
Connected
)
{
{
TcpHelper
.
tcpClient
.
Close
();
TcpHelper
.
tcpClient
.
Close
();
...
@@ -286,90 +65,67 @@ public class MyCard : WindowServantSP
...
@@ -286,90 +65,67 @@ public class MyCard : WindowServantSP
}
}
}
}
public
void
set_version
(
string
str
)
void
onClickDatabase
()
{
{
Application
.
OpenURL
(
"https://ygobbs.com/"
);
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"version_"
).
value
=
str
;
}
}
void
onClickJoin
()
void
onClickCommunity
()
{
{
Application
.
OpenURL
(
"https://mycard.moe/ygopro/arena"
);
if
(!
isShowed
)
{
return
;
}
string
Name
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"name_"
).
value
;
string
ipString
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
).
value
;
string
portString
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
).
value
;
string
pswString
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"psw_"
).
value
;
string
versionString
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"version_"
).
value
;
KF_onlineGame
(
Name
,
ipString
,
portString
,
versionString
,
pswString
);
}
}
public
void
onClickRoomList
()
void
matchThread
(
string
username
,
string
password
,
string
match_type
)
{
{
try
{
if
(!
isShowed
)
Program
.
PrintToChat
(
InterString
.
Get
(
"正在登录至MyCard。"
));
{
string
fail_reason
=
""
;
bool
res
=
helper
.
login
(
username
,
password
,
out
fail_reason
);
if
(!
res
)
{
Program
.
PrintToChat
(
InterString
.
Get
(
"MyCard登录失败。原因: "
)
+
fail_reason
);
isRequesting
=
false
;
return
;
return
;
}
}
string
Name
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"name_"
).
value
;
Program
.
PrintToChat
(
InterString
.
Get
(
"正在请求匹配。匹配类型: "
)
+
match_type
)
;
string
ipString
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"ip_"
).
value
;
string
pswString
=
helper
.
requestMatch
(
match_type
,
out
fail_reason
)
;
string
portString
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"port_"
).
value
;
if
(
pswString
==
null
)
{
string
pswString
=
"L"
;
Program
.
PrintToChat
(
InterString
.
Get
(
"匹配请求失败。原因: "
)
+
fail_reason
)
;
string
versionString
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"version_"
).
valu
e
;
isRequesting
=
fals
e
;
KF_onlineGame
(
Name
,
ipString
,
portString
,
versionString
,
pswString
)
;
return
;
}
}
Program
.
PrintToChat
(
InterString
.
Get
(
"匹配成功。正在进入房间。"
));
Program
.
I
().
mycard
.
isMatching
=
true
;
public
void
onHide
(
bool
Bool
)
(
new
Thread
(()
=>
{
TcpHelper
.
join
(
mycard_ip
,
username
,
match_type
==
"athletic"
?
athletic_port
:
entertain_port
,
pswString
,
"0x"
+
String
.
Format
(
"{0:X}"
,
Config
.
ClientVersion
));
})).
Start
();
{
isRequesting
=
false
;
gameObject
.
SetActive
(!
Bool
);
}
catch
(
Exception
e
)
{
if
(
e
!=
ThreadAbortException
)
{
Program
.
PrintToChat
(
InterString
.
Get
(
"未知错误: "
)
+
e
.
Message
);
}
else
{
Program
.
PrintToChat
(
"匹配已中断。"
);
}
}
isRequesting
=
false
;
public
void
KF_onlineGame
(
string
Name
,
string
ipString
,
string
portString
,
string
versionString
,
string
pswString
=
""
)
{
name
=
Name
;
Config
.
Set
(
"name"
,
name
);
if
(
ipString
==
""
||
portString
==
""
||
versionString
==
""
)
{
RMSshow_onlyYes
(
""
,
InterString
.
Get
(
"非法输入!请检查输入的主机名。"
),
null
);
}
}
else
{
if
(
name
!=
""
)
{
//string fantasty = "(" + versionString + ")" + ipString + ":" + portString + " " + pswString;
string
fantasty
=
"psw: "
+
pswString
;
list
.
items
.
Remove
(
fantasty
);
list
.
items
.
Insert
(
0
,
fantasty
);
list
.
value
=
fantasty
;
if
(
list
.
items
.
Count
>
5
)
{
list
.
items
.
RemoveAt
(
list
.
items
.
Count
-
1
);
}
}
string
all
=
""
;
for
(
int
i
=
0
;
i
<
list
.
items
.
Count
;
i
++)
void
startMatch
(
string
match_type
)
{
const
string
username
=
inputUsername
.
value
;
const
string
password
=
inputPsw
.
value
;
if
(
username
==
""
||
password
==
""
)
{
{
all
+=
list
.
items
[
i
]
+
"\r\n"
;
RMSshow_onlyYes
(
""
,
InterString
.
Get
(
"用户名或密码为空。"
),
null
);
}
return
;
File
.
WriteAllText
(
"config/passwords.conf"
,
all
);
printFile
(
false
);
(
new
Thread
(()
=>
{
TcpHelper
.
join
(
ipString
,
name
,
portString
,
pswString
,
versionString
);
})).
Start
();
}
}
else
saveUser
();
isRequesting
=
true
;
requestThread
=
new
Thread
(()
=>
{
{
RMSshow_onlyYes
(
""
,
InterString
.
Get
(
"昵称不能为空。"
),
null
);
matchThread
(
username
,
password
,
match_type
);
});
}
}
}
}
GameObject
faceShow
=
null
;
public
string
name
=
""
;
void
onJoinAthletic
()
{
startMatch
(
"athletic"
);
void
onClickFace
()
{
name
=
UIHelper
.
getByName
<
UIInput
>(
gameObject
,
"name_"
).
value
;
RMSshow_face
(
"showFace"
,
name
);
Config
.
Set
(
"name"
,
name
);
}
}
void
onJoinEntertain
()
{
startMatch
(
"entertain"
);
}
}
}
Assets/SibylSystem/Ocgcore/Ocgcore.cs
View file @
0a379347
...
@@ -756,7 +756,7 @@ public class Ocgcore : ServantWithCardDescription
...
@@ -756,7 +756,7 @@ public class Ocgcore : ServantWithCardDescription
}
}
public
void
setDefaultReturnServant
()
{
public
void
setDefaultReturnServant
()
{
if
(
Program
.
I
().
mycard
.
isMatching
WithMyCard
)
{
if
(
Program
.
I
().
mycard
.
isMatching
)
{
returnServant
=
Program
.
I
().
mycard
;
returnServant
=
Program
.
I
().
mycard
;
}
else
{
}
else
{
returnServant
=
Program
.
I
().
selectServer
;
returnServant
=
Program
.
I
().
selectServer
;
...
...
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