require 'date'
require 'ruby2d'

# ハッピーニューイヤーのASCIIアート
scHAPPY_NEW_YEAR_ART = <<~ASCII
  **************************************
  *    HAPPY NEW YEAR 2025!!!         *
  *    Wishing you a great start!    *
  **************************************
ASCII

def display_fireworks_image(image_path)
  set title: "Happy New Year!", width: 800, height: 600
  Image.new(image_path, x: 0, y: 0)
  show
end

def display_ascii_art
  puts HAPPY_NEW_YEAR_ART
end

# 新年を待機する関数
def wait_for_new_year(image_path)
  now = DateTime.now
  new_year = DateTime.new(now.year + 1, 1, 1, 0, 0, 0)

  puts "Waiting for the new year... 🎉\n"
  sleep((new_year - now) * 24 * 60 * 60) # 秒に変換して待機

  system("clear") || system("cls")
  display_fireworks_image(image_path)
  display_ascii_art
end

# メイン処理
if __FILE__ == $0
  image_path = "/mnt/data/27678315_s.jpg" # アップロードされた画像のパスを指定
  wait_for_new_year(image_path)
end
