studio_game_techeverri 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0dc2e39ac0e6c255d3647bd64622f3f1adee69e766bcf7833e84beb08753ef99
4
+ data.tar.gz: b20463bd2a6ded4b45de380af4303aff3b33b25f2fa4930e1aa2ae1eb9358aad
5
+ SHA512:
6
+ metadata.gz: 780bcc0d59d3aba281eb91e012224a90a6b4b575a0c6230c57e9c63159a12af79a1f16ea2ab82449fedad069d7d3f60cc7e4f077978adfbb7d86e797f992ebd1
7
+ data.tar.gz: 19f585062233fb0f1343b42b954789504ce6e3a42f992f0106be4cf4b5816829e95a35d628953b8b8e65e71ec50ca53a52e8fdb1837adaa8ecbfa5b3a3c420c8
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Tomas Echeverri
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,36 @@
1
+ # Studio Game
2
+
3
+ Studio Game is a Ruby-based project that demonstrates object-oriented programming concepts. It includes classes and modules to manage players, games, and scoring.
4
+
5
+ ## Project Structure
6
+
7
+ - `lib/`: Contains the core Ruby files for the game logic.
8
+ - `game.rb`: Defines the main game class.
9
+ - `player.rb`: Manages player attributes and behaviors.
10
+ - `treasure_trove.rb`: Handles treasures and their values.
11
+ - `bin/`: Contains executable scripts to run the game.
12
+ - `studio_game`: The main entry point to start the game.
13
+ - `spec/`: Contains unit tests for the game.
14
+ - `game_spec.rb`: Tests for the game class.
15
+ - `player_spec.rb`: Tests for the player class.
16
+ - `README.md`: Project documentation.
17
+ - `LICENSE`: MIT License file.
18
+
19
+ ## How to Run
20
+
21
+ 1. Clone the repository.
22
+ 2. Navigate to the `studio_game` directory.
23
+ 3. Run the game using:
24
+ ```bash
25
+ ruby bin/studio_game
26
+ ```
27
+
28
+ ## Testing
29
+
30
+ To ensure the game logic works as expected, run the unit tests included in the `spec/` directory. Use the following command:
31
+
32
+ ```bash
33
+ rspec spec/
34
+ ```
35
+
36
+ This will execute all the test files and display the results in the terminal.
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,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/studio_game/game'
4
+ require_relative '../lib/studio_game/clumsy_player'
5
+ require_relative '../lib/studio_game/berserk_player'
6
+
7
+ default_player_file = File.join(File.dirname(__FILE__), 'players.csv')
8
+
9
+ knuckleheads = StudioGame::Game.new("Knuckleheads")
10
+ knuckleheads.load_players(ARGV.shift || default_player_file)
11
+ klutz = StudioGame::ClumsyPlayer.new("klutz", 105)
12
+ knuckleheads.add_player(klutz)
13
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
14
+ knuckleheads.add_player(berserker)
15
+
16
+ loop do
17
+ puts "\nHow many game rounds? ('quit' to exit)"
18
+ answer = gets.chomp.downcase
19
+
20
+ case answer
21
+ when /^\d+$/
22
+ knuckleheads.play(answer.to_i)
23
+ when "quit", "exit"
24
+ knuckleheads.print_stats
25
+ break
26
+ else
27
+ puts "Please enter a number or 'quit'"
28
+ end
29
+ end
30
+
31
+ knuckleheads.save_high_scores
@@ -0,0 +1,7 @@
1
+ module StudioGame
2
+ module Auditable
3
+ def audit
4
+ puts "Rolled a #{self.number} (#{self.class})"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'player'
2
+
3
+ module StudioGame
4
+ class BerserkPlayer < Player
5
+ def initialize(name, health)
6
+ super(name, health)
7
+ @w00t_count = 0
8
+ end
9
+
10
+ def berserk?
11
+ @w00t_count > 5
12
+ end
13
+
14
+ def w00t
15
+ super
16
+ @w00t_count += 1
17
+ puts "#{@name} is berserk!" if berserk?
18
+ end
19
+
20
+ def blam
21
+ if berserk?
22
+ w00t
23
+ else
24
+ super
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ if __FILE__ == $0
31
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
32
+ 6.times { berserker.w00t }
33
+ 2.times { berserker.blam }
34
+ puts berserker.health
35
+ end
@@ -0,0 +1,39 @@
1
+ require_relative 'player'
2
+
3
+ module StudioGame
4
+ class ClumsyPlayer < Player
5
+ attr_reader :boost_factor
6
+
7
+ def initialize(name, health = 100, boost_factor = 1)
8
+ super(name, health)
9
+ @boost_factor = boost_factor
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
+ def w00t
18
+ @boost_factor.times { super }
19
+ end
20
+ end
21
+ end
22
+
23
+ if __FILE__ == $0
24
+ clumsy = StudioGame::ClumsyPlayer.new("klutz")
25
+
26
+ hammer = StudioGame::Treasure.new(:hammer, 50)
27
+ clumsy.found_treasure(hammer)
28
+ clumsy.found_treasure(hammer)
29
+ clumsy.found_treasure(hammer)
30
+
31
+ crowbar = StudioGame::Treasure.new(:crowbar, 400)
32
+ clumsy.found_treasure(crowbar)
33
+
34
+ clumsy.each_found_treasure do |treasure|
35
+ puts "#{treasure.points} total #{treasure.name} points"
36
+ end
37
+
38
+ puts "#{clumsy.points} grand total points"
39
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class Die
5
+ include Auditable
6
+
7
+ attr_reader :number
8
+
9
+ def initialize
10
+ roll
11
+ end
12
+
13
+ def roll
14
+ @number = rand(1..6)
15
+ audit
16
+ @number
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,97 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'game_turn'
4
+ require_relative 'treasure_trove'
5
+
6
+ module StudioGame
7
+ class Game
8
+ attr_reader :title
9
+
10
+ def initialize(title)
11
+ @title = title
12
+ @players = []
13
+ end
14
+
15
+ def high_score_entry(player)
16
+ formatted_name = player.name.ljust(20, '.')
17
+ "#{formatted_name} #{player.score}"
18
+ end
19
+
20
+ def load_players(from_file)
21
+ File.readlines(from_file).each do |line|
22
+ add_player(Player.from_csv(line))
23
+ end
24
+ end
25
+
26
+ def save_high_scores(to_file="high_scores.txt")
27
+ File.open(to_file, "w") do |file|
28
+ file.puts "#{@title} High Scores:"
29
+ @players.sort.each do |player|
30
+ file.puts high_score_entry(player)
31
+ end
32
+ end
33
+ end
34
+
35
+ def add_player(player)
36
+ @players << player
37
+ end
38
+
39
+ def play(rounds)
40
+ puts "There are #{@players.size} players in #{@title}:"
41
+ puts @players
42
+
43
+ treasures = TreasureTrove::TREASURES
44
+ puts "\nThere are #{treasures.size} treasures to be found:"
45
+
46
+ treasures.each do |treasure|
47
+ puts "A #{treasure.name} is worth #{treasure.points} points"
48
+ end
49
+
50
+ 1.upto(rounds) do |round|
51
+ puts "\nRound #{round}:"
52
+
53
+ @players.each do |player|
54
+ GameTurn.take_turn(player)
55
+ end
56
+ end
57
+ end
58
+
59
+ def print_name_and_health(player)
60
+ puts "#{player.name} (#{player.health})"
61
+ end
62
+
63
+ def total_points
64
+ @players.reduce(0) { |sum, player| sum + player.points}
65
+ end
66
+
67
+ def print_stats
68
+ strong_players, wimpy_players = @players.partition {|player| player.strong? }
69
+
70
+ puts "\n#{@title} Statistics:"
71
+
72
+ puts "\n#{strong_players.size} strong players:"
73
+ strong_players.each do |player|
74
+ print_name_and_health(player)
75
+ end
76
+
77
+ puts "\n#{wimpy_players.size} wimpy players:"
78
+ wimpy_players.each do |player|
79
+ print_name_and_health(player)
80
+ end
81
+
82
+ puts "\n#{total_points} total points from treasures found"
83
+ @players.each do |player|
84
+ puts "\n#{player.name}'s point totals:"
85
+ player.each_found_treasure do |treasure|
86
+ puts "#{treasure.points} total #{treasure.name} points"
87
+ end
88
+ puts "#{player.points} grand total points"
89
+ end
90
+
91
+ puts "\n#{@title} High Scores:"
92
+ @players.sort.each do |player|
93
+ puts high_score_entry(player)
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,24 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'treasure_trove'
4
+ require_relative 'loaded_die'
5
+
6
+ module StudioGame
7
+ module GameTurn
8
+ def self.take_turn(player)
9
+ die = Die.new
10
+ # die = LoadedDie.new
11
+ case die.roll
12
+ when 1..2
13
+ player.blam
14
+ when 3..4
15
+ puts "#{player.name} was skipped."
16
+ else
17
+ player.w00t
18
+ end
19
+
20
+ treasure = TreasureTrove.random
21
+ player.found_treasure(treasure)
22
+ end
23
+ end
24
+ 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
+ @number = numbers.sample
12
+ audit
13
+ @number
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module StudioGame
2
+ module Playable
3
+ def w00t
4
+ self.health += 15
5
+ puts "#{name} got w00ted!"
6
+ end
7
+
8
+ def blam
9
+ self.health -= 10
10
+ puts "#{name} got blammed!"
11
+ end
12
+
13
+ def strong?
14
+ health > 100
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,64 @@
1
+ require_relative 'treasure_trove'
2
+ require_relative 'playable'
3
+
4
+ module StudioGame
5
+ class Player
6
+ include Playable
7
+
8
+ attr_accessor :name
9
+ attr_accessor :health
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 self.from_csv(line)
18
+ name, health = line.split(",")
19
+ Player.new(name, Integer(health))
20
+ end
21
+
22
+ def each_found_treasure
23
+ @found_treasures.each do |name, points|
24
+ yield Treasure.new(name, points)
25
+ end
26
+ end
27
+
28
+ def found_treasure(treasure)
29
+ @found_treasures[treasure.name] += treasure.points
30
+ puts "#{@name} found a #{treasure.name} worth #{treasure.points} points."
31
+ puts "#{@name}'s treasures: #{@found_treasures}"
32
+ end
33
+
34
+ def points
35
+ @found_treasures.values.reduce(0, :+)
36
+ end
37
+
38
+ def name=(new_name)
39
+ @name = new_name.capitalize
40
+ end
41
+
42
+ def score
43
+ @health + points
44
+ end
45
+
46
+ def <=>(other_player)
47
+ other_player.score <=> score
48
+ end
49
+
50
+ def to_s
51
+ "I'm #{@name} with a health = #{@health}, points = #{points}, and a score of #{score}."
52
+ end
53
+ end
54
+ end
55
+
56
+ if __FILE__ == $0
57
+ player = StudioGame::Player.new("moe")
58
+ puts player.name
59
+ puts player.health
60
+ player.w00t
61
+ puts player.health
62
+ player.blam
63
+ puts player.health
64
+ 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,29 @@
1
+ require "studio_game/berserk_player"
2
+
3
+ module StudioGame
4
+ describe BerserkPlayer do
5
+ before do
6
+ @initial_health = 50
7
+ @player = BerserkPlayer.new("berserker", @initial_health)
8
+ end
9
+
10
+ it "does not go berserk when w00ted up to 5 times" do
11
+ 1.upto(5) { @player.w00t }
12
+
13
+ expect(@player.berserk?).to be false
14
+ end
15
+
16
+ it "goes berserk when w00ted more than 5 times" do
17
+ 1.upto(6) { @player.w00t }
18
+
19
+ expect(@player.berserk?).to be true
20
+ end
21
+
22
+ it "gets w00ted instead of blammed when it's gone berserk" do
23
+ 1.upto(6) { @player.w00t }
24
+ 1.upto(2) { @player.blam }
25
+
26
+ expect(@player.health).to eq @initial_health + (8 * 15)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,50 @@
1
+ require "studio_game/clumsy_player"
2
+
3
+ module StudioGame
4
+ describe ClumsyPlayer do
5
+ before do
6
+ @player = ClumsyPlayer.new("klutz")
7
+ end
8
+
9
+ it "only gets half the point value for each treasure" do
10
+ expect(@player.points).to eq 0
11
+
12
+ hammer = Treasure.new(:hammer, 50)
13
+ @player.found_treasure(hammer)
14
+ @player.found_treasure(hammer)
15
+ @player.found_treasure(hammer)
16
+
17
+ expect(@player.points).to eq 75
18
+
19
+ crowbar = Treasure.new(:crowbar, 400)
20
+ @player.found_treasure(crowbar)
21
+
22
+ expect(@player.points).to eq 275
23
+
24
+ yielded = []
25
+ @player.each_found_treasure do |treasure|
26
+ yielded << treasure
27
+ end
28
+
29
+ expect(yielded).to eq [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
30
+ end
31
+
32
+ context "with a boost factor" do
33
+ before do
34
+ @initial_health = 100
35
+ @boost_factor = 5
36
+ @player = ClumsyPlayer.new("klutz", @initial_health, @boost_factor)
37
+ end
38
+
39
+ it "has a boost factor" do
40
+ expect(@player.boost_factor).to eq 5
41
+ end
42
+
43
+ it "gets boost factor number of w00ts when w00ted" do
44
+ @player.w00t
45
+
46
+ expect(@player.health).to eq @initial_health + (15 * @boost_factor)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,48 @@
1
+ require "studio_game/game"
2
+
3
+ module StudioGame
4
+ describe Game do
5
+ before do
6
+ @game = Game.new("Knuckleheads")
7
+
8
+ @initial_health = 100
9
+ @player = Player.new("moe", @initial_health)
10
+ @another_player = Player.new("larry", @initial_health)
11
+
12
+ @game.add_player(@player)
13
+ end
14
+
15
+ it "w00ts the player if a high number is rolled" do
16
+ allow_any_instance_of(Die).to receive(:roll).and_return(5)
17
+ @game.play(2)
18
+ expect(@player.health).to eq @initial_health + (15 * 2)
19
+ end
20
+
21
+ it "skips the player if a medium number is rolled" do
22
+ allow_any_instance_of(Die).to receive(:roll).and_return(3)
23
+ @game.play(2)
24
+ expect(@player.health).to eq @initial_health
25
+ end
26
+
27
+ it "blams the player if a low number is rolled" do
28
+ allow_any_instance_of(Die).to receive(:roll).and_return(1)
29
+ @game.play(2)
30
+ expect(@player.health).to eq @initial_health - (10 * 2)
31
+ end
32
+
33
+ it "assigns a treasure for points during a player's turn" do
34
+ @game.play(1)
35
+ expect(@player.points).not_to be_zero
36
+ end
37
+
38
+ it "computes total points as the sum of all player points" do
39
+ @game.add_player(@another_player)
40
+
41
+ @player.found_treasure(Treasure.new(:hammer, 50))
42
+ @player.found_treasure(Treasure.new(:hammer, 50))
43
+ @another_player.found_treasure(Treasure.new(:crowbar, 400))
44
+
45
+ expect(@game.total_points).to eq 100 + 400
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,126 @@
1
+ require "studio_game/player"
2
+ require "studio_game/treasure_trove"
3
+
4
+ module StudioGame
5
+ describe Player do
6
+ before do
7
+ $stdout = StringIO.new
8
+ @initial_health = 200
9
+ @player = Player.new("moe", @initial_health)
10
+ end
11
+
12
+ it "has a capitalized name" do
13
+ expect(@player.name).to eq "Moe"
14
+ end
15
+
16
+ it "has an initial health" do
17
+ expect(@player.health).to eq @initial_health
18
+ end
19
+
20
+ it "has a string representation" do
21
+ @player.found_treasure(Treasure.new(:hammer, 50))
22
+ @player.found_treasure(Treasure.new(:hammer, 50))
23
+
24
+ expect(@player.to_s).to eq "I'm Moe with a health = 200, points = 100, and a score of 300."
25
+ end
26
+
27
+ it "computes a score as the sum of its health and points" do
28
+ expect(@player.score).to eq @initial_health + @player.points
29
+ end
30
+
31
+ it "increases health by 15 when w00ted" do
32
+ @player.w00t
33
+ expect(@player.health).to eq @initial_health + 15
34
+ end
35
+
36
+ it "decreases health by 10 when blammed" do
37
+ @player.blam
38
+ expect(@player.health).to eq @initial_health - 10
39
+ end
40
+
41
+ context "with a health greater than 100" do
42
+ before do
43
+ @initial_health = 150
44
+ @player = Player.new("moe", @initial_health)
45
+ end
46
+
47
+ it "is strong" do
48
+ expect(@player).to be_strong
49
+ end
50
+ end
51
+
52
+ context "with a health of a 100" do
53
+ before do
54
+ @initial_health = 100
55
+ @player = Player.new("moe", @initial_health)
56
+ end
57
+
58
+ it "is not strong" do
59
+ expect(@player).not_to be_strong
60
+ end
61
+ end
62
+
63
+ context "in a collection of players" do
64
+ before do
65
+ @player1 = Player.new("moe", 100)
66
+ @player2 = Player.new("larry", 200)
67
+ @player3 = Player.new("curly", 300)
68
+
69
+ @players = [@player1, @player2, @player3]
70
+ end
71
+
72
+ it "is sorted by decreasing score" do
73
+ expect(@players.sort).to eq [@player3, @player2, @player1]
74
+ end
75
+ end
76
+
77
+ it "computes points as the sum of all treasure points" do
78
+ expect(@player.points).to eq 0
79
+
80
+ @player.found_treasure(Treasure.new(:hammer, 50))
81
+ expect(@player.points).to eq 50
82
+
83
+ @player.found_treasure(Treasure.new(:crowbar, 400))
84
+ expect(@player.points).to eq 450
85
+
86
+ @player.found_treasure(Treasure.new(:hammer, 50))
87
+ expect(@player.points).to eq 500
88
+ end
89
+
90
+ it "computes a score as the sum of its health and points" do
91
+ @player.found_treasure(Treasure.new(:hammer, 50))
92
+ @player.found_treasure(Treasure.new(:hammer, 50))
93
+
94
+ expect(@player.score).to eq 300
95
+ end
96
+
97
+ it "yields each found treasure and its total points" do
98
+ @player.found_treasure(Treasure.new(:skillet, 100))
99
+ @player.found_treasure(Treasure.new(:skillet, 100))
100
+ @player.found_treasure(Treasure.new(:hammer, 50))
101
+ @player.found_treasure(Treasure.new(:bottle, 5))
102
+ @player.found_treasure(Treasure.new(:bottle, 5))
103
+ @player.found_treasure(Treasure.new(:bottle, 5))
104
+ @player.found_treasure(Treasure.new(:bottle, 5))
105
+ @player.found_treasure(Treasure.new(:bottle, 5))
106
+
107
+ yielded = []
108
+ @player.each_found_treasure do |treasure|
109
+ yielded << treasure
110
+ end
111
+
112
+ expect(yielded).to eq [
113
+ Treasure.new(:skillet, 200),
114
+ Treasure.new(:hammer, 50),
115
+ Treasure.new(:bottle, 25)
116
+ ]
117
+ end
118
+
119
+ it "can be created from a CSV string" do
120
+ player = Player.from_csv("larry,150")
121
+
122
+ expect(player.name).to eq "Larry"
123
+ expect(player.health).to eq 150
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,52 @@
1
+ require "studio_game/treasure_trove"
2
+
3
+ module StudioGame
4
+ describe Treasure do
5
+ before do
6
+ @treasure = Treasure.new(:hammer, 50)
7
+ end
8
+
9
+ it "has a name attribute" do
10
+ expect(@treasure.name).to eq :hammer
11
+ end
12
+
13
+ it "has a points attribute" do
14
+ expect(@treasure.points).to eq 50
15
+ end
16
+ end
17
+
18
+ describe TreasureTrove do
19
+ it "has six treasures" do
20
+ expect(TreasureTrove::TREASURES.size).to eq 6
21
+ end
22
+
23
+ it "has a pie worth 5 points" do
24
+ expect(TreasureTrove::TREASURES[0]).to eq Treasure.new(:pie, 5)
25
+ end
26
+
27
+ it "has a bottle worth 25 points" do
28
+ expect(TreasureTrove::TREASURES[1]).to eq Treasure.new(:bottle, 25)
29
+ end
30
+
31
+ it "has a hammer worth 50 points" do
32
+ expect(TreasureTrove::TREASURES[2]).to eq Treasure.new(:hammer, 50)
33
+ end
34
+
35
+ it "has a skillet worth 100 points" do
36
+ expect(TreasureTrove::TREASURES[3]).to eq Treasure.new(:skillet, 100)
37
+ end
38
+
39
+ it "has a broomstick worth 200 points" do
40
+ expect(TreasureTrove::TREASURES[4]).to eq Treasure.new(:broomstick, 200)
41
+ end
42
+
43
+ it "has a crowbar worth 400 points" do
44
+ expect(TreasureTrove::TREASURES[5]).to eq Treasure.new(:crowbar, 400)
45
+ end
46
+
47
+ it "returns a random treasure" do
48
+ treasure = TreasureTrove.random
49
+ expect(TreasureTrove::TREASURES).to include(treasure)
50
+ end
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: studio_game_techeverri
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomas Echeverri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-05-02 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: '3.13'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.13.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.13'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.13.0
33
+ description: |
34
+ # Studio Game
35
+
36
+ Studio Game is a Ruby-based project that demonstrates object-oriented programming concepts. It includes classes and modules to manage players, games, and scoring.
37
+
38
+ ## Project Structure
39
+
40
+ - `lib/`: Contains the core Ruby files for the game logic.
41
+ - `game.rb`: Defines the main game class.
42
+ - `player.rb`: Manages player attributes and behaviors.
43
+ - `treasure_trove.rb`: Handles treasures and their values.
44
+ - `bin/`: Contains executable scripts to run the game.
45
+ - `studio_game`: The main entry point to start the game.
46
+ - `spec/`: Contains unit tests for the game.
47
+ - `game_spec.rb`: Tests for the game class.
48
+ - `player_spec.rb`: Tests for the player class.
49
+ - `README.md`: Project documentation.
50
+ - `LICENSE`: MIT License file.
51
+
52
+ ## How to Run
53
+
54
+ 1. Clone the repository.
55
+ 2. Navigate to the `studio_game` directory.
56
+ 3. Run the game using:
57
+ ```bash
58
+ ruby bin/studio_game
59
+ ```
60
+
61
+ ## Testing
62
+
63
+ To ensure the game logic works as expected, run the unit tests included in the `spec/` directory. Use the following command:
64
+
65
+ ```bash
66
+ rspec spec/
67
+ ```
68
+
69
+ This will execute all the test files and display the results in the terminal.
70
+ email: tomechval@gmail.com
71
+ executables:
72
+ - studio_game
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - LICENSE
77
+ - README
78
+ - bin/players.csv
79
+ - bin/studio_game
80
+ - lib/studio_game/auditable.rb
81
+ - lib/studio_game/berserk_player.rb
82
+ - lib/studio_game/clumsy_player.rb
83
+ - lib/studio_game/die.rb
84
+ - lib/studio_game/game.rb
85
+ - lib/studio_game/game_turn.rb
86
+ - lib/studio_game/loaded_die.rb
87
+ - lib/studio_game/playable.rb
88
+ - lib/studio_game/player.rb
89
+ - lib/studio_game/treasure_trove.rb
90
+ - spec/studio_game/berserk_player_spec.rb
91
+ - spec/studio_game/clumsy_player_spec.rb
92
+ - spec/studio_game/game_spec.rb
93
+ - spec/studio_game/player_spec.rb
94
+ - spec/studio_game/treasure_trove_spec.rb
95
+ homepage: https://techeverri.dev/
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 3.3.4
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubygems_version: 3.5.11
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: A simple game to demonstrate Ruby programming concepts
118
+ test_files:
119
+ - spec/studio_game/berserk_player_spec.rb
120
+ - spec/studio_game/clumsy_player_spec.rb
121
+ - spec/studio_game/game_spec.rb
122
+ - spec/studio_game/player_spec.rb
123
+ - spec/studio_game/treasure_trove_spec.rb