chansu 0.1.1 → 0.1.2
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/README.md +30 -0
- data/chansu-0.1.1.gem +0 -0
- data/lib/chansu/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2bd3a9802f008e4b9045a46bc9025143a67963bbcdf7a587b794e97b0193704
|
|
4
|
+
data.tar.gz: 4ea0f19eca8a4e5fdcd5779e5fa443dc51ede58846254bcce035555253858504
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b5cfe052b373060bcc1b5a128cf3933b3fdfd641fad9fe5fc87cd5de64820289276c34c4b3a8dae33fd0ffe11c5060217bfb0afcd7f43736436e3f56bb06f9d
|
|
7
|
+
data.tar.gz: a241fb82a1711f896ada8e273a06a49b462b018e092a5455b746d922b420a3f45b4f7a9dece615e75c99dc6fb4c19a5bddaf903d27a715b9be19b90227522d44
|
data/README.md
CHANGED
|
@@ -36,6 +36,33 @@ Or just do
|
|
|
36
36
|
---
|
|
37
37
|
|
|
38
38
|
## 🛠️ Usage
|
|
39
|
+
|
|
40
|
+
### Basic chance
|
|
41
|
+
```ruby
|
|
42
|
+
chance # true/false with 50% chance
|
|
43
|
+
chance(10) # 10% chance
|
|
44
|
+
chance(0.65) # 60% chance
|
|
45
|
+
chance("38%") # 38% chance
|
|
46
|
+
```
|
|
47
|
+
It also receives a block
|
|
48
|
+
```ruby
|
|
49
|
+
chance(40) {
|
|
50
|
+
puts "There's a 40% chance this was printed"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Loop until probability is met
|
|
55
|
+
You are provided with two methods that take a block and execute it until it either success or fails
|
|
56
|
+
```ruby
|
|
57
|
+
until_success {
|
|
58
|
+
p "this will be printed until it is successfull!"
|
|
59
|
+
} #returns the number of attempts it took
|
|
60
|
+
|
|
61
|
+
until_failure(chance: 0.1, max_attempts: 25) {
|
|
62
|
+
p "this will be printed until it fails or hits 25 attempts!"
|
|
63
|
+
} #returns the number of attempts it took
|
|
64
|
+
```
|
|
65
|
+
Keep in mind the arguments work for both methods
|
|
39
66
|
### Probability DSL
|
|
40
67
|
```ruby
|
|
41
68
|
require "chansu"
|
|
@@ -70,6 +97,7 @@ always { puts "Guaranteed!" } # 100%
|
|
|
70
97
|
```ruby
|
|
71
98
|
require "chansu"
|
|
72
99
|
|
|
100
|
+
coin # :tails or :heads
|
|
73
101
|
dice # 2
|
|
74
102
|
dice(42) # 31
|
|
75
103
|
dice(15, 3) # [15, 9, 15]
|
|
@@ -78,7 +106,9 @@ d20 # 11
|
|
|
78
106
|
d100 # 90
|
|
79
107
|
dice("2d10") # {:rolls=>[9, 5], :total=>14}
|
|
80
108
|
dice("3d8+5") # {:rolls=>[3, 3, 4], :total=>15}
|
|
109
|
+
roll # is an alias of dice
|
|
81
110
|
```
|
|
111
|
+
|
|
82
112
|
---
|
|
83
113
|
## ⚙️ Config
|
|
84
114
|
### Controlling globals
|
data/chansu-0.1.1.gem
ADDED
|
Binary file
|
data/lib/chansu/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chansu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Santiago Calderon
|
|
@@ -9,8 +9,8 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
|
-
description:
|
|
13
|
-
|
|
12
|
+
description: |2-
|
|
13
|
+
|
|
14
14
|
Chansu is a Ruby DSL for working with randomness and probability.
|
|
15
15
|
It provides helpers like `chance("35%")`, `dice(6, 3)`, and RPG-style
|
|
16
16
|
aliases such as `d20` and `d100`. It also includes higher-level
|
|
@@ -30,6 +30,7 @@ files:
|
|
|
30
30
|
- README.md
|
|
31
31
|
- Rakefile
|
|
32
32
|
- chansu-0.1.0.gem
|
|
33
|
+
- chansu-0.1.1.gem
|
|
33
34
|
- lib/chansu.rb
|
|
34
35
|
- lib/chansu/dsl.rb
|
|
35
36
|
- lib/chansu/loops.rb
|