sea_battle 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -26
- data/lib/sea_battle/gui.rb +3 -3
- data/lib/sea_battle/version.rb +1 -1
- data/sea_battle.gemspec +0 -1
- data/spec/sea_battle/gui_spec.rb +1 -1
- metadata +1 -17
data/README.md
CHANGED
@@ -34,64 +34,65 @@ Or install it yourself as:
|
|
34
34
|
|
35
35
|
### Use class SeaBattle
|
36
36
|
|
37
|
-
|
37
|
+
$ require "sea_battle"
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
$ first_board = SeaBattle::Board.new
|
40
|
+
$ second_board = SeaBattle::Board.new
|
41
|
+
$ sea_battle = SeaBattle.new(first_board, second_board)
|
42
42
|
|
43
43
|
#### Game is activated?
|
44
|
-
|
44
|
+
$ sea_battle.is_activated?
|
45
45
|
|
46
46
|
#### You can get which player is active
|
47
|
-
|
47
|
+
$ sea_battle.active_user #=> :first_player
|
48
48
|
|
49
49
|
#### Ship on position row, column is sunken?
|
50
|
-
|
50
|
+
$ sea_battle.is_sunken_ship?(3, 7) #=> false
|
51
51
|
|
52
52
|
#### You can attack position (row, column)
|
53
|
-
|
53
|
+
$ sea_battle.move(:second_player, :attack, 2, 9)
|
54
54
|
|
55
55
|
#### When game is over you can see winner
|
56
|
-
|
56
|
+
$ sea_battle.winner_is #=> :first_player
|
57
57
|
|
58
58
|
### Play on console (min 92x40)
|
59
59
|
|
60
60
|
$ sea_battle
|
61
61
|
|
62
|
-
#=>
|
62
|
+
#=> SEA BATTLE
|
63
63
|
|
64
64
|
#=> A B C D E F G H I J A B C D E F G H I J
|
65
65
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
66
|
-
#=> 0 │ □ │
|
66
|
+
#=> 0 │ │ • │ □ │ • │ │ │ │ │ • │ │ 0 │ • │ • │ • │ │ • │ ※ │ ※ │ ※ │ ※ │ • │
|
67
67
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
68
|
-
#=> 1 │
|
68
|
+
#=> 1 │ • │ │ │ │ │ │ │ │ │ • │ 1 │ │ │ │ ■ │ │ │ • │ • │ • │ │
|
69
69
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
70
|
-
#=> 2 │ □ │ │
|
70
|
+
#=> 2 │ □ │ │ • │ • │ │ □ │ │ │ • │ │ 2 │ • │ • │ • │ ■ │ │ │ │ │ │ │
|
71
71
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
72
|
-
#=> 3 │
|
72
|
+
#=> 3 │ ■ │ • │ │ • │ │ □ │ │ • │ □ │ • │ 3 │ • │ • │ • │ • │ • │ ※ │ • │ • │ • │ • │
|
73
73
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
74
|
-
#=> 4 │ │ │ • │ │ │ │
|
74
|
+
#=> 4 │ │ • │ │ • │ │ │ │ • │ • │ • │ 4 │ • │ │ • │ │ │ │ • │ ■ │ │ │
|
75
75
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
76
|
-
#=> 5 │
|
76
|
+
#=> 5 │ □ │ • │ □ │ │ □ │ □ │ ■ │ □ │ │ • │ 5 │ │ │ │ ※ │ ※ │ │ │ ■ │ • │ │
|
77
77
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
78
|
-
#=> 6 │
|
78
|
+
#=> 6 │ □ │ • │ □ │ │ │ • │ • │ │ │ │ 6 │ │ │ • │ • │ • │ • │ │ │ • │ • │
|
79
79
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
80
|
-
#=> 7 │ │ │
|
80
|
+
#=> 7 │ │ │ ■ │ • │ • │ │ • │ │ │ │ 7 │ • │ • │ │ │ │ • │ │ │ • │ • │
|
81
81
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
82
|
-
#=> 8 │
|
82
|
+
#=> 8 │ • │ │ │ • │ │ │ │ │ • │ □ │ 8 │ │ │ • │ │ │ │ ■ │ │ • │ • │
|
83
83
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
84
|
-
#=> 9 │
|
84
|
+
#=> 9 │ │ • │ ※ │ │ □ │ □ │ □ │ │ • │ • │ 9 │ • │ │ • │ │ • │ • │ │ │ │ │
|
85
85
|
#=> ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼ ┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼
|
86
|
-
|
87
|
-
#=>
|
88
|
-
#=>
|
89
|
-
#=>
|
90
|
-
#=>
|
86
|
+
#=>
|
87
|
+
#=> 11:12:50 Computer: Moved on position 0d
|
88
|
+
#=> 11:12:50 You: Moved on position 3a
|
89
|
+
#=> 11:12:52 Computer: Moved on position 4i
|
90
|
+
#=> 11:12:52 You: Moved on position 4h
|
91
91
|
#=> ____________________________________________________________
|
92
|
-
#=>
|
92
|
+
#=> ※ - sunk ship; ■ - hit ship; □ - selected ship; • - mishit
|
93
93
|
|
94
94
|
#=> (r)andom position into attack
|
95
95
|
#=> 4a, 8i, ... - select part of ship
|
96
96
|
#=> (e)xit of game
|
97
97
|
#=> #=>
|
98
|
+
|
data/lib/sea_battle/gui.rb
CHANGED
@@ -66,20 +66,20 @@ class SeaBattle
|
|
66
66
|
unless cell.is_sunk?
|
67
67
|
" ■ "
|
68
68
|
else
|
69
|
-
"
|
69
|
+
" ※ "
|
70
70
|
end
|
71
71
|
elsif cell.is_attacked? and not cell.is_in_ship?
|
72
72
|
" • "
|
73
73
|
elsif not cell.is_attacked? and cell.is_in_ship? and player == :first_player
|
74
74
|
" □ "
|
75
75
|
else
|
76
|
-
"
|
76
|
+
" "
|
77
77
|
end
|
78
78
|
end.join("│")
|
79
79
|
end
|
80
80
|
|
81
81
|
def info_command
|
82
|
-
puts "
|
82
|
+
puts "※ - sunk ship; ■ - hit ship; □ - selected ship; • - mishit"
|
83
83
|
puts ""
|
84
84
|
unless @sea_battle.is_activated?
|
85
85
|
puts "(r)andom your ships on board"
|
data/lib/sea_battle/version.rb
CHANGED
data/sea_battle.gemspec
CHANGED
data/spec/sea_battle/gui_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sea_battle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,22 +43,6 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 2.0.0
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec_progress
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
46
|
- !ruby/object:Gem::Dependency
|
63
47
|
name: rake
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|