ceml 0.5.6 → 0.5.7

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.6
1
+ 0.5.7
data/ceml.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ceml}
8
- s.version = "0.5.6"
8
+ s.version = "0.5.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joe Edelman"]
12
- s.date = %q{2011-01-18}
12
+ s.date = %q{2011-01-21}
13
13
  s.description = %q{a language for coordinating real world events}
14
14
  s.email = %q{joe@citizenlogistics.com}
15
15
  s.extra_rdoc_files = [
data/lib/ceml/driver.rb CHANGED
@@ -16,7 +16,7 @@ module CEML
16
16
  PLAYERS[id] ||= []
17
17
  INCIDENTS[id] ||= CEML::Incident.new script, id if script
18
18
  raise "no incident #{id}" unless INCIDENTS[id]
19
- yield INCIDENTS[id], PLAYERS[id] if block_given?
19
+ yield INCIDENTS[id], PLAYERS[id], {} if block_given?
20
20
  id
21
21
  end
22
22
 
@@ -26,8 +26,8 @@ module CEML
26
26
  script.post candidate, LOCATIONS[script]
27
27
  LOCATIONS[script].delete_if do |loc|
28
28
  next unless loc.cast
29
- with_incident nil, script do |incident, players|
30
- loc.cast.each{ |guy| subpost incident, players, guy.initial_state }
29
+ with_incident nil, script do |incident, players, metadata|
30
+ loc.cast.each{ |guy| subpost incident, players, metadata, guy.initial_state }
31
31
  end
32
32
  end
33
33
  end
@@ -37,12 +37,13 @@ module CEML
37
37
  end
38
38
 
39
39
  def post incident_id, player = nil
40
- with_incident incident_id do |incident, players|
41
- subpost incident, players, player
40
+ with_incident incident_id do |incident, players, metadata|
41
+ subpost incident, players, metadata, player
42
42
  end
43
43
  end
44
+ alias_method :run, :post
44
45
 
45
- def subpost incident, players, player = nil
46
+ def subpost incident, players, metadata, player = nil
46
47
  if player
47
48
  player_id = player[:id]
48
49
  player[:roles] = Set.new([*player[:roles] || []])
@@ -56,18 +57,14 @@ module CEML
56
57
  end
57
58
  incident.run(players) do |player, meth, what|
58
59
  meth = "player_#{meth}"
59
- send(meth, incident.id, player, what) if respond_to? meth
60
+ send(meth, incident.id, metadata, player, what) if respond_to? meth
60
61
  end
61
62
  end
62
63
 
63
64
  JUST_SAID = {}
64
- def player_said(incident_id, player, what)
65
+ def player_said(incident_id, metadata, player, what)
65
66
  JUST_SAID[player[:id]] = what
66
67
  puts "Said #{what.inspect}"
67
68
  end
68
-
69
- # def player_delay(incident_id, player, seconds)
70
- # sleep seconds if seconds < 20
71
- # end
72
69
  end
73
70
  end
data/lib/ceml/incident.rb CHANGED
@@ -69,8 +69,11 @@ module CEML
69
69
  end
70
70
 
71
71
  def expand(role, var)
72
- return (this[:qs_answers]||{})[var] if role =~ /^his|her$/
73
- role = nil if role == 'otherguy'
72
+ case role
73
+ when 'his', 'her', 'their'; return qs_answers[var]
74
+ when 'world', 'game', 'exercise', 'group'; return (cb :world, var)
75
+ when 'somebody', 'someone'; role = nil
76
+ end
74
77
  role = role.to_sym if role
75
78
  @players.each do |p|
76
79
  next if p == this
@@ -35,11 +35,11 @@ grammar Casting
35
35
  (rolename &and / range ws qualifier ws rolename / range ws rolename / qualifier ws rolename / rolename) {
36
36
  def name; if respond_to? :rolename then rolename.text_value else text_value end; end
37
37
  def min
38
- return range.min if respond_to? :range
38
+ return range.value.min if respond_to? :range
39
39
  name =~ /s$/ ? 2 : 1
40
40
  end
41
41
  def max
42
- return range.max if respond_to? :range
42
+ return range.value.max if respond_to? :range
43
43
  name =~ /s$/ ? 10000 : 1
44
44
  end
45
45
  def qualifiers
@@ -22,12 +22,9 @@ grammar Lexer
22
22
  end
23
23
 
24
24
  rule number
25
- ([1-9]+ [0-9]* / '0' / 'an' / 'a' / 'one' / 'the') {
25
+ ([1-9]+ [0-9]* / '0') {
26
26
  def value
27
- case text_value
28
- when 'a', 'an', 'the', 'one' then 1
29
- else text_value.to_i
30
- end
27
+ text_value.to_i
31
28
  end
32
29
  }
33
30
  end
@@ -66,16 +63,22 @@ grammar Lexer
66
63
  end
67
64
 
68
65
  rule range
69
- min:number max:('+' / '-' number)?
70
- {
71
- def min
72
- super.value
73
- end
74
- def max
75
- return min if super.empty?
76
- return 10000 if super.text_value == '+'
77
- return super.number.text_value.to_i
78
- end
66
+ (
67
+ min:number '-' max:number / floor:number '+'? /
68
+ 'an' / 'a' / 'one' / 'the' / 'some' / 'several' / 'many'
69
+ ) {
70
+ def value
71
+ case text_value
72
+ when 'an', 'a', 'one', 'the' then (1..1)
73
+ when 'some' then (1..10000)
74
+ when 'several' then (3..10000)
75
+ when 'many' then (5..10000)
76
+ when /^\d+\+$/ then (floor.value..10000)
77
+ when /^\d+\-\d+$/ then (min.value..max.value)
78
+ when /^\d+$/ then (floor.value..floor.value)
79
+ else raise 'hell'
80
+ end
81
+ end
79
82
  }
80
83
  end
81
84
 
@@ -5,7 +5,7 @@ COMPLIMENT_SCRIPT = <<XXX
5
5
  "Overwhelm a specific person with compliments"
6
6
  gather 5-20 players within 4 blocks
7
7
  ask organizer re target: Describe their appearance and location
8
- tell agents: Look for |otherguy.target| and compliment them briefly, then move on.
8
+ tell agents: Look for |somebody.target| and compliment them briefly, then move on.
9
9
  XXX
10
10
 
11
11
  JANE_SCRIPT = <<XXX
@@ -144,8 +144,8 @@ ASKCHAIN_SCRIPT = <<XXX
144
144
  "Meet your neighbor"
145
145
  gather 2 players within 1 block
146
146
  ask players re color: what's your favorite color?
147
- ask players re observation: find someone near you with the color |otherguy.color|. what are they wearing?
148
- ask players re rightmatch: are you wearing |otherguy.observation|?
147
+ ask players re observation: find someone near you with the color |somebody.color|. what are they wearing?
148
+ ask players re rightmatch: are you wearing |somebody.observation|?
149
149
  ask players re task: take your new partner and see if you can find something beautiful in the park.
150
150
  XXX
151
151
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 6
9
- version: 0.5.6
8
+ - 7
9
+ version: 0.5.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Edelman
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-18 00:00:00 -08:00
17
+ date: 2011-01-21 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency