Class: Minesweeprb::Commands::Play
- Inherits:
-
Minesweeprb::Command
- Object
- Minesweeprb::Command
- Minesweeprb::Commands::Play
- Defined in:
- lib/minesweeprb/commands/play.rb
Constant Summary collapse
- SIZES =
[ # [ label, width, height, # of mines ] ['Tiny', 5, 5, 3], ['Small', 9, 9, 10], ['Medium', 13, 13, 15], ['Large', 17, 17, 20], ['Huge', 21, 21, 25], ].map { || GameTemplate.new(*) }.freeze
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Play
constructor
A new instance of Play.
Methods inherited from Minesweeprb::Command
#add_color, #command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(options) ⇒ Play
Returns a new instance of Play.
20 21 22 |
# File 'lib/minesweeprb/commands/play.rb', line 20 def initialize() @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/minesweeprb/commands/play.rb', line 24 def execute(input: $stdin, output: $stdout) template = prompt_size(output) template = prompt_custom(output) if template == :custom game = Game.new(**template.to_h) gameboard = Gameboard.new(game) begin gameboard.draw ensure gameboard.clear end end |