[gosuhunt] rubocop'd

This commit is contained in:
Gwenhael Le Moine 2023-03-14 14:23:15 +01:00
parent 801490298c
commit a96a4097ba
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -9,7 +9,7 @@ class GosuHunt < Gosu::Window
def initialize( number_of_mines = 20 )
super 325, 180
self.caption = "Gosu Hunt"
self.caption = 'Gosu Hunt'
@number_of_mines = number_of_mines
@field = MineHunt::Board.new( @number_of_mines )
@ -74,15 +74,15 @@ class GosuHunt < Gosu::Window
def update; end
def draw
if @state[:dead]
self.caption = "You died! :(, score #{@field.score} "
elsif @state[:victory]
self.caption = "You won!! :), score #{@field.score} "
else
self.caption = "#{@field.number_of_mines} mines, #{@field.count_nearby_mines} nearby, score #{@field.score}"
end
self.caption = if @state[:dead]
"You died! :(, score #{@field.score} "
elsif @state[:victory]
"You won!! :), score #{@field.score} "
else
"#{@field.number_of_mines} mines, #{@field.count_nearby_mines} nearby, score #{@field.score}"
end
@font.draw_text( self.caption, 0, 0, 0 )
@font.draw_text( caption, 0, 0, 0 )
@field.height.times do |y|
@field.width.times do |x|
@ -96,8 +96,7 @@ class GosuHunt < Gosu::Window
@images[:mine]
else
@images[:cell]
end )
.draw( x * 2 * 10, (y * 20) + 20, 0 )
end ).draw( x * 10, (y * 20) + 20, 0 )
end
end
end