Commit fe697aec authored by 神楽坂玲奈's avatar 神楽坂玲奈

临时提交

parent 27403848
...@@ -53,8 +53,8 @@ class DuelsController < ApplicationController ...@@ -53,8 +53,8 @@ class DuelsController < ApplicationController
@duel.winreason = params[:duel][:winreason] @duel.winreason = params[:duel][:winreason]
@duel.replay = params[:duel][:replay] @duel.replay = params[:duel][:replay]
@duel.version = params[:duel][:version] @duel.version = params[:duel][:version]
@duel.user1 = User.find_by_name params[:duel][:user1_name] if params[:duel][:user1_name] @duel.user1 = User.find_or_create_by_name params[:duel][:user1_name] if params[:duel][:user1_name]
@duel.user2 = User.find_by_name params[:duel][:user2_name] if params[:duel][:user2_name] @duel.user2 = User.find_or_create_by_name params[:duel][:user2_name] if params[:duel][:user2_name]
[params[:duel][:user1_main], params[:duel][:user1_extra], params[:duel][:user2_main], params[:duel][:user2_extra]].each_with_index do |cards, index| [params[:duel][:user1_main], params[:duel][:user1_extra], params[:duel][:user2_main], params[:duel][:user2_extra]].each_with_index do |cards, index|
user = index / 2 == 0 ? @duel.user1 : @duel.user2 user = index / 2 == 0 ? @duel.user1 : @duel.user2
main = index % 2 == 0 main = index % 2 == 0
......
...@@ -2,12 +2,21 @@ class MycardController < ApplicationController ...@@ -2,12 +2,21 @@ class MycardController < ApplicationController
def update def update
result = [] result = []
version = params[:version] version = params[:version]
Dir.glob('public/mycard/mycard-update-*-*.zip') do |file| loop do
if file =~ /mycard-update-(.+?)-(.+?).zip/ new_version = false
if $1 <= version and $2 > version Dir.glob('public/mycard/mycard-update-*-*.zip') do |file|
result << "http://card.touhou.cc/mycard/#{$&}" if file =~ /mycard-update-(.+?)-(.+?).zip/
if $1 <= version and $2 > version
version = $2
result << "http://card.touhou.cc/mycard/#{$&}"
new_version = true
break
end
end end
end end
if !new_version
break
end
end end
respond_to do |format| respond_to do |format|
format.json { render json: result } format.json { render json: result }
......
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