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,38 @@
|
|
1
|
+
# lib/gemwarrior/entities/weapon.rb
|
2
|
+
# Entity::Item::Weapon base class
|
3
|
+
|
4
|
+
require_relative 'item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Weapon < Item
|
8
|
+
attr_accessor :atk_lo,
|
9
|
+
:atk_hi,
|
10
|
+
:is_weapon
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super
|
14
|
+
|
15
|
+
self.atk_lo = 0
|
16
|
+
self.atk_hi = 0
|
17
|
+
self.takeable = true
|
18
|
+
self.equippable = true
|
19
|
+
self.is_weapon = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def use(world)
|
23
|
+
'Save the using of your weapon for battle.'
|
24
|
+
end
|
25
|
+
|
26
|
+
def describe_detailed
|
27
|
+
desc_text = "\"#{name_display}\"\n".colorize(:yellow)
|
28
|
+
desc_text << "(#{name})\n".colorize(:green)
|
29
|
+
desc_text << "#{description}\n".colorize(:white)
|
30
|
+
desc_text << "ATTACK_RANGE: #{atk_lo}-#{atk_hi}\n".colorize(:white)
|
31
|
+
desc_text << "TAKEABLE? #{takeable}\n".colorize(:white)
|
32
|
+
desc_text << "USEABLE? #{useable}\n".colorize(:white)
|
33
|
+
desc_text << "EQUIPPABLE? #{equippable}\n".colorize(:white)
|
34
|
+
desc_text << "EQUIPPED? #{equipped}\n".colorize(:white)
|
35
|
+
desc_text
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
# lib/gemwarrior/entities/
|
2
|
-
# Item::Dagger
|
1
|
+
# lib/gemwarrior/entities/weapons/dagger.rb
|
2
|
+
# Entity::Item::Weapon::Dagger
|
3
3
|
|
4
|
-
require_relative '../
|
4
|
+
require_relative '../weapon'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
|
-
class Dagger <
|
7
|
+
class Dagger < Weapon
|
8
8
|
def initialize
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'dagger'
|
12
|
+
self.name_display = 'Dagger'
|
12
13
|
self.description = 'Flint that has been sharpened to a point, attached to a block of smooth granite by thin rope. Truly a work of art.'
|
13
14
|
self.atk_lo = 1
|
14
15
|
self.atk_hi = 3
|
15
|
-
self.takeable = true
|
16
|
-
self.useable = false
|
17
|
-
self.equippable = true
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
@@ -1,23 +1,21 @@
|
|
1
|
-
# lib/gemwarrior/entities/
|
2
|
-
# Item::Gun
|
1
|
+
# lib/gemwarrior/entities/weapons/gun.rb
|
2
|
+
# Entity::Item::Weapon::Gun
|
3
3
|
|
4
|
-
require_relative '../
|
4
|
+
require_relative '../weapon'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
|
-
class Gun <
|
7
|
+
class Gun < Weapon
|
8
8
|
def initialize
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'gun'
|
12
|
-
self.
|
12
|
+
self.name_display = 'Gun'
|
13
|
+
self.description = 'Pew pew goes this firearm, you suspect (if it has bullets).'
|
13
14
|
self.atk_lo = 2
|
14
|
-
self.atk_hi =
|
15
|
-
self.takeable = true
|
16
|
-
self.useable = true
|
17
|
-
self.equippable = true
|
15
|
+
self.atk_hi = 6
|
18
16
|
end
|
19
17
|
|
20
|
-
def use(
|
18
|
+
def use(world)
|
21
19
|
puts 'You pull the trigger on the gun, but it does not fire. An inscription on the barrel reads: "Only shoots when pointed at a monster." How safe!'
|
22
20
|
{ type: nil, data: nil }
|
23
21
|
end
|
@@ -1,24 +1,21 @@
|
|
1
|
-
# lib/gemwarrior/entities/
|
2
|
-
# Item::Mace
|
1
|
+
# lib/gemwarrior/entities/weapons/mace.rb
|
2
|
+
# Entity::Item::Weapon::Mace
|
3
3
|
|
4
|
-
require_relative '../
|
4
|
+
require_relative '../weapon'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
|
-
class Mace <
|
7
|
+
class Mace < Weapon
|
8
8
|
def initialize
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'mace'
|
12
|
+
self.name_display = 'Mace'
|
12
13
|
self.description = 'Sharp spikes atop a steel ball, affixed to a sturdy wooden handle. You could do damage with this.'
|
13
14
|
self.atk_lo = 4
|
14
15
|
self.atk_hi = 6
|
15
|
-
self.takeable = true
|
16
|
-
self.useable = true
|
17
|
-
self.consumable = false
|
18
|
-
self.equippable = true
|
19
16
|
end
|
20
17
|
|
21
|
-
def use(
|
18
|
+
def use(world)
|
22
19
|
puts 'You swing the mace around a few times, really testing out its smashability.'
|
23
20
|
{ type: nil, data: nil }
|
24
21
|
end
|
@@ -1,23 +1,21 @@
|
|
1
|
-
# lib/gemwarrior/entities/
|
2
|
-
# Item::Opalaser
|
1
|
+
# lib/gemwarrior/entities/weapons/opalaser.rb
|
2
|
+
# Entity::Item::Weapon::Opalaser
|
3
3
|
|
4
4
|
require_relative '../item'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
|
-
class Opalaser <
|
7
|
+
class Opalaser < Weapon
|
8
8
|
def initialize
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'opalaser'
|
12
|
+
self.name_display = 'Opalaser'
|
12
13
|
self.description = 'Gleaming with supernatural light, this object feels alien, yet familiar.'
|
13
14
|
self.atk_lo = 9
|
14
15
|
self.atk_hi = 11
|
15
|
-
self.takeable = true
|
16
|
-
self.useable = true
|
17
|
-
self.equippable = true
|
18
16
|
end
|
19
17
|
|
20
|
-
def use(
|
18
|
+
def use(world)
|
21
19
|
puts 'You pull the "trigger" on the opalaser, but nothing happens.'
|
22
20
|
{ type: nil, data: nil }
|
23
21
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# lib/gemwarrior/entities/weapons/spear.rb
|
2
|
+
# Entity::Item::Weapon::Spear
|
3
|
+
|
4
|
+
require_relative '../weapon'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Spear < Weapon
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
|
11
|
+
self.name = 'spear'
|
12
|
+
self.name_display = 'Spear'
|
13
|
+
self.description = 'About six feet in length and razor-sharp at the point, this spear requires two hands, but only one good stab.'
|
14
|
+
self.atk_lo = 3
|
15
|
+
self.atk_hi = 7
|
16
|
+
end
|
17
|
+
|
18
|
+
def use(world)
|
19
|
+
puts 'This spear does, indeed, appear to strike fear upon that which is near.'
|
20
|
+
{ type: nil, data: nil }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,20 +1,18 @@
|
|
1
|
-
# lib/gemwarrior/entities/
|
2
|
-
# Item::Stalactite
|
1
|
+
# lib/gemwarrior/entities/weapons/stalactite.rb
|
2
|
+
# Entity::Item::Weapon::Stalactite
|
3
3
|
|
4
|
-
require_relative '../
|
4
|
+
require_relative '../weapon'
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
|
-
class Stalactite <
|
7
|
+
class Stalactite < Weapon
|
8
8
|
def initialize
|
9
9
|
super
|
10
10
|
|
11
11
|
self.name = 'stalactite'
|
12
|
+
self.name_display = 'Stalactite'
|
12
13
|
self.description = 'Long protrusion of cave adornment, broken off and fallen to the ground, where the stalagmites sneer at it from.'
|
13
14
|
self.atk_lo = 2
|
14
15
|
self.atk_hi = 3
|
15
|
-
self.takeable = true
|
16
|
-
self.useable = false
|
17
|
-
self.equippable = true
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# lib/gemwarrior/entities/weapons/stone.rb
|
2
|
+
# Entity::Item::Weapon::Stone
|
3
|
+
|
4
|
+
require_relative '../weapon'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Stone < Weapon
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
|
11
|
+
self.name = 'stone'
|
12
|
+
self.name_display = 'Stone'
|
13
|
+
self.description = 'A small, yet quite sharp, sedimentary pebble, suitable for tossing in amusement, and perhaps combat.'
|
14
|
+
self.atk_lo = 1
|
15
|
+
self.atk_hi = 2
|
16
|
+
end
|
17
|
+
|
18
|
+
def use(world)
|
19
|
+
puts 'You toss the stone a few feet into the air, and then it falls back into your palm. The experience was truly thrilling.'
|
20
|
+
{ type: nil, data: nil }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/gemwarrior/evaluator.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# Evaluates prompt input
|
3
3
|
|
4
4
|
require_relative 'arena'
|
5
|
+
require_relative 'game_assets'
|
5
6
|
require_relative 'game_options'
|
6
7
|
|
7
8
|
module Gemwarrior
|
@@ -13,7 +14,7 @@ module Gemwarrior
|
|
13
14
|
|
14
15
|
GO_PARAMS = 'Options: north, east, south, west'
|
15
16
|
CHANGE_PARAMS = 'Options: name'
|
16
|
-
DEBUG_LIST_PARAMS = 'Options:
|
17
|
+
DEBUG_LIST_PARAMS = 'Options: players, creatures, items, locations, monsters, weapons'
|
17
18
|
DEBUG_STAT_PARAMS = 'Options: hp_cur, atk_lo, atk_hi, experience, rox, strength, dexterity, defense, inventory'
|
18
19
|
|
19
20
|
ERROR_COMMAND_INVALID = 'That is not something the game yet understands.'
|
@@ -39,20 +40,27 @@ module Gemwarrior
|
|
39
40
|
ERROR_LIST_PARAM_INVALID = 'You cannot list that...yet.'
|
40
41
|
ERROR_DEBUG_STAT_PARAM_MISSING = 'You cannot just "change stats". You gotta choose a stat to change.'
|
41
42
|
ERROR_DEBUG_STAT_PARAM_INVALID = 'You cannot change that stat...yet.'
|
43
|
+
ERROR_DEBUG_STAT_INV_PARAM_INVALID = 'You cannot add that to your inventory...yet.'
|
42
44
|
ERROR_DEBUG_TELEPORT_PARAMS_MISSING = 'You cannot just "teleport". You gotta specify an x AND y coordinate, at least.'
|
43
45
|
ERROR_DEBUG_TELEPORT_PARAMS_NEEDED = 'You cannot just "teleport" to an x coordinate without a y coordinate.'
|
44
46
|
ERROR_DEBUG_TELEPORT_PARAMS_INVALID = 'You cannot teleport there...yet.'
|
45
47
|
|
46
48
|
attr_accessor :world,
|
47
|
-
:commands,
|
48
|
-
:
|
49
|
+
:commands,
|
50
|
+
:aliases,
|
51
|
+
:extras,
|
52
|
+
:cmd_descriptions,
|
53
|
+
:devcommands,
|
54
|
+
:devaliases,
|
55
|
+
:devextras,
|
56
|
+
:devcmd_descriptions
|
49
57
|
|
50
58
|
def initialize(world)
|
51
59
|
self.world = world
|
52
60
|
|
53
|
-
self.devcommands
|
54
|
-
self.devaliases
|
55
|
-
self.devextras
|
61
|
+
self.devcommands = %w(god beast list vars map stat teleport spawn levelbump restfight)
|
62
|
+
self.devaliases = %w(gd bs ls vs m st tp sp lb rf)
|
63
|
+
self.devextras = %w()
|
56
64
|
self.devcmd_descriptions = [
|
57
65
|
'Toggle god mode (i.e. invincible)',
|
58
66
|
'Toggle beast mode (i.e. super strength)',
|
@@ -66,16 +74,16 @@ module Gemwarrior
|
|
66
74
|
'Rest, but ensure battle for testing'
|
67
75
|
]
|
68
76
|
|
69
|
-
self.commands
|
70
|
-
self.aliases
|
71
|
-
self.extras
|
77
|
+
self.commands = %w(character look rest take talk inventory use drop equip unequip go north east south west attack change version checkupdate help quit quit!)
|
78
|
+
self.aliases = %w(c l r t tk i u d eq ue g n e s w a ch v cu h q qq)
|
79
|
+
self.extras = %w(exit exit! x xx fight f ? ?? ???)
|
72
80
|
self.cmd_descriptions = [
|
73
81
|
'Display character information',
|
74
|
-
'Look in your inventory',
|
75
|
-
'Take a load off and regain HP',
|
76
82
|
'Look around your current location',
|
83
|
+
'Take a load off and regain HP',
|
77
84
|
'Take item',
|
78
85
|
'Talk to person',
|
86
|
+
'Look in your inventory',
|
79
87
|
'Use item (in inventory or environment)',
|
80
88
|
'Drop item',
|
81
89
|
'Equip item',
|
@@ -86,7 +94,7 @@ module Gemwarrior
|
|
86
94
|
'Go south (shortcut)',
|
87
95
|
'Go west (shortcut)',
|
88
96
|
'Attack a monster (also fight)',
|
89
|
-
'Change
|
97
|
+
'Change attribute',
|
90
98
|
'Display game version',
|
91
99
|
'Check for newer game releases',
|
92
100
|
'This help menu (also ?)',
|
@@ -95,24 +103,25 @@ module Gemwarrior
|
|
95
103
|
]
|
96
104
|
end
|
97
105
|
|
98
|
-
def
|
106
|
+
def parse(input)
|
99
107
|
case input
|
100
108
|
# Ctrl-D or empty command
|
101
109
|
when nil, ''
|
102
110
|
return
|
103
111
|
# real command
|
104
112
|
else
|
105
|
-
|
106
|
-
unless input_valid?(input)
|
107
|
-
return ERROR_COMMAND_INVALID
|
108
|
-
end
|
113
|
+
return ERROR_COMMAND_INVALID.colorize(:red) unless input_valid?(input)
|
109
114
|
end
|
110
115
|
|
116
|
+
tokens = input.split
|
111
117
|
command = tokens.first.downcase
|
112
118
|
param1 = tokens[1]
|
113
119
|
param2 = tokens[2]
|
114
120
|
param3 = tokens[3]
|
115
121
|
|
122
|
+
# helpful
|
123
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
124
|
+
|
116
125
|
# dev commands
|
117
126
|
if GameOptions.data['debug_mode']
|
118
127
|
case command
|
@@ -123,7 +132,11 @@ module Gemwarrior
|
|
123
132
|
GameOptions.data['beast_mode'] = !GameOptions.data['beast_mode']
|
124
133
|
return "Beast mode set to #{GameOptions.data['beast_mode']}"
|
125
134
|
when 'vars', 'vs'
|
126
|
-
|
135
|
+
if param1
|
136
|
+
world.print_vars(param1)
|
137
|
+
else
|
138
|
+
world.print_vars
|
139
|
+
end
|
127
140
|
when 'list', 'ls'
|
128
141
|
if param1.nil?
|
129
142
|
puts ERROR_LIST_PARAM_MISSING
|
@@ -214,16 +227,23 @@ module Gemwarrior
|
|
214
227
|
end
|
215
228
|
when 'inventory', 'inv'
|
216
229
|
unless param2.nil?
|
217
|
-
|
230
|
+
begin
|
231
|
+
item_const_name = Gemwarrior.const_get(Formatting.upstyle(param2))
|
232
|
+
item = item_const_name.new
|
233
|
+
world.player.inventory.items.push(item)
|
234
|
+
return "#{item.name} added to player inventory."
|
235
|
+
rescue
|
236
|
+
return ERROR_DEBUG_STAT_INV_PARAM_INVALID
|
237
|
+
end
|
218
238
|
end
|
219
239
|
else
|
220
240
|
return ERROR_DEBUG_STAT_PARAM_INVALID
|
221
241
|
end
|
222
242
|
end
|
223
243
|
when 'spawn', 'sp'
|
224
|
-
|
225
|
-
|
226
|
-
return world.describe(
|
244
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
245
|
+
player_cur_location.populate_monsters(GameMonsters.data, spawn: true)
|
246
|
+
return world.describe(player_cur_location)
|
227
247
|
when 'teleport', 'tp'
|
228
248
|
if param1.nil?
|
229
249
|
return ERROR_DEBUG_TELEPORT_PARAMS_MISSING
|
@@ -239,7 +259,7 @@ module Gemwarrior
|
|
239
259
|
|
240
260
|
# check to make sure new location exists
|
241
261
|
if world.location_by_coords(x: x_coord, y: y_coord, z: z_coord)
|
242
|
-
world.player.cur_coords = {x: x_coord, y: y_coord, z: z_coord}
|
262
|
+
world.player.cur_coords = { x: x_coord, y: y_coord, z: z_coord }
|
243
263
|
else
|
244
264
|
return ERROR_DEBUG_TELEPORT_PARAMS_INVALID
|
245
265
|
end
|
@@ -264,8 +284,9 @@ module Gemwarrior
|
|
264
284
|
# stats
|
265
285
|
world.player.movements_made += 1
|
266
286
|
|
267
|
-
Animation
|
268
|
-
|
287
|
+
Animation.run(phrase: '** TELEPORT! **', speed: :insane)
|
288
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
289
|
+
return world.describe(player_cur_location)
|
269
290
|
end
|
270
291
|
when 'levelbump', 'lb'
|
271
292
|
world.player.update_stats(reason: :level_bump, value: 1)
|
@@ -289,16 +310,29 @@ module Gemwarrior
|
|
289
310
|
else
|
290
311
|
world.player.list_inventory
|
291
312
|
end
|
313
|
+
when 'look', 'l'
|
314
|
+
if param1
|
315
|
+
# convert 'look at' to 'look'
|
316
|
+
if param1.eql?('at')
|
317
|
+
if param2
|
318
|
+
param1 = param2
|
319
|
+
else
|
320
|
+
return ERROR_LOOK_AT_PARAM_MISSING
|
321
|
+
end
|
322
|
+
end
|
323
|
+
world.describe_entity(player_cur_location, param1)
|
324
|
+
else
|
325
|
+
world.describe(player_cur_location)
|
326
|
+
end
|
292
327
|
when 'rest', 'r'
|
293
328
|
tent_uses = 0
|
294
|
-
player_inventory = world.player.inventory
|
295
|
-
location_inventory = world.location_by_coords(world.player.cur_coords).items
|
329
|
+
player_inventory = world.player.inventory
|
296
330
|
|
297
|
-
if player_inventory.
|
298
|
-
player_inventory.each do |i|
|
331
|
+
if player_inventory.contains_item?('tent')
|
332
|
+
player_inventory.items.each do |i|
|
299
333
|
if i.name.eql?('tent')
|
300
334
|
if i.number_of_uses > 0
|
301
|
-
result = i.use(world
|
335
|
+
result = i.use(world)
|
302
336
|
tent_uses = i.number_of_uses
|
303
337
|
i.number_of_uses -= 1
|
304
338
|
|
@@ -306,11 +340,11 @@ module Gemwarrior
|
|
306
340
|
end
|
307
341
|
end
|
308
342
|
end
|
309
|
-
elsif
|
310
|
-
|
343
|
+
elsif player_cur_location.contains_item?('tent')
|
344
|
+
player_cur_location.items.each do |i|
|
311
345
|
if i.name.eql?('tent')
|
312
346
|
if i.number_of_uses > 0
|
313
|
-
result = i.use(world
|
347
|
+
result = i.use(world)
|
314
348
|
tent_uses = i.number_of_uses
|
315
349
|
i.number_of_uses -= 1
|
316
350
|
|
@@ -327,24 +361,11 @@ module Gemwarrior
|
|
327
361
|
else
|
328
362
|
result
|
329
363
|
end
|
330
|
-
when 'look', 'l'
|
331
|
-
if param1
|
332
|
-
if param1.eql?('at')
|
333
|
-
if param2
|
334
|
-
param1 = param2
|
335
|
-
else
|
336
|
-
return ERROR_LOOK_AT_PARAM_MISSING
|
337
|
-
end
|
338
|
-
end
|
339
|
-
world.describe_entity(world.location_by_coords(world.player.cur_coords), param1)
|
340
|
-
else
|
341
|
-
world.describe(world.location_by_coords(world.player.cur_coords))
|
342
|
-
end
|
343
364
|
when 'take', 't'
|
344
365
|
if param1.nil?
|
345
366
|
ERROR_TAKE_PARAM_MISSING
|
346
367
|
else
|
347
|
-
world.player.inventory.add_item(
|
368
|
+
world.player.inventory.add_item(param1, player_cur_location, world.player)
|
348
369
|
end
|
349
370
|
when 'talk', 'tk'
|
350
371
|
if param1.nil?
|
@@ -356,52 +377,32 @@ module Gemwarrior
|
|
356
377
|
return ERROR_TALK_TO_PARAM_MISSING
|
357
378
|
end
|
358
379
|
end
|
359
|
-
|
380
|
+
|
360
381
|
person_name = param1
|
361
|
-
result = nil
|
362
382
|
|
363
|
-
player_inventory = world.player.inventory
|
364
|
-
location = world.location_by_coords(world.player.cur_coords)
|
365
|
-
location_inventory = location.items
|
383
|
+
player_inventory = world.player.inventory
|
366
384
|
|
367
|
-
if player_inventory.
|
368
|
-
player_inventory.each do |person|
|
385
|
+
if player_inventory.contains_item?(person_name)
|
386
|
+
player_inventory.items.each do |person|
|
369
387
|
if person.name.eql?(person_name)
|
370
388
|
if person.talkable
|
371
|
-
|
389
|
+
return self.parse("use #{person_name}")
|
372
390
|
else
|
373
391
|
return ERROR_TALK_PARAM_UNTALKABLE
|
374
392
|
end
|
375
393
|
end
|
376
394
|
end
|
377
|
-
elsif
|
378
|
-
|
395
|
+
elsif player_cur_location.contains_item?(person_name)
|
396
|
+
player_cur_location.items.each do |person|
|
379
397
|
if person.name.eql?(person_name)
|
380
398
|
if person.talkable
|
381
|
-
|
399
|
+
return self.parse("use #{person_name}")
|
382
400
|
else
|
383
401
|
return ERROR_TALK_PARAM_UNTALKABLE
|
384
402
|
end
|
385
403
|
end
|
386
404
|
end
|
387
405
|
end
|
388
|
-
|
389
|
-
return ERROR_TALK_PARAM_INVALID if result.nil?
|
390
|
-
|
391
|
-
case result[:type]
|
392
|
-
when 'arena'
|
393
|
-
arena_result = Arena.new(world: world, player: world.player)
|
394
|
-
arena_result = arena.start
|
395
|
-
|
396
|
-
if arena_result.eql?('death')
|
397
|
-
player_death_resurrection
|
398
|
-
end
|
399
|
-
when 'purchase'
|
400
|
-
result[:data].each do |i|
|
401
|
-
world.player.inventory.items.push(i)
|
402
|
-
end
|
403
|
-
return
|
404
|
-
end
|
405
406
|
when 'use', 'u'
|
406
407
|
if param1.nil?
|
407
408
|
ERROR_USE_PARAM_MISSING
|
@@ -409,50 +410,48 @@ module Gemwarrior
|
|
409
410
|
item_name = param1
|
410
411
|
result = nil
|
411
412
|
|
412
|
-
player_inventory = world.player.inventory
|
413
|
-
location = world.location_by_coords(world.player.cur_coords)
|
414
|
-
location_inventory = location.items
|
413
|
+
player_inventory = world.player.inventory
|
415
414
|
|
416
|
-
if player_inventory.
|
417
|
-
player_inventory.each do |i|
|
415
|
+
if player_inventory.contains_item?(item_name)
|
416
|
+
player_inventory.items.each do |i|
|
418
417
|
if i.name.eql?(item_name)
|
419
418
|
if i.useable
|
420
419
|
if !i.number_of_uses.nil?
|
421
420
|
if i.number_of_uses > 0
|
422
|
-
result = i.use(world
|
421
|
+
result = i.use(world)
|
423
422
|
i.number_of_uses -= 1
|
424
423
|
puts ">> #{i.name} can be used #{i.number_of_uses} more time(s)."
|
425
424
|
else
|
426
425
|
return ">> #{i.name} cannot be used anymore."
|
427
426
|
end
|
428
427
|
elsif i.consumable
|
429
|
-
result = i.use(world
|
428
|
+
result = i.use(world)
|
430
429
|
world.player.inventory.remove_item(i.name)
|
431
430
|
else
|
432
|
-
result = i.use(world
|
431
|
+
result = i.use(world)
|
433
432
|
end
|
434
433
|
else
|
435
434
|
return ERROR_USE_PARAM_UNUSEABLE
|
436
435
|
end
|
437
436
|
end
|
438
437
|
end
|
439
|
-
elsif
|
440
|
-
|
438
|
+
elsif player_cur_location.contains_item?(item_name)
|
439
|
+
player_cur_location.items.each do |i|
|
441
440
|
if i.name.eql?(item_name)
|
442
441
|
if i.useable
|
443
442
|
if !i.number_of_uses.nil?
|
444
443
|
if i.number_of_uses > 0
|
445
|
-
result = i.use(world
|
444
|
+
result = i.use(world)
|
446
445
|
i.number_of_uses -= 1
|
447
446
|
puts ">> #{i.name} can be used #{i.number_of_uses} more time(s)."
|
448
447
|
else
|
449
448
|
return ">> #{i.name} cannot be used anymore."
|
450
449
|
end
|
451
450
|
elsif i.consumable
|
452
|
-
result = i.use(world
|
451
|
+
result = i.use(world)
|
453
452
|
location.remove_item(i.name)
|
454
453
|
else
|
455
|
-
result = i.use(world
|
454
|
+
result = i.use(world)
|
456
455
|
end
|
457
456
|
else
|
458
457
|
return ERROR_USE_PARAM_UNUSEABLE
|
@@ -467,11 +466,16 @@ module Gemwarrior
|
|
467
466
|
case result[:type]
|
468
467
|
when 'move'
|
469
468
|
world.player.cur_coords = world.location_coords_by_name(result[:data])
|
470
|
-
world.
|
469
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
470
|
+
world.describe(player_cur_location)
|
471
471
|
when 'move_dangerous'
|
472
|
-
|
472
|
+
dmg = rand(0..2)
|
473
|
+
puts ">> You lose #{dmg} hit point(s)." if dmg > 0
|
474
|
+
world.player.take_damage(dmg)
|
475
|
+
|
473
476
|
world.player.cur_coords = world.location_coords_by_name(result[:data])
|
474
|
-
world.
|
477
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
478
|
+
world.describe(player_cur_location)
|
475
479
|
when 'dmg'
|
476
480
|
world.player.take_damage(result[:data])
|
477
481
|
return
|
@@ -496,7 +500,7 @@ module Gemwarrior
|
|
496
500
|
player_death_resurrection
|
497
501
|
end
|
498
502
|
when 'item'
|
499
|
-
|
503
|
+
player_cur_location.add_item(result[:data])
|
500
504
|
return
|
501
505
|
when 'purchase'
|
502
506
|
result[:data].each do |i|
|
@@ -564,11 +568,11 @@ module Gemwarrior
|
|
564
568
|
else
|
565
569
|
monster_name = param1
|
566
570
|
if world.has_monster_to_attack?(monster_name)
|
567
|
-
monster =
|
571
|
+
monster = player_cur_location.monster_by_name(monster_name)
|
568
572
|
result = world.player.attack(world, monster)
|
569
573
|
|
570
574
|
if result.eql?('death')
|
571
|
-
player_death_resurrection
|
575
|
+
return player_death_resurrection
|
572
576
|
elsif result.eql?('exit')
|
573
577
|
return 'exit'
|
574
578
|
end
|
@@ -579,7 +583,8 @@ module Gemwarrior
|
|
579
583
|
result[:data]
|
580
584
|
when 'move'
|
581
585
|
world.player.cur_coords = world.location_coords_by_name(result[:data])
|
582
|
-
world.
|
586
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
587
|
+
world.describe(player_cur_location)
|
583
588
|
end
|
584
589
|
end
|
585
590
|
else
|
@@ -606,8 +611,8 @@ module Gemwarrior
|
|
606
611
|
'checkupdate'
|
607
612
|
when 'quit', 'exit', 'q', 'x'
|
608
613
|
print 'You sure you want to quit? (y/n) '
|
609
|
-
|
610
|
-
|
614
|
+
answer = gets.chomp.downcase
|
615
|
+
|
611
616
|
case answer
|
612
617
|
when 'y', 'yes'
|
613
618
|
puts QUIT_MESSAGE
|
@@ -628,37 +633,36 @@ module Gemwarrior
|
|
628
633
|
def try_to_move_player(direction)
|
629
634
|
if world.can_move?(direction)
|
630
635
|
world.player.go(world.locations, direction)
|
631
|
-
world.location_by_coords(world.player.cur_coords)
|
632
|
-
|
636
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
637
|
+
player_cur_location.checked_for_monsters = false
|
638
|
+
world.describe(player_cur_location)
|
633
639
|
else
|
634
640
|
return ERROR_GO_PARAM_INVALID
|
635
641
|
end
|
636
642
|
end
|
637
643
|
|
638
644
|
def player_death_resurrection
|
639
|
-
|
640
|
-
{ frequencies: 'D#5', duration: 100 },
|
641
|
-
{ frequencies: 'A4', duration: 150 },
|
642
|
-
{ frequencies: 'F#4', duration: 200 },
|
643
|
-
{ frequencies: 'F4', duration: 1000 }
|
644
|
-
])
|
645
|
+
Audio.play_synth(:player_resurrection)
|
645
646
|
|
646
647
|
puts 'Somehow, though, your adventure does not end here!'.colorize(:yellow)
|
647
648
|
puts 'Instead, you are whisked back home via some magical force.'.colorize(:yellow)
|
648
649
|
puts 'A bit worse for the weary and somewhat poorer, but you are ALIVE!'.colorize(:yellow)
|
650
|
+
puts
|
651
|
+
|
649
652
|
world.player.hp_cur = 1
|
650
653
|
world.player.rox -= (world.player.rox * 0.1).to_i
|
651
654
|
if world.player.rox < 0
|
652
655
|
world.player.rox = 0
|
653
656
|
end
|
654
657
|
world.player.cur_coords = world.location_coords_by_name('Home')
|
655
|
-
world.
|
658
|
+
player_cur_location = world.location_by_coords(world.player.cur_coords)
|
659
|
+
world.describe(player_cur_location)
|
656
660
|
world.player.deaths += 1
|
657
661
|
return
|
658
662
|
end
|
659
663
|
|
660
664
|
def print_separator
|
661
|
-
puts
|
665
|
+
puts '========================================================='
|
662
666
|
end
|
663
667
|
|
664
668
|
def list_commands
|