Commit e80a98ef authored by 不如归去's avatar 不如归去 Committed by GitHub

Merge pull request #3 from IamIpanda/master

Merge Develop
parents 94fa2e2a 5640bc3f
......@@ -3,6 +3,7 @@
module Global
class << self
attr_accessor :language
attr_accessor :raw_image_path
attr_accessor :git_path
attr_accessor :git_uri
attr_accessor :database_path
......@@ -17,8 +18,8 @@ module Global
attr_accessor :sql_fix_name
end
self.language = 'zh-CN'
self.git_path = 'pics'
self.database_path = 'ygopro-database'
self.raw_image_path = 'ygopro-images-raw/pics/'
self.database_path = 'ygopro-database/locales/'
self.git_uri = 'https://github.com/mycard/ygopro-images-raw.git'
self.database_name = '%s.cdb'
self.temp_database_name = "working-cards.cdb"
......@@ -31,11 +32,11 @@ module Global
self.mse_set_path = "mse-sets"
module_function
def full_database_path
return File.join self.database_path, sprintf(self.database_name, self.language)
return self.database_path + self.language + "/cards.cdb"
end
def full_image_path
return self.git_path
return self.raw_image_path
end
def full_answer_path
......
......@@ -25,6 +25,8 @@ class LanguageConstants
attr_accessor :term_cartoon
attr_accessor :term_xyz
attr_accessor :term_pendulum
attr_accessor :term_link
attr_accessor :term_spsummon
attr_accessor :pendulum_effect_head
attr_accessor :monster_effect_head
attr_accessor :term_races # 偷个鸡
......
......@@ -53,6 +53,7 @@ module MSEConstants
TagText = "rule text"
TagAtk = "attack"
TagDef = "defense"
TagLink = "link number"
TagNumber = "number"
TagRarity = "rarity"
TagPendulum = "pendulum"
......@@ -103,6 +104,7 @@ module MSEConstants
Token = "token monster"
Token2 = "token card"
Synchro = "synchro monster"
Link = "link monster"
Spell = "spell card"
Trap = "trap card"
Special = {10000000 => "obelisk", 10000010 => "ra", 10000020 => "slifer"}
......@@ -110,4 +112,7 @@ module MSEConstants
SetFileName = "set"
SingleFileMaxCount = 200
LinkMarkerHead = "Link Marker "
LinkMarks = ["DL", "Down", "DR", "Left", "", "Right", "UL", "Up", "UR"]
end
......@@ -47,6 +47,11 @@ module MSETranslator
else
file.write self.generate_text MSEConstants::MSETags::TagText, YGOCoreJudgers.get_desc(card)
end
# Link data
if YGOCoreJudgers.is_link card
file.write self.generate_line MSEConstants::MSETags::TagLink, YGOCoreJudgers.get_link(card)
write_link_lines file, card
end
file.write self.generate_line MSEConstants::MSETags::TagAtk, YGOCoreJudgers.get_attack(card)
file.write self.generate_line MSEConstants::MSETags::TagDef, YGOCoreJudgers.get_defense(card)
file.write self.generate_line MSEConstants::MSETags::TagCode, YGOCoreJudgers.get_id(card).to_s
......@@ -63,6 +68,11 @@ module MSETranslator
file.write self.generate_line MSEConstants::MSETags::TagCode, YGOCoreJudgers.get_id(card).to_s
end
def write_link_lines(file, card)
markers = YGOCoreJudgers.get_link_marks card
(0..8).each { |i| file.write self.generate_line MSEConstants::LinkMarkerHead + MSEConstants::LinkMarks[i], 'yes' if markers[i] }
end
LineHead = "\t"#" "
def generate_line(key, word)
"#{LineHead}#{key}: #{word}\n"
......
......@@ -29,4 +29,12 @@ def unit_test_god
p MSETranslator.split_effect YGOCoreJudgers.get_desc(Sqlite.load(17390179)[0])
end
unit_test_god
def link_test
require './Commands.rb'
Commands.generate_all
end
def god_test
require './Commands.rb'
MSETranslator.generate_mse Sqlite.load(10000010)
end
\ No newline at end of file
......@@ -37,6 +37,7 @@ module YGOCoreConstants
Devine = 0x200000 # 幻兽神
Creatorgod = 0x400000 # 创世神
Wyrm = 0x800000 # 幻龙
Cyverse = 0x1000000 # 电子界
end
module Rule
......@@ -71,6 +72,8 @@ module YGOCoreConstants
Cartoon = 0x400000 # 卡通
Xyz = 0x800000 # Xyz
Pendulum = 0x1000000 # 灵摆
SpSummon = 0x2000000 # 特殊召唤
Link = 0x4000000 # 连接
end
PendulumLeftMod = 65536
......
......@@ -138,6 +138,14 @@ module YGOCoreJudgers
return card[ColumnType] & YGOCoreConstants::Type::Pendulum != 0
end
def is_spsummon(card)
return card[ColumnType] & YGOCoreConstants::Type::SpSummon != 0
end
def is_link(card)
return card[ColumnType] & YGOCoreConstants::Type::Link != 0
end
def get_id(card)
return card[ColumnID].to_i
end
......@@ -163,14 +171,27 @@ module YGOCoreJudgers
def get_defense(card)
value = card[ColumnDef].to_i
return "?" if value == YGOCoreConstants::QuestionMark
return "" if self.is_link card
value
end
def get_link(card)
return "" unless self.is_link card
return card[ColumnLevel].to_i
end
def get_link_marks(card)
value = card[ColumnDef]
sprintf("%09b", value).scan(/\d/).reverse.map { |s| s == '1' }
end
def get_level(card)
return 0 if self.is_link card
return card[ColumnLevel].to_i % YGOCoreConstants::PendulumLeftMod
end
def get_monster_level_str(card)
return "" if self.is_link card
return MSEConstants::MSESpellTrap::Level * self.get_level(card)
end
......@@ -309,6 +330,8 @@ module YGOCoreJudgers
return MSEConstants::MSECardType::Fusion
elsif self.is_sync card
return MSEConstants::MSECardType::Synchro
elsif self.is_link card
return MSEConstants::MSECardType::Link
elsif self.is_effect card
return MSEConstants::MSECardType::Effect
end
......@@ -326,7 +349,9 @@ module YGOCoreJudgers
types.push LanguageConstants.current.term_fusion if self.is_fusion card
types.push LanguageConstants.current.term_synchro if self.is_sync card
types.push LanguageConstants.current.term_pendulum if self.is_pendulum card
types.push LanguageConstants.current.term_link if self.is_link card
# 子类别
types.push LanguageConstants.current.term_spsummon if self.is_spsummon card
types.push LanguageConstants.current.term_spirit if self.is_spirit card
types.push LanguageConstants.current.term_union if self.is_union card
types.push LanguageConstants.current.term_dual if self.is_dual card
......
......@@ -23,6 +23,8 @@ en-US:
cartoon: "Cartoon"
xyz: "Xyz"
pendulum: "Pendulum"
spsummon: "Special Summon"
link: "Link"
races:
- ""
- "Warrior"
......@@ -49,6 +51,7 @@ en-US:
- "Divine-Beast"
- "Creator God"
- "Wyrm"
- "Cyverse"
pendulum_effect_head: !ruby/regexp /Pendulum Scale\s*=\s*\d+\n*\[\s*Pendulum Effect\s*\]\n*(\-n\/a(\-)*)*/
monster_effect_head: !ruby/regexp /\n*(-+?\n+)*\n*\[\s*(Monster Effect|Flavor Text)\s*\]\s*?\n/
mse_language: en
......
......@@ -23,6 +23,8 @@ ja-JP:
cartoon: "トゥーン"
xyz: "エクシーズ"
pendulum: "ペンデュラム"
spsummon: "特殊召唤"
link: "リンク"
races:
- ""
- "戦士族"
......@@ -49,6 +51,7 @@ ja-JP:
- "幻神獣族"
- "創造神族"
- "幻竜族"
- "サイバース族"
pendulum_effect_head: !ruby/regexp /【Pスケール:青(.*)/赤(.*)】(\n)*/
monster_effect_head: !ruby/regexp /(\n)*(【モンスター効果】|【モンスター情報】)\n/
mse_language: jp
......
......@@ -23,6 +23,8 @@ zh-CN:
cartoon: "卡通"
xyz: "超量"
pendulum: "灵摆"
spsummon: "特殊召唤"
link: "连接"
races:
- ""
- "战士族"
......@@ -49,6 +51,7 @@ zh-CN:
- "幻兽神族"
- "创世神族"
- "幻龙族"
- "电子界族"
pendulum_effect_head: !ruby/regexp /←\d+ 【灵摆】 \d+→\n?/
monster_effect_head: !ruby/regexp /(\n)*(?:【怪兽效果】|【怪兽简介】|【怪兽描述】)\n/
mse_language: cn
......
......@@ -23,6 +23,8 @@ zh-Classical:
cartoon: "卡通"
xyz: "超量"
pendulum: "灵摆"
spsummon: "特殊召唤"
link: "连接"
races:
- ""
- "战士族"
......@@ -49,6 +51,7 @@ zh-Classical:
- "幻兽神族"
- "创世神族"
- "幻龙族"
- "电子界族"
pendulum_effect_head: !ruby/regexp /←\d+ 【灵摆】 \d+→\n?/
monster_effect_head: !ruby/regexp /(\n)?(?:【怪兽效果】|【怪兽简介】|【怪兽描述】)\n/
mse_language: cn
......
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