Commit d41e218c authored by IamIpanda's avatar IamIpanda

Merge pull request #1 from mycard/master

Merge from zh
parents 17293014 01eb3560
Dockerfile Dockerfile
#.git
#.gitattributes
#.gitignore
#.gitmodules
#.gitkeep
.dockerignore .dockerignore
[submodule "magicseteditor"] [submodule "magicseteditor"]
path = magicseteditor path = magicseteditor
url = https://github.com/mycard/magicseteditor.git url = git@github.com:mycard/magicseteditor.git
branch = win32 branch = win32
[submodule "ygopro-images-raw"] [submodule "ygopro-images-raw"]
path = ygopro-images-raw path = ygopro-images-raw
url = https://github.com/mycard/ygopro-images-raw.git url = git@github.com:mycard/ygopro-images-raw.git
[submodule "ygopro-database"] [submodule "ygopro-database"]
path = ygopro-database path = ygopro-database
url = https://github.com/mycard/ygopro-database.git url = git@github.com:mycard/ygopro-database.git
branch = build
[submodule "ygopro-images"] [submodule "ygopro-images"]
path = ygopro-images path = ygopro-images
url = https://github.com/mycard/ygopro-images.git url = git@github.com:mycard/ygopro-images.git
[submodule "ImgGen"]
path = ImgGen
url = git@github.com:mycard/ImgGen.git
...@@ -18,37 +18,38 @@ module Commands ...@@ -18,37 +18,38 @@ module Commands
def generate_all def generate_all
Log.logger.info "Generate all the card images with language #{Global.language}." Log.logger.info "Generate all the card images with language #{Global.language}."
self.clear_mse self.clear_mse
data = Sqlite.split Sqlite.load data = Sqlite.split Sqlite.load
MSETranslator.generate_mse_all(data) MSETranslator.generate_mse_all(data)
MSETranslator.export_mse_all MSETranslator.export_mse_all
end end
def generate_delta(languages = nil) def generate_delta(languages = nil, export = true)
Log.logger.info "Generate delta card image(s)" Log.logger.info "Generate delta card image(s) with parameter: #{languages.inspect}"
self.clear_mse
data = Sqlite.load
changes = HashJudger.compare data
generates = changes[0] + changes[2]
removes = changes[1]
data = Sqlite.split generates
if languages == nil if languages == nil
process(removes, data) process_generate_delta(export)
else else
for language in languages for language in languages
Global.language = language Global.language = language
process(removes, data) process_generate_delta(export)
end end
end end
end end
def process(removes, data) def process_generate_delta(export = true)
Log.logger.info "Generate delta card image with language #{Global.language}"
self.clear_mse
data = Sqlite.load # Language effected here
changes = HashJudger.compare data
generates = changes[0] + changes[2]
removes = changes[1]
data = Sqlite.split generates
for card in removes for card in removes
id = YGOCoreJudgers.get_id card id = YGOCoreJudgers.get_id card
path = File.join Global.full_answer_path, id.to_s + Global.image_type path = File.join Global.full_answer_path, id.to_s + Global.image_type
File.delete path if File.exist? path File.delete path if File.exist? path
end end
MSETranslator.generate_mse_all(data) MSETranslator.generate_mse_all(data)
MSETranslator.export_mse_all MSETranslator.export_mse_all if export
end end
def generate_single(id) def generate_single(id)
...@@ -69,4 +70,4 @@ module Commands ...@@ -69,4 +70,4 @@ module Commands
languages languages
end end
end end
\ No newline at end of file
...@@ -2,7 +2,7 @@ FROM ruby ...@@ -2,7 +2,7 @@ FROM ruby
RUN dpkg --add-architecture i386 RUN dpkg --add-architecture i386
RUN apt-get update RUN apt-get update
RUN apt-get install -y wine wine32 xvfb RUN apt-get install -y wine wine32 xvfb imagemagick mono-complete
RUN bundle config --global frozen 1 RUN bundle config --global frozen 1
RUN mkdir -p /usr/src/app RUN mkdir -p /usr/src/app
...@@ -10,13 +10,24 @@ WORKDIR /usr/src/app ...@@ -10,13 +10,24 @@ WORKDIR /usr/src/app
COPY Gemfile /usr/src/app/ COPY Gemfile /usr/src/app/
COPY Gemfile.lock /usr/src/app/ COPY Gemfile.lock /usr/src/app/
RUN bundle install RUN bundle install
COPY . /usr/src/app
RUN cp -r /usr/src/app/ygopro-database/* /usr/src/app/ygopro-images-raw/ #TODO: implement in ruby RUN git config --global user.email "zh99998+mycard@gmail.com"
RUN git config --global user.name "mycard"
RUN git config --global push.default simple
RUN ssh-keyscan github.com > /etc/ssh/ssh_known_hosts
ENV DISPLAY=:0.0
ENV WINEARCH=win32 ENV WINEARCH=win32
ENV RACK_ENV=production ENV RACK_ENV=production
RUN wineboot -i RUN wineboot -i
COPY magicseteditor/fonts /root/.wine/drive_c/windows/Fonts COPY magicseteditor/fonts /root/.wine/drive_c/windows/Fonts
CMD ["./entrypoint.sh"]
COPY . /usr/src/app
RUN mv /usr/src/app/ImgGen /usr/src/app/ImgGen-source
WORKDIR /usr/src/app/ImgGen-source
RUN xbuild /property:Configuration=Release /property:OutDir=/usr/src/app/ImgGen/
RUN ln -s /usr/src/app/ygopro-database/zh-CN.cdb /usr/src/app/cards.cdb
RUN ln -s /usr/src/app/ygopro-images-raw /usr/src/app/ImgGen/pico
RUN ln -s /usr/src/app/ygopro-images /usr/src/app/ImgGen/picn
CMD xvfb-run --server-args="-screen 0 1x0x24" ./Server.rb
...@@ -23,7 +23,7 @@ module Global ...@@ -23,7 +23,7 @@ module Global
self.database_name = '%s.cdb' self.database_name = '%s.cdb'
self.temp_database_name = "working-cards.cdb" self.temp_database_name = "working-cards.cdb"
self.image_type = '.jpg' self.image_type = '.jpg'
self.records_name = "records.json" self.records_name = "ygopro-images/records.json"
self.answer_path = "ygopro-images-%s" self.answer_path = "ygopro-images-%s"
self.answer_uri = "https://github.com/mycard/ygo-images.git" self.answer_uri = "https://github.com/mycard/ygo-images.git"
self.mse_path = "magicseteditor" self.mse_path = "magicseteditor"
......
Subproject commit b1fe4ca39ced52dfbd55e31d6b47470f44918a71
...@@ -30,7 +30,7 @@ module MSEConstants ...@@ -30,7 +30,7 @@ module MSEConstants
FileConfigName = "Chinese-Simplified" FileConfigName = "Chinese-Simplified"
PathImage = "Images" PathImage = "Images"
Head = "mse version: 0.3.8\r\ngame: yugioh\r\nstylesheet: standard\r\nset info:\r\n\tlanguage: %s\r\n\tedition: \r\n\tST mark is text: yes\r\n\tpendulum image is small: yes\r\n\thide gamecode: yes\r\n" Head = "mse version: 0.3.8\ngame: yugioh\nstylesheet: standard\nset info:\n\tlanguage: %s\n\tedition: \n\tno corner: yes\n\tST mark is text: yes\n\tpendulum image is small: yes\n\thide gamecode: yes\n"
End = "version control:\n\ttype: none\napprentice code: " End = "version control:\n\ttype: none\napprentice code: "
Width = 319 Width = 319
...@@ -105,6 +105,7 @@ module MSEConstants ...@@ -105,6 +105,7 @@ module MSEConstants
Synchro = "synchro monster" Synchro = "synchro monster"
Spell = "spell card" Spell = "spell card"
Trap = "trap card" Trap = "trap card"
Special = {10000001 => "obelisk", 10000011 => "ra", 10000021 => "slifer"}
end end
SetFileName = "set" SetFileName = "set"
......
...@@ -68,12 +68,9 @@ module MSETranslator ...@@ -68,12 +68,9 @@ module MSETranslator
end end
def reline(word) def reline(word)
word = word.gsub "\n\r", "\n" word = word.delete "\r"
word = word.gsub "\r\n", "\n" word = word.squeeze "\n"
word = word.gsub "\r", "" word = word.gsub "。\n", "。"
word = word.gsub "\n\n", "\n"
# 这是特别处理。
word = word.gsub "。\n", "。" if Global.language == "jp"
word word
end end
......
#!/usr/bin/env ruby
# sinatra server core # sinatra server core
require "sinatra" require "sinatra"
require File.dirname(__FILE__) + "/Git.rb" require File.dirname(__FILE__) + "/Git.rb"
require File.dirname(__FILE__) + "/Commands.rb" require File.dirname(__FILE__) + "/Commands.rb"
post '/command' do # 由于卡图生成时间太长,因此应该收到请求之后立即给一个 2xx 的回复,以防调用的那边认为网络超时而进行不必要的重新请求等操作。
# 如果在一次生成完毕之前,又进来了多个调用,按如下方式处理:
# 1. 如果当前是空闲中,立即启动生成
# 2. 如果当前正在生成中,做一个【存在队列中的请求】的标记
# 3. 当生成完毕之后,如果存在队列标记,重新启动生成
def generate
system('./generate.sh')
if settings.status == :queued
settings.status = :running
generate
else
settings.status = :idle
end
end
configure do
set :status, :running
Thread.new { generate }
end end
post '/hook' do post '/hook' do
Git.pull status 204
Commands.generate_delta(Commands.get_languages) if settings.status == :idle
Git.commit settings.status = :running
Git.push Thread.new { generate }
else
settings.status = :queued
end
end end
...@@ -285,8 +285,10 @@ module YGOCoreJudgers ...@@ -285,8 +285,10 @@ module YGOCoreJudgers
end end
def get_cardtype_str(card) def get_cardtype_str(card)
if self.is_spell card if MSEConstants::MSECardType::Special[self.get_id(card)]
return MSEConstants::MSECardType::Spell return MSEConstants::MSECardType::Special[self.get_id(card)]
elsif self.is_spell card
return MSEConstants::MSECardType::Spell
elsif self.is_trap card elsif self.is_trap card
return MSEConstants::MSECardType::Trap return MSEConstants::MSECardType::Trap
elsif self.is_monster card elsif self.is_monster card
......
#!/bin/bash
Xvfb -screen 0 1x0x24 &
ruby Server.rb
update datas set level = 0 where id in (1686814, 90884403, 52653092, 65305468);
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
#usage: ./generator.rb zh-CN #usage: ./generator.rb zh-CN
require_relative 'Commands.rb' require_relative 'Commands.rb'
Commands.generate_delta(ARGV) Commands.generate_delta(ARGV, false)
#!/bin/bash
git_pull () {
cd $1
git clean -f -d
git reset --hard
git checkout $2
git reset --hard origin/$2
git pull
cd ..
}
git_push () {
cd $1
git add .
git commit -am 'Update card images by https://github.com/mycard/ygopro-images-generator'
git push
cd ..
}
git_pull ygopro-database build
git_pull ygopro-images-raw master
for locale in locales/*.yml; do
continue;
locale=$(basename "${locale}" .yml)
git_pull ygopro-images ${locale}
rm -rf ygopro-images-${locale} mse-set
./generate.rb ${locale}
if [ ! -f mse-sets/data0-${locale}.mse-set ]; then # skip if no cards updated.
continue
fi
for set in mse-sets/data*-${locale}.mse-set; do
echo ${set}
wine32 magicseteditor/mse.com --export "${set}" "ygopro-images-${locale}/{card.gamecode}.png"
done
for image in ygopro-images-${locale}/*.png; do
id=$(basename "${image}" .png)
convert "${image}" -colorspace RGB -resize 177x254! -colorspace sRGB "ygopro-images/${id}.jpg"
convert "${image}" -colorspace RGB -resize 44x64! -colorspace sRGB "ygopro-images/thumbnail/${id}.jpg"
done
git_push ygopro-images
done
#classical
git_pull ygopro-images classical
cd ImgGen
mono ImgGen.exe
cd ..
git_push ygopro-images
...@@ -49,6 +49,6 @@ zh-CN: ...@@ -49,6 +49,6 @@ zh-CN:
- "幻兽神族" - "幻兽神族"
- "创世神族" - "创世神族"
- "幻龙族" - "幻龙族"
pendulum_effect_head: !ruby/regexp /←\\d 【灵摆】 \\d→(\\n)?/ pendulum_effect_head: !ruby/regexp /←\d+ 【灵摆】 \d+→\n?/
monster_effect_head: "\n【怪兽效果】\n" monster_effect_head: !ruby/regexp /\n(?:【怪兽效果】|【怪兽简介】|【怪兽描述】)\n/
mse_language: cn mse_language: cn
#!/bin/bash
git_update () {
cd $1
git add -f .
git reset --hard
git checkout $2
git reset --hard origin/$2
git pull
cd ..
}
git_update ygopro-database build
git_update ygopro-images-raw master
for filename in locales/*.yml; do
locale=$(basename "$filename" .yml)
git_update ygopro-images ${locale}
ruby generator.rb ${locale}
cd ygopro-images
git commit -am 'Update card images'
#git push
cd ..
done
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