Newer
Older
Ruby / game.rb
@TAKABAYASHI Tomoo TAKABAYASHI Tomoo on 21 Feb 2025 726 bytes 2025-02-21 22:02:07
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-

puts <<EOF
-------------------------------------------------
|  □ー□ー□ー□ー□ー□ー□ー□ー□ー□ーGOAL |
-------------------------------------------------
EOF
puts"これは双六の板です。"
sqare = 10
players = %w[あなた,コンピュータ]

while sqare > 0
  players.each do |player|
    if player == "あなた"
      puts"ゴールまであと#{sqare}マス"
      sleep(1)
      saiko = rand(1..6)
      puts"サイコロの目は#{saiko}が出ました"
    else
      saiko = rand(1..6)
      puts"サイコロの目は#{saiko}が出ました"
    end
    sqare -= saiko
    if sqare <= 0
      puts"#{players}の勝ち!"
    end
  end
end