oolivera-studio_game 1.0.0 → 1.0.1
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 +4 -4
- data/lib/studio_game/auditable.rb +5 -3
- data/lib/studio_game/die.rb +13 -10
- data/lib/studio_game/game_turn.rb +18 -16
- data/lib/studio_game/loaded_die.rb +10 -8
- data/lib/studio_game/playable.rb +19 -17
- data/lib/studio_game/treasure_trove.rb +13 -11
- data/specs/treasure_trove_spec.rb +40 -39
- metadata +3 -3
- data/lib/studio_game/namespace.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83b4b897ff109237cc113646e3dc1d9340a98d9b0df842db11be99ae909924a8
|
4
|
+
data.tar.gz: edddcff1b28e49013ce66874fccf4b05e2c7c3dfd90e176b8855214593fed800
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f800ec89f61b2801baa7104b7bdf0455f03ff7b1aa14195742bd43d60c19b010efa5b8346c29ba6e8d9ab30aaee6829db9caa0af3460cb740a527bf5223f42c0
|
7
|
+
data.tar.gz: 5823927a88d73524316035f4bbb82eac1774744447b24616425405e16ad279dc51dee14f1c25712dd1debc63f0080b5ed49d2cb74172fc7464537177dbd3a675
|
data/lib/studio_game/die.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
# Documentation
|
2
2
|
require_relative 'auditable'
|
3
|
-
|
4
|
-
include Auditable
|
5
|
-
attr_reader :number
|
3
|
+
module StudioGame
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
class Die
|
6
|
+
include StudioGame::Auditable
|
7
|
+
attr_reader :number
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
roll
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def roll
|
14
|
+
@number = rand(1..7)
|
15
|
+
audit
|
16
|
+
@number
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
@@ -2,23 +2,25 @@ require_relative 'die'
|
|
2
2
|
require_relative 'loaded_die'
|
3
3
|
|
4
4
|
# Domumentation
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
module StudioGame
|
6
|
+
module GameTurn
|
7
|
+
def self.take_turn(player)
|
8
|
+
die = Die.new
|
9
|
+
players_fate(player, die)
|
10
|
+
treasure = TreasureTrove.random
|
11
|
+
player.found_treasure(treasure)
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
def self.players_fate(player, die)
|
15
|
+
number_rolled = die.roll
|
16
|
+
case number_rolled
|
17
|
+
when (1..2)
|
18
|
+
player.blam
|
19
|
+
when (3..4)
|
20
|
+
puts "#{player.name} was skipped."
|
21
|
+
else
|
22
|
+
player.w00t
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require_relative 'auditable'
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module StudioGame
|
3
|
+
class LoadedDie
|
4
|
+
include Auditable
|
5
|
+
attr_reader :number
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def roll
|
8
|
+
numbers = [1, 1, 2, 5, 6, 6]
|
9
|
+
audit
|
10
|
+
@number = numbers.sample
|
11
|
+
end
|
10
12
|
end
|
11
|
-
end
|
13
|
+
end
|
data/lib/studio_game/playable.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module StudioGame
|
2
|
+
module Playable
|
3
|
+
def w00t
|
4
|
+
puts "#{name} was w00ted, Yeah!!!"
|
5
|
+
self.health += 15
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def blam
|
9
|
+
puts "Oh! #{name} was blamed :("
|
10
|
+
self.health -= 10
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def score
|
14
|
+
self.health + points
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def status
|
18
|
+
strong? ? "#{name} is still standing." : "#{name} is out blammed."
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
def strong?
|
22
|
+
health > 150
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
@@ -2,17 +2,19 @@
|
|
2
2
|
Treasure = Struct.new(:name, :points)
|
3
3
|
|
4
4
|
# Documentation
|
5
|
-
module
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
module StudioGame
|
6
|
+
module TreasureTrove
|
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
|
+
].freeze
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
def self.random
|
17
|
+
TREASURES[rand(0..5)]
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,55 +1,56 @@
|
|
1
1
|
# Documentation
|
2
2
|
require 'studio_game/treasure_trove'
|
3
|
+
module StudioGame
|
4
|
+
describe Treasure do
|
5
|
+
before do
|
6
|
+
$stdout = StringIO.new
|
7
|
+
end
|
8
|
+
let(:treasure) { Treasure.new(:hammer, 50) }
|
3
9
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
8
|
-
let(:treasure) { Treasure.new(:hammer, 50) }
|
10
|
+
it 'has a name attribute' do
|
11
|
+
expect(treasure.name).to eq(:hammer)
|
12
|
+
end
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
it 'has a points attribute' do
|
15
|
+
expect(treasure.points).to eq(50)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
describe TreasureTrove do # rubocop:disable Metrics/BlockLength
|
20
|
+
describe 'Validations' do
|
21
|
+
it 'has six treasures' do
|
22
|
+
expect(TreasureTrove::TREASURES.size).to eq(6)
|
23
|
+
end
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
expect(TreasureTrove::TREASURES.size).to eq(6)
|
23
|
-
end
|
25
|
+
it 'has a pie worth 5 points' do
|
26
|
+
expect(TreasureTrove::TREASURES[0]).to eq(Treasure.new(:pie, 5))
|
27
|
+
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
it 'has a bottle worth 25 points' do
|
30
|
+
expect(TreasureTrove::TREASURES[1]).to eq(Treasure.new(:bottle, 25))
|
31
|
+
end
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
it 'has a hammer worth 50 points' do
|
34
|
-
expect(TreasureTrove::TREASURES[2]).to eq(Treasure.new(:hammer, 50))
|
35
|
-
end
|
33
|
+
it 'has a hammer worth 50 points' do
|
34
|
+
expect(TreasureTrove::TREASURES[2]).to eq(Treasure.new(:hammer, 50))
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
it 'has a skillet worth 100 points' do
|
38
|
+
expect(TreasureTrove::TREASURES[3]).to eq(Treasure.new(:skillet, 100))
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
it 'has a broomstick worth 200 points' do
|
42
|
+
expect(TreasureTrove::TREASURES[4]).to eq(Treasure.new(:broomstick, 200))
|
43
|
+
end
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
it 'has a crowbar worth 400 points' do
|
46
|
+
expect(TreasureTrove::TREASURES[5]).to eq(Treasure.new(:crowbar, 400))
|
47
|
+
end
|
47
48
|
end
|
48
|
-
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
describe '#random' do
|
51
|
+
it 'sholud return a object treasure from TREASURES' do
|
52
|
+
expect(TreasureTrove.random.class).to eq(Treasure)
|
53
|
+
end
|
53
54
|
end
|
54
55
|
end
|
55
|
-
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oolivera-studio_game
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar M. Olivera
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- lib/studio_game/game.rb
|
38
38
|
- lib/studio_game/game_turn.rb
|
39
39
|
- lib/studio_game/loaded_die.rb
|
40
|
-
- lib/studio_game/namespace.rb
|
41
40
|
- lib/studio_game/playable.rb
|
42
41
|
- lib/studio_game/player.rb
|
43
42
|
- lib/studio_game/treasure_trove.rb
|
@@ -47,7 +46,8 @@ files:
|
|
47
46
|
- specs/player_spec.rb
|
48
47
|
- specs/treasure_trove_spec.rb
|
49
48
|
homepage: https://facebook.com
|
50
|
-
licenses:
|
49
|
+
licenses:
|
50
|
+
- MIT No Attribution License
|
51
51
|
metadata: {}
|
52
52
|
post_install_message:
|
53
53
|
rdoc_options: []
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module MovieSystem
|
2
|
-
VERSION = 1.0
|
3
|
-
|
4
|
-
def self.info
|
5
|
-
puts "Movie system version #{VERSION}"
|
6
|
-
end
|
7
|
-
|
8
|
-
class Player
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
module GameSystem
|
13
|
-
VERSION = 2.0
|
14
|
-
|
15
|
-
def self.info
|
16
|
-
puts "Game system version #{VERSION}"
|
17
|
-
end
|
18
|
-
|
19
|
-
class Player
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
puts MovieSystem::VERSION
|
24
|
-
puts MovieSystem.info
|
25
|
-
puts MovieSystem::Player.new
|
26
|
-
|
27
|
-
puts GameSystem::VERSION
|
28
|
-
puts GameSystem.info
|
29
|
-
puts GameSystem::Player.new
|