フロントエンドプレイアブル
This commit is contained in:
51
app/helpers/games_helper.rb
Normal file
51
app/helpers/games_helper.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
module GamesHelper
|
||||
def power_color_class(power)
|
||||
case power
|
||||
when "AUSTRIA"
|
||||
"bg-red-100 text-red-800"
|
||||
when "ENGLAND"
|
||||
"bg-purple-100 text-purple-800"
|
||||
when "FRANCE"
|
||||
"bg-sky-100 text-sky-800"
|
||||
when "GERMANY"
|
||||
"bg-amber-100 text-amber-900"
|
||||
when "ITALY"
|
||||
"bg-green-100 text-green-800"
|
||||
when "RUSSIA"
|
||||
"bg-gray-100 text-gray-800"
|
||||
when "TURKEY"
|
||||
"bg-yellow-100 text-yellow-800"
|
||||
else
|
||||
"bg-gray-100 text-gray-800"
|
||||
end
|
||||
end
|
||||
|
||||
def parse_phase(phase_string)
|
||||
# 例: "S1901M" -> "1901年 春 (移動)"
|
||||
# 例: "F1901R" -> "1901年 秋 (撤退)"
|
||||
# 例: "W1901A" -> "1901年 冬 (調整)"
|
||||
|
||||
return phase_string if phase_string.blank?
|
||||
return phase_string unless phase_string.match?(/^[SFW]\d{4}[MRA]$/)
|
||||
|
||||
season_code = phase_string[0]
|
||||
year = phase_string[1..4]
|
||||
type_code = phase_string[5]
|
||||
|
||||
season = case season_code
|
||||
when "S" then "春"
|
||||
when "F" then "秋"
|
||||
when "W" then "冬"
|
||||
else season_code
|
||||
end
|
||||
|
||||
type = case type_code
|
||||
when "M" then "移動"
|
||||
when "R" then "撤退"
|
||||
when "A" then "調整"
|
||||
else type_code
|
||||
end
|
||||
|
||||
"#{year}年 #{season} (#{type})"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user