masma_game 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bc55d22966ca7a18e10a42669111b164af5aff22
4
+ data.tar.gz: cdb1f2b9e03025e63d55f14d7f48fa85139be034
5
+ SHA512:
6
+ metadata.gz: 99564622b6b25eac14af7774c3acc0c108d30cb1d545e28d9458af07401842c0484bd5eabcbe8c3f84017b74c9a3f46c58fa1918d0de1dc6b0a0246a222f4c58
7
+ data.tar.gz: 1bbdbf361525afb20fc793dc15bdec5594ffa2d41e8dc71c103e132fd007ab31a948d79c118fe8c89631b2265cb6fb9c34fd2948e98b58a187f2d1d4768309d5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2013 Said Maadan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ - You may not use this Software in other training contexts.
11
+
12
+ - The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ This is Ruby application Game
2
+
3
+ This code is Copyright 2014. See the LICENSE file.
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/masma_game/game'
4
+ require_relative '../lib/masma_game/next_game'
5
+ require_relative '../lib/masma_game/blue_player'
6
+ require_relative '../lib/masma_game/red_player'
7
+
8
+ # player1 = Player.new("fola", 80)
9
+ # player2 = Player.new("morounkeji", 50)
10
+ # player3 = Player.new("bolaji", 70)
11
+
12
+ game = MasmaGame::Game.new("chess")
13
+ default_player_file =
14
+ File.join(File.dirname(__FILE__), 'players.csv')
15
+ game.load_players(ARGV.shift || default_player_file)
16
+
17
+ # game.add_player(player1)
18
+ # game.add_player(player2)
19
+ #game.add_player(player3)
20
+ # game.play(3)
21
+ # game.print_stats
22
+
23
+ blue = MasmaGame::BluePlayer.new("michel", 105)
24
+ game.add_player(blue)
25
+
26
+ red = MasmaGame::RedPlayer.new("red", 50)
27
+ game.add_player(red)
28
+
29
+ loop do
30
+ puts "\nHow many game rounds? (Type 'quit' to exit)"
31
+ answer = gets.chomp.downcase
32
+ case answer
33
+ when /^\d+$/
34
+ game.play(answer.to_i)
35
+ when 'quit', 'exit'
36
+ game.print_stats
37
+ break
38
+ else
39
+ puts "Please enter a number or type 'quit' to exit"
40
+ end
41
+ end
42
+
43
+ game.save_high_scores
44
+
45
+
@@ -0,0 +1,3 @@
1
+ Fola, 80
2
+ Morounkeji, 50
3
+ Bolaji, 70
@@ -0,0 +1,7 @@
1
+ module MasmaGame
2
+ module Auditable
3
+ def audit
4
+ puts "Rolled a #{self.number} (#{self.class})"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'player'
2
+ #require_relative 'treasure_trove'
3
+
4
+ module MasmaGame
5
+ class BluePlayer < Player
6
+ def found_hoard(hoard)
7
+ damaged_hoard = Hoard.new(hoard.name, hoard.points / 2.0)
8
+ super(damaged_hoard)
9
+ end
10
+
11
+ # def found_hoard(hoard)
12
+ # points = hoard.points / 2
13
+ # @found_hoards[hoard.name] += points
14
+ # puts "#{@name} found a #{hoard.name} worth #{points} points."
15
+ # end
16
+ end
17
+ end
18
+
19
+ if __FILE__ == $0
20
+ blue = MasmaGame::BluePlayer.new("michel")
21
+ hammer = MasmaGame::Hoard.new(:hammer, 50)
22
+ blue.found_hoard(hammer)
23
+ blue.found_hoard(hammer)
24
+ blue.found_hoard(hammer)
25
+ crowbar = MasmaGame::Hoard.new(:crowbar, 400)
26
+ blue.found_hoard(crowbar)
27
+ blue.each_found_hoard do |hoard|
28
+ puts "#{hoard.points} total #{hoard.name} points"
29
+ end
30
+ puts "#{blue.points} grand total points"
31
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'auditable'
2
+
3
+ module MasmaGame
4
+ class Die
5
+ include Auditable
6
+ attr_reader :number
7
+
8
+ def initialize
9
+ roll
10
+ end
11
+
12
+ def roll
13
+ @number = rand(1..6)
14
+ end
15
+ end
16
+ end
17
+ if __FILE__ == $0
18
+ die = MasmaGame::Die.new
19
+ puts die.roll
20
+ puts die.roll
21
+ puts die.roll
22
+ end
@@ -0,0 +1,101 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'next_game'
4
+ require_relative 'hoard_store'
5
+
6
+ module MasmaGame
7
+ class Game
8
+ attr_accessor :name
9
+
10
+ def initialize(name)
11
+ @name = name.capitalize
12
+ @player = []
13
+ end
14
+
15
+ def add_player(player)
16
+ @player << player
17
+ end
18
+
19
+ def total_points
20
+ @player.reduce(0) { |sum, player| sum + player.points}
21
+ end
22
+
23
+ def high_score_entry(p)
24
+ formatted_name = p.name.ljust(20, '.')
25
+ "#{formatted_name} #{p.score}"
26
+ end
27
+
28
+ def play(rounds)
29
+ puts "There are #{@player.size} players in #{@name} game"
30
+
31
+ @player.each do |player|
32
+ puts player
33
+ end
34
+
35
+ hoards = HoardStore::HOARDS
36
+ puts "\nThere are #{hoards.size} hoards to be found"
37
+
38
+ hoards.each do |hoard|
39
+ puts "A #{hoard.name} is worth #{hoard.points} points"
40
+ end
41
+
42
+ puts "---------------------------------"
43
+ 1.upto(rounds) do |n|
44
+ puts "\nRound #{n}"
45
+ @player.each do |p|
46
+ NextGame.next_player(p)
47
+ hoard = HoardStore.random
48
+ puts "#{p.name} found a #{hoard.name} worth #{hoard.points} points"
49
+ puts p
50
+ end
51
+ end
52
+ end
53
+
54
+ def print_stats
55
+ puts "\n#{@name} Statistics:"
56
+
57
+ puts "#{total_points} total points from hoards found"
58
+ @player.each do |p|
59
+ puts "\n#{p.name}'s point totals"
60
+ p.each_found_hoard do |hoard|
61
+ puts "#{hoard.points} total #{hoard.name} points"
62
+ end
63
+ puts "#{p.points} grand total points"
64
+ end
65
+
66
+
67
+ strong, wimpy = @player.partition {|p| p.strong?}
68
+
69
+ puts "\n#{strong.size} Strong Players:"
70
+ strong.each do |p|
71
+ puts "#{p.name} (#{p.health})"
72
+ end
73
+
74
+ puts "\n#{wimpy.size} Wimpy Players:"
75
+ wimpy.each do |p|
76
+ puts "#{p.name} (#{p.health})"
77
+ end
78
+
79
+ puts "\n#{@name} High Scores:"
80
+ @player.sort.each do |p|
81
+ puts "#{p.name.ljust(25, '-')} #{p.score}"
82
+ end
83
+ end
84
+
85
+ def load_players(from_file)
86
+ File.readlines(from_file).each do |line|
87
+ add_player(Player.from_csv(line))
88
+ end
89
+ end
90
+
91
+ def save_high_scores(to_file="high_scores.txt")
92
+ File.open(to_file, "w") do |file|
93
+ file.puts "#{@name} High Scores:"
94
+ @player.sort.each do |p|
95
+ file.puts high_score_entry(p)
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
@@ -0,0 +1,25 @@
1
+ module MasmaGame
2
+ Hoard = Struct.new(:name, :points)
3
+
4
+ module HoardStore
5
+ HOARDS = [
6
+ Hoard.new(:pie, 5),
7
+ Hoard.new(:bottle, 25),
8
+ Hoard.new(:hammer, 50),
9
+ Hoard.new(:skillet, 100),
10
+ Hoard.new(:broomstick, 200),
11
+ Hoard.new(:crowbar, 400)
12
+ ]
13
+
14
+ def self.random
15
+ HOARDS.sample
16
+ end
17
+ end
18
+ end
19
+
20
+ if __FILE__ ==$0
21
+ puts HoardStore::HOARDS
22
+ hoard = MasmaGame::HoardStore.random
23
+ puts "Enjoy your #{hoard.points} point of #{hoard.name}"
24
+
25
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'auditable'
2
+
3
+ module MasmaGame
4
+ class LoadedDie
5
+ include Auditable
6
+
7
+ attr_reader :number
8
+
9
+ def roll
10
+ numbers = [1, 1, 2, 5, 6, 6]
11
+ @number = numbers.sample
12
+ audit
13
+ @number
14
+ end
15
+ end
16
+ end
17
+
18
+ if __FILE__ == $0
19
+ die = MasmaGame::LoadedDie.new
20
+ puts die.roll
21
+ puts die.roll
22
+ puts die.roll
23
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'die'
2
+ require_relative 'player'
3
+ require_relative 'hoard_store'
4
+ require_relative 'loaded_die'
5
+
6
+ module MasmaGame
7
+ module NextGame
8
+
9
+ def self.next_player(p)
10
+ die = Die.new
11
+ case die.roll
12
+ when 1..2
13
+ p.blam
14
+ when 3..4
15
+ puts "#{p.name} was skipped."
16
+ else
17
+ p.w00t
18
+ end
19
+
20
+ hoard = HoardStore.random
21
+ p.found_hoard(hoard)
22
+
23
+ end
24
+ end
25
+ end
26
+
27
+ if __FILE__ == $0
28
+ p = MasmaGame::Player.new("bimbo", 125)
29
+ MasmaGame::NextGame.next_player(p)
30
+ end
31
+
32
+
@@ -0,0 +1,32 @@
1
+ # module Playable
2
+ # def w00t
3
+ # @health += 15
4
+ # puts "#{@name} got w00ted!"
5
+ # end
6
+ #
7
+ # def blam
8
+ # @health -= 10
9
+ # puts "#{@name} got blammed!"
10
+ # end
11
+ #
12
+ # def strong?
13
+ # @health > 100
14
+ # end
15
+ # end
16
+ module MasmaGame
17
+ module Playable
18
+ def w00t
19
+ self.health += 15
20
+ puts "#{name} got w00ted!"
21
+ end
22
+
23
+ def blam
24
+ self.health -= 10
25
+ puts "#{name} got blammed!"
26
+ end
27
+
28
+ def strong?
29
+ self.health >= 100
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,80 @@
1
+ require_relative 'hoard_store'
2
+ require_relative 'playable'
3
+
4
+ module MasmaGame
5
+ class Player
6
+ include Playable
7
+ attr_accessor :name, :health
8
+
9
+ def initialize(name, health=0)
10
+ @name = name.capitalize
11
+ @health = health
12
+ @found_hoards = Hash.new(0)
13
+ end
14
+
15
+ def found_hoard(hoard)
16
+ @found_hoards[hoard.name] += hoard.points
17
+ puts "#{@name} found a #{hoard.name} worth #{hoard.points} points."
18
+ puts "#{@name}'s hoards: #{@found_hoards}"
19
+ end
20
+
21
+ def points
22
+ @found_hoards.values.reduce(0, :+)
23
+ end
24
+
25
+ def each_found_hoard
26
+ @found_hoards.each do |name, points|
27
+ next_hoard = Hoard.new(name, points)
28
+ yield next_hoard
29
+ end
30
+ end
31
+
32
+ def score
33
+ @health + points
34
+ end
35
+
36
+ def <=>(other)
37
+ other.score <=> score
38
+ end
39
+
40
+ def to_s
41
+
42
+ "I'm #{@name} with health = #{@health}, points = #{points} and score = #{score}"
43
+ end
44
+
45
+ def self.from_csv(string)
46
+ name, health = string.split(',')
47
+ new(name, Integer(health))
48
+ end
49
+ end
50
+ end
51
+
52
+ if __FILE__ == $0
53
+
54
+ player1 = MasmaGame::Player.new("fola", 80)
55
+ player2 = MasmaGame::Player.new("morounkeji", 50)
56
+ player3 = MasmaGame::Player.new("bolaji", 70)
57
+
58
+ players = [player1, player2, player3]
59
+
60
+ puts "There are #{players.size} in this game"
61
+ players.each do |p|
62
+ puts p
63
+ puts "**********************"
64
+ end
65
+ players.each do |p|
66
+ p.w00t
67
+ p.blam
68
+ puts p
69
+ end
70
+ puts "**********************"
71
+
72
+ players.each do |p|
73
+ puts p.name
74
+ puts p.health
75
+
76
+ end
77
+
78
+ end
79
+
80
+
@@ -0,0 +1,38 @@
1
+ require_relative 'player'
2
+
3
+ module MasmaGame
4
+ class RedPlayer < Player
5
+ def initialize(name, health=100)
6
+ super(name, health)
7
+ @w00t_count = 0
8
+ end
9
+
10
+ def red?
11
+ @w00t_count > 5
12
+ end
13
+
14
+ def w00t
15
+ super
16
+ @w00t_count +=1
17
+ puts "#{@name} is Red Army!" if red?
18
+ end
19
+
20
+ def blam
21
+ if red?
22
+ w00t
23
+ else
24
+ super
25
+ end
26
+
27
+ # or use the ternary operator:
28
+ # red? ? w00t : super
29
+ end
30
+ end
31
+ end
32
+
33
+ if __FILE__ == $0
34
+ red = MasmaGame::RedPlayer.new("red", 50)
35
+ 6.times { red.w00t }
36
+ 2.times { red.blam }
37
+ puts red.health
38
+ end
@@ -0,0 +1,33 @@
1
+ require 'masma_game/blue_player'
2
+
3
+ module MasmaGame
4
+ describe BluePlayer do
5
+
6
+ before do
7
+ @player = BluePlayer.new("michel")
8
+ end
9
+
10
+ it "only gets half the point value for each hoard" do
11
+ @player.points.should == 0
12
+
13
+ hammer = Hoard.new(:hammer, 50)
14
+ @player.found_hoard(hammer)
15
+ @player.found_hoard(hammer)
16
+ @player.found_hoard(hammer)
17
+
18
+ @player.points.should == 75
19
+
20
+ crowbar = Hoard.new(:crowbar, 400)
21
+ @player.found_hoard(crowbar)
22
+
23
+ @player.points.should == 275
24
+
25
+ yielded = []
26
+ @player.each_found_hoard do |hoard|
27
+ yielded << hoard
28
+ end
29
+
30
+ yielded.should == [Hoard.new(:hammer, 75), Hoard.new(:crowbar, 200)]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,70 @@
1
+ require 'masma_game/game'
2
+
3
+ module MasmaGame
4
+ describe Game do
5
+
6
+ before do
7
+ @game = Game.new("chess")
8
+
9
+ @initial_health = 80
10
+ @player = Player.new("biola", @initial_health)
11
+
12
+ @game.add_player(@player)
13
+ end
14
+
15
+ it "has a name" do
16
+ @game.name.should == "Chess"
17
+ end
18
+
19
+ it "w00ts the player if a high number is rolled" do
20
+ Die.any_instance.stub(:roll).and_return(5)
21
+
22
+ @game.play(2)
23
+
24
+ @player.health.should == @initial_health + (15 * 2)
25
+ end
26
+
27
+ it "skips the player if a medium number is rolled" do
28
+ Die.any_instance.stub(:roll).and_return(3)
29
+
30
+ @game.play(2)
31
+
32
+ @player.health.should == @initial_health
33
+ end
34
+
35
+ it "blams the player if a low number is rolled" do
36
+ Die.any_instance.stub(:roll).and_return(1)
37
+
38
+ @game.play(2)
39
+
40
+ @player.health.should == @initial_health - (10 * 2)
41
+ end
42
+
43
+ it "assigns a treasure for points during a player's turn" do
44
+ game = Game.new("chess")
45
+ player = Player.new("biolae")
46
+
47
+ game.add_player(player)
48
+
49
+ game.play(1)
50
+
51
+ player.points.should_not be_zero
52
+ end
53
+
54
+ it "computes total points as the sum of all player points" do
55
+ game = Game.new("chess")
56
+
57
+ player1 = Player.new("biola")
58
+ player2 = Player.new("bimbo")
59
+
60
+ game.add_player(player1)
61
+ game.add_player(player2)
62
+
63
+ player1.found_hoard(Hoard.new(:hammer, 50))
64
+ player1.found_hoard(Hoard.new(:hammer, 50))
65
+ player2.found_hoard(Hoard.new(:crowbar, 400))
66
+
67
+ game.total_points.should == 500
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,58 @@
1
+ require 'masma_game/hoard_store'
2
+
3
+ module MasmaGame
4
+ describe Hoard do
5
+
6
+ before do
7
+ @hoard = Hoard.new(:hammer, 50)
8
+ end
9
+
10
+ it "has a name attribute" do
11
+ @hoard.name.should == :hammer
12
+ end
13
+
14
+ it "has a points attribute" do
15
+ @hoard.points.should == 50
16
+ end
17
+
18
+ end
19
+
20
+ describe HoardStore do
21
+
22
+ it "has six hoard" do
23
+ HoardStore::HOARDS.size.should == 6
24
+ end
25
+
26
+ it "has a pie worth 5 points" do
27
+ HoardStore::HOARDS[0].should == Hoard.new(:pie, 5)
28
+ end
29
+
30
+ it "has a bottle worth 25 points" do
31
+ HoardStore::HOARDS[1].should == Hoard.new(:bottle, 25)
32
+ end
33
+
34
+ it "has a hammer worth 50 points" do
35
+ HoardStore::HOARDS[2].should == Hoard.new(:hammer, 50)
36
+ end
37
+
38
+ it "has a skillet worth 100 points" do
39
+ HoardStore::HOARDS[3].should == Hoard.new(:skillet, 100)
40
+ end
41
+
42
+ it "has a broomstick worth 200 points" do
43
+ HoardStore::HOARDS[4].should == Hoard.new(:broomstick, 200)
44
+ end
45
+
46
+ it "has a crowbar worth 400 points" do
47
+ HoardStore::HOARDS[5].should == Hoard.new(:crowbar, 400)
48
+ end
49
+
50
+ it "returns a random hoard" do
51
+ hoard = HoardStore.random
52
+
53
+ HoardStore::HOARDS.should include(hoard)
54
+ end
55
+ end
56
+ end
57
+
58
+
@@ -0,0 +1,134 @@
1
+ require 'masma_game/player'
2
+ require 'masma_game/hoard_store'
3
+
4
+ module MasmaGame
5
+ describe Player do
6
+ before do
7
+ @initial_health = 50
8
+ @player = Player.new("bimbo", @initial_health)
9
+ end
10
+
11
+ it "has a capitalized name" do
12
+ @player.name.should == "Bimbo"
13
+ end
14
+
15
+ it "has an initial health" do
16
+ @player.health.should == 50
17
+ end
18
+
19
+ it "has a string representation" do
20
+ @player.found_hoard(Hoard.new(:hammer, 50))
21
+ @player.found_hoard(Hoard.new(:hammer, 50))
22
+
23
+ @player.to_s.should == "I'm Bimbo with health = 50, points = 100 and score = 150"
24
+ end
25
+
26
+ it "increase the health by 15 when w00ted" do
27
+ @player.w00t
28
+
29
+ @player.health.should == @initial_health + 15
30
+ end
31
+
32
+ it "decrease the health by 10 when w00ted" do
33
+ @player.blam
34
+
35
+ @player.health.should == @initial_health - 10
36
+ end
37
+
38
+ context "create default health value" do
39
+ before do
40
+ @player = Player.new("tunji")
41
+ end
42
+
43
+ it "has a health value of 0" do
44
+ @player.health.should == 0
45
+ end
46
+ end
47
+
48
+ context "create a player with an initial health of 100" do
49
+ before do
50
+ @player = Player.new("adeola", 100)
51
+ end
52
+
53
+ it "is strong" do
54
+ @player.should be_strong
55
+ end
56
+
57
+ it "is not strong" do
58
+ @player = Player.new("abiola", 90)
59
+
60
+ @player.should_not be_strong
61
+ end
62
+ end
63
+
64
+ it "computes a score as the sum of its health and points" do
65
+ @player.found_hoard(Hoard.new(:hammer, 50))
66
+ @player.found_hoard(Hoard.new(:hammer, 50))
67
+
68
+ @player.score.should == 150
69
+ end
70
+
71
+ it "computes points as the sum of all hoard points" do
72
+ @player.points.should == 0
73
+
74
+ @player.found_hoard(Hoard.new(:hammer, 50))
75
+
76
+ @player.points.should == 50
77
+
78
+ @player.found_hoard(Hoard.new(:crowbar, 400))
79
+
80
+ @player.points.should == 450
81
+
82
+ @player.found_hoard(Hoard.new(:hammer, 50))
83
+
84
+ @player.points.should == 500
85
+ end
86
+
87
+ it "yields each found hoard and its total points" do
88
+ @player.found_hoard(Hoard.new(:skillet, 100))
89
+ @player.found_hoard(Hoard.new(:skillet, 100))
90
+ @player.found_hoard(Hoard.new(:hammer, 50))
91
+ @player.found_hoard(Hoard.new(:bottle, 5))
92
+ @player.found_hoard(Hoard.new(:bottle, 5))
93
+ @player.found_hoard(Hoard.new(:bottle, 5))
94
+ @player.found_hoard(Hoard.new(:bottle, 5))
95
+ @player.found_hoard(Hoard.new(:bottle, 5))
96
+
97
+ yielded = []
98
+ @player.each_found_hoard do |hoard|
99
+ yielded << hoard
100
+ end
101
+
102
+ yielded.should == [
103
+ Hoard.new(:skillet, 200),
104
+ Hoard.new(:hammer, 50),
105
+ Hoard.new(:bottle, 25)
106
+ ]
107
+ end
108
+
109
+ it "can be created from a CSV string" do
110
+ player = Player.from_csv("bimbo,50")
111
+
112
+ player.name.should == "Bimbo"
113
+ player.health.should == 50
114
+ end
115
+ end
116
+ end
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
@@ -0,0 +1,30 @@
1
+ require 'masma_game/red_player'
2
+
3
+ module MasmaGame
4
+ describe RedPlayer do
5
+
6
+ before do
7
+ @initial_health = 50
8
+ @player = RedPlayer.new("red_army", @initial_health)
9
+ end
10
+
11
+ it "does not go red when w00ted up to 5 times" do
12
+ 1.upto(5) { @player.w00t }
13
+
14
+ @player.red?.should be_false
15
+ end
16
+
17
+ it "goes red when w00ted more than 5 times" do
18
+ 1.upto(6) { @player.w00t }
19
+
20
+ @player.red?.should be_true
21
+ end
22
+
23
+ it "gets w00ted instead of blammed when it's gone red" do
24
+ 1.upto(6) { @player.w00t }
25
+ 1.upto(2) { @player.blam }
26
+
27
+ @player.health.should == @initial_health + (8 * 15)
28
+ end
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: masma_game
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Said Maadan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: "This is Ruby application Game \n\nThis code is Copyright 2014. See the
28
+ LICENSE file."
29
+ email: info@saidmaadan.com
30
+ executables:
31
+ - masma_game
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/masma_game
36
+ - bin/players.csv
37
+ - lib/masma_game/auditable.rb
38
+ - lib/masma_game/blue_player.rb
39
+ - lib/masma_game/die.rb
40
+ - lib/masma_game/game.rb
41
+ - lib/masma_game/hoard_store.rb
42
+ - lib/masma_game/loaded_die.rb
43
+ - lib/masma_game/next_game.rb
44
+ - lib/masma_game/playable.rb
45
+ - lib/masma_game/player.rb
46
+ - lib/masma_game/red_player.rb
47
+ - spec/masma_game/blue_player_spec.rb
48
+ - spec/masma_game/game_spec.rb
49
+ - spec/masma_game/hoard_store_spec.rb
50
+ - spec/masma_game/player_spec.rb
51
+ - spec/masma_game/red_player_spec.rb
52
+ - LICENSE
53
+ - README
54
+ homepage: http://masmatechnologies.com
55
+ licenses: []
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '1.9'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.1.11
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: A fun, and entirely random, text-based game
77
+ test_files:
78
+ - spec/masma_game/blue_player_spec.rb
79
+ - spec/masma_game/game_spec.rb
80
+ - spec/masma_game/hoard_store_spec.rb
81
+ - spec/masma_game/player_spec.rb
82
+ - spec/masma_game/red_player_spec.rb