first_ever_studio_game 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b446aab2aac750f4c28a7736e3bbdb2e6356c75
4
+ data.tar.gz: d70a96ca71a40952986a96da184836727757ec6d
5
+ SHA512:
6
+ metadata.gz: f400d3782a686eeb01a9f7503015f0eef053d1a94a436eaa124e0b358c2956bc6a8070def23bbd67ce5abc188c06193d49790ef1078fa52a39fe2fe6faf760e1
7
+ data.tar.gz: 34de9530022dbda3c73bf9c1b9c40332e89207c6957bb39a19dda4dce6f9f37f73f77b92b0897d0cac37f4924fefee8d9990aa15ebff2d869dcb8b8d4845e0d2
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ of this software and associated documentation files (the "Software"), to deal
3
+ in the Software without restriction, including without limitation the rights
4
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ copies of the Software, and to permit persons to whom the Software is
6
+ furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all
9
+ copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ SOFTWARE.
data/README ADDED
@@ -0,0 +1,20 @@
1
+ Studio Game
2
+
3
+ Program is meant to add multiple players to a game, and then give or remove health and points based on random rolls of a die. These players also accumulate random treasures that give them bonus points. Included are some other mixins that have weighted die, or players that have higher chances of gaining health and different point values dependent upon their treasures. After many rounds, the stats are printed to see what player came out on top. A great game if you want to bet against random odds with your coworkers that know too much about sports.
4
+
5
+
6
+ Getting Started:
7
+
8
+ Just need Ruby to make this baby work.
9
+
10
+ Prerequisites:
11
+
12
+ Computer (preferably a mac), and ruby 2.3.3, plus some of that good ol' worldwide web.
13
+
14
+ License:
15
+
16
+ This project is licensed under the MIT License - see the LICENSE.md file for details
17
+
18
+ Acknowledgments:
19
+
20
+ The Pragmatic Studio, Radbear, God, my parents (probably), spotify mathrock playlists, the movie Swordfish because of that one scene where Halle Berry does that thing to the guy coding, etc.
@@ -0,0 +1,3 @@
1
+ Alvin,100
2
+ Simon,60
3
+ Theo,125
@@ -0,0 +1,37 @@
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
+ module StudioGame
9
+ #This is the format to use when adding playerssss:
10
+ # player1 = StudioGame::Player.new("moe", 100)
11
+ # player2 = StudioGame::Player.new("larry", 100)
12
+ # player3 = StudioGame::Player.new("curly", 100)
13
+ # player4 = StudioGame::ClumsyPlayer.new("klutz", 105, 5)
14
+ # player5 = StudioGame::BerserkPlayer.new("berserker", 50)
15
+
16
+ game = StudioGame::Game.new("Game")
17
+
18
+ default_player_file = File.join(File.dirname(__FILE__), "players.csv")
19
+ game.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 "quit", "exit"
26
+ game.print_stats
27
+ break
28
+ when /^\d+$/
29
+ game.play(answer.to_i)
30
+ else
31
+ puts "Enter a number or 'quit'!"
32
+ end
33
+ end
34
+
35
+ game.save_high_scores
36
+
37
+ end
@@ -0,0 +1,9 @@
1
+ module StudioGame
2
+ module Auditable
3
+
4
+ def audit
5
+ puts "Rolled a #{self.number}."
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,36 @@
1
+ require_relative "player"
2
+
3
+ module StudioGame
4
+ class BerserkPlayer < Player
5
+
6
+ def initialize(name, health = 100)
7
+ super(name, health)
8
+ @w00t_count = 0
9
+ end
10
+
11
+ def berserk?
12
+ @w00t_count > 5
13
+ end
14
+
15
+ def w00t
16
+ super
17
+ @w00t_count += 1
18
+ puts "#{@name} is berserk!!" if berserk?
19
+ end
20
+
21
+ def blam
22
+ if berserk?
23
+ w00t
24
+ else
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ if __FILE__ == $0
32
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
33
+ 6.times { berserker.w00t }
34
+ 2.times { berserker.blam }
35
+ puts berserker.health
36
+ end
@@ -0,0 +1,40 @@
1
+ require_relative "player"
2
+
3
+ module StudioGame
4
+ class ClumsyPlayer < Player
5
+ attr_reader :w00t_b00st
6
+
7
+ def initialize(name, health = 100, w00t_b00st = 1)
8
+ super(name, health)
9
+ @w00t_b00st = w00t_b00st
10
+ end
11
+
12
+ def found_treasure(treasure)
13
+ damaged_treasure = Treasure.new(treasure.name, treasure.points / 2)
14
+ super(damaged_treasure)
15
+ end
16
+
17
+ def w00t
18
+ @w00t_b00st.times { super }
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+
25
+ if __FILE__ == $0
26
+ clumsy = StudioGame::ClumsyPlayer.new("klutz")
27
+ puts clumsy.health
28
+
29
+ hammer = StudioGame::Treasure.new(:hammer, 50)
30
+ clumsy.found_treasure(hammer)
31
+ clumsy.found_treasure(hammer)
32
+ clumsy.found_treasure(hammer)
33
+ crowbar = StudioGame::Treasure.new(:crowbar, 400)
34
+ clumsy.found_treasure(crowbar)
35
+ clumsy.each_treasure do |treasure|
36
+ puts "#{treasure.points} total #{treasure.name} points"
37
+ end
38
+ puts "#{clumsy.points} grand total points"
39
+
40
+ end
@@ -0,0 +1,16 @@
1
+ require_relative "auditable"
2
+
3
+ module StudioGame
4
+ class Die
5
+ include Auditable
6
+
7
+ attr_reader :number
8
+
9
+ def roll
10
+ @number = rand(1..6)
11
+ audit
12
+ @number
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,112 @@
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
+ def initialize(title)
10
+ @title = title.capitalize
11
+ @players = []
12
+ end
13
+
14
+ def load_players(file_name)
15
+ File.readlines(file_name).each do |line|
16
+ add_player(Player.from_csv(line))
17
+ end
18
+ end
19
+
20
+ def save_high_scores(file_name="high_scores.txt")
21
+ File.open(file_name, "w") do |file|
22
+ file.puts "#{@title} High Scores:"
23
+ @players.sort.each do |player|
24
+ file.puts high_score_entry(player)
25
+ end
26
+ end
27
+ end
28
+
29
+ def high_score_entry(player)
30
+ format_var = player.name.ljust(20, ".")
31
+ "#{format_var}#{player.score}"
32
+ end
33
+
34
+ def add_player(name)
35
+ @players << name
36
+ end
37
+
38
+ def player_name_and_health(player)
39
+ puts "\t#{player.name} (#{player.health})"
40
+ end
41
+
42
+ def total_points
43
+ @players.reduce(0) { |sum, player| sum + player.points }
44
+ end
45
+
46
+ def print_stats
47
+ strong, wimpy = @players.partition { |player| player.strong? }
48
+
49
+ puts "\n#{@title} Statistics:"
50
+ puts "\n #{strong.size} Strong Player(s):"
51
+ strong.each do |name|
52
+ player_name_and_health(name)
53
+ end
54
+
55
+ puts "\n #{wimpy.size} Wimpy Player(s):"
56
+ wimpy.each do |name|
57
+ player_name_and_health(name)
58
+ end
59
+
60
+ puts "\n#{@title} High Scores:"
61
+ @players.sort.each do |player|
62
+ puts high_score_entry(player)
63
+ end
64
+
65
+ @players.each do |player|
66
+ puts "\n#{player.name}'s point totals:"
67
+ player.each_treasure do |treasure|
68
+ puts "#{treasure.points} total #{treasure.name} points"
69
+ end
70
+
71
+ puts "#{player.points} grand total points"
72
+ end
73
+ puts "\n#{total_points} total points from treasures found"
74
+ end
75
+
76
+ def play(rounds)
77
+ puts "\nThere are #{@players.size} player(s)."
78
+ @players.each do |player|
79
+ puts player
80
+ end
81
+
82
+ treasures =TreasureTrove::TREASURES
83
+ puts "\nThere are #{treasures.size} treasures to be found:"
84
+ treasures.each do |treasure|
85
+ puts "A #{treasure.name} is worth #{treasure.points} points"
86
+ end
87
+
88
+ 1.upto(rounds) do |round|
89
+ if block_given?
90
+ break if yield
91
+ end
92
+ puts "\nRound #{round}:"
93
+ @players.sort.each do |player|
94
+ StudioGame::GameTurn.take_turn(player)
95
+ puts player
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+
102
+ if __FILE__ == $0
103
+ new_game = StudioGame::Game.new("ohhh_dat_game")
104
+
105
+ player1 = StudioGame::Player.new("moe", 100)
106
+ new_game.add_player(player1)
107
+ puts player1
108
+
109
+ new_game.play(10)
110
+
111
+ end
112
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "die"
2
+ require_relative "player"
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 = StudioGame::Die.new
10
+ # number_rolled = die.roll (could have made "number_rolled" the case value, but that prints an extra dice value when we audit it.)
11
+ case die.roll
12
+ when 1..2
13
+ player.blam
14
+ when 3..4
15
+ puts "#{player.name} got skipped."
16
+ else
17
+ player.w00t
18
+ end
19
+
20
+ rand_treasure = StudioGame::TreasureTrove.random
21
+ player.found_treasure(rand_treasure)
22
+
23
+
24
+
25
+ end
26
+ end
27
+ 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,26 @@
1
+ module StudioGame
2
+ module Playable
3
+
4
+ def w00t
5
+ puts "#{name} got w00ted!"
6
+ self.health += 15
7
+ end
8
+
9
+ def blam
10
+ puts "#{name} got blammed!"
11
+ self.health -= 10
12
+ end
13
+
14
+ def score
15
+ health + points
16
+ end
17
+
18
+ def strong?
19
+ health > 100 #don't think that I need to use self.health here, since it just seems like it's reading the health value.
20
+ end
21
+
22
+ def <=>(other)
23
+ other.score <=> score
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,61 @@
1
+ require_relative "treasure_trove"
2
+ require_relative "playable"
3
+
4
+ module StudioGame
5
+ class Player
6
+ include Playable
7
+
8
+ attr_accessor :health
9
+ attr_reader :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 self.from_csv(file)
18
+ name, health = file.split(",")
19
+ StudioGame::Player.new(name, Integer(health))
20
+ end
21
+
22
+ def found_treasure(treasure)
23
+ @found_treasures[treasure.name] += treasure.points
24
+ puts "#{@name} found a #{treasure.name} worth #{treasure.points} points."
25
+ puts "#{@name}'s treasures: #{@found_treasures}"
26
+
27
+ end
28
+
29
+ def points
30
+ @found_treasures.values.reduce(0, :+)
31
+ end
32
+
33
+ def each_treasure
34
+ @found_treasures.each do |name, points|
35
+ treasure = StudioGame::Treasure.new(name, points)
36
+ yield treasure
37
+ end
38
+ end
39
+
40
+ def to_s
41
+ "I'm #{@name} with a health = #{@health}, points = #{points}, and score = #{score}."
42
+ end
43
+
44
+ def name= (new_name)
45
+ @name = new_name.capitalize
46
+ end
47
+ end
48
+ end
49
+
50
+
51
+ if __FILE__ == $0
52
+ player = StudioGame::Player.new("moe")
53
+ puts player.name
54
+ puts player.health
55
+ player.w00t
56
+ puts player.health
57
+ player.blam
58
+ puts player.health
59
+ puts player
60
+ puts player.strong?
61
+ end
@@ -0,0 +1,32 @@
1
+
2
+ module StudioGame
3
+ Treasure = Struct.new(:name, :points)
4
+
5
+ module TreasureTrove
6
+
7
+ TREASURES =[
8
+ Treasure.new(:pie, 5),
9
+ Treasure.new(:bottle, 25),
10
+ Treasure.new(:hammer, 50),
11
+ Treasure.new(:skillet, 100),
12
+ Treasure.new(:broomstick, 200),
13
+ Treasure.new(:crowbar, 400)
14
+ ]
15
+
16
+ def self.random
17
+ TREASURES.sample
18
+ end
19
+ end
20
+
21
+
22
+ if __FILE__ == $0
23
+ things = TreasureTrove::TREASURES
24
+
25
+ puts "There are #{things.size} treasures to be found:\n\n"
26
+ things.each do |treasure|
27
+ puts "There's a #{treasure.name} worth #{treasure.points} points."
28
+ end
29
+ rand_snack = TreasureTrove.random
30
+ puts "\nLooks like you randomly got a #{rand_snack.name} worth #{rand_snack.points} points."
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ require 'studio_game/berserk_player'
2
+ require_relative 'spec_helper'
3
+
4
+ module StudioGame
5
+ describe BerserkPlayer do
6
+
7
+ before do
8
+ @initial_health = 50
9
+ @player = BerserkPlayer.new("berserker", @initial_health)
10
+ end
11
+
12
+ it "does not go berserk when w00ted up to 5 times" do
13
+ 1.upto(5) { @player.w00t }
14
+
15
+ @player.berserk?.should be_falsey
16
+ end
17
+
18
+ it "goes berserk when w00ted more than 5 times" do
19
+ 1.upto(6) { @player.w00t }
20
+
21
+
22
+ @player.berserk?.should be_truthy
23
+ end
24
+
25
+ it "gets w00ted instead of blammed when it's gone berserk" do
26
+ 1.upto(6) { @player.w00t }
27
+ 1.upto(2) { @player.blam }
28
+
29
+ @player.health.should == @initial_health + (8 * 15)
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,52 @@
1
+ require "studio_game/clumsy_player"
2
+ require_relative 'spec_helper'
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_treasure do |treasure|
27
+ yielded << treasure
28
+ end
29
+
30
+ yielded.should == [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
31
+ end
32
+
33
+ context "with a w00t b00st" do
34
+ before do
35
+ @initial_health = 100
36
+ @w00t_b00st = 5
37
+ @player = ClumsyPlayer.new("klutz", @initial_health, @w00t_b00st)
38
+ end
39
+
40
+ it "has a w00t b00st" do
41
+ @player.w00t_b00st.should == 5
42
+ end
43
+
44
+ it "gets w00t b00st number of w00ts when w00ted" do
45
+ @player.w00t
46
+
47
+ @player.health.should == @initial_health + (15 * @w00t_b00st)
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,72 @@
1
+ require "studio_game/game"
2
+ require_relative "spec_helper"
3
+
4
+ module StudioGame
5
+ describe Game do
6
+
7
+ before do
8
+ @stdout = StringIO.new
9
+ end
10
+
11
+ before do
12
+ @game = Game.new("Knuckleheads")
13
+
14
+ @initial_health = 100
15
+ @player = Player.new("brochacho", @initial_health)
16
+
17
+ @game.add_player(@player)
18
+ end
19
+
20
+ it "W00ts the player when a 5 or 6 is rolled" do
21
+ allow_any_instance_of(Die).to receive(:roll).and_return(5)
22
+
23
+ @game.play(2)
24
+
25
+ @player.health.should == @initial_health + 15 * 2
26
+ end
27
+
28
+ it "skips over the player when a medium number is rolled" do
29
+ allow_any_instance_of(Die).to receive(:roll).and_return(3)
30
+
31
+ @game.play(2)
32
+
33
+ @player.health.should == @initial_health
34
+ end
35
+
36
+ it "blams the player when a low number is rolled" do
37
+ allow_any_instance_of(Die).to receive(:roll).and_return(1)
38
+
39
+ @game.play(2)
40
+
41
+ @player.health.should == @initial_health - 10 * 2
42
+ end
43
+
44
+ it "assigns a treasure for points during a player's turn" do
45
+ game = Game.new("Knuckleheads")
46
+ player = Player.new("moe")
47
+
48
+ game.add_player(player)
49
+
50
+ game.play(1)
51
+
52
+ player.points.should_not be_zero
53
+ end
54
+
55
+ it "computes total points as the sum of all player points" do
56
+ game = Game.new("Knuckleheads")
57
+
58
+ player1 = Player.new("moe")
59
+ player2 = Player.new("larry")
60
+
61
+ game.add_player(player1)
62
+ game.add_player(player2)
63
+
64
+ player1.found_treasure(Treasure.new(:hammer, 50))
65
+ player1.found_treasure(Treasure.new(:hammer, 50))
66
+ player2.found_treasure(Treasure.new(:crowbar, 400))
67
+
68
+ game.total_points.should == 500
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,128 @@
1
+ require "studio_game/player"
2
+ require_relative "spec_helper"
3
+
4
+ module StudioGame
5
+ describe Player do
6
+
7
+ before do
8
+ $stdout = StringIO.new
9
+ end
10
+
11
+ before do
12
+ @initial_health = 100
13
+ @player = Player.new("moe", @initial_health)
14
+ end
15
+
16
+ it "has a capitalized name" do
17
+ expect(@player.name).to eq("Moe") #newer syntax from rspec 3
18
+ end
19
+
20
+ it "has an initial health" do
21
+ @player.health.should == 100 #older rspec syntax from 2.8 (both ways work)
22
+ end
23
+
24
+ it "has a string representation" do
25
+ @player.found_treasure(Treasure.new(:hammer, 50))
26
+ @player.found_treasure(Treasure.new(:hammer, 50))
27
+
28
+ @player.to_s.should == "I'm Moe with a health = 100, points = 100, and score = 200."
29
+ end
30
+
31
+ it "computes a score as the sum of its health and points" do
32
+ @player.found_treasure(Treasure.new(:hammer, 50))
33
+ @player.found_treasure(Treasure.new(:hammer, 50))
34
+
35
+ @player.score.should == 200
36
+ end
37
+
38
+ it "increases health by 15 from w00t" do
39
+ @player.w00t
40
+ @player.health.should == @initial_health + 15
41
+ end
42
+
43
+ it "decreases health by 10 from blam" do
44
+ @player.blam
45
+
46
+ @player.health.should == @initial_health - 10
47
+ end
48
+
49
+ context "creating a player with a health of 150" do
50
+ before do
51
+ @player = Player.new("twochainz", 150)
52
+ end
53
+ it "shows that a character is strong" do
54
+ @player.strong?.should == true
55
+ end
56
+ end
57
+
58
+ context "creating a player with a health of 100" do
59
+ before do
60
+ @player = Player.new("twochainz", 100)
61
+ end
62
+
63
+ it "shows a character is wimpy" do
64
+ @player.strong?.should == false
65
+ end
66
+ end
67
+
68
+ context "adding players with varying health (which a major component of their score)" do
69
+ before do
70
+ @player1 = Player.new("moe", 100)
71
+ @player2 = Player.new("larry", 200)
72
+ @player3 = Player.new("curly", 300)
73
+
74
+ @players = [@player1, @player2, @player3]
75
+ end
76
+
77
+ it "lists the players from highest to lowest health" do
78
+ @players.sort.should == [@player3, @player2, @player1]
79
+ end
80
+ end
81
+
82
+ it "computes points as the sum of all treasure points" do
83
+ @player.points.should == 0
84
+
85
+ @player.found_treasure(Treasure.new(:hammer, 50))
86
+
87
+ @player.points.should == 50
88
+
89
+ @player.found_treasure(Treasure.new(:crowbar, 400))
90
+
91
+ @player.points.should == 450
92
+
93
+ @player.found_treasure(Treasure.new(:hammer, 50))
94
+
95
+ @player.points.should == 500
96
+ end
97
+
98
+ it "yields each found treasure and its total points" do
99
+ @player.found_treasure(Treasure.new(:skillet, 100))
100
+ @player.found_treasure(Treasure.new(:skillet, 100))
101
+ @player.found_treasure(Treasure.new(:hammer, 50))
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
+ @player.found_treasure(Treasure.new(:bottle, 5))
107
+
108
+ yielded = []
109
+ @player.each_treasure do |treasure|
110
+ yielded << treasure
111
+ end
112
+
113
+ yielded.should == [
114
+ Treasure.new(:skillet, 200),
115
+ Treasure.new(:hammer, 50),
116
+ Treasure.new(:bottle, 25)
117
+ ]
118
+ end
119
+
120
+ it "can be created from a CSV string" do
121
+ player = Player.from_csv("larry,150")
122
+
123
+ player.name.should == "Larry"
124
+ player.health.should == 150
125
+ end
126
+
127
+ end
128
+ end
@@ -0,0 +1,10 @@
1
+ module StudioGame
2
+ RSpec.configure do |config|
3
+ config.expect_with :rspec do |c|
4
+ c.syntax = [:should, :expect]
5
+ end
6
+ config.mock_with :rspec do |c|
7
+ c.syntax = [:should, :expect]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,57 @@
1
+ require 'studio_game/treasure_trove'
2
+ require_relative 'spec_helper'
3
+
4
+ module StudioGame
5
+ describe Treasure do
6
+
7
+ before do
8
+ @treasure = Treasure.new(:hammer, 50)
9
+ end
10
+
11
+ it "has a name attribute" do
12
+ @treasure.name.should == :hammer
13
+ end
14
+
15
+ it "has a points attribute" do
16
+ @treasure.points.should == 50
17
+ end
18
+
19
+ end
20
+
21
+ describe TreasureTrove do
22
+
23
+ it "has six treasures" do
24
+ TreasureTrove::TREASURES.size.should == 6
25
+ end
26
+
27
+ it "has a pie worth 5 points" do
28
+ TreasureTrove::TREASURES[0].should == Treasure.new(:pie, 5)
29
+ end
30
+
31
+ it "has a bottle worth 25 points" do
32
+ TreasureTrove::TREASURES[1].should == Treasure.new(:bottle, 25)
33
+ end
34
+
35
+ it "has a hammer worth 50 points" do
36
+ TreasureTrove::TREASURES[2].should == Treasure.new(:hammer, 50)
37
+ end
38
+
39
+ it "has a skillet worth 100 points" do
40
+ TreasureTrove::TREASURES[3].should == Treasure.new(:skillet, 100)
41
+ end
42
+
43
+ it "has a broomstick worth 200 points" do
44
+ TreasureTrove::TREASURES[4].should == Treasure.new(:broomstick, 200)
45
+ end
46
+
47
+ it "has a crowbar worth 400 points" do
48
+ TreasureTrove::TREASURES[5].should == Treasure.new(:crowbar, 400)
49
+ end
50
+
51
+ it "returns a random treasure" do
52
+ treasure = TreasureTrove.random
53
+
54
+ TreasureTrove::TREASURES.should include(treasure)
55
+ end
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: first_ever_studio_game
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Boyd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-10 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: "Studio Game\n\nProgram is meant to add multiple players to a game, and
28
+ then give or remove health and points based on random rolls of a die. These players
29
+ also accumulate random treasures that give them bonus points. Included are some
30
+ other mixins that have weighted die, or players that have higher chances of gaining
31
+ health and different point values dependent upon their treasures. After many rounds,
32
+ the stats are printed to see what player came out on top. A great game if you want
33
+ to bet against random odds with your coworkers that know too much about sports.
34
+ \n\n\nGetting Started:\n\nJust need Ruby to make this baby work. \n\nPrerequisites:\n\nComputer
35
+ (preferably a mac), and ruby 2.3.3, plus some of that good ol' worldwide web. \n\nLicense:
36
+ \n\nThis project is licensed under the MIT License - see the LICENSE.md file for
37
+ details\n\nAcknowledgments:\n\nThe Pragmatic Studio, Radbear, God, my parents (probably),
38
+ spotify mathrock playlists, the movie Swordfish because of that one scene where
39
+ Halle Berry does that thing to the guy coding, etc. \n"
40
+ email: mike.boyd@radicalbear.com}
41
+ executables:
42
+ - studio_game
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - LICENSE
47
+ - README
48
+ - bin/players.csv
49
+ - bin/studio_game
50
+ - lib/studio_game/auditable.rb
51
+ - lib/studio_game/berserk_player.rb
52
+ - lib/studio_game/clumsy_player.rb
53
+ - lib/studio_game/die.rb
54
+ - lib/studio_game/game.rb
55
+ - lib/studio_game/game_turn.rb
56
+ - lib/studio_game/loaded_die.rb
57
+ - lib/studio_game/playable.rb
58
+ - lib/studio_game/player.rb
59
+ - lib/studio_game/treasure_trove.rb
60
+ - spec/studio_game/berserk_player_spec.rb
61
+ - spec/studio_game/clumsy_player_spec.rb
62
+ - spec/studio_game/game_spec.rb
63
+ - spec/studio_game/player_spec.rb
64
+ - spec/studio_game/spec_helper.rb
65
+ - spec/studio_game/treasure_trove_spec.rb
66
+ homepage: https://github.com/ohboyd/Game-
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '1.9'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.6.14
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: The millionth studio game online
90
+ test_files:
91
+ - spec/studio_game/berserk_player_spec.rb
92
+ - spec/studio_game/clumsy_player_spec.rb
93
+ - spec/studio_game/game_spec.rb
94
+ - spec/studio_game/player_spec.rb
95
+ - spec/studio_game/spec_helper.rb
96
+ - spec/studio_game/treasure_trove_spec.rb