Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions minesweeper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# REV: You probably don't want to include the .txt files for your high scores & saves into your git repo

require 'debugger'
require 'yaml'
# REV: Nice with the color!
require 'colorize'

class Minesweeper
Expand All @@ -16,6 +19,7 @@ def user_settings
puts "Do you want to load a saved game? Yes/No"
@saved = gets.chomp.downcase

# REV: I think you could bring the if saved statement from below up here, would be helpful for clarity.
if @saved != "yes"
puts "Board size?"
@size = gets.chomp.to_i
Expand All @@ -32,6 +36,8 @@ def run
@gameboard = Board.new(@size, @mines)
end

# REV: How does the game time interact with saves? You may need to keep multiple time intervals
# to get accurate time recordings
@gameboard.print_high_scores

start_time = Time.now
Expand Down Expand Up @@ -209,6 +215,7 @@ def check_bomb(pos)
[pos[0]-1,pos[1]], [pos[0]-1,pos[1]-1],
[pos[0]-1,pos[1]+1], [pos[0]+1,pos[1]-1]
]
# REV: An alternative to the position array that you could try is [-1, 0, 1].product([-1, 0, 1]).select
@check_pos.select! do |position|
position[0] < @size && position[1] < @size && position[0] >= 0 && position[1] >= 0
end
Expand All @@ -228,7 +235,7 @@ def high_scores(name, duration)
line.puts @high_scores.to_yaml
end
end

# REV: Nice job with the high scores table, my partner and I had to write a lot more code to get the same effect
def print_high_scores
high_scores = YAML::load(File.read("high-scores-minesweeper.txt"))
puts "**HIGH SCORES**"
Expand All @@ -241,4 +248,4 @@ def print_high_scores


y = Minesweeper.new
y.run
y.run