Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
DataEditorX
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
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
nanahira
DataEditorX
Commits
3b1132f8
Commit
3b1132f8
authored
May 24, 2015
by
keyongyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.3.2.0
parent
522136b9
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
952 additions
and
829 deletions
+952
-829
DataEditorX/Common/MyUtils.cs
DataEditorX/Common/MyUtils.cs
+52
-0
DataEditorX/Common/StrUtil.cs
DataEditorX/Common/StrUtil.cs
+1
-1
DataEditorX/Core/Mse/MSEConfig.cs
DataEditorX/Core/Mse/MSEConfig.cs
+155
-134
DataEditorX/Core/Mse/MseMaker.cs
DataEditorX/Core/Mse/MseMaker.cs
+710
-688
DataEditorX/Core/TaskHelper.cs
DataEditorX/Core/TaskHelper.cs
+2
-1
DataEditorX/DataEditorX.csproj
DataEditorX/DataEditorX.csproj
+1
-0
DataEditorX/Properties/AssemblyInfo.cs
DataEditorX/Properties/AssemblyInfo.cs
+1
-1
DataEditorX/changed.txt
DataEditorX/changed.txt
+2
-0
DataEditorX/data/mse_Chinese-Simplified.txt
DataEditorX/data/mse_Chinese-Simplified.txt
+3
-0
DataEditorX/data/mse_Chinese-Traditional.txt
DataEditorX/data/mse_Chinese-Traditional.txt
+3
-0
DataEditorX/data/mse_English.txt
DataEditorX/data/mse_English.txt
+3
-0
DataEditorX/data/mse_Japan.txt
DataEditorX/data/mse_Japan.txt
+3
-0
DataEditorX/readme.txt
DataEditorX/readme.txt
+1
-1
win32/DataEditorX.exe
win32/DataEditorX.exe
+0
-0
win32/changed.txt
win32/changed.txt
+2
-0
win32/data/language_chinese.txt
win32/data/language_chinese.txt
+0
-1
win32/data/language_english.txt
win32/data/language_english.txt
+0
-1
win32/data/mse_Chinese-Simplified.txt
win32/data/mse_Chinese-Simplified.txt
+3
-0
win32/data/mse_Chinese-Traditional.txt
win32/data/mse_Chinese-Traditional.txt
+3
-0
win32/data/mse_English.txt
win32/data/mse_English.txt
+3
-0
win32/data/mse_Japan.txt
win32/data/mse_Japan.txt
+3
-0
win32/readme.txt
win32/readme.txt
+1
-1
win32/win32.zip
win32/win32.zip
+0
-0
No files found.
DataEditorX/Common/MyUtils.cs
0 → 100644
View file @
3b1132f8
/*
* 由SharpDevelop创建。
* 用户: Acer
* 日期: 2015-5-24
* 时间: 10:55
*
* 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
*/
using
System
;
using
System.Text
;
using
System.IO
;
namespace
DataEditorX.Common
{
/// <summary>
/// Description of MyUtils.
/// </summary>
public
class
MyUtils
{
/// <summary>
/// 计算文件的MD5校验
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public
static
string
GetMD5HashFromFile
(
string
fileName
)
{
try
{
FileStream
file
=
new
FileStream
(
fileName
,
FileMode
.
Open
);
System
.
Security
.
Cryptography
.
MD5
md5
=
new
System
.
Security
.
Cryptography
.
MD5CryptoServiceProvider
();
byte
[]
retVal
=
md5
.
ComputeHash
(
file
);
file
.
Close
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
retVal
.
Length
;
i
++)
{
sb
.
Append
(
retVal
[
i
].
ToString
(
"x2"
));
}
return
sb
.
ToString
();
}
catch
{
}
return
""
;
}
public
static
bool
Md5isEmpty
(
string
md5
){
return
md5
==
null
||
md5
.
Length
<
16
;
}
}
}
DataEditorX/Common/StrUtil.cs
View file @
3b1132f8
...
...
@@ -8,7 +8,7 @@ public class StrUtil
{
public
static
string
AutoEnter
(
string
str
,
int
lineNum
,
char
re
)
{
if
(
str
==
null
||
str
.
Length
==
0
||
re
==
null
)
if
(
str
==
null
||
str
.
Length
==
0
)
return
str
;
str
=
str
.
Replace
(
"\r\n"
,
"\n"
);
char
[]
ch
=
str
.
ToCharArray
();
...
...
DataEditorX/Core/Mse/MSEConfig.cs
View file @
3b1132f8
...
...
@@ -17,143 +17,164 @@
namespace
DataEditorX.Core.Mse
{
/// <summary>
/// Description of MSEConfig.
/// </summary>
public
class
MSEConfig
{
#
region
常量
public
const
string
TAG
=
"mse"
;
/// <summary>存档头部</summary>
public
const
string
TAG_HEAD
=
"head"
;
/// <summary>存档尾部</summary>
public
const
string
TAG_END
=
"end"
;
/// <summary>简体转繁体</summary>
public
const
string
TAG_CN2TW
=
"cn2tw"
;
/// <summary>魔法标志格式</summary>
public
const
string
TAG_SPELL
=
"spell"
;
/// <summary>陷阱标志格式</summary>
public
const
string
TAG_TRAP
=
"trap"
;
public
const
string
TAG_REG_PENDULUM
=
"pendulum-text"
;
public
const
string
TAG_REG_MONSTER
=
"monster-text"
;
public
const
string
TAG_MAXCOUNT
=
"maxcount"
;
public
const
string
TAG_RACE
=
"race"
;
public
const
string
TAG_TYPE
=
"type"
;
/// <summary>
/// Description of MSEConfig.
/// </summary>
public
class
MSEConfig
{
#
region
常量
public
const
string
TAG
=
"mse"
;
/// <summary>存档头部</summary>
public
const
string
TAG_HEAD
=
"head"
;
/// <summary>存档尾部</summary>
public
const
string
TAG_END
=
"end"
;
/// <summary>简体转繁体</summary>
public
const
string
TAG_CN2TW
=
"cn2tw"
;
/// <summary>魔法标志格式</summary>
public
const
string
TAG_SPELL
=
"spell"
;
/// <summary>陷阱标志格式</summary>
public
const
string
TAG_TRAP
=
"trap"
;
public
const
string
TAG_REG_PENDULUM
=
"pendulum-text"
;
public
const
string
TAG_REG_MONSTER
=
"monster-text"
;
public
const
string
TAG_MAXCOUNT
=
"maxcount"
;
public
const
string
TAG_RACE
=
"race"
;
public
const
string
TAG_TYPE
=
"type"
;
public
const
string
TAG_WIDTH
=
"width"
;
public
const
string
TAG_HEIGHT
=
"height"
;
public
const
string
TAG_IMAGE
=
"imagepath"
;
public
const
string
TAG_REPALCE
=
"replace"
;
public
const
string
TAG_TEXT
=
"text"
;
public
const
string
TAG_IMAGE
=
"imagepath"
;
public
const
string
TAG_REPALCE
=
"replace"
;
public
const
string
TAG_TEXT
=
"text"
;
public
const
string
TAG_REP
=
"%%"
;
public
const
string
SEP_LINE
=
" "
;
//默认的配置
public
const
string
FILE_CONFIG_NAME
=
"Chinese-Simplified"
;
public
const
string
PATH_IMAGE
=
"Images"
;
public
string
configName
=
FILE_CONFIG_NAME
;
#
endregion
public
MSEConfig
(
string
path
)
{
init
(
path
);
}
public
void
SetConfig
(
string
config
,
string
path
)
{
if
(!
File
.
Exists
(
config
))
return
;
regx_monster
=
"(\\s\\S*?)"
;
regx_pendulum
=
"(\\s\\S*?)"
;
//设置文件名
configName
=
MyPath
.
getFullFileName
(
MSEConfig
.
TAG
,
config
);
public
const
string
TAG_REP
=
"%%"
;
public
const
string
SEP_LINE
=
" "
;
//默认的配置
public
const
string
FILE_CONFIG_NAME
=
"Chinese-Simplified"
;
public
const
string
PATH_IMAGE
=
"Images"
;
public
string
configName
=
FILE_CONFIG_NAME
;
#
endregion
public
MSEConfig
(
string
path
)
{
init
(
path
);
}
public
void
SetConfig
(
string
config
,
string
path
)
{
if
(!
File
.
Exists
(
config
))
return
;
regx_monster
=
"(\\s\\S*?)"
;
regx_pendulum
=
"(\\s\\S*?)"
;
//设置文件名
configName
=
MyPath
.
getFullFileName
(
MSEConfig
.
TAG
,
config
);
replaces
=
new
SortedList
<
string
,
string
>();
replaces
=
new
SortedList
<
string
,
string
>();
typeDic
=
new
SortedList
<
long
,
string
>();
raceDic
=
new
SortedList
<
long
,
string
>();
string
[]
lines
=
File
.
ReadAllLines
(
config
,
Encoding
.
UTF8
);
foreach
(
string
line
in
lines
)
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
continue
;
if
(
line
.
StartsWith
(
TAG_CN2TW
))
Iscn2tw
=
ConfHelper
.
getBooleanValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_SPELL
))
str_spell
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_HEAD
))
head
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_END
))
end
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_TEXT
))
temp_text
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_TRAP
))
str_trap
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_REG_PENDULUM
))
regx_pendulum
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_REG_MONSTER
))
regx_monster
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_MAXCOUNT
))
maxcount
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
else
if
(
line
.
StartsWith
(
TAG_IMAGE
))
{
//如果路径不合法,则为后面的路径
imagepath
=
MyPath
.
CheckDir
(
ConfHelper
.
getValue
(
line
),
MyPath
.
Combine
(
path
,
PATH_IMAGE
));
}
else
if
(
line
.
StartsWith
(
TAG_REPALCE
))
{
//特数字替换
string
word
=
ConfHelper
.
getValue
(
line
);
string
p
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue1
(
word
));
string
r
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue2
(
word
));
if
(!
string
.
IsNullOrEmpty
(
p
))
replaces
.
Add
(
p
,
r
);
typeDic
=
new
SortedList
<
long
,
string
>();
raceDic
=
new
SortedList
<
long
,
string
>();
string
[]
lines
=
File
.
ReadAllLines
(
config
,
Encoding
.
UTF8
);
foreach
(
string
line
in
lines
)
{
if
(
string
.
IsNullOrEmpty
(
line
)
||
line
.
StartsWith
(
"#"
))
continue
;
if
(
line
.
StartsWith
(
TAG_CN2TW
))
Iscn2tw
=
ConfHelper
.
getBooleanValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_SPELL
))
str_spell
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_HEAD
))
head
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_END
))
end
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_TEXT
))
temp_text
=
ConfHelper
.
getMultLineValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_TRAP
))
str_trap
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_REG_PENDULUM
))
regx_pendulum
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_REG_MONSTER
))
regx_monster
=
ConfHelper
.
getValue
(
line
);
else
if
(
line
.
StartsWith
(
TAG_MAXCOUNT
))
maxcount
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
else
if
(
line
.
StartsWith
(
TAG_WIDTH
)){
width
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_HEIGHT
)){
height
=
ConfHelper
.
getIntegerValue
(
line
,
0
);
}
else
if
(
line
.
StartsWith
(
TAG_IMAGE
))
{
//如果路径不合法,则为后面的路径
imagepath
=
MyPath
.
CheckDir
(
ConfHelper
.
getValue
(
line
),
MyPath
.
Combine
(
path
,
PATH_IMAGE
));
//图片缓存目录
imagecache
=
MyPath
.
Combine
(
imagepath
,
"cache"
);
MyPath
.
CreateDir
(
imagecache
);
}
else
if
(
line
.
StartsWith
(
TAG_REPALCE
))
{
//特数字替换
string
word
=
ConfHelper
.
getValue
(
line
);
string
p
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue1
(
word
));
string
r
=
ConfHelper
.
getRegex
(
ConfHelper
.
getValue2
(
word
));
if
(!
string
.
IsNullOrEmpty
(
p
))
replaces
.
Add
(
p
,
r
);
}
else
if
(
line
.
StartsWith
(
TAG_RACE
))
{
//种族
ConfHelper
.
DicAdd
(
raceDic
,
line
);
}
else
if
(
line
.
StartsWith
(
TAG_TYPE
))
{
//类型
ConfHelper
.
DicAdd
(
typeDic
,
line
);
}
}
}
public
void
init
(
string
path
)
{
Iscn2tw
=
false
;
//读取配置
string
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
MyConfig
.
readString
(
MyConfig
.
TAG_MSE
)));
if
(!
File
.
Exists
(
tmp
))
{
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
FILE_CONFIG_NAME
));
if
(!
File
.
Exists
(
tmp
))
return
;
//如果默认的也不存在
}
SetConfig
(
tmp
,
path
);
}
//每个存档最大数
public
int
maxcount
;
//图片路径
public
string
imagepath
;
//魔法标志
public
string
str_spell
;
//陷阱标志
public
string
str_trap
;
//效果格式
public
string
temp_text
;
//简体转繁体?
public
bool
Iscn2tw
;
//特数字替换
public
SortedList
<
string
,
string
>
replaces
;
//效果文正则提取
public
string
regx_pendulum
;
public
string
regx_monster
;
//存档头部
public
string
head
;
//存档结尾
public
string
end
;
public
SortedList
<
long
,
string
>
typeDic
;
public
SortedList
<
long
,
string
>
raceDic
;
}
}
else
if
(
line
.
StartsWith
(
TAG_RACE
))
{
//种族
ConfHelper
.
DicAdd
(
raceDic
,
line
);
}
else
if
(
line
.
StartsWith
(
TAG_TYPE
))
{
//类型
ConfHelper
.
DicAdd
(
typeDic
,
line
);
}
}
}
public
void
init
(
string
path
)
{
Iscn2tw
=
false
;
//读取配置
string
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
MyConfig
.
readString
(
MyConfig
.
TAG_MSE
)));
if
(!
File
.
Exists
(
tmp
))
{
tmp
=
MyPath
.
Combine
(
path
,
MyPath
.
getFileName
(
MSEConfig
.
TAG
,
FILE_CONFIG_NAME
));
if
(!
File
.
Exists
(
tmp
))
return
;
//如果默认的也不存在
}
SetConfig
(
tmp
,
path
);
}
/// <summary>
/// 中间图宽度
/// </summary>
public
int
width
;
/// <summary>
/// 中间图高度
/// </summary>
public
int
height
;
//每个存档最大数
public
int
maxcount
;
//图片路径
public
string
imagepath
;
/// <summary>
/// 图片缓存路径
/// </summary>
public
string
imagecache
;
//魔法标志
public
string
str_spell
;
//陷阱标志
public
string
str_trap
;
//效果格式
public
string
temp_text
;
//简体转繁体?
public
bool
Iscn2tw
;
//特数字替换
public
SortedList
<
string
,
string
>
replaces
;
//效果文正则提取
public
string
regx_pendulum
;
public
string
regx_monster
;
//存档头部
public
string
head
;
//存档结尾
public
string
end
;
public
SortedList
<
long
,
string
>
typeDic
;
public
SortedList
<
long
,
string
>
raceDic
;
}
}
DataEditorX/Core/Mse/MseMaker.cs
View file @
3b1132f8
...
...
@@ -11,714 +11,736 @@
using
System.Text.RegularExpressions
;
using
Microsoft.VisualBasic
;
using
System.Drawing
;
using
DataEditorX.Core.Info
;
using
DataEditorX.Config
;
using
DataEditorX.Language
;
using
DataEditorX.Common
;
namespace
DataEditorX.Core.Mse
{
/// <summary>
/// MSE制作
/// </summary>
public
class
MseMaker
{
#
region
常量
public
const
string
TAG_CARD
=
"card"
;
public
const
string
TAG_CARDTYPE
=
"card type"
;
public
const
string
TAG_NAME
=
"name"
;
public
const
string
TAG_ATTRIBUTE
=
"attribute"
;
public
const
string
TAG_LEVEL
=
"level"
;
public
const
string
TAG_IMAGE
=
"image"
;
/// <summary>种族</summary>
public
const
string
TAG_TYPE1
=
"type 1"
;
/// <summary>效果1</summary>
public
const
string
TAG_TYPE2
=
"type 2"
;
/// <summary>效果2/summary>
public
const
string
TAG_TYPE3
=
"type 3"
;
/// <summary>效果3</summary>
public
const
string
TAG_TYPE4
=
"type 4"
;
public
const
string
TAG_TEXT
=
"rule text"
;
public
const
string
TAG_ATK
=
"attack"
;
public
const
string
TAG_DEF
=
"defense"
;
public
const
string
TAG_PENDULUM
=
"pendulum"
;
public
const
string
TAG_PSCALE1
=
"pendulum scale 1"
;
public
const
string
TAG_PSCALE2
=
"pendulum scale 2"
;
public
const
string
TAG_PEND_TEXT
=
"pendulum text"
;
public
const
string
TAG_CODE
=
"gamecode"
;
public
const
string
UNKNOWN_ATKDEF
=
"?"
;
public
const
int
UNKNOWN_ATKDEF_VALUE
=
-
2
;
public
const
string
TAG_REP_TEXT
=
"%text%"
;
public
const
string
TAG_REP_PTEXT
=
"%ptext%"
;
#
endregion
/// <summary>
/// MSE制作
/// </summary>
public
class
MseMaker
{
#
region
常量
public
const
string
TAG_CARD
=
"card"
;
public
const
string
TAG_CARDTYPE
=
"card type"
;
public
const
string
TAG_NAME
=
"name"
;
public
const
string
TAG_ATTRIBUTE
=
"attribute"
;
public
const
string
TAG_LEVEL
=
"level"
;
public
const
string
TAG_IMAGE
=
"image"
;
/// <summary>种族</summary>
public
const
string
TAG_TYPE1
=
"type 1"
;
/// <summary>效果1</summary>
public
const
string
TAG_TYPE2
=
"type 2"
;
/// <summary>效果2/summary>
public
const
string
TAG_TYPE3
=
"type 3"
;
/// <summary>效果3</summary>
public
const
string
TAG_TYPE4
=
"type 4"
;
public
const
string
TAG_TEXT
=
"rule text"
;
public
const
string
TAG_ATK
=
"attack"
;
public
const
string
TAG_DEF
=
"defense"
;
public
const
string
TAG_PENDULUM
=
"pendulum"
;
public
const
string
TAG_PSCALE1
=
"pendulum scale 1"
;
public
const
string
TAG_PSCALE2
=
"pendulum scale 2"
;
public
const
string
TAG_PEND_TEXT
=
"pendulum text"
;
public
const
string
TAG_CODE
=
"gamecode"
;
public
const
string
UNKNOWN_ATKDEF
=
"?"
;
public
const
int
UNKNOWN_ATKDEF_VALUE
=
-
2
;
public
const
string
TAG_REP_TEXT
=
"%text%"
;
public
const
string
TAG_REP_PTEXT
=
"%ptext%"
;
#
endregion
#
region
成员,初始化
MSEConfig
cfg
;
public
int
MaxNum
{
get
{
return
cfg
.
maxcount
;
}
}
#
region
成员,初始化
MSEConfig
cfg
;
public
int
MaxNum
{
get
{
return
cfg
.
maxcount
;
}
}
public
string
ImagePath
{
get
{
return
cfg
.
imagepath
;
}
}
public
string
ImagePath
{
get
{
return
cfg
.
imagepath
;
}
}
public
MseMaker
(
MSEConfig
mcfg
)
{
SetConfig
(
mcfg
);
}
public
void
SetConfig
(
MSEConfig
mcfg
)
{
cfg
=
mcfg
;
}
public
MSEConfig
GetConfig
()
{
return
cfg
;
}
#
endregion
public
MseMaker
(
MSEConfig
mcfg
)
{
SetConfig
(
mcfg
);
}
public
void
SetConfig
(
MSEConfig
mcfg
)
{
cfg
=
mcfg
;
}
public
MSEConfig
GetConfig
()
{
return
cfg
;
}
#
endregion
#
region
数据处理
//合并
public
string
GetLine
(
string
key
,
string
word
)
{
return
" "
+
key
+
": "
+
word
;
}
//特殊字
public
string
reItalic
(
string
str
)
{
str
=
cn2tw
(
str
);
foreach
(
string
rs
in
cfg
.
replaces
.
Keys
)
{
str
=
Regex
.
Replace
(
str
,
rs
,
cfg
.
replaces
[
rs
]);
}
return
str
;
}
//简体转繁体
public
string
cn2tw
(
string
str
)
{
if
(
cfg
.
Iscn2tw
)
{
str
=
Strings
.
StrConv
(
str
,
VbStrConv
.
TraditionalChinese
,
0
);
str
=
str
.
Replace
(
"巖"
,
"岩"
);
}
return
str
;
}
//获取魔法陷阱的类型符号
public
string
GetSpellTrapSymbol
(
Card
c
,
bool
isSpell
)
{
string
level
;
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
level
=
MseSpellTrap
.
EQUIP
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_QUICKPLAY
))
level
=
MseSpellTrap
.
QUICKPLAY
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_FIELD
))
level
=
MseSpellTrap
.
FIELD
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
level
=
MseSpellTrap
.
CONTINUOUS
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
level
=
MseSpellTrap
.
RITUAL
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_COUNTER
))
level
=
MseSpellTrap
.
COUNTER
;
else
if
(
cfg
.
str_spell
==
MSEConfig
.
TAG_REP
&&
cfg
.
str_trap
==
MSEConfig
.
TAG_REP
)
level
=
MseSpellTrap
.
NORMAL
;
//带文字的图片
else
level
=
""
;
#
region
数据处理
//合并
public
string
GetLine
(
string
key
,
string
word
)
{
return
" "
+
key
+
": "
+
word
;
}
//特殊字
public
string
reItalic
(
string
str
)
{
str
=
cn2tw
(
str
);
foreach
(
string
rs
in
cfg
.
replaces
.
Keys
)
{
str
=
Regex
.
Replace
(
str
,
rs
,
cfg
.
replaces
[
rs
]);
}
return
str
;
}
//简体转繁体
public
string
cn2tw
(
string
str
)
{
if
(
cfg
.
Iscn2tw
)
{
str
=
Strings
.
StrConv
(
str
,
VbStrConv
.
TraditionalChinese
,
0
);
str
=
str
.
Replace
(
"巖"
,
"岩"
);
}
return
str
;
}
//获取魔法陷阱的类型符号
public
string
GetSpellTrapSymbol
(
Card
c
,
bool
isSpell
)
{
string
level
;
if
(
c
.
IsType
(
CardType
.
TYPE_EQUIP
))
level
=
MseSpellTrap
.
EQUIP
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_QUICKPLAY
))
level
=
MseSpellTrap
.
QUICKPLAY
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_FIELD
))
level
=
MseSpellTrap
.
FIELD
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_CONTINUOUS
))
level
=
MseSpellTrap
.
CONTINUOUS
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
level
=
MseSpellTrap
.
RITUAL
;
else
if
(
c
.
IsType
(
CardType
.
TYPE_COUNTER
))
level
=
MseSpellTrap
.
COUNTER
;
else
if
(
cfg
.
str_spell
==
MSEConfig
.
TAG_REP
&&
cfg
.
str_trap
==
MSEConfig
.
TAG_REP
)
level
=
MseSpellTrap
.
NORMAL
;
//带文字的图片
else
level
=
""
;
if
(
isSpell
)
level
=
cfg
.
str_spell
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
else
level
=
cfg
.
str_trap
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
return
level
;
}
//获取图片路径
public
static
string
GetCardImagePath
(
string
picpath
,
Card
c
)
{
//密码,带0密码,卡名
string
jpg
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".jpg"
);
string
jpg2
=
MyPath
.
Combine
(
picpath
,
c
.
idString
+
".jpg"
);
string
jpg3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".jpg"
);
string
png
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".png"
);
string
png2
=
MyPath
.
Combine
(
picpath
,
c
.
idString
+
".png"
);
string
png3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".png"
);
if
(
File
.
Exists
(
jpg
))
{
return
jpg
;
}
else
if
(
File
.
Exists
(
jpg2
))
{
return
jpg2
;
}
else
if
(
File
.
Exists
(
jpg3
))
{
File
.
Copy
(
jpg3
,
jpg
,
true
);
if
(
File
.
Exists
(
jpg
))
{
//复制失败
return
jpg
;
}
}
else
if
(
File
.
Exists
(
png
))
{
return
png
;
}
else
if
(
File
.
Exists
(
png2
))
{
return
png2
;
}
else
if
(
File
.
Exists
(
png3
))
{
File
.
Copy
(
png3
,
png
,
true
);
if
(
File
.
Exists
(
png
))
{
//复制失败
return
png
;
}
}
return
""
;
}
//获取属性
public
static
string
GetAttribute
(
int
attr
)
{
CardAttribute
cattr
=
(
CardAttribute
)
attr
;
string
sattr
=
MseAttribute
.
NONE
;
switch
(
cattr
)
{
case
CardAttribute
.
ATTRIBUTE_DARK
:
sattr
=
MseAttribute
.
DARK
;
break
;
case
CardAttribute
.
ATTRIBUTE_DEVINE
:
sattr
=
MseAttribute
.
DIVINE
;
break
;
case
CardAttribute
.
ATTRIBUTE_EARTH
:
sattr
=
MseAttribute
.
EARTH
;
break
;
case
CardAttribute
.
ATTRIBUTE_FIRE
:
sattr
=
MseAttribute
.
FIRE
;
break
;
case
CardAttribute
.
ATTRIBUTE_LIGHT
:
sattr
=
MseAttribute
.
LIGHT
;
break
;
case
CardAttribute
.
ATTRIBUTE_WATER
:
sattr
=
MseAttribute
.
WATER
;
break
;
case
CardAttribute
.
ATTRIBUTE_WIND
:
sattr
=
MseAttribute
.
WIND
;
break
;
}
return
sattr
;
}
//获取效果文本
public
static
string
GetDesc
(
string
cdesc
,
string
regx
)
{
string
desc
=
cdesc
;
desc
=
desc
.
Replace
(
"\r\n"
,
"\n"
);
desc
=
desc
.
Replace
(
"\r"
,
"\n"
);
Regex
regex
=
new
Regex
(
regx
,
RegexOptions
.
Multiline
);
Match
mc
=
regex
.
Match
(
desc
);
if
(
mc
.
Success
)
return
((
mc
.
Groups
.
Count
>
1
)
?
mc
.
Groups
[
1
].
Value
:
mc
.
Groups
[
0
].
Value
)
.
Trim
(
'\n'
).
Replace
(
"\n"
,
"\n\t\t"
);
return
""
;
}
if
(
isSpell
)
level
=
cfg
.
str_spell
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
else
level
=
cfg
.
str_trap
.
Replace
(
MSEConfig
.
TAG_REP
,
level
);
return
level
;
}
//获取图片路径
public
static
string
GetCardImagePath
(
string
picpath
,
Card
c
)
{
//密码,带0密码,卡名
string
jpg
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".jpg"
);
string
jpg2
=
MyPath
.
Combine
(
picpath
,
c
.
idString
+
".jpg"
);
string
jpg3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".jpg"
);
string
png
=
MyPath
.
Combine
(
picpath
,
c
.
id
+
".png"
);
string
png2
=
MyPath
.
Combine
(
picpath
,
c
.
idString
+
".png"
);
string
png3
=
MyPath
.
Combine
(
picpath
,
c
.
name
+
".png"
);
if
(
File
.
Exists
(
jpg
))
{
return
jpg
;
}
else
if
(
File
.
Exists
(
jpg2
))
{
return
jpg2
;
}
else
if
(
File
.
Exists
(
jpg3
))
{
File
.
Copy
(
jpg3
,
jpg
,
true
);
if
(
File
.
Exists
(
jpg
))
{
//复制失败
return
jpg
;
}
}
else
if
(
File
.
Exists
(
png
))
{
return
png
;
}
else
if
(
File
.
Exists
(
png2
))
{
return
png2
;
}
else
if
(
File
.
Exists
(
png3
))
{
File
.
Copy
(
png3
,
png
,
true
);
if
(
File
.
Exists
(
png
))
{
//复制失败
return
png
;
}
}
return
""
;
}
//获取属性
public
static
string
GetAttribute
(
int
attr
)
{
CardAttribute
cattr
=
(
CardAttribute
)
attr
;
string
sattr
=
MseAttribute
.
NONE
;
switch
(
cattr
)
{
case
CardAttribute
.
ATTRIBUTE_DARK
:
sattr
=
MseAttribute
.
DARK
;
break
;
case
CardAttribute
.
ATTRIBUTE_DEVINE
:
sattr
=
MseAttribute
.
DIVINE
;
break
;
case
CardAttribute
.
ATTRIBUTE_EARTH
:
sattr
=
MseAttribute
.
EARTH
;
break
;
case
CardAttribute
.
ATTRIBUTE_FIRE
:
sattr
=
MseAttribute
.
FIRE
;
break
;
case
CardAttribute
.
ATTRIBUTE_LIGHT
:
sattr
=
MseAttribute
.
LIGHT
;
break
;
case
CardAttribute
.
ATTRIBUTE_WATER
:
sattr
=
MseAttribute
.
WATER
;
break
;
case
CardAttribute
.
ATTRIBUTE_WIND
:
sattr
=
MseAttribute
.
WIND
;
break
;
}
return
sattr
;
}
//获取效果文本
public
static
string
GetDesc
(
string
cdesc
,
string
regx
)
{
string
desc
=
cdesc
;
desc
=
desc
.
Replace
(
"\r\n"
,
"\n"
);
desc
=
desc
.
Replace
(
"\r"
,
"\n"
);
Regex
regex
=
new
Regex
(
regx
,
RegexOptions
.
Multiline
);
Match
mc
=
regex
.
Match
(
desc
);
if
(
mc
.
Success
)
return
((
mc
.
Groups
.
Count
>
1
)
?
mc
.
Groups
[
1
].
Value
:
mc
.
Groups
[
0
].
Value
)
.
Trim
(
'\n'
).
Replace
(
"\n"
,
"\n\t\t"
);
return
""
;
}
public
string
ReText
(
string
text
)
{
StringBuilder
sb
=
new
StringBuilder
(
text
);
sb
.
Replace
(
"\r\n"
,
"\n"
);
sb
.
Replace
(
"\r"
,
"\n"
);
sb
.
Replace
(
"\n\n"
,
"\n"
);
sb
.
Replace
(
"\n"
,
"\n\t\t"
);
return
sb
.
ToString
().
Trim
(
'\n'
);
}
//获取星星
public
static
string
GetStar
(
long
level
)
{
long
j
=
level
&
0xff
;
string
star
=
""
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
star
+=
"*"
;
}
return
star
;
}
//获取种族
public
string
GetRace
(
long
race
)
{
if
(
cfg
.
raceDic
.
ContainsKey
(
race
))
return
cfg
.
raceDic
[
race
].
Trim
();
return
race
.
ToString
(
"x"
);
}
//获取类型文字
public
string
GetType
(
CardType
ctype
)
{
long
type
=
(
long
)
ctype
;
if
(
cfg
.
typeDic
.
ContainsKey
(
type
))
return
cfg
.
typeDic
[
type
].
Trim
();
return
type
.
ToString
(
"x"
);
}
public
string
ReText
(
string
text
)
{
StringBuilder
sb
=
new
StringBuilder
(
text
);
sb
.
Replace
(
"\r\n"
,
"\n"
);
sb
.
Replace
(
"\r"
,
"\n"
);
sb
.
Replace
(
"\n\n"
,
"\n"
);
sb
.
Replace
(
"\n"
,
"\n\t\t"
);
return
sb
.
ToString
().
Trim
(
'\n'
);
}
//获取星星
public
static
string
GetStar
(
long
level
)
{
long
j
=
level
&
0xff
;
string
star
=
""
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
star
+=
"*"
;
}
return
star
;
}
//获取种族
public
string
GetRace
(
long
race
)
{
if
(
cfg
.
raceDic
.
ContainsKey
(
race
))
return
cfg
.
raceDic
[
race
].
Trim
();
return
race
.
ToString
(
"x"
);
}
//获取类型文字
public
string
GetType
(
CardType
ctype
)
{
long
type
=
(
long
)
ctype
;
if
(
cfg
.
typeDic
.
ContainsKey
(
type
))
return
cfg
.
typeDic
[
type
].
Trim
();
return
type
.
ToString
(
"x"
);
}
//获取卡片类型
public
string
[]
GetTypes
(
Card
c
)
{
//卡片类型,效果1,效果2,效果3
string
[]
types
=
new
string
[]
{
MseCardType
.
CARD_NORMAL
,
""
,
""
,
""
};
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
{
//卡片类型和第1效果
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
{
types
[
0
]
=
MseCardType
.
CARD_XYZ
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_XYZ
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOKEN
))
{
types
[
0
]
=
(
c
.
race
==
0
)
?
MseCardType
.
CARD_TOKEN2
:
MseCardType
.
CARD_TOKEN
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_TOKEN
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
{
types
[
0
]
=
MseCardType
.
CARD_RITUAL
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_RITUAL
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_FUSION
))
{
types
[
0
]
=
MseCardType
.
CARD_FUSION
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_FUSION
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_SYNCHRO
))
{
types
[
0
]
=
MseCardType
.
CARD_SYNCHRO
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_SYNCHRO
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
types
[
0
]
=
MseCardType
.
CARD_EFFECT
;
}
else
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
//同调
if
(
types
[
0
]
==
MseCardType
.
CARD_SYNCHRO
||
types
[
0
]
==
MseCardType
.
CARD_TOKEN
)
{
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
)
&&
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
//调整效果
types
[
2
]
=
GetType
(
CardType
.
TYPE_TUNER
);
types
[
3
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
))
{
types
[
2
]
=
GetType
(
CardType
.
TYPE_TUNER
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
types
[
2
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
}
}
else
if
(
types
[
0
]
==
MseCardType
.
CARD_NORMAL
)
{
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//灵摆
types
[
1
]
=
GetType
(
CardType
.
TYPE_PENDULUM
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
))
//调整
types
[
1
]
=
GetType
(
CardType
.
TYPE_TUNER
);
}
else
if
(
types
[
0
]
!=
MseCardType
.
CARD_EFFECT
)
{
//效果
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
types
[
2
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
}
else
{
//效果怪兽
types
[
2
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_PENDULUM
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_TUNER
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_SPIRIT
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_SPIRIT
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOON
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_TOON
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_UNION
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_UNION
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_DUAL
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_DUAL
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_FLIP
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_FLIP
);
else
{
types
[
1
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
types
[
2
]
=
""
;
}
}
//获取卡片类型
public
string
[]
GetTypes
(
Card
c
)
{
//卡片类型,效果1,效果2,效果3
string
[]
types
=
new
string
[]
{
MseCardType
.
CARD_NORMAL
,
""
,
""
,
""
};
if
(
c
.
IsType
(
CardType
.
TYPE_MONSTER
))
{
//卡片类型和第1效果
if
(
c
.
IsType
(
CardType
.
TYPE_XYZ
))
{
types
[
0
]
=
MseCardType
.
CARD_XYZ
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_XYZ
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOKEN
))
{
types
[
0
]
=
(
c
.
race
==
0
)
?
MseCardType
.
CARD_TOKEN2
:
MseCardType
.
CARD_TOKEN
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_TOKEN
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_RITUAL
))
{
types
[
0
]
=
MseCardType
.
CARD_RITUAL
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_RITUAL
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_FUSION
))
{
types
[
0
]
=
MseCardType
.
CARD_FUSION
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_FUSION
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_SYNCHRO
))
{
types
[
0
]
=
MseCardType
.
CARD_SYNCHRO
;
types
[
1
]
=
GetType
(
CardType
.
TYPE_SYNCHRO
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
types
[
0
]
=
MseCardType
.
CARD_EFFECT
;
}
else
types
[
0
]
=
MseCardType
.
CARD_NORMAL
;
//同调
if
(
types
[
0
]
==
MseCardType
.
CARD_SYNCHRO
||
types
[
0
]
==
MseCardType
.
CARD_TOKEN
)
{
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
)
&&
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
//调整效果
types
[
2
]
=
GetType
(
CardType
.
TYPE_TUNER
);
types
[
3
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
))
{
types
[
2
]
=
GetType
(
CardType
.
TYPE_TUNER
);
}
else
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
{
types
[
2
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
}
}
else
if
(
types
[
0
]
==
MseCardType
.
CARD_NORMAL
)
{
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
//灵摆
types
[
1
]
=
GetType
(
CardType
.
TYPE_PENDULUM
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
))
//调整
types
[
1
]
=
GetType
(
CardType
.
TYPE_TUNER
);
}
else
if
(
types
[
0
]
!=
MseCardType
.
CARD_EFFECT
)
{
//效果
if
(
c
.
IsType
(
CardType
.
TYPE_EFFECT
))
types
[
2
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
}
else
{
//效果怪兽
types
[
2
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_PENDULUM
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_TUNER
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_TUNER
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_SPIRIT
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_SPIRIT
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_TOON
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_TOON
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_UNION
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_UNION
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_DUAL
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_DUAL
);
else
if
(
c
.
IsType
(
CardType
.
TYPE_FLIP
))
types
[
1
]
=
GetType
(
CardType
.
TYPE_FLIP
);
else
{
types
[
1
]
=
GetType
(
CardType
.
TYPE_EFFECT
);
types
[
2
]
=
""
;
}
}
}
if
(
c
.
race
==
0
)
//如果没有种族
{
types
[
1
]
=
""
;
types
[
2
]
=
""
;
}
return
types
;
}
#
endregion
}
if
(
c
.
race
==
0
)
//如果没有种族
{
types
[
1
]
=
""
;
types
[
2
]
=
""
;
}
return
types
;
}
#
endregion
#
region
写存档
//写存档
public
string
[]
WriteSet
(
string
file
,
Card
[]
cards
)
{
List
<
string
>
list
=
new
List
<
string
>();
string
pic
=
cfg
.
imagepath
;
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
cfg
.
head
);
foreach
(
Card
c
in
cards
)
{
string
jpg
=
GetCardImagePath
(
pic
,
c
);
if
(!
string
.
IsNullOrEmpty
(
jpg
))
{
list
.
Add
(
jpg
);
jpg
=
Path
.
GetFileName
(
jpg
);
}
if
(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
sw
.
WriteLine
(
getSpellTrap
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_SPELL
)));
else
sw
.
WriteLine
(
getMonster
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_PENDULUM
)));
}
sw
.
WriteLine
(
cfg
.
end
);
sw
.
Close
();
}
#
region
写存档
//写存档
public
string
[]
WriteSet
(
string
file
,
Card
[]
cards
)
{
List
<
string
>
list
=
new
List
<
string
>();
string
pic
=
cfg
.
imagepath
;
using
(
FileStream
fs
=
new
FileStream
(
file
,
FileMode
.
Create
,
FileAccess
.
Write
))
{
StreamWriter
sw
=
new
StreamWriter
(
fs
,
Encoding
.
UTF8
);
sw
.
WriteLine
(
cfg
.
head
);
foreach
(
Card
c
in
cards
)
{
string
jpg
=
GetCardImagePath
(
pic
,
c
);
if
(!
string
.
IsNullOrEmpty
(
jpg
))
{
list
.
Add
(
jpg
);
jpg
=
Path
.
GetFileName
(
jpg
);
}
if
(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
sw
.
WriteLine
(
getSpellTrap
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_SPELL
)));
else
sw
.
WriteLine
(
getMonster
(
c
,
jpg
,
c
.
IsType
(
CardType
.
TYPE_PENDULUM
)));
}
sw
.
WriteLine
(
cfg
.
end
);
sw
.
Close
();
}
return
list
.
ToArray
();
}
//怪兽,pendulum怪兽
string
getMonster
(
Card
c
,
string
img
,
bool
isPendulum
)
{
StringBuilder
sb
=
new
StringBuilder
();
string
[]
types
=
GetTypes
(
c
);
string
race
=
GetRace
(
c
.
race
);
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
GetLine
(
TAG_CARDTYPE
,
types
[
0
]));
sb
.
AppendLine
(
GetLine
(
TAG_NAME
,
reItalic
(
c
.
name
)));
sb
.
AppendLine
(
GetLine
(
TAG_ATTRIBUTE
,
GetAttribute
(
c
.
attribute
)));
sb
.
AppendLine
(
GetLine
(
TAG_LEVEL
,
GetStar
(
c
.
level
)));
sb
.
AppendLine
(
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE1
,
cn2tw
(
race
)));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE2
,
cn2tw
(
types
[
1
])));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE3
,
cn2tw
(
types
[
2
])));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE4
,
cn2tw
(
types
[
3
])));
if
(
isPendulum
)
//P怪兽
{
string
text
=
GetDesc
(
c
.
desc
,
cfg
.
regx_monster
);
if
(
string
.
IsNullOrEmpty
(
text
))
text
=
ReText
(
c
.
desc
);
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
//sb.AppendLine(cfg.regx_monster + ":" + cfg.regx_pendulum);
sb
.
AppendLine
(
" "
+
reItalic
(
text
));
sb
.
AppendLine
(
GetLine
(
TAG_PENDULUM
,
"medium"
));
sb
.
AppendLine
(
GetLine
(
TAG_PSCALE1
,
((
c
.
level
>>
0x18
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
GetLine
(
TAG_PSCALE2
,
((
c
.
level
>>
0x10
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
" "
+
TAG_PEND_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
reItalic
(
GetDesc
(
c
.
desc
,
cfg
.
regx_pendulum
)));
}
else
//一般怪兽
{
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
reItalic
(
ReText
(
c
.
desc
)));
}
sb
.
AppendLine
(
GetLine
(
TAG_ATK
,
(
c
.
atk
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
atk
.
ToString
()));
sb
.
AppendLine
(
GetLine
(
TAG_DEF
,
(
c
.
def
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
def
.
ToString
()));
return
list
.
ToArray
();
}
//怪兽,pendulum怪兽
string
getMonster
(
Card
c
,
string
img
,
bool
isPendulum
)
{
StringBuilder
sb
=
new
StringBuilder
();
string
[]
types
=
GetTypes
(
c
);
string
race
=
GetRace
(
c
.
race
);
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
GetLine
(
TAG_CARDTYPE
,
types
[
0
]));
sb
.
AppendLine
(
GetLine
(
TAG_NAME
,
reItalic
(
c
.
name
)));
sb
.
AppendLine
(
GetLine
(
TAG_ATTRIBUTE
,
GetAttribute
(
c
.
attribute
)));
sb
.
AppendLine
(
GetLine
(
TAG_LEVEL
,
GetStar
(
c
.
level
)));
sb
.
AppendLine
(
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE1
,
cn2tw
(
race
)));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE2
,
cn2tw
(
types
[
1
])));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE3
,
cn2tw
(
types
[
2
])));
sb
.
AppendLine
(
GetLine
(
TAG_TYPE4
,
cn2tw
(
types
[
3
])));
if
(
isPendulum
)
//P怪兽
{
string
text
=
GetDesc
(
c
.
desc
,
cfg
.
regx_monster
);
if
(
string
.
IsNullOrEmpty
(
text
))
text
=
ReText
(
c
.
desc
);
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
//sb.AppendLine(cfg.regx_monster + ":" + cfg.regx_pendulum);
sb
.
AppendLine
(
" "
+
reItalic
(
text
));
sb
.
AppendLine
(
GetLine
(
TAG_PENDULUM
,
"medium"
));
sb
.
AppendLine
(
GetLine
(
TAG_PSCALE1
,
((
c
.
level
>>
0x18
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
GetLine
(
TAG_PSCALE2
,
((
c
.
level
>>
0x10
)
&
0xff
).
ToString
()));
sb
.
AppendLine
(
" "
+
TAG_PEND_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
reItalic
(
GetDesc
(
c
.
desc
,
cfg
.
regx_pendulum
)));
}
else
//一般怪兽
{
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
reItalic
(
ReText
(
c
.
desc
)));
}
sb
.
AppendLine
(
GetLine
(
TAG_ATK
,
(
c
.
atk
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
atk
.
ToString
()));
sb
.
AppendLine
(
GetLine
(
TAG_DEF
,
(
c
.
def
<
0
)
?
UNKNOWN_ATKDEF
:
c
.
def
.
ToString
()));
sb
.
AppendLine
(
GetLine
(
TAG_CODE
,
c
.
idString
));
return
sb
.
ToString
();
}
//魔法陷阱
string
getSpellTrap
(
Card
c
,
string
img
,
bool
isSpell
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
GetLine
(
TAG_CARDTYPE
,
isSpell
?
"spell card"
:
"trap card"
));
sb
.
AppendLine
(
GetLine
(
TAG_NAME
,
reItalic
(
c
.
name
)));
sb
.
AppendLine
(
GetLine
(
TAG_ATTRIBUTE
,
isSpell
?
"spell"
:
"trap"
));
sb
.
AppendLine
(
GetLine
(
TAG_LEVEL
,
GetSpellTrapSymbol
(
c
,
isSpell
)));
sb
.
AppendLine
(
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
reItalic
(
ReText
(
c
.
desc
)));
sb
.
AppendLine
(
GetLine
(
TAG_CODE
,
c
.
idString
));
return
sb
.
ToString
();
}
#
endregion
sb
.
AppendLine
(
GetLine
(
TAG_CODE
,
c
.
idString
));
return
sb
.
ToString
();
}
//魔法陷阱
string
getSpellTrap
(
Card
c
,
string
img
,
bool
isSpell
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
AppendLine
(
TAG_CARD
+
":"
);
sb
.
AppendLine
(
GetLine
(
TAG_CARDTYPE
,
isSpell
?
"spell card"
:
"trap card"
));
sb
.
AppendLine
(
GetLine
(
TAG_NAME
,
reItalic
(
c
.
name
)));
sb
.
AppendLine
(
GetLine
(
TAG_ATTRIBUTE
,
isSpell
?
"spell"
:
"trap"
));
sb
.
AppendLine
(
GetLine
(
TAG_LEVEL
,
GetSpellTrapSymbol
(
c
,
isSpell
)));
sb
.
AppendLine
(
GetLine
(
TAG_IMAGE
,
img
));
sb
.
AppendLine
(
" "
+
TAG_TEXT
+
":"
);
sb
.
AppendLine
(
" "
+
reItalic
(
ReText
(
c
.
desc
)));
sb
.
AppendLine
(
GetLine
(
TAG_CODE
,
c
.
idString
));
return
sb
.
ToString
();
}
#
endregion
#
region
读存档
public
static
int
GetAttributeInt
(
string
cattr
)
{
int
iattr
=
0
;
switch
(
cattr
)
{
case
MseAttribute
.
DARK
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DARK
;
break
;
case
MseAttribute
.
DIVINE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DEVINE
;
break
;
case
MseAttribute
.
EARTH
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_EARTH
;
break
;
case
MseAttribute
.
FIRE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_FIRE
;
break
;
case
MseAttribute
.
LIGHT
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_LIGHT
;
break
;
case
MseAttribute
.
WATER
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WATER
;
break
;
case
MseAttribute
.
WIND
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WIND
;
break
;
}
return
iattr
;
}
long
GetRaceInt
(
string
race
)
{
if
(!
string
.
IsNullOrEmpty
(
race
))
{
foreach
(
long
key
in
cfg
.
raceDic
.
Keys
)
{
if
(
race
.
Equals
(
cfg
.
raceDic
[
key
]))
return
key
;
}
}
return
(
long
)
CardRace
.
RACE_NONE
;
}
long
GetTypeInt
(
string
type
)
{
if
(!
string
.
IsNullOrEmpty
(
type
))
{
foreach
(
long
key
in
cfg
.
typeDic
.
Keys
)
{
if
(
type
.
Equals
(
cfg
.
typeDic
[
key
]))
return
key
;
}
}
return
0
;
}
static
string
GetValue
(
string
content
,
string
tag
)
{
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\s\S]*?)$"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
return
RemoveTag
(
m
.
Groups
[
1
].
Value
);
}
return
""
;
}
//多行
static
string
GetMultiValue
(
string
content
,
string
tag
)
{
//TODO
content
=
content
.
Replace
(
"\t\t"
,
""
);
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\S\s]*?)^\t[\S\s]+?:"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
{
string
word
=
m
.
Groups
[
1
].
Value
;
return
RemoveTag
(
word
).
Replace
(
"^"
,
""
).
Replace
(
"\t"
,
""
);
}
}
return
""
;
}
long
GetSpellTrapType
(
string
level
)
{
long
type
=
0
;
//魔法陷阱
if
(
level
.
Contains
(
MseSpellTrap
.
EQUIP
))
type
=
(
long
)
CardType
.
TYPE_EQUIP
;
if
(
level
.
Contains
(
MseSpellTrap
.
QUICKPLAY
))
type
=
(
long
)
CardType
.
TYPE_QUICKPLAY
;
if
(
level
.
Contains
(
MseSpellTrap
.
FIELD
))
type
=
(
long
)
CardType
.
TYPE_FIELD
;
if
(
level
.
Contains
(
MseSpellTrap
.
CONTINUOUS
))
type
=
(
long
)
CardType
.
TYPE_CONTINUOUS
;
if
(
level
.
Contains
(
MseSpellTrap
.
RITUAL
))
type
=
(
long
)
CardType
.
TYPE_RITUAL
;
if
(
level
.
Contains
(
MseSpellTrap
.
COUNTER
))
type
=
(
long
)
CardType
.
TYPE_COUNTER
;
return
type
;
}
#
region
读存档
public
static
int
GetAttributeInt
(
string
cattr
)
{
int
iattr
=
0
;
switch
(
cattr
)
{
case
MseAttribute
.
DARK
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DARK
;
break
;
case
MseAttribute
.
DIVINE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_DEVINE
;
break
;
case
MseAttribute
.
EARTH
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_EARTH
;
break
;
case
MseAttribute
.
FIRE
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_FIRE
;
break
;
case
MseAttribute
.
LIGHT
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_LIGHT
;
break
;
case
MseAttribute
.
WATER
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WATER
;
break
;
case
MseAttribute
.
WIND
:
iattr
=
(
int
)
CardAttribute
.
ATTRIBUTE_WIND
;
break
;
}
return
iattr
;
}
long
GetRaceInt
(
string
race
)
{
if
(!
string
.
IsNullOrEmpty
(
race
))
{
foreach
(
long
key
in
cfg
.
raceDic
.
Keys
)
{
if
(
race
.
Equals
(
cfg
.
raceDic
[
key
]))
return
key
;
}
}
return
(
long
)
CardRace
.
RACE_NONE
;
}
long
GetTypeInt
(
string
type
)
{
if
(!
string
.
IsNullOrEmpty
(
type
))
{
foreach
(
long
key
in
cfg
.
typeDic
.
Keys
)
{
if
(
type
.
Equals
(
cfg
.
typeDic
[
key
]))
return
key
;
}
}
return
0
;
}
static
string
GetValue
(
string
content
,
string
tag
)
{
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\s\S]*?)$"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
return
RemoveTag
(
m
.
Groups
[
1
].
Value
);
}
return
""
;
}
//多行
static
string
GetMultiValue
(
string
content
,
string
tag
)
{
//TODO
content
=
content
.
Replace
(
"\t\t"
,
""
);
Regex
regx
=
new
Regex
(
@"^[\t]+?"
+
tag
+
@":([\S\s]*?)^\t[\S\s]+?:"
,
RegexOptions
.
Multiline
);
Match
m
=
regx
.
Match
(
content
);
if
(
m
.
Success
)
{
if
(
m
.
Groups
.
Count
>=
2
)
{
string
word
=
m
.
Groups
[
1
].
Value
;
return
RemoveTag
(
word
).
Replace
(
"^"
,
""
).
Replace
(
"\t"
,
""
);
}
}
return
""
;
}
long
GetSpellTrapType
(
string
level
)
{
long
type
=
0
;
//魔法陷阱
if
(
level
.
Contains
(
MseSpellTrap
.
EQUIP
))
type
=
(
long
)
CardType
.
TYPE_EQUIP
;
if
(
level
.
Contains
(
MseSpellTrap
.
QUICKPLAY
))
type
=
(
long
)
CardType
.
TYPE_QUICKPLAY
;
if
(
level
.
Contains
(
MseSpellTrap
.
FIELD
))
type
=
(
long
)
CardType
.
TYPE_FIELD
;
if
(
level
.
Contains
(
MseSpellTrap
.
CONTINUOUS
))
type
=
(
long
)
CardType
.
TYPE_CONTINUOUS
;
if
(
level
.
Contains
(
MseSpellTrap
.
RITUAL
))
type
=
(
long
)
CardType
.
TYPE_RITUAL
;
if
(
level
.
Contains
(
MseSpellTrap
.
COUNTER
))
type
=
(
long
)
CardType
.
TYPE_COUNTER
;
return
type
;
}
long
GetMonsterType
(
string
cardtype
)
{
long
type
=
0
;
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_SPELL
))
type
=
(
long
)
CardType
.
TYPE_SPELL
;
else
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_TRAP
))
type
=
(
long
)
CardType
.
TYPE_TRAP
;
else
{
type
=
(
long
)
CardType
.
TYPE_MONSTER
;
switch
(
cardtype
)
{
case
MseCardType
.
CARD_NORMAL
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
case
MseCardType
.
CARD_EFFECT
:
type
|=
(
long
)
CardType
.
TYPE_EFFECT
;
break
;
case
MseCardType
.
CARD_XYZ
:
type
|=
(
long
)
CardType
.
TYPE_XYZ
;
break
;
case
MseCardType
.
CARD_RITUAL
:
type
|=
(
long
)
CardType
.
TYPE_RITUAL
;
break
;
case
MseCardType
.
CARD_FUSION
:
type
|=
(
long
)
CardType
.
TYPE_FUSION
;
break
;
case
MseCardType
.
CARD_TOKEN
:
case
MseCardType
.
CARD_TOKEN2
:
type
|=
(
long
)
CardType
.
TYPE_TOKEN
;
break
;
case
MseCardType
.
CARD_SYNCHRO
:
type
|=
(
long
)
CardType
.
TYPE_SYNCHRO
;
break
;
default
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
}
}
return
type
;
}
//卡片类型
long
GetCardType
(
string
cardtype
,
string
level
,
string
type1
,
string
type2
,
string
type3
)
{
long
type
=
0
;
//魔法陷阱
type
|=
GetSpellTrapType
(
level
);
//怪兽
type
|=
GetMonsterType
(
cardtype
);
//type2-4是识别怪兽效果类型
type
|=
GetTypeInt
(
type1
);
type
|=
GetTypeInt
(
type2
);
type
|=
GetTypeInt
(
type3
);
return
type
;
}
long
GetMonsterType
(
string
cardtype
)
{
long
type
=
0
;
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_SPELL
))
type
=
(
long
)
CardType
.
TYPE_SPELL
;
else
if
(
cardtype
.
Equals
(
MseCardType
.
CARD_TRAP
))
type
=
(
long
)
CardType
.
TYPE_TRAP
;
else
{
type
=
(
long
)
CardType
.
TYPE_MONSTER
;
switch
(
cardtype
)
{
case
MseCardType
.
CARD_NORMAL
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
case
MseCardType
.
CARD_EFFECT
:
type
|=
(
long
)
CardType
.
TYPE_EFFECT
;
break
;
case
MseCardType
.
CARD_XYZ
:
type
|=
(
long
)
CardType
.
TYPE_XYZ
;
break
;
case
MseCardType
.
CARD_RITUAL
:
type
|=
(
long
)
CardType
.
TYPE_RITUAL
;
break
;
case
MseCardType
.
CARD_FUSION
:
type
|=
(
long
)
CardType
.
TYPE_FUSION
;
break
;
case
MseCardType
.
CARD_TOKEN
:
case
MseCardType
.
CARD_TOKEN2
:
type
|=
(
long
)
CardType
.
TYPE_TOKEN
;
break
;
case
MseCardType
.
CARD_SYNCHRO
:
type
|=
(
long
)
CardType
.
TYPE_SYNCHRO
;
break
;
default
:
type
|=
(
long
)
CardType
.
TYPE_NORMAL
;
break
;
}
}
return
type
;
}
//卡片类型
long
GetCardType
(
string
cardtype
,
string
level
,
string
type1
,
string
type2
,
string
type3
)
{
long
type
=
0
;
//魔法陷阱
type
|=
GetSpellTrapType
(
level
);
//怪兽
type
|=
GetMonsterType
(
cardtype
);
//type2-4是识别怪兽效果类型
type
|=
GetTypeInt
(
type1
);
type
|=
GetTypeInt
(
type2
);
type
|=
GetTypeInt
(
type3
);
return
type
;
}
static
string
RemoveTag
(
string
word
)
{
//移除标签<>
word
=
Regex
.
Replace
(
word
,
"<[^>]+?>"
,
""
);
return
word
.
Trim
().
Replace
(
"\t"
,
""
);
}
//解析卡片
public
Card
ReadCard
(
string
content
,
out
string
img
)
{
string
tmp
;
int
itmp
;
Card
c
=
new
Card
();
c
.
ot
=
(
int
)
CardRule
.
OCGTCG
;
//卡名
c
.
name
=
GetValue
(
content
,
TAG_NAME
);
tmp
=
GetValue
(
content
,
TAG_LEVEL
);
//卡片种族
c
.
race
=
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
//卡片类型
c
.
type
=
GetCardType
(
GetValue
(
content
,
TAG_CARDTYPE
),
tmp
,
GetValue
(
content
,
TAG_TYPE2
),
GetValue
(
content
,
TAG_TYPE3
),
GetValue
(
content
,
TAG_TYPE4
));
long
t
=
GetSpellTrapType
(
GetValue
(
content
,
TAG_LEVEL
));
//不是魔法,陷阱卡片的星数
if
(!(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
&&
t
==
0
)
c
.
level
=
GetValue
(
content
,
TAG_LEVEL
).
Length
;
static
string
RemoveTag
(
string
word
)
{
//移除标签<>
word
=
Regex
.
Replace
(
word
,
"<[^>]+?>"
,
""
);
return
word
.
Trim
().
Replace
(
"\t"
,
""
);
}
//解析卡片
public
Card
ReadCard
(
string
content
,
out
string
img
)
{
string
tmp
;
int
itmp
;
Card
c
=
new
Card
();
c
.
ot
=
(
int
)
CardRule
.
OCGTCG
;
//卡名
c
.
name
=
GetValue
(
content
,
TAG_NAME
);
tmp
=
GetValue
(
content
,
TAG_LEVEL
);
//卡片种族
c
.
race
=
GetRaceInt
(
GetValue
(
content
,
TAG_TYPE1
));
//卡片类型
c
.
type
=
GetCardType
(
GetValue
(
content
,
TAG_CARDTYPE
),
tmp
,
GetValue
(
content
,
TAG_TYPE2
),
GetValue
(
content
,
TAG_TYPE3
),
GetValue
(
content
,
TAG_TYPE4
));
long
t
=
GetSpellTrapType
(
GetValue
(
content
,
TAG_LEVEL
));
//不是魔法,陷阱卡片的星数
if
(!(
c
.
IsType
(
CardType
.
TYPE_SPELL
)
||
c
.
IsType
(
CardType
.
TYPE_TRAP
))
&&
t
==
0
)
c
.
level
=
GetValue
(
content
,
TAG_LEVEL
).
Length
;
//属性
c
.
attribute
=
GetAttributeInt
(
GetValue
(
content
,
TAG_ATTRIBUTE
));
//密码
long
.
TryParse
(
GetValue
(
content
,
TAG_CODE
),
out
c
.
id
);
//ATK
tmp
=
GetValue
(
content
,
TAG_ATK
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
c
.
atk
=
UNKNOWN_ATKDEF_VALUE
;
else
int
.
TryParse
(
tmp
,
out
c
.
atk
);
//DEF
tmp
=
GetValue
(
content
,
TAG_DEF
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
c
.
def
=
UNKNOWN_ATKDEF_VALUE
;
else
int
.
TryParse
(
tmp
,
out
c
.
def
);
//图片
img
=
GetValue
(
content
,
TAG_IMAGE
);
//摇摆
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
{
//根据预设的模版,替换内容
tmp
=
cfg
.
temp_text
.
Replace
(
TAG_REP_TEXT
,
GetMultiValue
(
content
,
TAG_TEXT
));
tmp
=
tmp
.
Replace
(
TAG_REP_PTEXT
,
GetMultiValue
(
content
,
TAG_PEND_TEXT
));
c
.
desc
=
tmp
;
}
else
c
.
desc
=
GetMultiValue
(
content
,
TAG_TEXT
);
//摇摆刻度
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE1
),
out
itmp
);
c
.
level
+=
(
itmp
<<
0x18
);
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE2
),
out
itmp
);
c
.
level
+=
(
itmp
<<
0x10
);
return
c
;
}
//读取所有卡片
public
Card
[]
ReadCards
(
string
set
,
bool
repalceOld
)
{
List
<
Card
>
cards
=
new
List
<
Card
>();
if
(!
File
.
Exists
(
set
))
return
null
;
string
allcontent
=
File
.
ReadAllText
(
set
,
Encoding
.
UTF8
);
//属性
c
.
attribute
=
GetAttributeInt
(
GetValue
(
content
,
TAG_ATTRIBUTE
));
//密码
long
.
TryParse
(
GetValue
(
content
,
TAG_CODE
),
out
c
.
id
);
//ATK
tmp
=
GetValue
(
content
,
TAG_ATK
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
c
.
atk
=
UNKNOWN_ATKDEF_VALUE
;
else
int
.
TryParse
(
tmp
,
out
c
.
atk
);
//DEF
tmp
=
GetValue
(
content
,
TAG_DEF
);
if
(
tmp
==
UNKNOWN_ATKDEF
)
c
.
def
=
UNKNOWN_ATKDEF_VALUE
;
else
int
.
TryParse
(
tmp
,
out
c
.
def
);
//图片
img
=
GetValue
(
content
,
TAG_IMAGE
);
//摇摆
if
(
c
.
IsType
(
CardType
.
TYPE_PENDULUM
))
{
//根据预设的模版,替换内容
tmp
=
cfg
.
temp_text
.
Replace
(
TAG_REP_TEXT
,
GetMultiValue
(
content
,
TAG_TEXT
));
tmp
=
tmp
.
Replace
(
TAG_REP_PTEXT
,
GetMultiValue
(
content
,
TAG_PEND_TEXT
));
c
.
desc
=
tmp
;
}
else
c
.
desc
=
GetMultiValue
(
content
,
TAG_TEXT
);
//摇摆刻度
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE1
),
out
itmp
);
c
.
level
+=
(
itmp
<<
0x18
);
int
.
TryParse
(
GetValue
(
content
,
TAG_PSCALE2
),
out
itmp
);
c
.
level
+=
(
itmp
<<
0x10
);
return
c
;
}
//读取所有卡片
public
Card
[]
ReadCards
(
string
set
,
bool
repalceOld
)
{
List
<
Card
>
cards
=
new
List
<
Card
>();
if
(!
File
.
Exists
(
set
))
return
null
;
string
allcontent
=
File
.
ReadAllText
(
set
,
Encoding
.
UTF8
);
Regex
regx
=
new
Regex
(
@"^card:[\S\s]+?gamecode:[\S\s]+?$"
,
RegexOptions
.
Multiline
);
MatchCollection
matchs
=
regx
.
Matches
(
allcontent
);
int
i
=
0
;
foreach
(
Match
match
in
matchs
)
{
string
content
=
match
.
Groups
[
0
].
Value
;
i
++;
string
img
;
Card
c
=
ReadCard
(
content
,
out
img
);
if
(
c
.
id
<=
0
)
c
.
id
=
i
;
//添加卡片
cards
.
Add
(
c
);
//已经解压出来的图片
string
saveimg
=
MyPath
.
Combine
(
cfg
.
imagepath
,
img
);
if
(!
File
.
Exists
(
saveimg
))
//没有解压相应的图片
continue
;
//改名后的图片
img
=
MyPath
.
Combine
(
cfg
.
imagepath
,
c
.
idString
+
".jpg"
);
if
(
img
==
saveimg
)
//文件名相同
continue
;
if
(
File
.
Exists
(
img
))
{
if
(
repalceOld
)
//如果存在,则备份原图
{
File
.
Delete
(
img
+
".bak"
);
//删除备份
File
.
Move
(
img
,
img
+
".bak"
);
//备份
File
.
Move
(
saveimg
,
img
);
//改名
}
}
else
File
.
Move
(
saveimg
,
img
);
}
File
.
Delete
(
set
);
return
cards
.
ToArray
();
}
#
endregion
}
Regex
regx
=
new
Regex
(
@"^card:[\S\s]+?gamecode:[\S\s]+?$"
,
RegexOptions
.
Multiline
);
MatchCollection
matchs
=
regx
.
Matches
(
allcontent
);
int
i
=
0
;
foreach
(
Match
match
in
matchs
)
{
string
content
=
match
.
Groups
[
0
].
Value
;
i
++;
string
img
;
Card
c
=
ReadCard
(
content
,
out
img
);
if
(
c
.
id
<=
0
)
c
.
id
=
i
;
//添加卡片
cards
.
Add
(
c
);
//已经解压出来的图片
string
saveimg
=
MyPath
.
Combine
(
cfg
.
imagepath
,
img
);
if
(!
File
.
Exists
(
saveimg
))
//没有解压相应的图片
continue
;
//改名后的图片
img
=
MyPath
.
Combine
(
cfg
.
imagepath
,
c
.
idString
+
".jpg"
);
if
(
img
==
saveimg
)
//文件名相同
continue
;
if
(
File
.
Exists
(
img
))
{
if
(
repalceOld
)
//如果存在,则备份原图
{
File
.
Delete
(
img
+
".bak"
);
//删除备份
File
.
Move
(
img
,
img
+
".bak"
);
//备份
File
.
Move
(
saveimg
,
img
);
//改名
}
}
else
File
.
Move
(
saveimg
,
img
);
}
File
.
Delete
(
set
);
return
cards
.
ToArray
();
}
#
endregion
public
string
getImageCache
(
string
img
){
if
(
cfg
.
width
<=
0
&&
cfg
.
height
<=
0
)
return
img
;
string
md5
=
MyUtils
.
GetMD5HashFromFile
(
img
);
if
(
MyUtils
.
Md5isEmpty
(
md5
)||
cfg
.
imagecache
==
null
){
//md5为空
return
img
;
}
string
file
=
MyPath
.
Combine
(
cfg
.
imagecache
,
md5
+
".png"
);
if
(!
File
.
Exists
(
file
)){
//生成缓存
Bitmap
bmp
=
MyBitmap
.
readImage
(
file
);
//缩放
bmp
=
MyBitmap
.
Zoom
(
bmp
,
cfg
.
width
,
cfg
.
height
);
//保存文件
MyBitmap
.
SaveAsJPEG
(
bmp
,
file
,
100
);
}
return
img
;
}
}
}
DataEditorX/Core/TaskHelper.cs
View file @
3b1132f8
...
...
@@ -293,7 +293,8 @@ public void SaveMSE(int num, string file, Card[] cards, bool isUpdate)
break
;
i
++;
worker
.
ReportProgress
(
i
/
count
,
string
.
Format
(
"{0}/{1}-{2}"
,
i
,
count
,
num
));
zips
.
AddFile
(
img
,
Path
.
GetFileName
(
img
),
""
);
//TODO 先裁剪图片
zips
.
AddFile
(
mseHelper
.
getImageCache
(
img
),
Path
.
GetFileName
(
img
),
""
);
}
}
File
.
Delete
(
setFile
);
...
...
DataEditorX/DataEditorX.csproj
View file @
3b1132f8
...
...
@@ -69,6 +69,7 @@
</Compile>
<Compile
Include=
"Common\CheckUpdate.cs"
/>
<Compile
Include=
"Common\ConfHelper.cs"
/>
<Compile
Include=
"Common\MyUtils.cs"
/>
<Compile
Include=
"Common\StrUtil.cs"
/>
<Compile
Include=
"Common\XMLReader.cs"
/>
<Compile
Include=
"Config\YgoPath.cs"
/>
...
...
DataEditorX/Properties/AssemblyInfo.cs
View file @
3b1132f8
...
...
@@ -28,4 +28,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[
assembly
:
AssemblyVersion
(
"2.3.
1.4
"
)]
[
assembly
:
AssemblyVersion
(
"2.3.
2.0
"
)]
DataEditorX/changed.txt
View file @
3b1132f8
★更新历史
2.3.2.0
MSE存档的中间图缩放
2.3.1.4
增加灵摆刻度的搜索功能
关闭数据库时清理备份文件
...
...
DataEditorX/data/mse_Chinese-Simplified.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### 存档最大卡片数
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
#jp setting
# spell = %%
...
...
DataEditorX/data/mse_Chinese-Traditional.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### Setting
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
#jp setting
# spell = %%
...
...
DataEditorX/data/mse_English.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### Setting
maxcount = 200
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
spell = [Sepll Card%%]
trap = [Trap Card%%]
...
...
DataEditorX/data/mse_Japan.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### Setting
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
#jp setting
spell = %%
...
...
DataEditorX/readme.txt
View file @
3b1132f8
[DataEditorX]2.3.
1.4
[DataEditorX]
[DataEditorX]2.3.
2.0
[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
...
...
win32/DataEditorX.exe
View file @
3b1132f8
No preview for this file type
win32/changed.txt
View file @
3b1132f8
★更新历史
2.3.2.0
MSE存档的中间图缩放
2.3.1.4
增加灵摆刻度的搜索功能
关闭数据库时清理备份文件
...
...
win32/data/language_chinese.txt
View file @
3b1132f8
...
...
@@ -157,4 +157,3 @@ MainForm.mainMenu.menuitem_closeall 关闭所有
0x47 读取MSE存档
0x48 读取MSE存档完成!
0x49 请重启程序使更改生效
0x4c 是否同时删除卡图、脚本等资源?
\ No newline at end of file
win32/data/language_english.txt
View file @
3b1132f8
...
...
@@ -156,4 +156,3 @@ MainForm.mainMenu.menuitem_closeall Close All
0x47 Read MSE-set
0x48 Read MSE-set is OK.
0x49 Please restart program to apply changes.
0x4c Also delete pics and scripts?
\ No newline at end of file
win32/data/mse_Chinese-Simplified.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### 存档最大卡片数
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
#jp setting
# spell = %%
...
...
win32/data/mse_Chinese-Traditional.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### Setting
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
#jp setting
# spell = %%
...
...
win32/data/mse_English.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### Setting
maxcount = 200
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
spell = [Sepll Card%%]
trap = [Trap Card%%]
...
...
win32/data/mse_Japan.txt
View file @
3b1132f8
...
...
@@ -7,6 +7,9 @@ cn2tw = false
########################### Setting
maxcount = 0
imagepath = ./Images
########################### 中间图
width = 345
height = 346
########################### Spell/Trap
#jp setting
spell = %%
...
...
win32/readme.txt
View file @
3b1132f8
[DataEditorX]2.3.
1.4
[DataEditorX]
[DataEditorX]2.3.
2.0
[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
...
...
win32/win32.zip
View file @
3b1132f8
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