class MineField::Actions
Public Class Methods
new()
click to toggle source
# File lib/mine_field/actions.rb, line 3 def initialize @score = Score.new @map = Map.new end
Public Instance Methods
entry()
click to toggle source
# File lib/mine_field/actions.rb, line 12 def entry print "Koordinatlar(x#{PIPE_SYMBOL}y): " coordinates = gets.chomp x, y = coordinates.split(PIPE_SYMBOL).map(&:to_i) if x.nil? || y.nil? puts 'Geçersiz bir koordinat girdiniz' return end point = @map.get_point(x, y) if point.nil? puts 'Geçersiz bir koordinat girdiniz' return end if point.opened puts 'Bu koordinat zaten açıldı!' return end point.opened = true if point.content == MINE_CHARACTER @map.visible! @map.draw puts 'Mayınlı Bölgeye Bastınız!' puts "Puanınız: #{@score.total}" exit else @score.increment @map.draw end # Alanda kalan noktalar sadece mayın mı diye kontrol et # Eğer kalanların hepsi mayın ise oyunu başarıyla bitir # Değil ise haritayı ekrana çiz end
finish()
click to toggle source
# File lib/mine_field/actions.rb, line 52 def finish # Ekrana puanı yazdır # Restart seçeneği olsun end
start()
click to toggle source
# File lib/mine_field/actions.rb, line 8 def start @map.draw end