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
83ad5777
Commit
83ad5777
authored
Apr 13, 2019
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test deck code
parent
c56628f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
2 deletions
+120
-2
Assets/SibylSystem/SelectDeck/selectDeck.cs
Assets/SibylSystem/SelectDeck/selectDeck.cs
+47
-2
Assets/SibylSystem/deckManager/DeckManager.cs
Assets/SibylSystem/deckManager/DeckManager.cs
+73
-0
No files found.
Assets/SibylSystem/SelectDeck/selectDeck.cs
View file @
83ad5777
...
...
@@ -3,8 +3,8 @@ using System.Collections.Generic;
using
System.IO
;
using
System.Text.RegularExpressions
;
using
UnityEngine
;
using
YGOSharp.OCGWrapper.Enums
;
using
YGOSharp.OCGWrapper.Enums
;
public
class
selectDeck
:
WindowServantSP
{
...
...
@@ -187,6 +187,41 @@ public class selectDeck : WindowServantSP
RMSshow_none
(
InterString
.
Get
(
"非法输入!请检查输入的文件名。"
));
}
}
if
(
hashCode
==
"onCode"
)
{
if
(
result
[
0
].
value
!=
""
)
{
try
{
YGOSharp
.
Deck
deck
;
if
(!
deckManager
.
FromBase64toCodedDeck
(
result
[
0
].
value
,
deck
))
{
RMSshow_none
(
InterString
.
Get
(
"卡组代码无效。"
));
return
;
}
string
value
=
"#created by ygopro2\r\n#main\r\n"
;
for
(
int
i
=
0
;
i
<
deck
.
Main
.
Count
;
i
++)
{
value
+=
deck
.
Main
[
i
].
ToString
()
+
"\r\n"
;
}
value
+=
"#extra\r\n"
;
for
(
int
i
=
0
;
i
<
deck
.
Extra
.
Count
;
i
++)
{
value
+=
deck
.
Extra
[
i
].
ToString
()
+
"\r\n"
;
}
value
+=
"!side\r\n"
;
for
(
int
i
=
0
;
i
<
deck
.
Side
.
Count
;
i
++)
{
value
+=
deck
.
Side
[
i
].
ToString
()
+
"\r\n"
;
}
System
.
IO
.
File
.
WriteAllText
(
"deck/"
+
superScrollView
.
selectedString
+
".ydk"
,
value
,
System
.
Text
.
Encoding
.
UTF8
);
printSelected
();
}
catch
(
Exception
)
{
RMSshow_none
(
InterString
.
Get
(
"卡组代码无效。"
));
}
}
}
}
void
onNew
()
...
...
@@ -255,6 +290,7 @@ public class selectDeck : WindowServantSP
string
path
=
"deck/"
+
superScrollView
.
selectedString
+
".ydk"
;
if
(
File
.
Exists
(
path
))
{
/*
#if UNITY_EDITOR || UNITY_STANDALONE_WIN //编译器、Windows
System.Diagnostics.Process.Start("notepad.exe", path);
#elif UNITY_STANDALONE_OSX //Mac OS X
...
...
@@ -266,6 +302,15 @@ public class selectDeck : WindowServantSP
jo.Call("openFile", Program.ANDROID_GAME_PATH + path);
//#elif UNITY_IPHONE //iPhone
#endif
*/
YGOSharp
.
Deck
deck
;
deckManager
.
FromYDKtoCodedDeck
(
path
,
deck
);
string
default_string
;
if
(
deck
.
Main
.
Count
>
0
||
deck
.
Extra
.
Count
>
0
||
deck
.
Side
.
Count
>
0
)
default_string
=
deckManager
.
convertDeckToBase64
(
deck
);
else
default_string
=
""
;
RMSshow_input
(
"onCode"
,
InterString
.
Get
(
"卡组代码"
),
default_string
);
}
}
...
...
Assets/SibylSystem/deckManager/DeckManager.cs
View file @
83ad5777
...
...
@@ -1530,6 +1530,79 @@ public class DeckManager : ServantWithCardDescription
}
}
public
static
bool
FromBase64toCodedDeck
(
string
base64
,
out
YGOSharp
.
Deck
deck
)
{
deck
=
new
YGOSharp
.
Deck
();
bool
res
=
true
;
try
{
byte
[]
buffer
=
Convert
.
FromBase64String
(
base64
);
int
offset
=
0
;
int
mainc
=
BitConverter
.
ToInt32
(
buffer
,
offset
);
offset
+=
4
;
int
sidec
=
BitConverter
.
ToInt32
(
buffer
,
offset
);
offset
+=
4
;
for
(
int
i
=
0
;
i
<
mainc
;
++
i
)
{
int
code
=
BitConverter
.
ToInt32
(
buffer
,
offset
);
offset
+=
4
;
if
(
code
>
100
)
{
YGOSharp
.
Card
card
=
YGOSharp
.
CardsManager
.
Get
(
code
);
if
(
card
.
Id
>
0
&&
card
.
IsExtraCard
())
{
deck
.
Extra
.
Add
(
code
);
deck
.
Deck_O
.
Extra
.
Add
(
code
);
}
else
{
deck
.
Main
.
Add
(
code
);
deck
.
Deck_O
.
Main
.
Add
(
code
);
}
}
}
for
(
int
i
=
0
;
i
<
sidec
;
++
i
)
{
int
code
=
BitConverter
.
ToInt32
(
buffer
,
offset
);
offset
+=
4
;
if
(
code
>
100
)
{
deck
.
Side
.
Add
(
code
);
deck
.
Deck_O
.
Side
.
Add
(
code
);
}
}
}
catch
(
Exception
e
)
{
res
=
false
;
}
return
res
;
}
public
static
string
convertDeckToBase64
(
YGOSharp
.
Deck
deck
)
{
List
<
byte
>
array_list
=
List
<
byte
>();
writeInt32ToList
(
array_list
,
deck
.
Main
.
Count
+
deck
.
Extra
.
Count
);
writeInt32ToList
(
array_list
,
deck
.
Side
.
Count
);
for
(
int
i
=
0
;
i
<
deck
.
Main
.
Count
;
i
++)
{
writeInt32ToList
(
array_list
,
deck
.
Main
[
i
]);
}
for
(
int
i
=
0
;
i
<
deck
.
Extra
.
Count
;
i
++)
{
writeInt32ToList
(
array_list
,
deck
.
Extra
[
i
]);
}
for
(
int
i
=
0
;
i
<
deck
.
Side
.
Count
;
i
++)
{
writeInt32ToList
(
array_list
,
deck
.
Side
[
i
]);
}
byte
[]
buffer
=
array_list
.
ToArray
();
return
Convert
.
ToBase64String
(
buffer
);
}
private
void
writeInt32ToList
(
List
<
byte
>
array_list
,
int
value
)
{
byte
[]
int_buffer
=
BitConverter
.
GetBytes
(
value
);
for
(
int
i
=
0
;
i
<
4
;
++
i
)
{
array_list
.
Add
(
int_buffer
[
i
]);
}
}
public
YGOSharp
.
Deck
getRealDeck
()
{
if
(
canSave
)
...
...
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