Class: MineField::Actions
- Inherits:
-
Object
- Object
- MineField::Actions
- Defined in:
- lib/mine_field/actions.rb
Instance Method Summary collapse
- #entry ⇒ Object
- #finish ⇒ Object
-
#initialize ⇒ Actions
constructor
A new instance of Actions.
- #start ⇒ Object
Constructor Details
Instance Method Details
#entry ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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 ⇒ Object
52 53 54 55 |
# File 'lib/mine_field/actions.rb', line 52 def finish # Ekrana puanı yazdır # Restart seçeneği olsun end |
#start ⇒ Object
8 9 10 |
# File 'lib/mine_field/actions.rb', line 8 def start @map.draw end |