Commit 2cf4ede4 authored by keyongyu's avatar keyongyu

mse

parent 9d62faef
......@@ -29,7 +29,7 @@ public static string getValue2(string word)
return word.Substring(i + SEP_LINE.Length);
return "";
}
public static string getRegexValue(string line)
public static string getMultLineValue(string line)
{
return getRegex(getValue(line));
}
......
......@@ -21,13 +21,23 @@ namespace DataEditorX.Config
public class MSEConfig
{
public const string TAG_HEAD = "head";
public const string TAG_MONSTER = "monster";
public const string TAG_PENDULUM = "pendulum";
public const string TAG_SPELL_TRAP = "spelltrap";
public const string FILE_CONFIG = "mse-config.txt";
public const string FILE_TEMPLATE = "mse-template.txt";
public const string SEP_LINE = " ";
public const string TAG_CN2TW = "cn2tw";
public const string TAG_SPELL = "spell";
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_IMAGE = "imagepath";
public const string TAG_REPALCE = "replace";
public const string TAG_REP = "%%";
public const string SEP_LINE = " ";
public const string FILE_CONFIG = "mse-config.txt";
public const string PATH_IMAGE = "Images";
public MSEConfig(string path)
{
init(path);
......@@ -38,17 +48,6 @@ public void init(string path)
regx_monster = "(\\s\\S*?)";
regx_pendulum = "(\\s\\S*?)";
string file = MyPath.Combine(path, FILE_TEMPLATE);
if (File.Exists(file))
{
string content = File.ReadAllText(file, Encoding.UTF8);
head = DataManager.subString(content, TAG_HEAD);
monster = DataManager.subString(content, TAG_MONSTER);
pendulum = DataManager.subString(content, TAG_PENDULUM);
spelltrap = DataManager.subString(content, TAG_SPELL_TRAP);
}
string tmp = MyPath.Combine(path, FILE_CONFIG);
replaces = new Dictionary<string, string>();
......@@ -62,24 +61,26 @@ public void init(string path)
{
if (string.IsNullOrEmpty(line) || line.StartsWith("#"))
continue;
if (line.StartsWith("cn2tw"))
if (line.StartsWith(TAG_CN2TW))
Iscn2tw = ConfHelper.getBooleanValue(line);
else if (line.StartsWith("spell"))
else if (line.StartsWith(TAG_SPELL))
str_spell = ConfHelper.getValue(line);
else if (line.StartsWith("trap"))
else if (line.StartsWith(TAG_HEAD))
head = ConfHelper.getMultLineValue(line);
else if (line.StartsWith(TAG_TRAP))
str_trap = ConfHelper.getValue(line);
else if (line.StartsWith("pendulum-text"))
regx_pendulum = ConfHelper.getRegexValue(line);
else if (line.StartsWith("monster-text"))
regx_monster = ConfHelper.getRegexValue(line);
else if (line.StartsWith("maxcount"))
else if (line.StartsWith(TAG_REG_PENDULUM))
regx_pendulum = ConfHelper.getMultLineValue(line);
else if (line.StartsWith(TAG_REG_MONSTER))
regx_monster = ConfHelper.getMultLineValue(line);
else if (line.StartsWith(TAG_MAXCOUNT))
maxcount = ConfHelper.getIntegerValue(line, 0);
else if (line.StartsWith("imagepath"))
else if (line.StartsWith(TAG_IMAGE))
{
//如果路径不合法,则为后面的路径
imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, "Images"));
imagepath = MyPath.CheckDir(ConfHelper.getValue(line), MyPath.Combine(path, PATH_IMAGE));
}
else if (line.StartsWith("replace"))
else if (line.StartsWith(TAG_REPALCE))
{//特数字替换
string word = ConfHelper.getValue(line);
string p = ConfHelper.getRegex(ConfHelper.getValue1(word));
......@@ -88,28 +89,21 @@ public void init(string path)
replaces.Add(p, r);
}
else if (line.StartsWith("race"))
else if (line.StartsWith(TAG_RACE))
{//种族
ConfHelper.DicAdd(raceDic, line);
}
else if (line.StartsWith("type"))
else if (line.StartsWith(TAG_TYPE))
{//类型
ConfHelper.DicAdd(typeDic, line);
}
}
//判断魔法标志是否为纯符号
if (str_spell == "%%" && str_trap == "%%")
st_is_symbol = true;
else
st_is_symbol = false;
}
//每个存档最大数
public int maxcount;
//图片路径
public string imagepath;
//标志是符号
public bool st_is_symbol;
//魔法标志
public string str_spell;
//陷阱标志
......@@ -121,11 +115,8 @@ public void init(string path)
//效果文正则提取
public string regx_pendulum;
public string regx_monster;
//模版
//存档头部
public string head;
public string monster;
public string pendulum;
public string spelltrap;
public Dictionary<long, string> typeDic;
public Dictionary<long, string> raceDic;
}
......
......@@ -89,15 +89,15 @@ public string GetST(Card c, bool isSpell)
level = "#";
else if (c.IsType(CardType.TYPE_COUNTER))
level = "!";
else if (cfg.st_is_symbol)
level = "^";
else if (cfg.str_spell == MSEConfig.TAG_REP && cfg.str_trap == MSEConfig.TAG_REP)
level = "^";//带文字的图片
else
level = "";
if (isSpell)
level = cfg.str_spell.Replace("%%", level);
level = cfg.str_spell.Replace(MSEConfig.TAG_REP, level);
else
level = cfg.str_trap.Replace("%%", level);
level = cfg.str_trap.Replace(MSEConfig.TAG_REP, level);
return level;
}
public static string GetCardImagePath(string picpath, Card c)
......@@ -334,51 +334,48 @@ public string[] WriteSet(string file,Card[] cards)
string getMonster(Card c,string img,bool isPendulum)
{
StringBuilder sb=new StringBuilder();
if(isPendulum)
sb.Append(cfg.pendulum);
else
sb.Append(cfg.monster);
string[] types = GetTypes(c);
string race = GetRace(c.race);
sb.Replace("%type%", types[0]);
sb.Replace("%name%", reItalic(c.name));
sb.Replace("%attribute%", GetAttribute(c.attribute));
sb.Replace("%level%", GetStar(c.level));
sb.Replace("%image%", img);
sb.Replace("%race%", cn2tw(race));
sb.Replace("%type1%",cn2tw(types[1]));
sb.Replace("%type2%",cn2tw(types[2]));
sb.Replace("%type3%",cn2tw(types[3]));
sb.AppendLine("card:");
sb.AppendLine(" card type: " + types[0]);
sb.AppendLine(" name: " + reItalic(c.name));
sb.AppendLine(" attribute: " + GetAttribute(c.attribute));
sb.AppendLine(" level: " + GetStar(c.level));
sb.AppendLine(" image: " + img);
sb.AppendLine(" type 1: %" + cn2tw(race));
sb.AppendLine(" type 2: " + cn2tw(types[1]));
sb.AppendLine(" type 3: " + cn2tw(types[2]));
sb.AppendLine(" type 4: " + cn2tw(types[3]));
if(isPendulum){
string text = GetDesc(c.desc, cfg.regx_monster);
if(string.IsNullOrEmpty(text))
text=c.desc;
sb.Replace("%desc%", ReDesc(text));
sb.Replace("%pl%", ((c.level >> 0x18) & 0xff).ToString());
sb.Replace("%pr%", ((c.level >> 0x10) & 0xff).ToString());
sb.Replace("%pdesc%", ReDesc(
sb.AppendLine(" rule text: " + ReDesc(text));
sb.AppendLine(" pendulum scale 1: " + ((c.level >> 0x18) & 0xff).ToString());
sb.AppendLine(" pendulum scale 2:" + ((c.level >> 0x10) & 0xff).ToString());
sb.AppendLine(" pendulum text: " + ReDesc(
GetDesc(c.desc, cfg.regx_pendulum)));
}
else
sb.Replace("%desc%", ReDesc(c.desc));
sb.Replace("%atk%", (c.atk<0)?"?":c.atk.ToString());
sb.Replace("%def%", (c.def<0)?"?":c.def.ToString());
sb.Replace("%code%", c.idString);
sb.AppendLine(" rule text: " + ReDesc(c.desc));
sb.AppendLine(" attack: "+((c.atk < 0) ? "?" : c.atk.ToString()));
sb.AppendLine(" defense: "+((c.def < 0) ? "?" : c.def.ToString()));
sb.AppendLine(" gamecode: "+c.idString);
return sb.ToString();
}
//魔法陷阱
string getSpellTrap(Card c,string img,bool isSpell)
{
StringBuilder sb=new StringBuilder(cfg.spelltrap);
sb.Replace("%type%", isSpell?"spell card":"trap card");
sb.Replace("%name%", reItalic(c.name));
sb.Replace("%attribute%", isSpell?"spell":"trap");
sb.Replace("%level%", GetST(c, isSpell));
sb.Replace("%image%", img);
sb.Replace("%desc%", ReDesc(c.desc));
sb.Replace("%code%", c.idString);
StringBuilder sb=new StringBuilder();
sb.AppendLine("card:");
sb.AppendLine(" card type: " + (isSpell ? "spell card" : "trap card"));
sb.AppendLine(" name: " + reItalic(c.name));
sb.AppendLine(" attribute: " + (isSpell ? "spell" : "trap"));
sb.AppendLine(" level: " + GetST(c, isSpell));
sb.AppendLine(" image: " + img);
sb.AppendLine(" rule text: " + ReDesc(c.desc));
sb.AppendLine(" gamecode: " + c.idString);
return sb.ToString();
}
}
......
......@@ -6,5 +6,21 @@ namespace DataEditorX.Core
{
public class MseReader
{
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";
public const string TAG_TYPE1 = "type 1";
public const string TAG_TYPE2 = "type 2";
public const string TAG_TYPE3 = "type 3";
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_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";
}
}
......@@ -201,9 +201,6 @@
<None Include="chinese\mse-config.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="chinese\mse-template.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="single.lua">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
......@@ -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.2.8.6")]
[assembly: AssemblyVersion("2.2.9.0")]
###########################
# Magic Set Editor 2
#
# \t = Tab \n = Enter \s = Space
########################### Chs 2 Cht
cn2tw = true
########################### Setting
......@@ -11,6 +13,8 @@ imagepath = ./Images
# trap = %%
spell = [魔法卡%%]
trap = [陷阱卡%%]
############################ language,style,other setting
head = mse version: 0.3.8\ngame: yugioh\nstylesheet: standard\nset info:\n\tlanguage: TW\n\tedition: \n\tST mark is text: no\n\tpendulum image is small: yes\n
############################ Text
# chs jp
pendulum-text = 】[\s\S]*?\n([\S\s]*?)\n【
......@@ -23,24 +27,6 @@ monster-text = [果|介|述|報]】\n([\S\s]*)
replace = ([鮟|鱇|・|·]) <i>$1</i>
#replace = \s <sym-auto>^</sym-auto>
#replace = ([A-Z]) <i>$1</i>
########################### Read MSE set
#
type = card type
name = name
attribute = attribute
level = level
image = image
type1 = type 1
type2 = type 2
type3 = type 3
type4 = type 4
rule = rule text
atk = attack
def = defense
pscale1 = pendulum scale 1
pscale2 = pendulum scale 2
prule = pendulum text
code = gamecode
###########################
##race
race 0x1 战士族
......
##head
mse version: 0.3.8
game: yugioh
stylesheet: standard
set info:
language: TW
edition:
ST mark is text: no
pendulum image is small: yes
##monster
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
type 1: %race%
type 2: %type1%
type 3: %type2%
type 4: %type3%
rule text:
%desc%
attack: %atk%
defense: %def%
gamecode: %code%
##pendulum
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
type 1: %race%
type 2: %type1%
type 3: %type2%
type 4: %type3%
rule text:
%desc%
attack: %atk%
defense: %def%
pendulum: medium
pendulum scale 1: %pl%
pendulum scale 2: %pr%
pendulum text:
%pdesc%
gamecode: %code%
##spelltrap
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
rule text:
%desc%
gamecode: %code%
#end
\ No newline at end of file
No preview for this file type
......@@ -11,6 +11,8 @@ imagepath = ./Images
# trap = %%
spell = [魔法卡%%]
trap = [陷阱卡%%]
############################ language,style,other setting
head = mse version: 0.3.8\ngame: yugioh\nstylesheet: standard\nset info:\n\tlanguage: TW\n\tedition: \n\tST mark is text: no\n\tpendulum image is small: yes\n
############################ Text
# chs jp
pendulum-text = 】[\s\S]*?\n([\S\s]*?)\n【
......@@ -23,24 +25,6 @@ monster-text = [果|介|述|報]】\n([\S\s]*)
replace = ([鮟|鱇|・|·]) <i>$1</i>
#replace = \s <sym-auto>^</sym-auto>
#replace = ([A-Z]) <i>$1</i>
########################### Read MSE set
#
type = card type
name = name
attribute = attribute
level = level
image = image
type1 = type 1
type2 = type 2
type3 = type 3
type4 = type 4
rule = rule text
atk = attack
def = defense
pscale1 = pendulum scale 1
pscale2 = pendulum scale 2
prule = pendulum text
code = gamecode
###########################
##race
race 0x1 战士族
......
##head
mse version: 0.3.8
game: yugioh
stylesheet: standard
set info:
language: TW
edition:
ST mark is text: no
pendulum image is small: yes
##monster
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
type 1: %race%
type 2: %type1%
type 3: %type2%
type 4: %type3%
rule text:
%desc%
attack: %atk%
defense: %def%
gamecode: %code%
##pendulum
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
type 1: %race%
type 2: %type1%
type 3: %type2%
type 4: %type3%
rule text:
%desc%
attack: %atk%
defense: %def%
pendulum: medium
pendulum scale 1: %pl%
pendulum scale 2: %pr%
pendulum text:
%pdesc%
gamecode: %code%
##spelltrap
card:
card type: %type%
name: %name%
attribute: %attribute%
level: %level%
image: %image%
rule text:
%desc%
gamecode: %code%
#end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment