Ackam 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aad2cf85cb572657ee447a92fe9fd52f515e42c0380e58da94757c4d4b47e18d
4
+ data.tar.gz: ded8a48de555fcac320c7354803f38d3f8dc7eaa3d78c528aeabe7d258523bde
5
+ SHA512:
6
+ metadata.gz: cab811b6dee923a295d5232588e7b3e60d8d2ef7a2567f6363255847633b07502af599de50116206dbaebb4039a7e0ff8fd18814e963eb6873bc8155dfba65a6
7
+ data.tar.gz: 3943fb7fc7e28ee12ec70acbfdae7638c3b27a3c97a37cd9729f1cd3d96a91e8d4cf70279b50402d0b95539c4e8dd793b03f5559cb8bbef64aa6c770773e6523
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2012 The Pragmatic Studio
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 AxN 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,6 @@
1
+ This is an example application used in The Pragmatic Studio's
2
+ Ruby Programming course, as described at
3
+
4
+ http://pragmaticstudio.com
5
+
6
+ This code is Copyright 2012 The Pragmatic Studio. See the LICENSE file.
@@ -0,0 +1,6 @@
1
+ knuckleheads High Scores:
2
+
3
+
4
+
5
+
6
+
@@ -0,0 +1,3 @@
1
+ Augustine,100
2
+ Kezia,60
3
+ Keren,125
data/bin/players.csv ADDED
@@ -0,0 +1,3 @@
1
+ Alvin,100
2
+ Simon,60
3
+ Theo,125
data/bin/studio_game ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/studio_game/player'
4
+ require_relative '../lib/studio_game/game'
5
+ require_relative '../lib/studio_game/clumsy_player'
6
+ require_relative '../lib/studio_game/berserk_player'
7
+
8
+
9
+ knuckleheads = StudioGame::Game.new("knuckleheads")
10
+ puts knuckleheads.title
11
+
12
+ clumsy = StudioGame::ClumsyPlayer.new('Klutz', 105);
13
+ knuckleheads.add_player(clumsy)
14
+
15
+ berserk = StudioGame::BerserkPlayer.new('Berserk', 50);
16
+ knuckleheads.add_player(berserk)
17
+
18
+ default_player_file = File.join(File.dirname(__FILE__), 'players.csv')
19
+ knuckleheads.load_players(ARGV.shift || default_player_file);
20
+
21
+ loop do
22
+ puts "\nHow many game rounds? ('quit' to exit)"
23
+ answer = gets.chomp.downcase
24
+ case answer
25
+ when /^\d+$/
26
+ knuckleheads.play(answer.to_i)
27
+ when 'quit', 'exit'
28
+ knuckleheads.print_stats
29
+ break
30
+ else
31
+ puts "Please enter a number or 'quit'"
32
+ end
33
+ end
34
+
35
+ knuckleheads.save_high_scores
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
@@ -0,0 +1,9 @@
1
+ module StudioGame
2
+ module Auditable
3
+
4
+ def audit
5
+ puts "Rolled a #{self.number} (#{self.class})"
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'player'
2
+
3
+
4
+ module StudioGame
5
+ class BerserkPlayer < Player
6
+
7
+ def initialize(name, health)
8
+ super(name, health)
9
+ @w00t_count = 0
10
+ end
11
+
12
+ def berserk?
13
+ @w00t_count > 5
14
+ end
15
+
16
+ def w00t
17
+ super
18
+ @w00t_count += 1
19
+ puts "Berserker is berserk!" if berserk?
20
+ end
21
+
22
+ def blam
23
+ if berserk?
24
+ w00t
25
+ else
26
+ super
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+
33
+ if __FILE__ == $0
34
+ berserker = BerserkPlayer.new("berserker", 50)
35
+ 6.times { berserker.w00t }
36
+ 2.times { berserker.blam }
37
+ puts berserker.health
38
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'player'
2
+
3
+
4
+ module StudioGame
5
+ class ClumsyPlayer < Player
6
+
7
+ # def initialize(name, points, clumsy)
8
+ # super(name, points)
9
+ # @clumsy = clumsy
10
+ # end
11
+
12
+ def found_treasure(treasure)
13
+ damaged_treasure = Treasure.new(treasure.name, treasure.points / 2.0)
14
+ super(damaged_treasure)
15
+ end
16
+
17
+ end
18
+ end
19
+
20
+ if __FILE__ == $0
21
+ clumsy = ClumsyPlayer.new("klutz")
22
+
23
+ hammer = Treasure.new(:hammer, 50)
24
+ clumsy.found_treasure(hammer)
25
+ clumsy.found_treasure(hammer)
26
+ clumsy.found_treasure(hammer)
27
+
28
+ crowbar = Treasure.new(:crowbar, 400)
29
+ clumsy.found_treasure(crowbar)
30
+
31
+ clumsy.each_found_treasure do |treasure|
32
+ puts "#{treasure.points} total #{treasure.name} points"
33
+ end
34
+ puts "#{clumsy.points} grand total points"
35
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
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
+ audit
15
+ @number
16
+ end
17
+ end
18
+ end
19
+
20
+ if __FILE__ == $0
21
+ die = Die.new
22
+ puts die.roll
23
+ puts die.roll
24
+ puts die.roll
25
+ end
@@ -0,0 +1,105 @@
1
+ require_relative 'player'
2
+ require_relative 'game_turn'
3
+ require_relative 'treasure_trove'
4
+
5
+ module StudioGame
6
+ class Game
7
+ attr_reader :title
8
+
9
+ def initialize(title)
10
+ @title = title
11
+ @players = []
12
+ end
13
+
14
+ def add_player(player)
15
+ @players << player
16
+ end
17
+
18
+ def print_name_and_health(player)
19
+ puts "#{player.name}#{player.score}"
20
+ end
21
+
22
+ def high_score_entry(player)
23
+ formatted_name = player.name.ljust(20, '.')
24
+ puts "#{formatted_name} #{player.score}"
25
+ end
26
+
27
+ def total_points
28
+ @players.reduce(0) { |sum, player| sum + player.points }
29
+ end
30
+
31
+ def print_stats
32
+ puts "\n#{@title} Statistics:"
33
+
34
+ strong_players, wimpy_players = @players.partition { |player| player.strong? }
35
+
36
+ puts "\n#{strong_players.size} strong players:"
37
+ strong_players.each do |player|
38
+ print_name_and_health(player)
39
+ end
40
+
41
+ puts "\n#{wimpy_players.size} wimpy players:"
42
+ wimpy_players.each do |player|
43
+ print_name_and_health(player)
44
+ end
45
+
46
+ puts "\n#{total_points} total points from treasures found"
47
+ @players.sort.each do |player|
48
+ puts "\n#{player.name}'s point totals:"
49
+ player.each_found_treasure do |treasure|
50
+ puts "#{treasure.points} total #{treasure.name} points"
51
+ end
52
+ puts "#{player.points} grand total points"
53
+ end
54
+
55
+ puts "\n#{@title} High Scores:"
56
+ @players.sort.each do |player|
57
+ high_score_entry(player)
58
+ end
59
+ end
60
+
61
+ def play(rounds)
62
+ puts "There are #{@players.size} players in #{@title}"
63
+
64
+ treasures = StudioGame::TreasureTrove::TREASURES
65
+
66
+ puts "\nThere are #{treasures.size} treasures to be found: "
67
+ treasures.each do |treasure|
68
+ puts "A #{treasure.name} is worth #{treasure.points} points "
69
+ end
70
+ puts "\n"
71
+
72
+ treasures.each do |treasure|
73
+ puts "\n"
74
+ puts "#{treasure.name}'s point totals:"
75
+ puts "#{treasure.points} grand total points"
76
+ puts "\n"
77
+ end
78
+
79
+ 1.upto(rounds) do |round|
80
+ puts "\nRound #{round}"
81
+ @players.sort.each do |player|
82
+ GameTurn.take_turn(player)
83
+ # puts player
84
+ end
85
+ end
86
+ end
87
+
88
+
89
+
90
+ def load_players(players_file)
91
+ File.readlines(players_file).each do |line|
92
+ add_player(Player.from_csv(line))
93
+ end
94
+ end
95
+
96
+ def save_high_scores(file_name = 'high_scores.txt')
97
+ File.open(file_name, "w") do |file|
98
+ file.puts "#{title} High Scores:"
99
+ @players.sort.each do |player|
100
+ file.puts high_score_entry(player)
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'die'
2
+ require_relative 'treasure_trove'
3
+ require_relative 'loaded_die'
4
+
5
+ module StudioGame
6
+ module GameTurn
7
+ def self.take_turn(player)
8
+ # die = LoadedDie.new
9
+ die = Die.new
10
+ number_rolled = die.roll
11
+
12
+ case die.roll
13
+ when 1..2
14
+ player.blam
15
+ when 3..4
16
+ puts "#{player.name} was skipped."
17
+ else
18
+ player.w00t
19
+ end
20
+
21
+ treasure = TreasureTrove.random
22
+ player.found_treasure(treasure)
23
+ # puts "#{player.name} found #{treasure.name} worth #{treasure.points} points"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ # def conversation
2
+ # yield
3
+ # end
4
+ #
5
+ # conversation {puts "me"}
6
+
7
+ # def five_times
8
+ # 1.upto(5) do |n|
9
+ # yield n
10
+ # end
11
+ # end
12
+ #
13
+ # five_times do |n|
14
+ # puts "\n#{n} situps"
15
+ # puts "#{n} pushups"
16
+ # puts "#{n} chinups"
17
+ # end
18
+
19
+
20
+ def n_times(n)
21
+ 1.upto(n) do |count|
22
+ yield count
23
+ end
24
+ end
25
+
26
+ n_times(5) do |n|
27
+ puts "\n#{n} situps"
28
+ puts "#{n} pushups"
29
+ puts "#{n} chinups"
30
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class LoadedDie
5
+ include Auditable
6
+
7
+ attr_reader :number
8
+
9
+ def roll
10
+ numbers = [1, 1, 2, 5, 6, 6]
11
+ audit
12
+ @number = numbers.sample
13
+ @number
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module Playable
2
+ def blam
3
+ @health -= 10
4
+ puts "#{@name} got blammed"
5
+ puts "Im #{@name} with health of #{@health}"
6
+ end
7
+
8
+ def w00t
9
+ @health += 15
10
+ puts "#{@name} got w00ted"
11
+ puts "Im #{@name} with health of #{@health}"
12
+ end
13
+
14
+ def strong?
15
+ if(health >= 100)
16
+ true
17
+ else
18
+ false
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,65 @@
1
+ require_relative 'treasure_trove'
2
+ require_relative 'playable'
3
+
4
+ module StudioGame
5
+ class Player
6
+ include Playable
7
+
8
+ attr_reader :health, :name
9
+ attr_accessor :name
10
+
11
+ def initialize(name, health=100)
12
+ @name = name.capitalize
13
+ @health = health
14
+ @found_treasures = Hash.new(0)
15
+ end
16
+
17
+ def each_found_treasure
18
+ @found_treasures.each do |name, points|
19
+ treasure = Treasure.new(name, points)
20
+ yield treasure
21
+ end
22
+ end
23
+
24
+ def points
25
+ @found_treasures.values.reduce(0, :+)
26
+ end
27
+
28
+ def score
29
+ points + @health
30
+ end
31
+
32
+ def <=>(player)
33
+ player.score <=> score
34
+ end
35
+
36
+ def to_s
37
+ "I'm #{@name} with health = #{@health}, points = #{points}, and score = #{score}."
38
+ end
39
+
40
+ def found_treasure(treasure)
41
+ @found_treasures[treasure.name] += treasure.points
42
+
43
+ puts "#{@name} found a #{treasure.name} worth #{treasure.points} points."
44
+
45
+ puts "#{@name} 's treasures: #{@found_treasures}"
46
+ end
47
+
48
+
49
+ def self.from_csv(string)
50
+ name, health = string.split(',')
51
+ new(name, Integer(health))
52
+ end
53
+
54
+ end
55
+ end
56
+
57
+ if __FILE__ ==$0
58
+ player = Player.new("moe")
59
+ puts player.name
60
+ puts player.health
61
+ player.w00t
62
+ puts player.health
63
+ player.blam
64
+ puts player.health
65
+ end
@@ -0,0 +1,18 @@
1
+ module StudioGame
2
+ Treasure = Struct.new(:name, :points)
3
+
4
+ module TreasureTrove
5
+ TREASURES = [
6
+ Treasure.new(:pie, 5),
7
+ Treasure.new(:bottle, 25),
8
+ Treasure.new(:hammer, 50),
9
+ Treasure.new(:skillet, 100),
10
+ Treasure.new(:broomstick, 200),
11
+ Treasure.new(:crowbar, 400)
12
+ ]
13
+
14
+ def self.random
15
+ TREASURES.sample
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ require 'studio_game/berserk_player'
2
+
3
+ module StudioGame
4
+ describe BerserkPlayer do
5
+
6
+ before do
7
+ @initial_health = 50
8
+ @player = BerserkPlayer.new("berserker", @initial_health)
9
+ end
10
+
11
+ it "does not go berserk when w00ted up to 5 times" do
12
+ 1.upto(5) { @player.w00t }
13
+
14
+ # @player.berserk?.should be_false
15
+
16
+ # or if using Rspec 3.0:
17
+ @player.berserk?.should be_falsey
18
+ end
19
+
20
+ it "goes berserk when w00ted more than 5 times" do
21
+ 1.upto(6) { @player.w00t }
22
+
23
+ # @player.berserk?.should be_true
24
+
25
+ # or if using Rspec 3.0:
26
+ @player.berserk?.should be_truthy
27
+ end
28
+
29
+ it "gets w00ted instead of blammed when it's gone berserk" do
30
+ 1.upto(6) { @player.w00t }
31
+ 1.upto(2) { @player.blam }
32
+
33
+ @player.health.should == @initial_health + (8 * 15)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,34 @@
1
+ require 'studio_game/clumsy_player'
2
+
3
+
4
+ module StudioGame
5
+ describe ClumsyPlayer do
6
+ before do
7
+ @player = ClumsyPlayer.new("klutz")
8
+ end
9
+
10
+ it "only gets half the point value for each treasure" do
11
+ @player.points.should == 0
12
+
13
+ hammer = Treasure.new(:hammer, 50)
14
+ @player.found_treasure(hammer)
15
+ @player.found_treasure(hammer)
16
+ @player.found_treasure(hammer)
17
+
18
+ @player.points.should == 75
19
+
20
+ crowbar = Treasure.new(:crowbar, 400)
21
+ @player.found_treasure(crowbar)
22
+
23
+ @player.points.should == 275
24
+
25
+ yielded = []
26
+ @player.each_found_treasure do |treasure|
27
+ yielded << treasure
28
+ end
29
+
30
+ yielded.should == [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,56 @@
1
+ require "studio_game/game"
2
+ require "studio_game/player"
3
+
4
+ module StudioGame
5
+ describe Game do
6
+
7
+ before do
8
+ @game = Game.new("Knuckleheads")
9
+
10
+ @initial_health = 100
11
+ @player = Player.new("moe", @initial_health)
12
+
13
+ @game.add_player(@player)
14
+ end
15
+
16
+ it "has title" do
17
+ expect(@game.title).to eq("Knuckleheads")
18
+ end
19
+
20
+ it "w00ts when a high number is rolled out" do
21
+ Die.any_instance.stub(:roll).and_return(5)
22
+ @game.play(2)
23
+
24
+ expect(@player.health).to eq(@initial_health + (15*2))
25
+ end
26
+
27
+ it "w00ts when a medium number is rolled out" do
28
+ Die.any_instance.stub(:roll).and_return(3)
29
+ @game.play(2)
30
+
31
+ expect(@player.health).to eq(@initial_health)
32
+ end
33
+
34
+ it "w00ts when a low number is rolled out" do
35
+ Die.any_instance.stub(:roll).and_return(1)
36
+ @game.play(2)
37
+
38
+ expect(@player.health).to eq(@initial_health - (10*2))
39
+ end
40
+
41
+ it "assigns a treasure for points during a player's turn" do
42
+ game = Game.new("Knuckleheads")
43
+ player = Player.new("moe")
44
+
45
+ game.add_player(player)
46
+
47
+ game.play(1)
48
+
49
+ # player.points.should_not be_zero
50
+
51
+ # or use alternate expectation syntax:
52
+ expect(player.points).not_to be_zero
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,131 @@
1
+ require "studio_game/player"
2
+ require "studio_game/treasure_trove"
3
+
4
+
5
+ module StudioGame
6
+ describe Player do
7
+
8
+ before do
9
+ @initial_health = 150
10
+ @player = Player.new("larry", @initial_health)
11
+ end
12
+
13
+
14
+ it "has a capitalised name" do
15
+
16
+ # player.name.should == "Larry"
17
+ # @player.name.should == "Larry"
18
+ expect(@player.name).to eq("Larry")
19
+ end
20
+
21
+ it "has an initial health" do
22
+
23
+ expect(@player.health).to eq(150)
24
+ end
25
+
26
+ it "has a string representation" do
27
+
28
+ @player.found_treasure(Treasure.new(:hammer, 50))
29
+ @player.found_treasure(Treasure.new(:hammer, 50))
30
+ # @player.to_s.should == "I'm Larry with a health of 150 and a score of 250."
31
+ @player.to_s.should == "I'm Larry with health = 150, points = 100, and score = 250."
32
+
33
+ end
34
+
35
+ it "computes a score as the sum of its health and length of name" do
36
+ @player.found_treasure(Treasure.new(:hammer, 50))
37
+ @player.found_treasure(Treasure.new(:hammer, 50))
38
+ @player.score.should == 250
39
+ end
40
+
41
+ it "increases health by 15 when w00ted" do
42
+ @player.w00t
43
+
44
+ expect(@player.health).to eq(@initial_health+15)
45
+ end
46
+
47
+ it "decreases health by 10 when blammed" do
48
+ @player.blam
49
+
50
+ expect(@player.health).to eq(150-10)
51
+ end
52
+
53
+ context "with a health greater than 100" do
54
+ before do
55
+ @initial_health = 150
56
+ @player = Player.new("larry", @initial_health)
57
+ end
58
+
59
+ it "is strong" do
60
+ expect(@player).to be_strong
61
+ end
62
+ end
63
+
64
+ context "with a health less than 100" do
65
+ before do
66
+ @initial_health = 99
67
+ @player = Player.new("larry", @initial_health)
68
+ end
69
+
70
+ it "is not strong" do
71
+ expect(@player).not_to be_strong
72
+ end
73
+ end
74
+
75
+ context "in a collection of players" do
76
+ before do
77
+ @player1 = Player.new("moe", 100)
78
+ @player2 = Player.new("larry", 200)
79
+ @player3 = Player.new("curly", 300)
80
+
81
+ @players = [@player1, @player2, @player3]
82
+ end
83
+
84
+ it "is sorted by decreasing score" do
85
+ @players.sort.should == [@player3, @player2, @player1]
86
+ end
87
+ end
88
+
89
+ it "computes points as the sum of all treasure points" do
90
+ @player.points.should == 0
91
+
92
+ @player.found_treasure(Treasure.new(:hammer, 50))
93
+ @player.points.should == 50
94
+
95
+ @player.found_treasure(Treasure.new(:crowbar, 400))
96
+ @player.points.should == 450
97
+
98
+ @player.found_treasure(Treasure.new(:hammer, 50))
99
+ @player.points.should == 500
100
+ end
101
+
102
+ it "yields each found treasure and its total points" do
103
+ @player.found_treasure(Treasure.new(:skillet, 100))
104
+ @player.found_treasure(Treasure.new(:skillet, 100))
105
+ @player.found_treasure(Treasure.new(:hammer, 50))
106
+ @player.found_treasure(Treasure.new(:bottle, 5))
107
+ @player.found_treasure(Treasure.new(:bottle, 5))
108
+ @player.found_treasure(Treasure.new(:bottle, 5))
109
+ @player.found_treasure(Treasure.new(:bottle, 5))
110
+ @player.found_treasure(Treasure.new(:bottle, 5))
111
+
112
+ yielded = []
113
+ @player.each_found_treasure do |treasure|
114
+ yielded << treasure
115
+ end
116
+
117
+ yielded.should == [
118
+ Treasure.new(:skillet, 200),
119
+ Treasure.new(:hammer, 50),
120
+ Treasure.new(:bottle, 25)
121
+ ]
122
+ end
123
+
124
+
125
+ it "test from csv" do
126
+ player = Player.from_csv("larry,150")
127
+ expect(@player.health).to eq(150)
128
+ expect(@player.name).to eq('Larry')
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,58 @@
1
+ require "studio_game/treasure_trove"
2
+
3
+ module StudioGame
4
+ describe Treasure do
5
+
6
+ before do
7
+ @treasure = Treasure.new(:hammer, 50)
8
+ end
9
+
10
+ it "has a name attribute" do
11
+ @treasure.name.should == :hammer
12
+ end
13
+
14
+ it "has a points attribute" do
15
+ @treasure.points.should == 50
16
+ end
17
+
18
+ end
19
+ end
20
+
21
+ module StudioGame
22
+ describe TreasureTrove do
23
+
24
+ it "has six treasures" do
25
+ TreasureTrove::TREASURES.size.should == 6
26
+ end
27
+
28
+ it "has a pie worth 5 points" do
29
+ TreasureTrove::TREASURES[0].should == Treasure.new(:pie, 5)
30
+ end
31
+
32
+ it "has a bottle worth 25 points" do
33
+ TreasureTrove::TREASURES[1].should == Treasure.new(:bottle, 25)
34
+ end
35
+
36
+ it "has a hammer worth 50 points" do
37
+ TreasureTrove::TREASURES[2].should == Treasure.new(:hammer, 50)
38
+ end
39
+
40
+ it "has a skillet worth 100 points" do
41
+ TreasureTrove::TREASURES[3].should == Treasure.new(:skillet, 100)
42
+ end
43
+
44
+ it "has a broomstick worth 200 points" do
45
+ TreasureTrove::TREASURES[4].should == Treasure.new(:broomstick, 200)
46
+ end
47
+
48
+ it "has a crowbar worth 400 points" do
49
+ TreasureTrove::TREASURES[5].should == Treasure.new(:crowbar, 400)
50
+ end
51
+
52
+ it "it returns a random treasure" do
53
+ treasure = TreasureTrove.random
54
+
55
+ expect(TreasureTrove::TREASURES).to include(treasure)
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Ackam
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Aviness
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-07 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: '2.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.8.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.0
33
+ description: "This is an example application used in The Pragmatic Studio's \nRuby
34
+ Programming course, as described at\n\n http://pragmaticstudio.com\n\nThis code
35
+ is Copyright 2012 The Pragmatic Studio. See the LICENSE file."
36
+ email: afrakumaa@gmail.com
37
+ executables:
38
+ - studio_game
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - LICENSE
43
+ - README
44
+ - bin/high_scores.txt
45
+ - bin/my_favorite_players.csv
46
+ - bin/players.csv
47
+ - bin/studio_game
48
+ - lib/studio_game/auditable.rb
49
+ - lib/studio_game/berserk_player.rb
50
+ - lib/studio_game/clumsy_player.rb
51
+ - lib/studio_game/die.rb
52
+ - lib/studio_game/game.rb
53
+ - lib/studio_game/game_turn.rb
54
+ - lib/studio_game/iterators.rb
55
+ - lib/studio_game/loaded_die.rb
56
+ - lib/studio_game/playable.rb
57
+ - lib/studio_game/player.rb
58
+ - lib/studio_game/treasure_trove.rb
59
+ - spec/studio_game/berserk_player_spec.rb
60
+ - spec/studio_game/clumsy_player_spec.rb
61
+ - spec/studio_game/game_spec.rb
62
+ - spec/studio_game/player_spec.rb
63
+ - spec/studio_game/treasure_trove_spec.rb
64
+ homepage: https://aa.ackam
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '1.9'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubygems_version: 3.3.7
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: INSERT SUMMARY HERE
87
+ test_files:
88
+ - spec/studio_game/berserk_player_spec.rb
89
+ - spec/studio_game/clumsy_player_spec.rb
90
+ - spec/studio_game/game_spec.rb
91
+ - spec/studio_game/player_spec.rb
92
+ - spec/studio_game/treasure_trove_spec.rb