Files
kondiplo_front/app/helpers/games_helper.rb
kontei f25fd6f802
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled
フロントエンドプレイアブル
2026-02-15 14:57:17 +09:00

52 lines
1.2 KiB
Ruby

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