Olib 0.1.2 → 2.0.0.pre.rc.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.
Files changed (69) hide show
  1. checksums.yaml +5 -5
  2. data/Olib.gemspec +1 -1
  3. data/README.md +0 -0
  4. data/TODOS.md +0 -0
  5. data/lib/Olib.rb +6 -79
  6. data/lib/Olib/actor/actor.rb +0 -0
  7. data/lib/Olib/area.rb +22 -37
  8. data/lib/Olib/bounty.rb +8 -10
  9. data/lib/Olib/character/char.rb +64 -68
  10. data/lib/Olib/character/disk.rb +31 -9
  11. data/lib/Olib/character/group.rb +122 -40
  12. data/lib/Olib/character/inventory.rb +0 -0
  13. data/lib/Olib/character/mind.rb +0 -0
  14. data/lib/Olib/character/stance.rb +0 -0
  15. data/lib/Olib/combat/creature.rb +77 -128
  16. data/lib/Olib/combat/creatures.rb +52 -36
  17. data/lib/Olib/core/action.rb +8 -0
  18. data/lib/Olib/core/container.rb +32 -236
  19. data/lib/Olib/core/containers.rb +42 -0
  20. data/lib/Olib/core/errors.rb +69 -71
  21. data/lib/Olib/core/exist.rb +88 -0
  22. data/lib/Olib/core/item.rb +43 -598
  23. data/lib/Olib/core/kinds.rb +6 -0
  24. data/lib/Olib/core/rummage.rb +42 -0
  25. data/lib/Olib/core/transaction.rb +53 -0
  26. data/lib/Olib/core/use.rb +2 -5
  27. data/lib/Olib/core/utils.rb +25 -123
  28. data/lib/Olib/core/verbs.rb +304 -0
  29. data/lib/Olib/dictionary/dictionary.rb +150 -150
  30. data/lib/Olib/ext/hash.rb +7 -0
  31. data/lib/Olib/ext/matchdata.rb +14 -0
  32. data/lib/Olib/ext/string.rb +9 -0
  33. data/lib/Olib/ext/symbol.rb +13 -0
  34. data/lib/Olib/go2.rb +48 -112
  35. data/lib/Olib/loot.rb +44 -0
  36. data/lib/Olib/npcs/npc.rb +4 -0
  37. data/lib/Olib/npcs/npcs.rb +45 -0
  38. data/lib/Olib/objects/box.rb +1 -1
  39. data/lib/Olib/objects/clothing.rb +1 -1
  40. data/lib/Olib/objects/herb.rb +1 -1
  41. data/lib/Olib/objects/jar.rb +0 -0
  42. data/lib/Olib/objects/jewel.rb +7 -7
  43. data/lib/Olib/objects/jewelry.rb +1 -1
  44. data/lib/Olib/objects/scroll.rb +1 -1
  45. data/lib/Olib/objects/uncommon.rb +1 -1
  46. data/lib/Olib/objects/wand.rb +1 -1
  47. data/lib/Olib/pattern_matching/any.rb +11 -0
  48. data/lib/Olib/pattern_matching/err.rb +4 -0
  49. data/lib/Olib/pattern_matching/ok.rb +4 -0
  50. data/lib/Olib/pattern_matching/outcome.rb +35 -0
  51. data/lib/Olib/pattern_matching/pattern_matching.rb +5 -0
  52. data/lib/Olib/pattern_matching/result.rb +80 -0
  53. data/lib/Olib/pattern_matching/rill.rb +43 -0
  54. data/lib/Olib/pattern_matching/where.rb +4 -0
  55. data/lib/Olib/shops.rb +147 -155
  56. data/lib/Olib/supervisor/supervisor.rb +0 -0
  57. data/lib/Olib/version.rb +1 -1
  58. data/lib/Olib/xml.rb +43 -0
  59. metadata +28 -15
  60. data/lib/Olib/core/extender.rb +0 -29
  61. data/lib/Olib/interface/queryable.rb +0 -50
  62. data/lib/Olib/npcs.rb +0 -5
  63. data/lib/Olib/pattern.rb +0 -34
  64. data/lib/Olib/storage/app_data.rb +0 -32
  65. data/lib/Olib/try/try.rb +0 -58
  66. data/lib/Olib/utils/cli.rb +0 -81
  67. data/lib/Olib/utils/help_menu.rb +0 -166
  68. data/lib/Olib/utils/monsterbold.rb +0 -5
  69. data/lib/Olib/utils/vbulletin.rb +0 -101
@@ -0,0 +1,44 @@
1
+ class Loot
2
+ include Enumerable
3
+
4
+ ALL = -> item { true }
5
+
6
+ attr_reader :predicate
7
+
8
+ def initialize(&predicate)
9
+ @predicate = predicate
10
+ end
11
+
12
+ def each()
13
+ GameObj.loot.to_a.map do |obj| Item.new(obj) end
14
+ .reject(&Where[noun: "disk"])
15
+ .select(&@predicate)
16
+ .each do |item| yield(item) end
17
+ end
18
+
19
+ def respond_to_missing?(method, include_private = false)
20
+ to_a.respond_to?(method) or super
21
+ end
22
+
23
+ def method_missing(method, *args)
24
+ if to_a.respond_to?(method)
25
+ to_a.send(method, *args)
26
+ else
27
+ super(method, *args)
28
+ end
29
+ end
30
+
31
+
32
+ def self.method_missing(method, *args, &block)
33
+ if respond_to?(method)
34
+ Loot.new.send(method, *args, &block)
35
+ else
36
+ super(method, *args, &block)
37
+ end
38
+ end
39
+
40
+ def self.respond_to?(method)
41
+ return super(method) unless Loot.new.respond_to?(method)
42
+ return true
43
+ end
44
+ end
@@ -0,0 +1,4 @@
1
+ require "Olib/core/exist"
2
+
3
+ class NPC < Exist
4
+ end
@@ -0,0 +1,45 @@
1
+ require "Olib/npcs/npc"
2
+ # a collection for managing all of the npcs in a room
3
+
4
+ class NPCS
5
+ include Enumerable
6
+
7
+ ALL = -> npc { true }
8
+
9
+ attr_reader :predicate
10
+
11
+ def initialize(&predicate)
12
+ @predicate = predicate
13
+ end
14
+
15
+ def each()
16
+ GameObj.npcs.to_a.map do |obj| NPC.new(obj) end
17
+ .select(&@predicate)
18
+ .each do |npc| yield(npc) unless npc.tags.include?(:aggressive) end
19
+ end
20
+
21
+ def respond_to_missing?(method, include_private = false)
22
+ to_a.respond_to?(method) or super
23
+ end
24
+
25
+ def method_missing(method, *args)
26
+ if to_a.respond_to?(method)
27
+ to_a.send(method, *args)
28
+ else
29
+ super(method, *args)
30
+ end
31
+ end
32
+
33
+ def self.method_missing(method, *args, &block)
34
+ if respond_to?(method)
35
+ NPCS.new.send(method, *args, &block)
36
+ else
37
+ super(method, *args, &block)
38
+ end
39
+ end
40
+
41
+ def self.respond_to?(method)
42
+ return super(method) unless NPCS.new.respond_to?(method)
43
+ return true
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
 
2
- class Box < Olib::Item
2
+ class Box < Item
3
3
  end
@@ -1,2 +1,2 @@
1
- class Clothing < Olib::Item
1
+ class Clothing < Item
2
2
  end
@@ -1,2 +1,2 @@
1
- class Herb < Olib::Item
1
+ class Herb < Item
2
2
  end
File without changes
@@ -1,18 +1,18 @@
1
1
  # Class to interact with gems
2
2
  # overwriting Gem is a bad idea
3
- class Jewel < Olib::Item
3
+ class Jewel < Item
4
4
  attr_accessor :quality, :value
5
5
 
6
6
  def appraise
7
- result = dothistimeout "appraise ##{@id}", 3, /#{Olib::Dictionary.gems[:appraise].values.join('|')}/
7
+ result = dothistimeout "appraise ##{@id}", 3, /#{Dictionary.gems[:appraise].values.join('|')}/
8
8
  case result
9
- when Olib::Dictionary.gems[:appraise][:gemshop]
9
+ when Dictionary.gems[:appraise][:gemshop]
10
10
  # handle gemshop appraisal
11
11
  @value = $1.to_i
12
- when Olib::Dictionary.gems[:appraise][:player]
12
+ when Dictionary.gems[:appraise][:player]
13
13
  @value = $3.to_i
14
14
  @quality = $2
15
- when Olib::Dictionary.gems[:appraise][:failure]
15
+ when Dictionary.gems[:appraise][:failure]
16
16
  waitrt?
17
17
  self.appraise
18
18
  else
@@ -22,11 +22,11 @@ class Jewel < Olib::Item
22
22
  end
23
23
 
24
24
  def normalized_name
25
- Olib::Dictionary.gems[:singularize].call(@name)
25
+ Dictionary.gems[:singularize].call(@name)
26
26
  end
27
27
 
28
28
  def sell
29
29
  result = take
30
- fput "sell ##{@id}" if result =~ Olib::Dictionary.get[:success]
30
+ fput "sell ##{@id}" if result =~ Dictionary.get[:success]
31
31
  end
32
32
  end
@@ -1,4 +1,4 @@
1
- class Jewelry < Olib::Item
1
+ class Jewelry < Item
2
2
  HEIRLOOM = /are the initials ([A-Z]{2})./
3
3
 
4
4
  attr_accessor :heirloom
@@ -1,4 +1,4 @@
1
- class Scroll < Olib::Item
1
+ class Scroll < Item
2
2
  @@whitelist = [
3
3
  101, 102, 103, 107, 116, 120,
4
4
  202, 211, 215, 219,
@@ -1,2 +1,2 @@
1
- class Uncommon < Olib::Item
1
+ class Uncommon < Item
2
2
  end
@@ -1,2 +1,2 @@
1
- class Wand < Olib::Item
1
+ class Wand < Item
2
2
  end
@@ -0,0 +1,11 @@
1
+ require "Olib/pattern_matching/result"
2
+
3
+ class Any < Result
4
+ def self.===(*args)
5
+ true
6
+ end
7
+
8
+ def ===(other)
9
+ true
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ require "Olib/pattern_matching/result"
2
+
3
+ class Err < Result
4
+ end
@@ -0,0 +1,4 @@
1
+ require "Olib/pattern_matching/result"
2
+
3
+ class Ok < Result
4
+ end
@@ -0,0 +1,35 @@
1
+ require "Olib/ext/matchdata"
2
+
3
+ class Outcome
4
+ HANDLEBARS = %r[{{(?<var>.*?)}}]
5
+
6
+ def self.union(outcomes, **vars)
7
+ Regexp.union(outcomes.map do |outcome| outcome.prepare(**vars) end)
8
+ end
9
+
10
+ def self.prepare(template, vars)
11
+ template.gsub(HANDLEBARS) do |name|
12
+ name = name.match(HANDLEBARS).to_struct.var.to_sym
13
+ if vars.respond_to?(name)
14
+ vars.send(name)
15
+ elsif vars.respond_to?(:fetch)
16
+ vars.fetch(name)
17
+ elsif vars.respond_to?(:[])
18
+ vars[name]
19
+ else
20
+ raise Exception.new "could not serialize var: #{name} of #{vars.class.name} in Outcome"
21
+ end
22
+ end
23
+ end
24
+
25
+ attr_reader :template
26
+
27
+ def initialize(template)
28
+ @template = template
29
+ end
30
+
31
+ def prepare(vars)
32
+ return @template if @template.is_a?(Regexp)
33
+ %r[#{Outcome.prepare(@template, vars)}]
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ require "Olib/pattern_matching/err"
2
+ require "Olib/pattern_matching/ok"
3
+ require "Olib/pattern_matching/result"
4
+ require "Olib/pattern_matching/where"
5
+ include Result::Constructors
@@ -0,0 +1,80 @@
1
+ class Result
2
+ def self.included(ctx)
3
+ ctx.include(Result::Constructors)
4
+ ctx.extend(Result:Constructors)
5
+ end
6
+
7
+ def self.of(); -> val { self.new(val); }; end
8
+ class << self; alias :[] :new; end
9
+
10
+ def self.compare(this, other)
11
+ return _match_class(this, other) if other.is_a?(Class)
12
+ return _match_result(this, other) if this.is_a?(Result) and other.is_a?(Result)
13
+ return _compare_object_shape(this.val, other) if this.val.is_a?(Object) and other.is_a?(Hash)
14
+ return _compare_object_shape(other, this.val) if this.val.is_a?(Hash) and other.is_a?(Object)
15
+ return _compare_values(this.val, other)
16
+ end
17
+
18
+ def self._match_class(this, other)
19
+ return this.is_a?(other) if [Err, Ok].include?(other)
20
+ this.val.is_a?(other)
21
+ end
22
+
23
+ def self._compare_values(left, right)
24
+ left == Any || right == Any || left === right
25
+ end
26
+
27
+ def self._compare_object_shape(this, expected)
28
+ fail "expected Shape(#{expected.inspect}) must be a Hash" unless expected.is_a?(Hash)
29
+ ## fail fast when not possible to be true
30
+ return false if this.is_a?(Hash) and expected.size > this.size
31
+ ## compare all keys
32
+ expected.all? do |k, v|
33
+ if this.respond_to?(k.to_sym)
34
+ _compare_values(v, this.send(k.to_sym))
35
+ elsif this.respond_to?(:[])
36
+ _compare_values(v, this[k.to_s]) or _compare_values(v, this[k.to_sym])
37
+ else
38
+ false
39
+ end
40
+ end
41
+ end
42
+
43
+ def self._match_result(this, other)
44
+ return false unless this.is_a?(other.class)
45
+ return _compare_object_shape(this.val, other.val) if this.val.is_a?(Object) and other.val.is_a?(Hash)
46
+ return _compare_values(this.val, other.val)
47
+ end
48
+
49
+ attr_reader :val
50
+
51
+ def initialize(val)
52
+ @val = val
53
+ end
54
+
55
+ def ==(other)
56
+ self.===(other)
57
+ end
58
+
59
+ def ===(other)
60
+ Result.compare(self, other)
61
+ end
62
+
63
+ def to_json(*args)
64
+ @val.to_json(*args)
65
+ end
66
+
67
+ def to_proc
68
+ -> other { Result.compare(self, other) }
69
+ end
70
+
71
+ module Constructors
72
+ def Ok(*args)
73
+ Ok[*args]
74
+ end
75
+
76
+ def Err(*args)
77
+ Err[*args]
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,43 @@
1
+ require "Olib/xml"
2
+ require "Olib/pattern_matching/outcome"
3
+ require "Olib/ext/matchdata"
4
+
5
+ class Rill
6
+ PROMPT = /<prompt/
7
+
8
+ include Enumerable
9
+ attr_reader :close, :start, :mode
10
+
11
+ def initialize(start: nil, close: PROMPT, mode: :xml)
12
+ fail "Rill.new() requires :start argument" if start.nil?
13
+ @mode = mode
14
+ @close = Outcome.new(close)
15
+ @start = Outcome.new(start)
16
+ end
17
+
18
+ def capture(obj, command_template)
19
+ return capture_xml(obj, command_template) if mode.eql?(:xml)
20
+ fail "non-XML mode not implemented yet"
21
+ end
22
+
23
+ def capture_xml(obj, command_template)
24
+ begin_pattern = @start.prepare(obj)
25
+ end_pattern = @close.prepare(obj)
26
+ command = Outcome.prepare(command_template, obj)
27
+ state = :start
28
+ lines = []
29
+ matches = {}
30
+ XML.cmd(command) do |line|
31
+ state = :open if line.match(begin_pattern)
32
+ lines << line if state.eql?(:open)
33
+ if (result = (line.match(begin_pattern) || line.match(end_pattern)))
34
+ matches.merge!(result.to_h)
35
+ end
36
+ return [matches, lines] if (line.match(end_pattern) and state.eql?(:open))
37
+ end
38
+ end
39
+
40
+ def each(&block)
41
+ @lines.each(&block)
42
+ end
43
+ end
@@ -0,0 +1,4 @@
1
+ require "Olib/pattern_matching/result"
2
+
3
+ class Where < Result
4
+ end
@@ -1,177 +1,169 @@
1
- module Olib
2
- module Shop
1
+ require "Olib/core/exist"
3
2
 
4
- @@containers = []
3
+ module Shop
5
4
 
6
- def Shop.items
7
- Shop.containers.map { |container| container.contents }.flatten
8
- end
5
+ @@containers = []
6
+
7
+ def Shop.items
8
+ Shop.containers.map { |container| container.contents }.flatten
9
+ end
10
+
11
+ def Shop.containers
12
+ #fput "look"
13
+ @@containers = [
14
+ GameObj.loot,
15
+ GameObj.room_desc
16
+ ]
17
+ .flatten
18
+ .compact
19
+ .select { |container| !(container.name =~ /^([A-z][a-z]+ disk$)/)}
20
+ .map { |container| Shop::Container.new(container) }
21
+
22
+ @@containers
9
23
 
10
- def Shop.containers
11
- #fput "look"
12
- @@containers = [
13
- GameObj.loot,
14
- GameObj.room_desc
15
- ]
16
- .flatten
17
- .compact
18
- .select { |container| !(container.name =~ /^([A-z][a-z]+ disk$)/)}
19
- .map { |container| Shop::Container.new(container) }
24
+ end
25
+
26
+ def Shop.cache
27
+ @@containers
28
+ end
20
29
 
21
- @@containers
30
+ class Container < Exist
31
+ attr_accessor :show, :nested, :containers, :id, :cache, :props
32
+
33
+ def to_s
34
+ info = {}
35
+ info[:name] = @name
36
+ info[:noun] = @noun
37
+ info[:props] = @props
38
+ info[:cache] = @cache
39
+ info.to_s
40
+ end
41
+
42
+ def initialize(obj)
43
+ @cache = Hash.new
44
+ @props = Hash.new
45
+ super(obj)
46
+ end
22
47
 
48
+ def action(verb)
49
+ "#{verb} ##{@id}"
23
50
  end
24
51
 
25
- def Shop.cache
26
- @@containers
52
+ def look
53
+ self
27
54
  end
28
55
 
29
- class Container < Olib::Gameobj_Extender
30
- attr_accessor :show, :nested, :containers, :id, :cache, :props
31
-
32
- def to_s
33
- info = {}
34
- info[:name] = @name
35
- info[:noun] = @noun
36
- info[:props] = @props
37
- info[:cache] = @cache
38
- info.to_s
39
- end
56
+ # detect nested containers
57
+ def at
40
58
 
41
- def initialize(obj)
42
- @cache = Hash.new
43
- @props = Hash.new
44
- super(obj)
45
- end
46
-
47
- def action(verb)
48
- "#{verb} ##{@id}"
49
- end
50
-
51
- def look
52
- self
53
- end
54
-
55
- # detect nested containers
56
- def at
59
+ Olib.wrap_stream(action 'look at') { |line|
57
60
 
58
- Olib.wrap_stream(action 'look at') { |line|
59
-
60
- raise Olib::Errors::Mundane if line =~ /You see nothing unusual/
61
+ raise Errors::Mundane if line =~ /You see nothing unusual/
61
62
 
62
- if line =~ /Looking at the (.*?), you see (?<nested>.*)/
63
- @nested = true
63
+ if line =~ /Looking at the (.*?), you see (?<nested>.*)/
64
+ @nested = true
64
65
 
65
- @containers = line.match(/Looking at the (.*?), you see (?<nested>.*)/)[:nested].scan(/<a exist="(?<id>.*?)" noun="(?<noun>.*?)">(?<name>.*?)<\/a>/).map {|matches|
66
- Container.new GameObj.new *matches
67
- }
68
- raise Olib::Errors::Prempt
69
- end
70
-
71
- }
72
-
73
- self
74
- end
75
-
76
- def nested?
77
- @nested || false
78
- end
79
-
80
- def in
81
- return self unless @id
82
- Olib.wrap_stream(action 'look in') { |line|
83
- raise Olib::Errors::Mundane if line=~ /^There is nothing in there|^That is closed|filled with a variety of garbage|Total items:/
84
- raise Olib::Errors::Prempt if line =~ /^In the (.*?) you see/
85
- }
86
- self
87
- end
88
-
89
- def on
90
- return self unless @id
91
- Olib.wrap_stream(action 'look on') { |line|
92
- raise Olib::Errors::Mundane if line =~ /^There is nothing on there/
93
- raise Olib::Errors::Prempt if line =~ /^On the (.*?) you see/
94
- }
95
- self
96
- end
97
-
98
- def contents
99
- look.in.on unless GameObj[@id].contents
100
- GameObj[@id].contents.map {|i| Item.new(i).define('container', @id) }
101
- end
102
-
103
- def containers
104
- @containers
105
- end
66
+ @containers = line.match(/Looking at the (.*?), you see (?<nested>.*)/)[:nested].scan(/<a exist="(?<id>.*?)" noun="(?<noun>.*?)">(?<name>.*?)<\/a>/).map {|matches|
67
+ Container.new GameObj.new *matches
68
+ }
69
+ raise Errors::Prempt
70
+ end
71
+
72
+ }
73
+
74
+ self
106
75
  end
76
+
77
+ def nested?
78
+ @nested || false
79
+ end
80
+
81
+ def in
82
+ return self unless @id
83
+ Olib.wrap_stream(action 'look in') { |line|
84
+ raise Errors::Mundane if line=~ /^There is nothing in there|^That is closed|filled with a variety of garbage|Total items:/
85
+ raise Errors::Prempt if line =~ /^In the (.*?) you see/
86
+ }
87
+ self
88
+ end
89
+
90
+ def on
91
+ return self unless @id
92
+ Olib.wrap_stream(action 'look on') { |line|
93
+ raise Errors::Mundane if line =~ /^There is nothing on there/
94
+ raise Errors::Prempt if line =~ /^On the (.*?) you see/
95
+ }
96
+ self
97
+ end
98
+
99
+ def contents
100
+ look.in.on unless GameObj[@id].contents
101
+ GameObj[@id].contents.map {|i| Item.new(i).define('container', @id) }
102
+ end
103
+
104
+ def containers
105
+ @containers
106
+ end
107
+ end
108
+
109
+ class Playershop
110
+ @@noncontainers = [ "wall", "ceiling", "permit", "floor", "helmet", "snowshoes",
111
+ "candelabrum", "flowerpot", "Hearthstone", "bear", "candelabra",
112
+ "sculpture", "anvil", "tapestry", "portrait", "Wehnimer", "spiderweb",
113
+ "rug", "fountain", "longsword", "ship", "panel", "painting", "armor",
114
+ "flowers", "head", "plate", "vase", "pillows", "mask", "skeleton", "fan",
115
+ "flag", "statue", "mat", "plaque", "mandolin", "plant", "sign" ]
107
116
 
108
- class Playershop
109
- @@noncontainers = [ "wall", "ceiling", "permit", "floor", "helmet", "snowshoes",
110
- "candelabrum", "flowerpot", "Hearthstone", "bear", "candelabra",
111
- "sculpture", "anvil", "tapestry", "portrait", "Wehnimer", "spiderweb",
112
- "rug", "fountain", "longsword", "ship", "panel", "painting", "armor",
113
- "flowers", "head", "plate", "vase", "pillows", "mask", "skeleton", "fan",
114
- "flag", "statue", "mat", "plaque", "mandolin", "plant", "sign" ]
115
-
116
- def Playershop.containers
117
- Shop.containers.reject { |container|
118
- @@noncontainers.include? container.noun
119
- }
120
- end
121
-
122
- def Playershop.balance
123
- balance = 0
124
- Olib.wrap_stream('shop withdraw') { |line|
125
- next if line =~ /^Usage: SHOP WITHDRAW <amount>/
126
- raise Olib::Errors::Prempt if line =~ /^You must be in your shop to do that.$/
127
-
128
- if line =~ /Your shop's bank account is currently ([\d]+)/
129
- balance = $1.to_i
130
- raise Olib::Errors::Prempt
117
+ def Playershop.containers
118
+ Shop.containers.reject { |container|
119
+ @@noncontainers.include? container.noun
120
+ }
121
+ end
122
+
123
+ def Playershop.balance
124
+ balance = 0
125
+ Olib.wrap_stream('shop withdraw') { |line|
126
+ next if line =~ /^Usage: SHOP WITHDRAW <amount>/
127
+ raise Errors::Prempt if line =~ /^You must be in your shop to do that.$/
128
+
129
+ if line =~ /Your shop's bank account is currently ([\d]+)/
130
+ balance = $1.to_i
131
+ raise Errors::Prempt
132
+ end
133
+
134
+ }
135
+ return balance
136
+ end
137
+
138
+ def Playershop.where(conditions)
139
+ Playershop.items.select { |item|
140
+ !conditions.keys.map { |key|
141
+ if conditions[key].class == Array
142
+ item.props[key].class == Array && !conditions[key].map { |ele| item.props[key].include? ele }.include?(false)
143
+ else
144
+ item.props[key] == conditions[key]
131
145
  end
146
+ }.include?(false)
147
+ }
148
+ end
132
149
 
133
- }
134
- return balance
135
- end
136
-
137
- def Playershop.where(conditions)
138
- Playershop.items.select { |item|
139
- !conditions.keys.map { |key|
140
- if conditions[key].class == Array
141
- item.props[key].class == Array && !conditions[key].map { |ele| item.props[key].include? ele }.include?(false)
142
- else
143
- item.props[key] == conditions[key]
144
- end
145
- }.include?(false)
146
- }
147
- end
148
-
149
- def Playershop.find_by_tags(*tags)
150
-
151
- Playershop.items.select { |item|
152
- !tags.map {|tag| item.is?(tag) }.include? false
153
- }
154
- end
155
-
156
- def Playershop.sign
157
- Shop.containers.select { |container|
158
- container.noun == 'sign'
159
- }[0]
160
- end
161
-
162
- def Playershop.items
163
- Playershop.containers.map { |container|
164
- container.contents
165
- }.flatten
166
- end
150
+ def Playershop.find_by_tags(*tags)
151
+
152
+ Playershop.items.select { |item|
153
+ !tags.map {|tag| item.is?(tag) }.include? false
154
+ }
167
155
  end
168
- end
169
156
 
170
- def Olib.Playershop
171
- Olib::Shop::Playershop
172
- end
157
+ def Playershop.sign
158
+ Shop.containers.select { |container|
159
+ container.noun == 'sign'
160
+ }[0]
161
+ end
173
162
 
174
- def Olib.Shop
175
- Olib::Shop
163
+ def Playershop.items
164
+ Playershop.containers.map { |container|
165
+ container.contents
166
+ }.flatten
167
+ end
176
168
  end
177
169
  end