fifthed_sim 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddda2121cd3af4289eaa5961ed3d9f35630fa949
4
- data.tar.gz: d2a0e56526dcbf6940c2dcea645ebff45113364f
3
+ metadata.gz: 013d357049f4fc8bad49ca544b13df32f870a7a4
4
+ data.tar.gz: 3e28e9a9267b05a799dafb8f1f4b483c1b3d552e
5
5
  SHA512:
6
- metadata.gz: 2941d1d94a12b967b62fcd3702172698f59a3329c05cf135806dd7f34c6bfedb467e72f5c42249fe055e2a05fae8ecaa25df9cea5ebfa07d9af5d1b535f10f29
7
- data.tar.gz: 664dd785fecba83b45f0a3374238cf9dcf5eddf80d003c8cfe49fba3ef08be466e267fb165ebb77f207d82970d4ee1ffd0acf13efa183c1b52b24fba069531bf
6
+ metadata.gz: a96cd8c16966da8e5499a29449d0c60fbdfaa1547071ac9600654f0e63c468a2eae9960c9dd171886dc0ebb790167d6820ed0f34352a9ddaa26c0f25272d74bf
7
+ data.tar.gz: 7c301fcfae55be5335fc9d34dec483d1bcb599e5a4125d3f60040345ca87db2701227839b47eb875ab1093345d63eb57a2ec6a7a2014c60a2dc2a98cc2c17da4
data/exe/diceroll CHANGED
@@ -4,6 +4,4 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "../lib"))
4
4
  require 'fifthed_sim'
5
5
  require 'readline'
6
6
 
7
-
8
-
9
7
  FifthedSim::RollRepl.new.run
@@ -15,7 +15,8 @@ class FifthedSim::Compiler
15
15
  .as(:dice)
16
16
  end
17
17
  rule(:base_term) { (dice | number) >> space? }
18
- rule(:primary) { lparen >> addition >> rparen | base_term }
18
+ rule(:parenthetical) { lparen >> addition >> rparen }
19
+ rule(:primary) { parenthetical | base_term }
19
20
 
20
21
  rule(:add_op) { match('\+|-').as(:op) >> space? }
21
22
  rule(:addition) do
@@ -1,8 +1,11 @@
1
1
  module FifthedSim
2
2
  class RollRepl
3
- def initialize(inspect = true, errors = false)
3
+ def initialize(inspect: true,
4
+ errors: false,
5
+ auto_info: false)
4
6
  @inspect = inspect
5
7
  @errors = errors
8
+ @auto_info = auto_info
6
9
  end
7
10
 
8
11
  def run(kill_on_interrupt = false)
@@ -18,11 +21,15 @@ module FifthedSim
18
21
  end
19
22
  end
20
23
 
21
- def info(cmd)
24
+ def info_command(cmd)
22
25
  s = cmd.gsub(/info/, "").chomp
23
26
  if s.length > 0
24
- run_command(s)
27
+ roll(s)
25
28
  end
29
+ print_last_info
30
+ end
31
+
32
+ def print_last_info
26
33
  return error_msg("Have nothing to get info of") unless @last_roll
27
34
  lb = ->(x){Rainbow(x).color(:yellow).bright.to_s + ": "}
28
35
  a = %i(max min percentile).map do |p|
@@ -33,7 +40,8 @@ module FifthedSim
33
40
 
34
41
  def reroll
35
42
  return error_msg("Nothing to reroll") unless @last_roll
36
- display_roll(@last_roll.reroll)
43
+ @last_roll = @last_roll.reroll
44
+ display_roll(@last_roll)
37
45
  end
38
46
 
39
47
  def run_cmd(cmd)
@@ -42,15 +50,16 @@ module FifthedSim
42
50
  self.exit
43
51
  when "rr", "reroll"
44
52
  self.reroll
45
- when /info/
46
-
47
- self.info(cmd)
53
+ when "info"
54
+ info_command(cmd)
48
55
  when "help"
49
56
  self.help
50
57
  when "inspect"
51
58
  toggle_inspect
52
59
  when "errors"
53
60
  toggle_errors
61
+ when "autoinfo"
62
+ toggle_auto_info
54
63
  else
55
64
  self.roll(cmd)
56
65
  end
@@ -69,12 +78,9 @@ module FifthedSim
69
78
  end
70
79
 
71
80
  def display_roll(r)
72
- if @inspect
73
- puts " = " + r.value_equation(terminal: true)
74
- puts " => " + Rainbow(r.value.to_s).underline.bright.to_s
75
- else
76
- puts r.value.to_s
77
- end
81
+ puts " = " + r.value_equation(terminal: true) if @inspect
82
+ puts " => " + Rainbow(r.value.to_s).underline.bright.to_s
83
+ print_last_info if @auto_info
78
84
  end
79
85
 
80
86
  def error_msg(msg)
@@ -89,7 +95,7 @@ module FifthedSim
89
95
  end
90
96
  end
91
97
 
92
- [:inspect, :errors].each do |m|
98
+ [:inspect, :errors, :auto_info].each do |m|
93
99
  send(:define_method, "toggle_#{m}") do
94
100
  t = instance_variable_get("@#{m}")
95
101
  puts "#{m}: #{t.inspect} => #{(!t).inspect}"
@@ -1,5 +1,5 @@
1
1
  module FifthedSim
2
2
  ##
3
3
  # Constant version string
4
- VERSION = "0.2.3"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fifthed_sim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Super
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-21 00:00:00.000000000 Z
11
+ date: 2017-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet