bloodymines 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/bloodymines CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # An example of how to use the bloodymines game egnine within a curses program.
2
+ # An example of how to use the bloodymines game-engine within a curses program.
3
3
 
4
4
  require "optparse"
5
5
  require File.dirname(__FILE__) + "/../lib/bloodymines"
@@ -31,7 +31,7 @@ game = Bloodymines.new(:difficulty => options[:difficulty])
31
31
 
32
32
  Curses.program do |scr|
33
33
  while true
34
- game.turn
34
+ break if game.turn
35
35
  if game.ended?
36
36
  game.draw_field
37
37
  setpos(0, 1)
@@ -45,7 +45,7 @@ Curses.program do |scr|
45
45
  if game.result[:finished]
46
46
  puts "You completed the game on #{game.difficulty.to_s.upcase}!"
47
47
  else
48
- puts "You did not manage to finish the game."
48
+ puts "You did not manage to finish this game on #{game.difficulty.to_s.upcase}."
49
49
  end
50
50
  puts "Your final score was: #{game.result[:score]}"
51
51
  end
data/lib/bloodymines.rb CHANGED
@@ -29,7 +29,7 @@ class Bloodymines
29
29
  {:score => score, :finished => finished}
30
30
  end
31
31
 
32
- # returns true if you triggered a mine or uncovered all save fields
32
+ # returns true if you triggered a mine or uncovered all safe fields
33
33
  def ended?
34
34
  uncovered = 0
35
35
  @minefield.fields.each do |rows|
@@ -68,6 +68,7 @@ module TUI
68
68
  end
69
69
 
70
70
  def turn
71
+ exit_flag = false
71
72
  draw_field
72
73
  case getch
73
74
  when Key::UP : move(:direction => :up)
@@ -75,8 +76,9 @@ module TUI
75
76
  when Key::LEFT : move(:direction => :left)
76
77
  when Key::RIGHT : move(:direction => :right)
77
78
  when 32 : uncover(@cursor_x, @cursor_y)
78
- when 27, ?q, ?Q : break
79
+ when 27, ?q, ?Q : exit_flag = true
79
80
  end
81
+ return exit_flag
80
82
 
81
83
  end
82
84
  end
data/lib/minefield.rb CHANGED
@@ -7,7 +7,7 @@ class MineField
7
7
 
8
8
  def initialize(params={})
9
9
  params = { :difficulty => :beginner }.merge params
10
- @difficulty = params[:difficulty]
10
+ @difficulty = params[:difficulty] || :beginner
11
11
  case @difficulty
12
12
  when :intermediate: @fields = create_fields(INTERMEDIATE_WIDTH, INTERMEDIATE_HEIGHT, INTERMEDIATE_MINES)
13
13
  when :expert: @fields = create_fields( EXPERT_WIDTH, EXPERT_HEIGHT, EXPERT_MINES)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloodymines
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 9
10
- version: 0.1.9
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - !binary |
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-08-20 00:00:00 +02:00
20
+ date: 2010-08-22 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies: []
23
23