Class: GamesAndRpgParadise::Mud::MudObject
- Inherits:
-
Object
- Object
- GamesAndRpgParadise::Mud::MudObject
show all
- Defined in:
- lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb
Overview
RpgParadise::Mud::MudObject
Constant Summary
collapse
- NAMESPACE =
inspect
- DEFAULT_NAME =
'Generic MudObject'
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add(i) ⇒ Object
(also: #equip)
# === add.
-
#add_prop(name_of_the_property, the_value = true) ⇒ Object
# === add_prop ========================================================================= #.
-
#add_to_inventory(i) ⇒ Object
(also: #<<)
# === add_to_inventory (add tag).
-
#alias_action(existing_action = 'wingattack', new_name = 'wattack') ⇒ Object
# === alias_action.
-
#can_speak? ⇒ Boolean
# === can_speak?.
-
#define_action(name_of_the_method = 'tie_someone', command_to_invoke_it = 'hang', disable_these_actionslots = 'SEE|MOVE|ARMS|MOTOR|ALIVE|HANDS|NON_BUSY') ⇒ Object
(also: #add_action, #action)
# === define_action.
-
#describe_the_mud_object ⇒ Object
(also: #show_desc, #show_description)
# === describe_the_mud_object ========================================================================= #.
-
#description? ⇒ Boolean
(also: #description)
# === description?.
-
#empty? ⇒ Boolean
# === empty?.
-
#enable_speak ⇒ Object
(also: #enable_talk)
# === enable_speak.
-
#find(what) ⇒ Object
# === find.
-
#has_inventory? ⇒ Boolean
# === has_inventory? ========================================================================= #.
-
#height? ⇒ Boolean
(also: #height)
# === height? (height tag).
-
#id? ⇒ Boolean
(also: #unique_id?)
# === id?.
-
#initialize(*arguments) ⇒ MudObject
constructor
# === initialize ========================================================================= #.
-
#inspect ⇒ Object
# === inspect.
-
#internal_hash? ⇒ Boolean
(also: #internal_hash)
# === internal_hash? ========================================================================= #.
-
#inventory? ⇒ Boolean
(also: #container?, #inventory)
# === inventory? (inv tag).
-
#is_armour? ⇒ Boolean
(also: #is_an_armour?)
# === is_armour?.
-
#is_inventory? ⇒ Boolean
# === is_inventory?.
-
#is_mud_object? ⇒ Boolean
# === is_mud_object?.
-
#is_weapon? ⇒ Boolean
# === is_weapon? ========================================================================= #.
-
#is_wearable? ⇒ Boolean
# === is_wearable? ========================================================================= #.
-
#length? ⇒ Boolean
(also: #length)
# === length? ========================================================================= #.
-
#method_missing(i, dont_care = nil, it_does_not_matter = nil) ⇒ Object
# === method_missing.
-
#name= ⇒ Object
# === set_name.
-
#name? ⇒ Boolean
(also: #short_description?, #short_description, #name)
# === name? ========================================================================= #.
-
#obtain_name_from_filename(i = __FILE__) ⇒ Object
# === obtain_name_from_filename.
-
#random_inventory_element ⇒ Object
(also: #random)
# === random_inventory_element.
-
#report_height ⇒ Object
# === report_height ========================================================================= #.
-
#report_weight ⇒ Object
(also: #pweight?)
# === report_weight.
-
#reset ⇒ Object
# === reset (reset tag).
-
#run ⇒ Object
# === run (run tag).
-
#set_description(i = 'standard MudObject') ⇒ Object
(also: #desc=)
# === set_description ========================================================================= #.
-
#set_height(i) ⇒ Object
(also: #height=)
# === set_height.
-
#set_is_an_armour ⇒ Object
# === set_is_an_armour ========================================================================= #.
-
#set_is_inventory ⇒ Object
(also: #is_inventory, #set_is_an_inventory)
# === set_is_inventory ========================================================================= #.
-
#set_is_wearable ⇒ Object
# === set_is_wearable ========================================================================= #.
-
#set_length(i = 100) ⇒ Object
# === set_length ========================================================================= #.
-
#set_name(i) ⇒ Object
# === set_name.
-
#set_object_name ⇒ Object
# === set_name.
-
#set_value(i = 0) ⇒ Object
# === set_value.
-
#set_weight(i) ⇒ Object
# === set_weight ========================================================================= #.
-
#show_inventory(inventory = inventory? ) ⇒ Object
(also: #display_inventory)
# === show_inventory.
-
#store ⇒ Object
# === store.
-
#store_where? ⇒ Boolean
# === store_where? ========================================================================= #.
-
#value? ⇒ Boolean
(also: #value)
# === value? ========================================================================= #.
-
#wear(i) ⇒ Object
# === wear ========================================================================= #.
-
#wearables? ⇒ Boolean
# === wearables?.
-
#weight? ⇒ Boolean
(also: #weight)
# === weight? (weight tag).
-
#who_am_i? ⇒ Boolean
(also: #verbose_id?)
# === who_am_i? ========================================================================= #.
-
#wields?(i = 'sword') ⇒ Boolean
# === wields?.
Constructor Details
#initialize(*arguments) ⇒ MudObject
53
54
55
56
57
58
59
60
61
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 53
def initialize(
*arguments
)
reset
if arguments and arguments.is_a?(Array) and !arguments.empty?
set_name(arguments.first)
end
run
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(i, dont_care = nil, it_does_not_matter = nil) ⇒ Object
#
method_missing
By default, undefined methods in this MUD engine will always return false.
This is used in order to “simulate” LPC, which never fails but instead will return 0 if the method is not known.
As of 2021 it is unclear whether this is kept - probably only as a switch that people can toggle, if they want LPC-like behaviour. For other MUD engine styles it is probably not really necessary, so this has to be re-evaluated eventually.
#
494
495
496
497
498
499
500
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 494
def method_missing(
i,
dont_care = nil,
it_does_not_matter = nil
)
return false
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
RpgParadise::Mud::MudObject[]
This method can be used to create a new mud object.
#
750
751
752
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 750
def self.[](i = ARGV)
new(i)
end
|
.disable_debug ⇒ Object
#
MudObject.disable_debug
#
764
765
766
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 764
def self.disable_debug
@shall_we_debug = false
end
|
.enable_debug ⇒ Object
#
MudObject.enable_debug
#
757
758
759
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 757
def self.enable_debug
@shall_we_debug = true
end
|
.shall_we_debug? ⇒ Boolean
#
MudObject.shall_we_debug?
#
771
772
773
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 771
def self.shall_we_debug?
@shall_we_debug
end
|
Instance Method Details
#add(i) ⇒ Object
Also known as:
equip
#
add
Add an object to this object. Only MudObjects can be added and only if these are considered to be inventories.
We can also add multiple objects at the same time.
#
420
421
422
423
424
425
426
427
428
429
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 420
def add(i)
if i.is_a? MudObject and
i.respond_to(:is_inventory?) and
i.is_inventory? and
!i.inventory?.include?(i)
add_to_inventory(i)
return true
end
false
end
|
#add_prop(name_of_the_property, the_value = true) ⇒ Object
563
564
565
566
567
568
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 563
def add_prop(
name_of_the_property,
the_value = true
)
@internal_hash[:properties][name_of_the_property] = the_value
end
|
#add_to_inventory(i) ⇒ Object
Also known as:
<<
#
add_to_inventory (add tag)
Use this method whenever you wish to append to the inventory.
We will only add if it is a MudObject, though.
Not all objects have an “inventory”.
#
440
441
442
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 440
def add_to_inventory(i)
@internal_hash[:inventory] << i if i.is_a? MudObject
end
|
#alias_action(existing_action = 'wingattack', new_name = 'wattack') ⇒ Object
#
alias_action
This method exists mostly as compatibility towards LPC code bases.
#
685
686
687
688
689
690
691
692
693
694
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 685
def alias_action(
existing_action = 'wingattack', new_name = 'wattack'
)
if registered_actions?.include? existing_action
e 'Aliasing now ... stub'
else
e 'Can not alias this as it does not exist.'
raise
end
end
|
#can_speak? ⇒ Boolean
#
can_speak?
Whether this object can speak or not.
#
165
166
167
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 165
def can_speak?
@internal_hash[:can_speak]
end
|
#define_action(name_of_the_method = 'tie_someone', command_to_invoke_it = 'hang', disable_these_actionslots = 'SEE|MOVE|ARMS|MOTOR|ALIVE|HANDS|NON_BUSY') ⇒ Object
Also known as:
add_action, action
#
define_action
This object can be used by an actor.
The third argument tells us which actionslots are available.
#
285
286
287
288
289
290
291
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 285
def define_action(
name_of_the_method = 'tie_someone',
command_to_invoke_it = 'hang',
disable_these_actionslots = 'SEE|MOVE|ARMS|MOTOR|ALIVE|HANDS|NON_BUSY'
)
@array_registered_actions << name_of_the_method
end
|
#describe_the_mud_object ⇒ Object
Also known as:
show_desc, show_description
#
describe_the_mud_object
#
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 633
def describe_the_mud_object
e word_wrap(description?)
if is_inventory? inventory.each {|entry|
e entry
}
end
end
|
#description? ⇒ Boolean
Also known as:
description
#
description?
The description of the object in question.
#
458
459
460
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 458
def description?
@internal_hash[:description]
end
|
#empty? ⇒ Boolean
#
empty?
This will tell us whether our container (the inventory) is empty or whether it is not.
#
602
603
604
605
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 602
def empty?
return true if @internal_hash[:inventory].empty?
false
end
|
#enable_speak ⇒ Object
Also known as:
enable_talk
#
enable_speak
Only living beings should be able to speak.
#
174
175
176
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 174
def enable_speak
@internal_hash[:can_speak] = true
end
|
#find(what) ⇒ Object
#
find
The input to this method should be a String. It will be what we will attempt to find in the inventory.
If we did not find anything then we will return false. Otherwise, we will return the object in question.
#
386
387
388
389
390
391
392
393
394
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 386
def find(what)
result = inventory?.map {|entry| entry.short_description }
if result.include? what
selection = inventory?.select {|entry| entry.short_description.include? what }
selection.first else
false
end
end
|
#has_inventory? ⇒ Boolean
274
275
276
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 274
def has_inventory?
!inventory?.empty?
end
|
#height? ⇒ Boolean
Also known as:
height
#
height? (height tag)
Feedback the height of a mud object.
#
507
508
509
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 507
def height?
@internal_hash[:height]
end
|
#id? ⇒ Boolean
Also known as:
unique_id?
#
id?
This helper method returns the object id. This is currently based on the object-id, but in the future we may have to store another larger number or even a hash, if we wish to store this in a database.
#
549
550
551
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 549
def id?
self.object_id.to_s
end
|
#inspect ⇒ Object
#
inspect
- We don’t need the leading Mud
-
prefix.
#
449
450
451
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 449
def inspect
super.sub('Mud::', '')
end
|
#internal_hash? ⇒ Boolean
Also known as:
internal_hash
718
719
720
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 718
def internal_hash?
@internal_hash
end
|
#inventory? ⇒ Boolean
Also known as:
container?, inventory
#
inventory? (inv tag)
Return the inventory of this container.
#
347
348
349
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 347
def inventory?
@internal_hash[:inventory]
end
|
#is_armour? ⇒ Boolean
Also known as:
is_an_armour?
#
is_armour?
Next we add some query-type methods.
#
239
240
241
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 239
def is_armour?
@internal_hash[:is_armour]
end
|
#is_inventory? ⇒ Boolean
#
is_inventory?
This method will query whether this object is an inventory or whether it is not. A “bag” is an inventory, for instance.
#
230
231
232
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 230
def is_inventory?
@internal_hash[:is_inventory]
end
|
#is_mud_object? ⇒ Boolean
#
is_mud_object?
Whether we are a mud-object or not. By default this is the case so.
#
585
586
587
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 585
def is_mud_object?
true
end
|
#is_weapon? ⇒ Boolean
253
254
255
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 253
def is_weapon?
@internal_hash[:is_weapon]
end
|
#is_wearable? ⇒ Boolean
725
726
727
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 725
def is_wearable?
@internal_hash[:is_wearable]
end
|
#length? ⇒ Boolean
Also known as:
length
260
261
262
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 260
def length?
@internal_hash[:length]
end
|
#name= ⇒ Object
#
set_name
You can also pass a Hash to this method.
#
name= We can not use name() as that is already used elsewhere.
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 212
def set_name(i = nil) i = DEFAULT_NAME if i.nil?
if i.is_a? Hash
if i.has_key? :name
value = i.delete(:name)
i = File.basename(value).gsub(/\.rb$/,'')
else
pp i
opn; e 'There may be an error with the above ^^^'
pp caller
exit
end
end
i = i.to_s
i = i.downcase if i.include? '/'
i = File.basename(i).gsub(/\.rb$/,'')
end
if i.include? '::'
i = i.split('::').last
end
if MudObject.shall_we_debug?
opn; e swarn('DEBUG:')+' We now set the name of this object to '+i+'.'
end
@internal_hash[:name] = i
end
|
#name? ⇒ Boolean
Also known as:
short_description?, short_description, name
674
675
676
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 674
def name?
@internal_hash[:name].to_s
end
|
#obtain_name_from_filename(i = __FILE__) ⇒ Object
#
obtain_name_from_filename
This does not really work. It was supposed to give a name based on the filename in question.
#
657
658
659
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 657
def obtain_name_from_filename(i = __FILE__)
i
end
|
#random_inventory_element ⇒ Object
Also known as:
random
#
random_inventory_element
This method will return a random member from the inventory-container.
It can be used when, for instance, a pick pocket tries to take an item and it is not so relevant which one that is, e. g. “grab some item from the backpack and then run away”.
#
616
617
618
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 616
def random_inventory_element
inventory?.sample unless empty?
end
|
#report_height ⇒ Object
537
538
539
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 537
def report_height
e "The height of #{name?} is #{height?}."
end
|
#report_weight ⇒ Object
Also known as:
pweight?
#
report_weight
Report the weight of this object.
#
373
374
375
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 373
def report_weight
e "The weight of this object `#{name?}` is #{weight?} kg."
end
|
#reset ⇒ Object
#
reset (reset tag)
We can not invoke set_name() here because it might overrule when a subclass sets a name.
#
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 69
def reset
@internal_hash = {}
@internal_hash[:weight] = 0
@internal_hash[:length] = 0
@internal_hash[:height] = 0
@internal_hash[:inventory] = []
@internal_hash[:is_armour] = false
@internal_hash[:is_weapon] = false
@internal_hash[:can_speak] = false
@internal_hash[:is_visible] = true @internal_hash[:is_inventory] = false
@internal_hash[:properties] = {}
@internal_hash[:is_wearable] = false
@internal_hash[:wearables] = []
@internal_hash[:name] = nil
@internal_hash[:array_wearables] = [] @internal_hash[:store_where] = '/home/Temp/mud_object_'+unique_id?+'.yml'
set_description
end
|
#run ⇒ Object
#
run (run tag)
This is a placeholder-method - most objects will not need to do anything in run().
#
627
628
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 627
def run
end
|
#set_description(i = 'standard MudObject') ⇒ Object
Also known as:
desc=
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 465
def set_description(
i = 'standard MudObject'
)
i = i.to_s if i.include? 'MATERIAL_TYPE' i.gsub!(/MATERIAL_TYPE/, material_type?)
end
if i.include? 'Mud::'
i.gsub!(/Mud::/,'')
elsif i.include? 'mud::'
i.gsub!(/mud::/,'')
end
@internal_hash[:description] = i
end
|
#set_height(i) ⇒ Object
Also known as:
height=
#
set_height
This method will set the height of the object at hand. This will be measured in cm.
If the input is something such as ‘80-120’ then this will be treated as “a range instruction”, from minumum 80 up to maximum 120.
Will be stored as a Float.
#
522
523
524
525
526
527
528
529
530
531
532
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 522
def set_height(i)
i = i.to_s
if i.include? '-'
splitted = i.split('-').map(&:to_f)
min = splitted.first
max = splitted.last
i = min + rand(max - min)
end
i = i.to_f
@internal_hash[:height] = i
end
|
#set_is_an_armour ⇒ Object
246
247
248
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 246
def set_is_an_armour
@internal_hash[:is_armour] = true
end
|
#set_is_inventory ⇒ Object
Also known as:
is_inventory, set_is_an_inventory
337
338
339
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 337
def set_is_inventory
@internal_hash[:is_inventory] = true
end
|
#set_is_wearable ⇒ Object
741
742
743
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 741
def set_is_wearable
@internal_hash[:is_wearable] = true
end
|
#set_length(i = 100) ⇒ Object
267
268
269
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 267
def set_length(i = 100)
@internal_hash[:length] = i
end
|
#set_name(i) ⇒ Object
#
set_name
This setter-method can be used to set the name of the object at hand, such as “sword” for class Sword in the file sword.rb.
#
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 183
def set_name(i = nil) i = DEFAULT_NAME if i.nil?
if i.is_a? Hash
if i.has_key? :name
value = i.delete(:name)
i = File.basename(value).gsub(/\.rb$/,'')
else
pp i
opn; e 'There may be an error with the above ^^^'
pp caller
exit
end
end
i = i.to_s
i = i.downcase if i.include? '/'
i = File.basename(i).gsub(/\.rb$/,'')
end
if i.include? '::'
i = i.split('::').last
end
if MudObject.shall_we_debug?
opn; e swarn('DEBUG:')+' We now set the name of this object to '+i+'.'
end
@internal_hash[:name] = i
end
|
#set_object_name ⇒ Object
#
set_name
You can also pass a Hash to this method.
#
set_object
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 211
def set_name(i = nil) i = DEFAULT_NAME if i.nil?
if i.is_a? Hash
if i.has_key? :name
value = i.delete(:name)
i = File.basename(value).gsub(/\.rb$/,'')
else
pp i
opn; e 'There may be an error with the above ^^^'
pp caller
exit
end
end
i = i.to_s
i = i.downcase if i.include? '/'
i = File.basename(i).gsub(/\.rb$/,'')
end
if i.include? '::'
i = i.split('::').last
end
if MudObject.shall_we_debug?
opn; e swarn('DEBUG:')+' We now set the name of this object to '+i+'.'
end
@internal_hash[:name] = i
end
|
#set_value(i = 0) ⇒ Object
#
set_value
Set the value of the object at hand.
#
401
402
403
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 401
def set_value(i = 0)
@internal_hash[:value] = i
end
|
#set_weight(i) ⇒ Object
364
365
366
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 364
def set_weight(i)
@internal_hash[:weight] = i
end
|
#show_inventory(inventory = inventory?
) ⇒ Object
Also known as:
display_inventory
#
show_inventory
Show the inventory to our actor.
#
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 299
def show_inventory(
inventory = inventory?
)
if is_inventory? if inventory.empty?
e 'You do not carry anything.'
else
armours = inventory.select {|entry| entry.is_armour? }
unless armours.empty?
_ = 'You are wearing '
armours.each_with_index {|entry, index|
if index == (armours.size-1) _.strip!
_.chop! if _.end_with? ','
_ << ' and a '+entry.description?+'.'
else
_ << 'a '+entry.description?+', '
end
}
_.strip!
_.chop! if _.end_with? ','
_ << '.' unless _.end_with? '.'
_ = word_wrap(_)
e _
end
e ' You are carrying:'
inventory?.each {|entry|
e " - a #{entry.description?}"
}
end
else
e 'It is not an inventory.'
end
end
|
#store ⇒ Object
#
store
This method can be used to store the mud-object.
#
575
576
577
578
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 575
def store
e "Now storing the mud-object in `{sfile(store_where?)}`."
save_file(YAML.dump(self), store_where?)
end
|
#store_where? ⇒ Boolean
592
593
594
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 592
def store_where?
@internal_hash[:store_where]
end
|
#value? ⇒ Boolean
Also known as:
value
408
409
410
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 408
def value?
@internal_hash[:value]
end
|
#wear(i) ⇒ Object
217
218
219
220
221
222
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 217
def wear(i)
if i.is_a?(MudObject) and @internal_hash[:is_wearable] and
!@internal_hash[:wearables].include?(i)
@internal_hash[:wearables] << i
end
end
|
#wearables? ⇒ Boolean
#
wearables?
Return all wearables, among the whole inventory.
#
734
735
736
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 734
def wearables?
inventory?.select {|entry| entry.is_wearable? }
end
|
#weight? ⇒ Boolean
Also known as:
weight
#
weight? (weight tag)
Feedback the weight of a mud object.
#
357
358
359
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 357
def weight?
@internal_hash[:weight]
end
|
#who_am_i? ⇒ Boolean
Also known as:
verbose_id?
556
557
558
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 556
def who_am_i?
"#{self.class.name} #{id?} #{self.to_s}"
end
|
#wields?(i = 'sword') ⇒ Boolean
#
wields?
This method will query whether the object at hand wields anything.
This should perhaps be moved to the actor-class or module eventually.
Example code:
if actor.wields? :sword
#
708
709
710
711
712
713
|
# File 'lib/games_and_rpg_paradise/mud/mud_object/mud_object.rb', line 708
def wields?(i = 'sword')
if get_all_toolslots.hands.wield?(i)
return true
end
return false end
|