gemwarrior 0.10.8 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gemwarrior +0 -0
- data/data/default_world.yaml +282 -436
- data/gemwarrior.gemspec +1 -1
- data/lib/gemwarrior/arena.rb +17 -17
- data/lib/gemwarrior/battle.rb +146 -77
- data/lib/gemwarrior/entities/armor.rb +34 -0
- data/lib/gemwarrior/entities/armor/iron_helmet.rb +17 -0
- data/lib/gemwarrior/entities/creature.rb +81 -4
- data/lib/gemwarrior/entities/creatures/cow.rb +24 -0
- data/lib/gemwarrior/entities/{items → creatures}/goat.rb +9 -11
- data/lib/gemwarrior/entities/creatures/pig.rb +24 -0
- data/lib/gemwarrior/entities/entity.rb +59 -5
- data/lib/gemwarrior/entities/item.rb +10 -22
- data/lib/gemwarrior/entities/items/apple.rb +2 -5
- data/lib/gemwarrior/entities/items/arena_door.rb +2 -6
- data/lib/gemwarrior/entities/items/bed.rb +7 -11
- data/lib/gemwarrior/entities/items/bookcase.rb +57 -0
- data/lib/gemwarrior/entities/items/bullet.rb +25 -0
- data/lib/gemwarrior/entities/items/couch.rb +6 -10
- data/lib/gemwarrior/entities/items/cup.rb +2 -5
- data/lib/gemwarrior/entities/items/dehumidifier.rb +3 -6
- data/lib/gemwarrior/entities/items/feather.rb +2 -5
- data/lib/gemwarrior/entities/items/floor_tile.rb +6 -10
- data/lib/gemwarrior/entities/items/flower.rb +1 -4
- data/lib/gemwarrior/entities/items/herb.rb +12 -13
- data/lib/gemwarrior/entities/items/keystone.rb +2 -5
- data/lib/gemwarrior/entities/items/ladder.rb +7 -11
- data/lib/gemwarrior/entities/items/letter.rb +20 -23
- data/lib/gemwarrior/entities/items/map.rb +3 -6
- data/lib/gemwarrior/entities/items/massive_door.rb +3 -7
- data/lib/gemwarrior/entities/items/pedestal.rb +6 -10
- data/lib/gemwarrior/entities/items/pond.rb +4 -8
- data/lib/gemwarrior/entities/items/rope.rb +4 -8
- data/lib/gemwarrior/entities/items/small_hole.rb +15 -77
- data/lib/gemwarrior/entities/items/snowman.rb +5 -9
- data/lib/gemwarrior/entities/items/sparkly_thing.rb +3 -7
- data/lib/gemwarrior/entities/items/stonemite.rb +2 -6
- data/lib/gemwarrior/entities/items/tent.rb +3 -6
- data/lib/gemwarrior/entities/items/throne.rb +7 -6
- data/lib/gemwarrior/entities/items/tree.rb +2 -6
- data/lib/gemwarrior/entities/items/waterfall.rb +9 -8
- data/lib/gemwarrior/entities/location.rb +49 -43
- data/lib/gemwarrior/entities/monster.rb +34 -28
- data/lib/gemwarrior/entities/monsters/alexandrat.rb +3 -3
- data/lib/gemwarrior/entities/monsters/amberoo.rb +3 -3
- data/lib/gemwarrior/entities/monsters/amethystle.rb +3 -3
- data/lib/gemwarrior/entities/monsters/apatiger.rb +3 -3
- data/lib/gemwarrior/entities/monsters/aquamarine.rb +3 -3
- data/lib/gemwarrior/entities/monsters/bloodstorm.rb +3 -3
- data/lib/gemwarrior/entities/monsters/bosses/emerald.rb +12 -27
- data/lib/gemwarrior/entities/monsters/bosses/garynetty.rb +17 -5
- data/lib/gemwarrior/entities/monsters/bosses/jaspern.rb +66 -0
- data/lib/gemwarrior/entities/monsters/citrinaga.rb +3 -3
- data/lib/gemwarrior/entities/monsters/coraliz.rb +3 -3
- data/lib/gemwarrior/entities/monsters/cubicat.rb +3 -3
- data/lib/gemwarrior/entities/monsters/diaman.rb +3 -3
- data/lib/gemwarrior/entities/{items → people}/arena_master.rb +8 -13
- data/lib/gemwarrior/entities/{items → people}/drunk_man.rb +14 -35
- data/lib/gemwarrior/entities/people/queen_ruby.rb +71 -0
- data/lib/gemwarrior/entities/people/rockney.rb +132 -0
- data/lib/gemwarrior/entities/{items → people}/shifty_woman.rb +7 -12
- data/lib/gemwarrior/entities/{items → people}/thin_man.rb +9 -14
- data/lib/gemwarrior/entities/people/ware_hawker.rb +153 -0
- data/lib/gemwarrior/entities/person.rb +20 -0
- data/lib/gemwarrior/entities/player.rb +102 -60
- data/lib/gemwarrior/entities/weapon.rb +38 -0
- data/lib/gemwarrior/entities/{items → weapons}/dagger.rb +5 -7
- data/lib/gemwarrior/entities/{items → weapons}/gun.rb +8 -10
- data/lib/gemwarrior/entities/{items → weapons}/mace.rb +6 -9
- data/lib/gemwarrior/entities/{items → weapons}/opalaser.rb +5 -7
- data/lib/gemwarrior/entities/weapons/spear.rb +23 -0
- data/lib/gemwarrior/entities/{items → weapons}/stalactite.rb +5 -7
- data/lib/gemwarrior/entities/weapons/stone.rb +23 -0
- data/lib/gemwarrior/evaluator.rb +111 -107
- data/lib/gemwarrior/game.rb +61 -29
- data/lib/gemwarrior/game_assets.rb +76 -0
- data/lib/gemwarrior/inventory.rb +77 -43
- data/lib/gemwarrior/misc/animation.rb +17 -13
- data/lib/gemwarrior/misc/{music.rb → audio.rb} +15 -7
- data/lib/gemwarrior/misc/audio_cues.rb +133 -0
- data/lib/gemwarrior/misc/formatting.rb +9 -9
- data/lib/gemwarrior/misc/player_levels.rb +21 -0
- data/lib/gemwarrior/repl.rb +32 -31
- data/lib/gemwarrior/version.rb +1 -1
- data/lib/gemwarrior/world.rb +155 -134
- metadata +34 -22
- data/lib/gemwarrior/entities/items/cow.rb +0 -26
- data/lib/gemwarrior/entities/items/pig.rb +0 -26
- data/lib/gemwarrior/entities/items/queen_ruby.rb +0 -62
- data/lib/gemwarrior/entities/items/spear.rb +0 -26
- data/lib/gemwarrior/entities/items/stone.rb +0 -25
- data/lib/gemwarrior/entities/items/ware_hawker.rb +0 -93
@@ -0,0 +1,34 @@
|
|
1
|
+
# lib/gemwarrior/entities/armor.rb
|
2
|
+
# Entity::Item::Armor base class
|
3
|
+
|
4
|
+
require_relative 'item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Armor < Item
|
8
|
+
attr_accessor :defense
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
|
13
|
+
self.equippable = true
|
14
|
+
self.defense = 0
|
15
|
+
self.is_armor = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def use(world)
|
19
|
+
'Save the donning of this piece of armor for battle.'
|
20
|
+
end
|
21
|
+
|
22
|
+
def describe
|
23
|
+
desc_text = "\"#{name_display}\"\n".colorize(:yellow)
|
24
|
+
desc_text << "(#{name})\n".colorize(:green)
|
25
|
+
desc_text << "#{description}\n".colorize(:white)
|
26
|
+
desc_text << "DEFENSE: #{defense}\n".colorize(:white)
|
27
|
+
desc_text << "TAKEABLE? #{takeable}\n".colorize(:white)
|
28
|
+
desc_text << "USEABLE? #{useable}\n".colorize(:white)
|
29
|
+
desc_text << "EQUIPPABLE? #{equippable}\n".colorize(:white)
|
30
|
+
desc_text << "EQUIPPED? #{equipped}\n".colorize(:white)
|
31
|
+
desc_text
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# lib/gemwarrior/entities/armor/iron_helmet.rb
|
2
|
+
# Entity::Item::Armor::IronHelmet
|
3
|
+
|
4
|
+
require_relative '../armor'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class IronHelmet < Armor
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
|
11
|
+
self.name = 'iron_helmet'
|
12
|
+
self.name_display = 'Iron Helmet'
|
13
|
+
self.description = 'The noggin is better off when encased in a heavy, yet safe, bowl-shaped carapace made of solid iron.'
|
14
|
+
self.defense = 3
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,12 +1,89 @@
|
|
1
1
|
# lib/gemwarrior/entities/creature.rb
|
2
|
-
# Creature base class
|
2
|
+
# Entity::Creature base class
|
3
3
|
|
4
4
|
require_relative 'entity'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
7
|
class Creature < Entity
|
8
|
-
attr_accessor :face,
|
9
|
-
:
|
10
|
-
:
|
8
|
+
attr_accessor :face,
|
9
|
+
:hands,
|
10
|
+
:mood,
|
11
|
+
:level,
|
12
|
+
:xp,
|
13
|
+
:hp_cur,
|
14
|
+
:hp_max,
|
15
|
+
:atk_lo,
|
16
|
+
:atk_hi,
|
17
|
+
:defense,
|
18
|
+
:dexterity,
|
19
|
+
:inventory,
|
20
|
+
:rox
|
21
|
+
|
22
|
+
attr_reader :use,
|
23
|
+
:speak
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
super
|
27
|
+
|
28
|
+
self.name = 'creature'
|
29
|
+
self.name_display = Formatting::upstyle(name)
|
30
|
+
self.description = 'A creature.'
|
31
|
+
self.face = 'face-y'
|
32
|
+
self.hands = 'handsy'
|
33
|
+
self.mood = 'moody'
|
34
|
+
self.level = 1
|
35
|
+
self.xp = 0
|
36
|
+
self.hp_cur = 10
|
37
|
+
self.hp_max = 10
|
38
|
+
self.atk_lo = 1
|
39
|
+
self.atk_hi = 1
|
40
|
+
self.defense = 1
|
41
|
+
self.dexterity = 1
|
42
|
+
self.inventory = Inventory.new
|
43
|
+
self.rox = 0
|
44
|
+
self.talkable = true
|
45
|
+
self.used = false
|
46
|
+
end
|
47
|
+
|
48
|
+
def use
|
49
|
+
'That creature does not seem to want to talk to you right now.'
|
50
|
+
end
|
51
|
+
|
52
|
+
def describe
|
53
|
+
desc_text = "#{description}".colorize(:white)
|
54
|
+
desc_text << "\n"
|
55
|
+
desc_text << "The creature has several distinguishing features, as well: face is #{face}, hands are #{hands}, and mood is, generally, #{mood}."
|
56
|
+
desc_text
|
57
|
+
end
|
58
|
+
|
59
|
+
def describe_detailed
|
60
|
+
desc_text = "\"#{name_display}\"\n".colorize(:yellow)
|
61
|
+
desc_text << "(#{name})\n".colorize(:green)
|
62
|
+
desc_text << "#{description}\n".colorize(:white)
|
63
|
+
desc_text << "FACE : #{face}\n".colorize(:white)
|
64
|
+
desc_text << "HANDS : #{hands}\n".colorize(:white)
|
65
|
+
desc_text << "MOOD : #{mood}\n".colorize(:white)
|
66
|
+
desc_text << "LEVEL : #{level}\n".colorize(:white)
|
67
|
+
desc_text << "XP : #{xp}\n".colorize(:white)
|
68
|
+
desc_text << "HP : #{hp_cur}/#{hp_max}\n".colorize(:white)
|
69
|
+
desc_text << "ATK_RANGE : #{atk_lo}-#{atk_hi}\n".colorize(:white)
|
70
|
+
desc_text << "DEFENSE : #{defense}\n".colorize(:white)
|
71
|
+
desc_text << "DEXTERITY : #{dexterity}\n".colorize(:white)
|
72
|
+
desc_text << "ROX : #{rox}\n".colorize(:white)
|
73
|
+
desc_text << "INVENTORY : #{inventory.list_contents}\n".colorize(:white)
|
74
|
+
desc_text
|
75
|
+
end
|
76
|
+
|
77
|
+
def speak(s, no_end_quote = false, no_line_feed = false)
|
78
|
+
text = ">> \"#{s}"
|
79
|
+
text += "\"" unless no_end_quote
|
80
|
+
text += "\n" unless no_line_feed
|
81
|
+
text = text.colorize(:yellow)
|
82
|
+
if no_line_feed
|
83
|
+
print text
|
84
|
+
else
|
85
|
+
print text.gsub(/(.{1,#{GameOptions.data['wrap_width']}})(\s+|\Z)/, "\\1\n")
|
86
|
+
end
|
87
|
+
end
|
11
88
|
end
|
12
89
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# lib/gemwarrior/entities/creatures/cow.rb
|
2
|
+
# Entity::Creature::Cow
|
3
|
+
|
4
|
+
require_relative '../creature'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Cow < Creature
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
|
11
|
+
self.name = 'cow'
|
12
|
+
self.name_display = 'Cow'
|
13
|
+
self.description = 'Grazing on some fake grass, unperturbed, this black and white herd animal looks bored.'
|
14
|
+
self.face = 'blank'
|
15
|
+
self.hands = 'stampy'
|
16
|
+
self.mood = 'reserved'
|
17
|
+
end
|
18
|
+
|
19
|
+
def use(world)
|
20
|
+
puts '>> "Moo."'
|
21
|
+
{ type: nil, data: nil }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,24 +1,22 @@
|
|
1
|
-
# lib/gemwarrior/entities/
|
2
|
-
#
|
1
|
+
# lib/gemwarrior/entities/people/goat.rb
|
2
|
+
# Entity::Creature::Goat
|
3
3
|
|
4
|
-
require_relative '../
|
4
|
+
require_relative '../creature'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
|
-
class Goat <
|
7
|
+
class Goat < Creature
|
8
8
|
def initialize
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'goat'
|
12
|
+
self.name_display = 'Goat'
|
12
13
|
self.description = 'The scruff is strong with this one as it chews through what appears to be a recent mystery novel most likely thrown into the pen by a passerby.'
|
13
|
-
self.
|
14
|
-
self.
|
15
|
-
self.
|
16
|
-
self.useable = true
|
17
|
-
self.equippable = false
|
18
|
-
self.talkable = true
|
14
|
+
self.face = 'busy'
|
15
|
+
self.hands = 'hoofy'
|
16
|
+
self.mood = 'content'
|
19
17
|
end
|
20
18
|
|
21
|
-
def use(
|
19
|
+
def use(world)
|
22
20
|
puts '>> "Baa."'
|
23
21
|
{ type: nil, data: nil }
|
24
22
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# lib/gemwarrior/entities/people/pig.rb
|
2
|
+
# Entity::Creature::Pig
|
3
|
+
|
4
|
+
require_relative '../creature'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Pig < Creature
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
|
11
|
+
self.name = 'pig'
|
12
|
+
self.name_display = 'Pig'
|
13
|
+
self.description = 'Dirty, eating slop, but still kind of cute. Yep, this is a pig.'
|
14
|
+
self.face = 'messy'
|
15
|
+
self.hands = 'muddy'
|
16
|
+
self.mood = 'restless'
|
17
|
+
end
|
18
|
+
|
19
|
+
def use(world)
|
20
|
+
puts '>> "Oink."'
|
21
|
+
{ type: nil, data: nil }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,15 +1,69 @@
|
|
1
1
|
# lib/gemwarrior/entities/entity.rb
|
2
|
-
# Base class for
|
2
|
+
# Base class for a describable object
|
3
3
|
|
4
4
|
require_relative '../game_options'
|
5
|
+
require_relative '../misc/formatting'
|
6
|
+
require_relative '../misc/animation'
|
5
7
|
|
6
8
|
module Gemwarrior
|
7
9
|
class Entity
|
8
|
-
attr_accessor :name,
|
10
|
+
attr_accessor :name,
|
11
|
+
:name_display,
|
12
|
+
:description,
|
13
|
+
:takeable,
|
14
|
+
:useable,
|
15
|
+
:useable_battle,
|
16
|
+
:talkable,
|
17
|
+
:consumable,
|
18
|
+
:equippable,
|
19
|
+
:equipped,
|
20
|
+
:used,
|
21
|
+
:number_of_uses
|
9
22
|
|
10
|
-
|
11
|
-
|
12
|
-
|
23
|
+
attr_reader :describe,
|
24
|
+
:describe_detailed,
|
25
|
+
:display_shopping_cart
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
self.name = 'entity'
|
29
|
+
self.name_display = Formatting::upstyle(name)
|
30
|
+
self.description = 'An entity.'
|
31
|
+
self.useable = true
|
32
|
+
self.useable_battle = false
|
33
|
+
self.talkable = false
|
34
|
+
self.consumable = false
|
35
|
+
self.takeable = true
|
36
|
+
self.equippable = false
|
37
|
+
self.equipped = false
|
38
|
+
self.used = false
|
39
|
+
self.number_of_uses = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def use(world)
|
43
|
+
'That does not appear to be useable.'
|
44
|
+
end
|
45
|
+
|
46
|
+
def describe
|
47
|
+
desc_text = "#{description}".colorize(:white)
|
48
|
+
end
|
49
|
+
|
50
|
+
def describe_detailed
|
51
|
+
desc_text = "\"#{name_display}\"\n".colorize(:yellow)
|
52
|
+
desc_text << "(#{name})\n".colorize(:green)
|
53
|
+
desc_text << "#{description}\n".colorize(:white)
|
54
|
+
desc_text << "TAKEABLE? #{takeable}\n".colorize(:white)
|
55
|
+
desc_text << "USEABLE? #{useable}\n".colorize(:white)
|
56
|
+
desc_text << "TALKABLE? #{talkable}\n".colorize(:white)
|
57
|
+
desc_text << "CONSUMABLE? #{consumable}\n".colorize(:white)
|
58
|
+
desc_text << "EQUIPPABLE? #{equippable}\n".colorize(:white)
|
59
|
+
desc_text << "EQUIPPED? #{equipped}\n".colorize(:white)
|
60
|
+
desc_text << "USED? #{used}\n".colorize(:white)
|
61
|
+
desc_text << "USES LEFT? #{number_of_uses}\n".colorize(:white) unless number_of_uses.nil?
|
62
|
+
desc_text
|
63
|
+
end
|
64
|
+
|
65
|
+
def display_shopping_cart(cart)
|
66
|
+
puts "ITEMS SELECTED: #{cart.map(&:name).join(', ')}"
|
13
67
|
end
|
14
68
|
|
15
69
|
def puts(s = '', width = GameOptions.data['wrap_width'])
|
@@ -1,36 +1,24 @@
|
|
1
1
|
# lib/gemwarrior/entities/item.rb
|
2
|
-
# Item base class
|
2
|
+
# Entity::Item base class
|
3
3
|
|
4
4
|
require_relative 'entity'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
7
|
class Item < Entity
|
8
|
-
attr_accessor :
|
9
|
-
:
|
8
|
+
attr_accessor :is_armor,
|
9
|
+
:is_weapon
|
10
|
+
|
11
|
+
attr_reader :use
|
10
12
|
|
11
13
|
def initialize
|
12
|
-
|
13
|
-
|
14
|
-
self.
|
15
|
-
self.
|
16
|
-
self.talkable = false
|
14
|
+
super
|
15
|
+
|
16
|
+
self.is_armor = false
|
17
|
+
self.is_weapon = false
|
17
18
|
end
|
18
19
|
|
19
|
-
def use(
|
20
|
+
def use(world)
|
20
21
|
'That item does not do anything...yet.'
|
21
22
|
end
|
22
|
-
|
23
|
-
def describe
|
24
|
-
status_text = name.upcase.colorize(:green)
|
25
|
-
status_text << "\n#{description} \n".colorize(:white)
|
26
|
-
status_text << "ATTACK: #{atk_lo}-#{atk_hi} \n".colorize(:white) unless atk_lo.nil?
|
27
|
-
status_text << "TAKEABLE? #{takeable}\n".colorize(:white)
|
28
|
-
status_text << "USEABLE? #{useable}\n".colorize(:white)
|
29
|
-
status_text << "USED? #{used}\n".colorize(:white)
|
30
|
-
status_text << "EQUIPPABLE? #{equippable}\n".colorize(:white)
|
31
|
-
status_text << "CONSUMABLE? #{consumable}\n".colorize(:white)
|
32
|
-
status_text << "NUMBER OF USES? #{number_of_uses}\n".colorize(:white) unless number_of_uses.nil?
|
33
|
-
status_text << "TALKABLE? #{talkable}\n".colorize(:white)
|
34
|
-
end
|
35
23
|
end
|
36
24
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# lib/gemwarrior/entities/items/apple.rb
|
2
|
-
# Item::Apple
|
2
|
+
# Entity::Item::Apple
|
3
3
|
|
4
4
|
require_relative '../item'
|
5
5
|
|
@@ -9,12 +9,9 @@ module Gemwarrior
|
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'apple'
|
12
|
+
self.name_display = 'Apple'
|
12
13
|
self.description = 'Reddish-orangeish in color, this fruit looks sweet, but it is heavy and feels more like a rock you would sooner not bite into.'
|
13
|
-
self.atk_lo = nil
|
14
|
-
self.atk_hi = nil
|
15
14
|
self.takeable = true
|
16
|
-
self.useable = false
|
17
|
-
self.equippable = false
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# lib/gemwarrior/entities/items/arena_door.rb
|
2
|
-
# Item::ArenaDoor
|
2
|
+
# Entity::Item::ArenaDoor
|
3
3
|
|
4
4
|
require_relative '../item'
|
5
5
|
|
@@ -9,12 +9,8 @@ module Gemwarrior
|
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'arena_door'
|
12
|
+
self.name_display = 'Arena Door'
|
12
13
|
self.description = 'The Arena is massive, with its numerous columns and stone walls stretching to the sky, but its entrance door is no slouch, keeping apace. Made of reinforced granite and impossible to break down, it nevertheless opens for you while battles are in session.'
|
13
|
-
self.atk_lo = nil
|
14
|
-
self.atk_hi = nil
|
15
|
-
self.takeable = false
|
16
|
-
self.useable = false
|
17
|
-
self.equippable = false
|
18
14
|
end
|
19
15
|
end
|
20
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# lib/gemwarrior/entities/items/bed.rb
|
2
|
-
# Item::Bed
|
2
|
+
# Entity::Item::Bed
|
3
3
|
|
4
4
|
require_relative '../item'
|
5
5
|
|
@@ -12,23 +12,19 @@ module Gemwarrior
|
|
12
12
|
super
|
13
13
|
|
14
14
|
self.name = 'bed'
|
15
|
+
self.name_display = 'Bed'
|
15
16
|
self.description = 'The place where you sleep when you are not adventuring.'
|
16
|
-
self.atk_lo = nil
|
17
|
-
self.atk_hi = nil
|
18
|
-
self.takeable = false
|
19
|
-
self.useable = true
|
20
|
-
self.equippable = false
|
21
17
|
end
|
22
18
|
|
23
|
-
def use(
|
24
|
-
if player.at_full_hp?
|
19
|
+
def use(world)
|
20
|
+
if world.player.at_full_hp?
|
25
21
|
puts 'You feel perfectly healthy and decide not to actually use the bed. Besides, the trail of fire ants currently leading up to and around the furniture seem somehow uninviting.'
|
26
22
|
{ type: nil, data: nil }
|
27
23
|
else
|
28
|
-
Animation
|
24
|
+
Animation.run(phrase: USE_TEXT)
|
29
25
|
puts 'You unmake the bed, get under the covers, close your eyes, and begin to think about all the things you need to do today. You realize sleep is not one of them and quickly get back up, remake the bed, and get on about your day.'
|
30
|
-
puts '>> You regain a few hit points.'
|
31
|
-
{ type: 'rest', data: 5 }
|
26
|
+
puts '>> You regain a few hit points.'.colorize(:green)
|
27
|
+
{ type: 'rest', data: rand(5..7) }
|
32
28
|
end
|
33
29
|
end
|
34
30
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/bookcase.rb
|
2
|
+
# Entity::Item::Bookcase
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Bookcase < Item
|
8
|
+
# CONSTANTS
|
9
|
+
OPEN_TEXT = '** BRRRRRNNNGG **'
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
self.name = 'bookcase'
|
15
|
+
self.name_display = 'Bookcase'
|
16
|
+
self.description = 'This oaken monstrosity has six shelves, each about 3 feet high. Mathing, you determine it to be "huge", featuring many books within it.'
|
17
|
+
end
|
18
|
+
|
19
|
+
def use(world)
|
20
|
+
forest_southwest = world.location_by_name('forest-southwest')
|
21
|
+
|
22
|
+
if forest_southwest.locs_connected[:west].eql? false
|
23
|
+
if !self.used
|
24
|
+
puts 'Many books look interesting, including one specific volume entitled "Use Me Again to Attempt Unlocking the Way", by Not Very Subtle.'
|
25
|
+
puts
|
26
|
+
self.used = true
|
27
|
+
else
|
28
|
+
puts 'You pull out the tome entitled "Use Me Again to Attempt Unlocking the Way".'
|
29
|
+
STDIN.getc
|
30
|
+
puts 'Opening the book, you see a question on the inside cover:'
|
31
|
+
puts '>> "What do you get when an underground excavator is named after a famous "weird" guy?"'
|
32
|
+
answer = gets.chomp.downcase
|
33
|
+
|
34
|
+
case answer
|
35
|
+
when 'mineral'
|
36
|
+
forest_southwest.locs_connected[:west] = true
|
37
|
+
puts
|
38
|
+
Animation.run(phrase: OPEN_TEXT)
|
39
|
+
puts
|
40
|
+
puts 'After you shout out your answer to the book\'s question to no one in particular, you manage to see a clearing in the forest to the west that was presumably not there before. Huh.'
|
41
|
+
STDIN.getc
|
42
|
+
|
43
|
+
puts 'Before getting back to your travels, however, you notice the book\'s back cover warns: "The path westward is a difficult one and has fallen many an adventurer. Take care before venturing thataway."'
|
44
|
+
else
|
45
|
+
puts 'For some reason, you blurt out an answer to the unhearing trees, feel embarrassed, and put the book back in the bookcase.'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
{ type: nil, data: nil }
|
50
|
+
else
|
51
|
+
puts 'You pull out a book here and there, glancing at their weathered pages and scuffed bindings. Nothing really interests you and it is back to staring at the forest.'
|
52
|
+
end
|
53
|
+
|
54
|
+
{ type: nil, data: nil }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|