rpg-tools 0.2.0 → 0.2.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.
@@ -124,6 +124,27 @@ Rolling a CheckRoll:
124
124
  check_roll.detailed_result # => [true, [12, [6, 4]]]
125
125
  </code></pre>
126
126
 
127
+ Using <code>greater_than_threshold</code> and <code>greater_to_threshold</code> attributes:
128
+ <pre><code>
129
+ dice = [Tools::Die.new(6),Tools::Die.new(6)]
130
+ offset = 2
131
+ throw = Tools::Throw.new dice,offset #Creates a new throw with 2D6+2
132
+ threshold = 9
133
+ #Creating a "greater and equal to" check
134
+ check_roll1 = Tools::CheckRoll.new throw, threshold #1,true,true (by default)
135
+ check_roll1.to_s # => "2D6+2 must be greater or equal to 9."
136
+ #Creating a "greater than" check
137
+ check_roll2 = Tools::CheckRoll.new throw, threshold, 1, true, false
138
+ check_roll2.to_s # => "2D6+2 must be greater than 9."
139
+ #Creating a "less than" check
140
+ check_roll3 = Tools::CheckRoll.new throw, threshold, 1, false, false
141
+ check_roll3.to_s # => "2D6+2 must be less than 9."
142
+ #Creating a "less and equal to" check
143
+ check_roll4 = Tools::CheckRoll.new throw, threshold, 1, false, true
144
+ check_roll4.to_s # => "2D6+2 must be less or equal to 9."
145
+ </code></pre>
146
+
147
+
127
148
  More methods of CheckRoll:
128
149
  <pre><code>
129
150
  #Converting CheckRoll into string
@@ -1,14 +1,18 @@
1
1
  module Tools
2
2
  class CheckRoll
3
3
 
4
- attr_accessor :throw, :threshold, :rolling_chances, :greater_than_threshold, :equal_than_threshold
4
+ attr_accessor :throw, :threshold, :rolling_chances, :greater_than_threshold, :equal_to_threshold
5
5
  attr_reader :result
6
- def initialize throw, threshold, rolling_chances=1, greater_than_threshold=true, equal_than_threshold=true
6
+ # Creates a new +CheckRoll+ with a +Throw+, a +Fixnum+ as +threshold+ and, optionally:
7
+ # * +rolling_chances+: The number of times the Throw will be rolled before checking. By default is +1+.
8
+ # * +greater_than_threshold+: Wheter the check is done as greater than (>) or less than (<). By default is +true+.
9
+ # * +equal_to_threshold+: Wheter the check accepts the threshold as success (>= and <= if +true+, > and < if +false+). By default is +true+.
10
+ def initialize throw, threshold, rolling_chances=1, greater_than_threshold=true, equal_to_threshold=true
7
11
  @throw = throw
8
12
  @threshold = threshold
9
13
  @rolling_chances = rolling_chances
10
14
  @greater_than_threshold = greater_than_threshold
11
- @equal_than_threshold = equal_than_threshold
15
+ @equal_to_threshold = equal_to_threshold
12
16
  end
13
17
 
14
18
  # Rolls the Throw as many times as rolling chances are set.If has already
@@ -75,7 +79,7 @@ module Tools
75
79
 
76
80
  def compare rolled_throw, threshold
77
81
  gtt = @greater_than_threshold
78
- ett = @equal_than_threshold
82
+ ett = @equal_to_threshold
79
83
  if gtt and ett
80
84
  return rolled_throw >= threshold
81
85
  elsif gtt and !ett
@@ -89,7 +93,7 @@ module Tools
89
93
 
90
94
  def comparatives_text
91
95
  gtt = @greater_than_threshold
92
- ett = @equal_than_threshold
96
+ ett = @equal_to_threshold
93
97
  if gtt and ett
94
98
  return I18n.t 'rpg_tools.check_roll.greater_and_equal'
95
99
  elsif gtt and !ett
@@ -1,6 +1,7 @@
1
1
  module Tools
2
2
  class Die
3
3
  attr_accessor :sides
4
+ # Creates a new +Die+ with a +Fixnum+ as the number of +sides+
4
5
  def initialize sides=20
5
6
  @sides = sides
6
7
  end
@@ -1,6 +1,8 @@
1
1
  module Tools
2
2
  class Throw
3
3
  attr_accessor :dice, :offset
4
+
5
+ # Creates a new +Throw+ with an +Array+ of +Die+ and a +Fixnum+ as +offset+
4
6
  def initialize dice, offset=0
5
7
  @dice = dice.sort_by{|die| die.sides}
6
8
  @offset = offset
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rpg-tools"
3
- s.version = "0.2.0"
3
+ s.version = "0.2.1"
4
4
  s.authors = ["Eduardo Casanova Cuesta"]
5
- s.summary = "Some tools useful when creating a RPG: Die, Throw and CheckRoll."
6
- s.description = "Some tools useful when creating a RPG: Die, Throw and CheckRoll."
5
+ s.summary = "RPG Tools is a compilation of helpful tools when developing a Role Playing Game (RPG). For now the gem has three classes: Die, Throw and CheckRoll. "
6
+ s.description = "RPG Tools is a compilation of helpful tools when developing a Role Playing Game (RPG). For now the gem has three classes: Die, Throw and CheckRoll."
7
7
  s.email = "ecasanovac@gmail.com"
8
8
  s.homepage = "https://github.com/roendal/rpg-tools"
9
9
  s.files = `git ls-files`.split("\n")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpg-tools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eduardo Casanova Cuesta
@@ -112,7 +112,7 @@ dependencies:
112
112
  type: :development
113
113
  name: capybara
114
114
  version_requirements: *id006
115
- description: "Some tools useful when creating a RPG: Die, Throw and CheckRoll."
115
+ description: "RPG Tools is a compilation of helpful tools when developing a Role Playing Game (RPG). For now the gem has three classes: Die, Throw and CheckRoll."
116
116
  email: ecasanovac@gmail.com
117
117
  executables: []
118
118
 
@@ -211,6 +211,6 @@ rubyforge_project:
211
211
  rubygems_version: 1.6.2
212
212
  signing_key:
213
213
  specification_version: 3
214
- summary: "Some tools useful when creating a RPG: Die, Throw and CheckRoll."
214
+ summary: "RPG Tools is a compilation of helpful tools when developing a Role Playing Game (RPG). For now the gem has three classes: Die, Throw and CheckRoll."
215
215
  test_files: []
216
216