addstr is more generic

This commit is contained in:
Gwenhael Le Moine 2022-09-14 16:25:51 +02:00
parent 11cda31ce7
commit d9f070c92e
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -26,13 +26,13 @@ def display_curses( field, state = { dead: false, victory: false } )
Curses.setpos y + 2, 0
field.width.times do |x|
if [field.explorer_x, field.explorer_y] == [x, y]
Curses.addch 'o'
Curses.addstr 'O'
elsif [field.width, field.height] == [x + 1, y + 1]
Curses.addch '_'
elsif field.field[[x, y]].open
Curses.addch field.field[[x, y]].mine ? '*' : ' '
Curses.addstr '^'
elsif field.field[[x, y]].open || state[:dead] || state[:victory]
Curses.addstr field.field[[x, y]].mine ? '*' : ' '
else
Curses.addch 'H'
Curses.addstr '-'
end
end
end