RpgTools 0.1.0 → 0.2.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 +4 -4
- data/LICENSE +21 -0
- data/README.md +18 -0
- data/Rakefile +3 -0
- data/lib/rpg_tools/card.rb +17 -0
- data/lib/rpg_tools/coin.rb +9 -0
- data/lib/rpg_tools/dice.rb +22 -0
- data/rpg_tools.gemspec +16 -0
- data/spec/card_spec.rb +10 -0
- data/spec/coin_spec.rb +8 -0
- data/spec/dice_spec.rb +25 -0
- data/spec/spec_helper.rb +13 -0
- metadata +46 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e72bdc2ab301bc360b174d27c1ce2b22ed44b135
|
4
|
+
data.tar.gz: 6c3f36a0c7c460733b9e7eb3bb340843032b0e5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67c945260be17a4e607431d0dea36add3789aa32a3cf17aa1a6152d9260918d011125df9d000a390a1c1a9304e40ace94cf78313b6d62d48b2ddde4265dcbf20
|
7
|
+
data.tar.gz: 4a2b45e6b52ed24102e20b6dc843368a2dcc4d13ce73b8f4c6925e44b0e4acce17473dcf4a6f14fe0c896639543ee41dcd59aa2d923139a3c114124b820c5cc1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Yohan Piron
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
RpgTools
|
2
|
+
=======
|
3
|
+
|
4
|
+
A gem that gives you tools for your RPGs : dices, coins, cards !
|
5
|
+
|
6
|
+
# Usage
|
7
|
+
|
8
|
+
* <tt>RpgTools::Coin.flip</tt> returns a "heads" or "tails" string.
|
9
|
+
* <tt>RpgTools::Dice.rool(arg)</tt> returns an array of dices of your choice (arg format : "1d6" or "4D10" for example).
|
10
|
+
* <tt>RpgTools::Card.pick</tt> returns a card of a 52 cards deck + 2 jokers.
|
11
|
+
|
12
|
+
## Contributing
|
13
|
+
|
14
|
+
1. Fork it
|
15
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
16
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
17
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
18
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module RpgTools
|
2
|
+
class Card
|
3
|
+
def self.pick
|
4
|
+
joker_pick_check == true ? 'Joker' : standard_card
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.joker_pick_check
|
8
|
+
[0, 1].include?((0..54).to_a.sample(1).first)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.standard_card
|
12
|
+
number = [(1..10).to_a, 'Jack', 'Queen', 'King'].flatten.sample(1)
|
13
|
+
color = ['clubs', 'hearts', 'diamonds', 'spades'].sample(1)
|
14
|
+
[number, color].join(' of ')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RpgTools
|
2
|
+
class Dice
|
3
|
+
class << self
|
4
|
+
def roll(arg)
|
5
|
+
dices_num = arg.split(/d/i).first.to_i
|
6
|
+
max_value = arg.split(/d/i).last.to_i
|
7
|
+
|
8
|
+
# I mean, seriously ?
|
9
|
+
return true if dices_num.zero?
|
10
|
+
|
11
|
+
# We don't roll d0 and d1 for obvious reasons.
|
12
|
+
return true if [0, 1].include?(max_value)
|
13
|
+
|
14
|
+
[].tap do |dice_set|
|
15
|
+
dices_num.times do
|
16
|
+
dice_set << rand(1..max_value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/rpg_tools.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{RpgTools}
|
3
|
+
s.version = '0.2.0'
|
4
|
+
s.author = 'Yohan Piron'
|
5
|
+
s.email = 'yinfei84@gmail.com'
|
6
|
+
s.date = %q{2014-12-18}
|
7
|
+
s.summary = %q{RpgTools is a toolbox for tabletop games and RPGs}
|
8
|
+
s.description = 'RpgTools gives you tools for your RPGs : dices, coins, cards...'
|
9
|
+
s.homepage = 'https://github.com/Yinfei/rpg_tools.git'
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.test_files = s.files.grep(%r{^(spec)/})
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
s.add_development_dependency 'rake', '~> 3.1'
|
15
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
16
|
+
end
|
data/spec/card_spec.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'rpg_tools'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe RpgTools::Card do
|
5
|
+
it 'must return a card name' do
|
6
|
+
expect(described_class.pick).not_to eq(true)
|
7
|
+
expect(described_class.pick).not_to eq(false)
|
8
|
+
expect(described_class.pick).not_to eq(nil)
|
9
|
+
end
|
10
|
+
end
|
data/spec/coin_spec.rb
ADDED
data/spec/dice_spec.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rpg_tools'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe RpgTools::Dice do
|
5
|
+
it "doesn't roll a '0d' dice" do
|
6
|
+
expect(described_class.roll('0d6')).to eq(true)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "doesn't roll a 'd0' dice" do
|
10
|
+
expect(described_class.roll('1d0')).to eq(true)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "doesn't roll a 'd1' dice" do
|
14
|
+
expect(described_class.roll('1d1')).to eq(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns the right number of dices' do
|
18
|
+
expect(described_class.roll('2d6').count).to eq(2)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "rolls a dice may the 'd' char be capitalized or not" do
|
22
|
+
expect(described_class.roll('1d6').count).to eq(1)
|
23
|
+
expect(described_class.roll('1D6').count).to eq(1)
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.color = true
|
3
|
+
config.tty = true
|
4
|
+
config.formatter = :documentation
|
5
|
+
|
6
|
+
config.mock_with :rspec do |c|
|
7
|
+
c.syntax = [:should, :expect]
|
8
|
+
end
|
9
|
+
|
10
|
+
config.expect_with :rspec do |c|
|
11
|
+
c.syntax = [:should, :expect]
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RpgTools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yohan Piron
|
@@ -9,14 +9,53 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-12-18 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
13
41
|
description: 'RpgTools gives you tools for your RPGs : dices, coins, cards...'
|
14
42
|
email: yinfei84@gmail.com
|
15
43
|
executables: []
|
16
44
|
extensions: []
|
17
45
|
extra_rdoc_files: []
|
18
46
|
files:
|
47
|
+
- LICENSE
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
19
50
|
- lib/rpg_tools.rb
|
51
|
+
- lib/rpg_tools/card.rb
|
52
|
+
- lib/rpg_tools/coin.rb
|
53
|
+
- lib/rpg_tools/dice.rb
|
54
|
+
- rpg_tools.gemspec
|
55
|
+
- spec/card_spec.rb
|
56
|
+
- spec/coin_spec.rb
|
57
|
+
- spec/dice_spec.rb
|
58
|
+
- spec/spec_helper.rb
|
20
59
|
homepage: https://github.com/Yinfei/rpg_tools.git
|
21
60
|
licenses:
|
22
61
|
- MIT
|
@@ -41,4 +80,8 @@ rubygems_version: 2.4.2
|
|
41
80
|
signing_key:
|
42
81
|
specification_version: 4
|
43
82
|
summary: RpgTools is a toolbox for tabletop games and RPGs
|
44
|
-
test_files:
|
83
|
+
test_files:
|
84
|
+
- spec/card_spec.rb
|
85
|
+
- spec/coin_spec.rb
|
86
|
+
- spec/dice_spec.rb
|
87
|
+
- spec/spec_helper.rb
|