Olib 2.0.0.pre.rc.2 → 2.0.0.pre.rc.3
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/lib/Olib/combat/creature.rb +13 -0
- data/lib/Olib/combat/creatures.rb +8 -3
- data/lib/Olib/core/container.rb +4 -0
- data/lib/Olib/core/containers.rb +37 -18
- data/lib/Olib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88c17ccdc2fc52aecad952d952a46005a5fbff7103a1b650d29d4d65f437a17a
|
4
|
+
data.tar.gz: 187d49baaf0362d38b87805b5beb71e345ce95654588095020b4a8de0f190a8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72af6ca80a60fa8527c7edbcab8697a8e8730989866d90a73f094dbdb5e550b4e1171e609c5fcc6ede53a8b9e4e4b8fd94e0a4cdf79d05d01f3ada904b2b543d
|
7
|
+
data.tar.gz: c6a9e86b1b0c33355a30e1262fde92800b82edc50e13dee9bcf048fdfb942819c9db3484e90e2ce443331316baed64130d6ee2ee3a7d43515695d7e4e1ff898e
|
data/lib/Olib/combat/creature.rb
CHANGED
@@ -49,12 +49,25 @@ class Creature < Exist
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def self.stem_name(foe)
|
53
|
+
foe.name.split(" ").slice(1..-1).join(" ")
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.add_boss_type(foe)
|
57
|
+
return if foe.tags.include?(:aggressive)
|
58
|
+
if GameObj.type_data["aggressive npc"][:name].match stem_name(foe)
|
59
|
+
foe.tags << :aggressive
|
60
|
+
foe.tags << :npc
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
52
64
|
attr_accessor :wounds, :tags
|
53
65
|
def initialize(creature)
|
54
66
|
super(creature)
|
55
67
|
@wounds = {}
|
56
68
|
@tags = (Exist.normalize_type_data(creature.type) + (metadata["tags"] || []) ).map(&:to_sym)
|
57
69
|
TAGS.each_pair do |tag, pattern| @tags << tag if @name =~ pattern end
|
70
|
+
Creature.add_boss_type(self)
|
58
71
|
heal
|
59
72
|
end
|
60
73
|
|
@@ -15,7 +15,6 @@ class Creatures
|
|
15
15
|
|
16
16
|
STATES = %i[
|
17
17
|
prone sitting kneeling
|
18
|
-
dead
|
19
18
|
sleeping webbed immobile
|
20
19
|
stunned
|
21
20
|
flying
|
@@ -48,9 +47,9 @@ class Creatures
|
|
48
47
|
end
|
49
48
|
|
50
49
|
def each()
|
51
|
-
GameObj.
|
50
|
+
GameObj.targets.to_a.map do |obj| Creature.new(obj) end
|
52
51
|
.select(&@predicate)
|
53
|
-
.each do |creature| yield(creature) if GameObj[creature.id]
|
52
|
+
.each do |creature| yield(creature) if GameObj[creature.id] end
|
54
53
|
end
|
55
54
|
|
56
55
|
def respond_to_missing?(method, include_private = false)
|
@@ -75,6 +74,12 @@ class Creatures
|
|
75
74
|
Creatures.new do |creature| creature.name.include?(Bounty.creature) end
|
76
75
|
end
|
77
76
|
|
77
|
+
def dead
|
78
|
+
GameObj.npcs.to_a
|
79
|
+
.select do |c| c.status.include?("dead") end
|
80
|
+
.map do |obj| Creature.new(obj) end
|
81
|
+
end
|
82
|
+
|
78
83
|
def self.method_missing(method, *args, &block)
|
79
84
|
if respond_to?(method)
|
80
85
|
Creatures.new.send(method, *args, &block)
|
data/lib/Olib/core/container.rb
CHANGED
data/lib/Olib/core/containers.rb
CHANGED
@@ -1,31 +1,45 @@
|
|
1
1
|
require "Olib/pattern_matching/pattern_matching"
|
2
2
|
|
3
3
|
module Containers
|
4
|
-
@@containers
|
5
|
-
|
6
|
-
def self.find_game_obj!(
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
@@containers ||= {}
|
5
|
+
|
6
|
+
def self.find_game_obj!(pattern)
|
7
|
+
candidates = GameObj.inv.select do |item|
|
8
|
+
if pattern.class.is_a?(String)
|
9
|
+
item.name.include?(pattern)
|
10
|
+
else
|
11
|
+
item.name.match(pattern)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
case candidates.size
|
15
|
+
when 1
|
16
|
+
return Container.new(candidates.first)
|
17
|
+
when 0
|
18
|
+
fail Exception, <<~ERROR
|
19
|
+
Source(GameObj.inv)
|
20
|
+
|
21
|
+
reason: no matches for Pattern(#{pattern}) found in GameObj.inv
|
22
|
+
ERROR
|
23
|
+
else
|
24
|
+
fail Exception, <<~ERROR
|
25
|
+
Source(GameObj.inv)
|
26
|
+
|
27
|
+
reason: aspecific Container[#{pattern.to_s}] found
|
28
|
+
matches: #{candidates.map(&:name)}
|
29
|
+
ERROR
|
30
|
+
end
|
10
31
|
end
|
11
32
|
|
12
33
|
def self.define(name)
|
13
|
-
|
14
|
-
|
34
|
+
var = Vars[name.to_s] or fail Exception, "Var[#{name}] is not set\n\t;vars set #{name}=<whatever>"
|
35
|
+
pattern = %r[#{var}]
|
36
|
+
@@containers[name] = Containers.find_game_obj!(pattern)
|
15
37
|
@@containers[name]
|
16
38
|
end
|
17
39
|
|
18
|
-
def self.method_missing(name, *args)
|
19
|
-
return @@containers[name] if @@containers[name]
|
20
|
-
return self.define(name)
|
21
|
-
end
|
22
|
-
|
23
40
|
def self.[](name)
|
24
|
-
|
25
|
-
|
26
|
-
rescue Exception => err
|
27
|
-
Err(why: err.message, error: err)
|
28
|
-
end
|
41
|
+
return define(name) if name.is_a?(Symbol)
|
42
|
+
find_game_obj!(name)
|
29
43
|
end
|
30
44
|
|
31
45
|
def self.right_hand
|
@@ -39,4 +53,9 @@ module Containers
|
|
39
53
|
def self.registry
|
40
54
|
@@containers
|
41
55
|
end
|
56
|
+
|
57
|
+
def self.method_missing(name, *args)
|
58
|
+
return @@containers[name] if @@containers[name]
|
59
|
+
return self.define(name)
|
60
|
+
end
|
42
61
|
end
|
data/lib/Olib/version.rb
CHANGED