gemwarrior 0.4.1 → 0.5
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/lib/gemwarrior/entities/creature.rb +13 -18
- data/lib/gemwarrior/entities/entity.rb +3 -9
- data/lib/gemwarrior/entities/item.rb +6 -13
- data/lib/gemwarrior/entities/items/bed.rb +19 -0
- data/lib/gemwarrior/entities/items/feather.rb +19 -0
- data/lib/gemwarrior/entities/items/gun.rb +19 -0
- data/lib/gemwarrior/entities/items/stalactite.rb +19 -0
- data/lib/gemwarrior/entities/items/stone.rb +19 -0
- data/lib/gemwarrior/entities/items/tree.rb +19 -0
- data/lib/gemwarrior/entities/location.rb +38 -74
- data/lib/gemwarrior/entities/monster.rb +12 -35
- data/lib/gemwarrior/entities/monsters/alexandrat.rb +30 -0
- data/lib/gemwarrior/entities/monsters/amberoo.rb +30 -0
- data/lib/gemwarrior/entities/monsters/amethystle.rb +30 -0
- data/lib/gemwarrior/entities/monsters/apatiger.rb +30 -0
- data/lib/gemwarrior/entities/monsters/aquamarine.rb +30 -0
- data/lib/gemwarrior/entities/monsters/bloodstorm.rb +30 -0
- data/lib/gemwarrior/entities/monsters/citrinaga.rb +30 -0
- data/lib/gemwarrior/entities/monsters/coraliz.rb +30 -0
- data/lib/gemwarrior/entities/monsters/cubicat.rb +30 -0
- data/lib/gemwarrior/entities/monsters/diaman.rb +30 -0
- data/lib/gemwarrior/entities/player.rb +117 -154
- data/lib/gemwarrior/evaluator.rb +31 -16
- data/lib/gemwarrior/game.rb +28 -26
- data/lib/gemwarrior/inventory.rb +14 -16
- data/lib/gemwarrior/misc/version.rb +1 -1
- data/lib/gemwarrior/misc/wordlist.rb +7 -1
- data/lib/gemwarrior/repl.rb +2 -2
- data/lib/gemwarrior/world.rb +130 -298
- metadata +20 -7
- data/lib/gemwarrior/defaults.rb +0 -137
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/alexandrat.rb
|
2
|
+
# Alexandrat monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Alexandrat < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'alexandrat'
|
10
|
+
self.description = 'Tiny, but fierce, color-changing rodent.'
|
11
|
+
self.face = 'ugly'
|
12
|
+
self.hands = 'gnarled'
|
13
|
+
self.mood = 'unsurprisingly unchipper'
|
14
|
+
|
15
|
+
self.level = rand(1..2)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 1.5).floor)
|
19
|
+
self.atk_hi = rand((level * 1.5).floor..(level * 2))
|
20
|
+
self.defense = rand(level..(level * 1.5).floor)
|
21
|
+
self.dexterity = rand(1..3)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = 'Bitey, bitey!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/amberoo.rb
|
2
|
+
# Amberoo monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Amberoo < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'amberoo'
|
10
|
+
self.description = 'Fossilized and jumping around like an adorably dangerous threat from the past.'
|
11
|
+
self.face = 'punchy'
|
12
|
+
self.hands = 'balled'
|
13
|
+
self.mood = 'jumpy'
|
14
|
+
|
15
|
+
self.level = rand(1..2)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 2))
|
19
|
+
self.atk_hi = rand((level * 2)..(level * 2.5).floor)
|
20
|
+
self.defense = rand((level * 2)..(level * 2.5).floor)
|
21
|
+
self.dexterity = rand(3..4)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = 'I\'m hoppin\' mad!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/amethystle.rb
|
2
|
+
# Amethystle monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Amethystle < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'amethystle'
|
10
|
+
self.description = 'Sober and contemplative, it moves with purplish tentacles swaying in the breeze.'
|
11
|
+
self.face = 'sharp'
|
12
|
+
self.hands = 'loose'
|
13
|
+
self.mood = 'mesmerizing'
|
14
|
+
|
15
|
+
self.level = rand(2..3)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 1.5).floor)
|
19
|
+
self.atk_hi = rand((level * 1.5).floor..(level * 2.5).floor)
|
20
|
+
self.defense = rand(2..4)
|
21
|
+
self.dexterity = rand(1..2)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = 'You\'ve found yourself in quite the thorny issue!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/apatiger.rb
|
2
|
+
# Apatiger monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Apatiger < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'apatiger'
|
10
|
+
self.description = 'Apathetic about most everything as it lazes around, save for eating you.'
|
11
|
+
self.face = 'calloused'
|
12
|
+
self.hands = 'soft'
|
13
|
+
self.mood = 'apathetic'
|
14
|
+
|
15
|
+
self.level = rand(4..5)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 1.5).floor)
|
19
|
+
self.atk_hi = rand((level * 1.5).floor..(level * 2.5).floor)
|
20
|
+
self.defense = rand(4..7)
|
21
|
+
self.dexterity = rand(3..7)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = 'Gggggggggrrrrrrrrrrrrrrrrooooooooooowwwwwwwwwwwwlllllllll!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/aquamarine.rb
|
2
|
+
# Aquamarine monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Aquamarine < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'aquamarine'
|
10
|
+
self.description = 'It is but one of the few, the proud, the underwater.'
|
11
|
+
self.face = 'strained'
|
12
|
+
self.hands = 'hairy'
|
13
|
+
self.mood = 'tempered'
|
14
|
+
|
15
|
+
self.level = rand(3..4)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 1.5).floor)
|
19
|
+
self.atk_hi = rand((level * 1.5).floor..(level * 2.5).floor)
|
20
|
+
self.defense = rand(3..5)
|
21
|
+
self.dexterity = rand(4..6)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = 'Attention! You are about to get smashed!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/bloodstorm.rb
|
2
|
+
# Bloodstorm monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Bloodstorm < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'bloodstorm'
|
10
|
+
self.description = 'A literal swirling, maniacal vortex of human hemoglobin.'
|
11
|
+
self.face = 'bloody'
|
12
|
+
self.hands = 'bloody'
|
13
|
+
self.mood = 'boiling'
|
14
|
+
|
15
|
+
self.level = rand(5..6)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 1.5).floor)
|
19
|
+
self.atk_hi = rand((level * 1.5).floor..(level * 3).floor)
|
20
|
+
self.defense = rand(6..7)
|
21
|
+
self.dexterity = rand(5..7)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = '/swirls'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/citrinaga.rb
|
2
|
+
# Citrinaga monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Citrinaga < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'citrinaga'
|
10
|
+
self.description = 'Refreshing in its shiny, gleaming effectiveness at ending your life.'
|
11
|
+
self.face = 'shiny'
|
12
|
+
self.hands = 'glistening'
|
13
|
+
self.mood = 'staid'
|
14
|
+
|
15
|
+
self.level = rand(5..7)
|
16
|
+
self.hp_cur = rand((level * 2)..(level*3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level*1.5).floor)
|
19
|
+
self.atk_hi = rand((level*1.5).floor..(level*3).floor)
|
20
|
+
self.defense = rand(7..9)
|
21
|
+
self.dexterity = rand(6..7)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 3))
|
26
|
+
|
27
|
+
self.battlecry = 'Slice and dice so nice!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/coraliz.rb
|
2
|
+
# Coraliz monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Coraliz < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'coraliz'
|
10
|
+
self.description = 'Small blue lizard that slithers around, nipping at your ankles.'
|
11
|
+
self.face = 'spotted'
|
12
|
+
self.hands = 'slippery'
|
13
|
+
self.mood = 'emotionless'
|
14
|
+
|
15
|
+
self.level = rand(5..8)
|
16
|
+
self.hp_cur = rand((level * 2)..(level*3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 3).floor)
|
19
|
+
self.atk_hi = rand((level * 3).floor..(level * 3).floor)
|
20
|
+
self.defense = rand(4..6)
|
21
|
+
self.dexterity = rand(7..9)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 3))
|
26
|
+
|
27
|
+
self.battlecry = 'Where am I? You\'ll never guess!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/cubicat.rb
|
2
|
+
# Cubicat monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Cubicat < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'cubicat'
|
10
|
+
self.description = 'Perfectly geometrically cubed feline, fresh from its woven enclosure, claws at the ready.'
|
11
|
+
self.face = 'striking'
|
12
|
+
self.hands = 'grippy'
|
13
|
+
self.mood = 'salacious'
|
14
|
+
|
15
|
+
self.level = rand(6..8)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 2).floor)
|
19
|
+
self.atk_hi = rand((level * 2).floor..(level * 3).floor)
|
20
|
+
self.defense = rand(5..7)
|
21
|
+
self.dexterity = rand(8..10)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = 'I don\'t really care, as long as you die!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# lib/gemwarrior/entities/monsters/diaman.rb
|
2
|
+
# Diaman monster
|
3
|
+
|
4
|
+
require_relative '../monster'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Diaman < Monster
|
8
|
+
def initialize
|
9
|
+
self.name = 'diaman'
|
10
|
+
self.description = 'Crystalline structure in the form of a man, lumbering toward you, with outstretched, edged pincers.'
|
11
|
+
self.face = 'bright'
|
12
|
+
self.hands = 'jagged'
|
13
|
+
self.mood = 'adamant'
|
14
|
+
|
15
|
+
self.level = rand(8..10)
|
16
|
+
self.hp_cur = rand((level * 2)..(level * 3))
|
17
|
+
self.hp_max = hp_cur
|
18
|
+
self.atk_lo = rand(level..(level * 2.5).floor)
|
19
|
+
self.atk_hi = rand((level * 2.5).floor..(level * 3).floor)
|
20
|
+
self.defense = rand(5..7)
|
21
|
+
self.dexterity = rand(8..10)
|
22
|
+
|
23
|
+
self.inventory = Inventory.new
|
24
|
+
self.rox = rand((level * 2)..(level * 3))
|
25
|
+
self.xp = rand(level..(level * 2))
|
26
|
+
|
27
|
+
self.battlecry = 'Precious human, prepare to be lost to the annals of time!'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -6,53 +6,50 @@ require_relative 'creature'
|
|
6
6
|
module Gemwarrior
|
7
7
|
class Player < Creature
|
8
8
|
# CONSTANTS
|
9
|
-
##
|
10
|
-
CHAR_UPPER_POOL
|
11
|
-
CHAR_LOWER_POOL
|
9
|
+
## CHARACTER ATTRIBUTES
|
10
|
+
CHAR_UPPER_POOL = (65..90).map{ |i| i.chr }
|
11
|
+
CHAR_LOWER_POOL = (97..122).map{ |i| i.chr }
|
12
12
|
CHAR_LOWER_VOWEL_POOL = ['a','e','i','o','u','y']
|
13
|
-
|
14
|
-
FACE_DESC = ['smooth', 'tired', 'ruddy', 'moist', 'shocked', 'handsome', '5 o\'clock-shadowed']
|
15
|
-
HANDS_DESC = ['worn', 'balled into fists', 'relaxed', 'cracked', 'tingly', 'mom\'s spaghetti']
|
16
|
-
MOOD_DESC = ['calm', 'excited', 'depressed', 'tense', 'lackadaisical', 'angry', 'positive']
|
17
|
-
|
18
|
-
## PLAYER DEFAULTS
|
19
|
-
PLYR_DESC_DEFAULT = 'Picked to do battle against a wizened madman for a shiny something or other for world-saving purposes, you\'re actually fairly able, as long as you\'ve had breakfast first.'
|
20
13
|
|
14
|
+
FACE_DESC = ['smooth', 'tired', 'ruddy', 'moist', 'shocked', 'handsome', '5 o\'clock-shadowed']
|
15
|
+
HANDS_DESC = ['worn', 'balled into fists', 'relaxed', 'cracked', 'tingly', 'mom\'s spaghetti']
|
16
|
+
MOOD_DESC = ['calm', 'excited', 'depressed', 'tense', 'lackadaisical', 'angry', 'positive']
|
17
|
+
|
21
18
|
## ERRORS
|
22
|
-
|
23
|
-
ERROR_ATTACK_PARAM_INVALID = 'That monster doesn\'t exist here or can\'t be attacked.'
|
24
|
-
ERROR_ATTACK_OPTION_INVALID = 'That won\'t do anything against the monster.'
|
19
|
+
ERROR_ATTACK_OPTION_INVALID = 'That will not do anything against the monster.'
|
25
20
|
|
26
|
-
attr_accessor :
|
27
|
-
:defense, :dexterity, :rox, :cur_loc,
|
28
|
-
:god_mode
|
21
|
+
attr_accessor :stam_cur, :stam_max, :cur_coords, :god_mode
|
29
22
|
|
30
23
|
def initialize(options)
|
31
|
-
|
32
|
-
|
33
|
-
self.level = options[:level]
|
34
|
-
self.xp = options[:xp]
|
24
|
+
self.name = generate_name
|
25
|
+
self.description = options.fetch(:description)
|
35
26
|
|
36
|
-
self.
|
37
|
-
self.
|
38
|
-
self.
|
39
|
-
self.stam_max = options[:stam_max]
|
27
|
+
self.face = generate_face
|
28
|
+
self.hands = generate_hands
|
29
|
+
self.mood = generate_mood
|
40
30
|
|
41
|
-
self.
|
42
|
-
self.
|
43
|
-
self.
|
44
|
-
self.
|
31
|
+
self.level = options.fetch(:level)
|
32
|
+
self.xp = options.fetch(:xp)
|
33
|
+
self.hp_cur = options.fetch(:hp_cur)
|
34
|
+
self.hp_max = options.fetch(:hp_max)
|
35
|
+
self.atk_lo = options.fetch(:atk_lo)
|
36
|
+
self.atk_hi = options.fetch(:atk_hi)
|
45
37
|
|
46
|
-
self.
|
47
|
-
self.
|
38
|
+
self.defense = options.fetch(:defense)
|
39
|
+
self.dexterity = options.fetch(:dexterity)
|
48
40
|
|
49
|
-
self.
|
50
|
-
|
51
|
-
|
41
|
+
self.inventory = Inventory.new
|
42
|
+
self.rox = options.fetch(:rox)
|
43
|
+
|
44
|
+
self.stam_cur = options.fetch(:stam_cur)
|
45
|
+
self.stam_max = options.fetch(:stam_max)
|
46
|
+
self.cur_coords = options.fetch(:cur_coords)
|
47
|
+
|
48
|
+
self.god_mode = false
|
52
49
|
end
|
53
50
|
|
54
51
|
def check_self(show_pic = true)
|
55
|
-
|
52
|
+
unless show_pic == false
|
56
53
|
print_char_pic
|
57
54
|
end
|
58
55
|
|
@@ -71,10 +68,13 @@ module Gemwarrior
|
|
71
68
|
self_text << "XP : #{xp}\n"
|
72
69
|
self_text << "HP : #{hp_cur}|#{hp_max}\n"
|
73
70
|
self_text << "ATK : #{atk_lo}-#{atk_hi}\n"
|
74
|
-
self_text << "DEF : #{defense}\n"
|
75
71
|
self_text << "DEX : #{dexterity}\n"
|
72
|
+
self_text << "DEF : #{defense}\n"
|
76
73
|
self_text << "GOD : #{god_mode}\n\n"
|
77
|
-
|
74
|
+
|
75
|
+
self_text << "#{description}\n\n"
|
76
|
+
|
77
|
+
self_text << "Current status - breathing, wearing clothing, and with a few other specific characteristics: face is #{face}, hands are #{hands}, and general mood is #{mood}.\n"
|
78
78
|
end
|
79
79
|
|
80
80
|
def rest
|
@@ -86,11 +86,13 @@ module Gemwarrior
|
|
86
86
|
mins_text = minutes == 1 ? "minute" : "minutes"
|
87
87
|
secs_text = seconds == 1 ? "second" : "seconds"
|
88
88
|
|
89
|
+
self.hp_cur = hp_max
|
90
|
+
|
89
91
|
return "You lie down somewhere quasi-flat and after a few moments, due to extreme exhaustion, you fall into a deep slumber. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up with a start, look around you, notice nothing in particular, and get back up, ready to go again."
|
90
92
|
end
|
91
93
|
|
92
94
|
def stamina_dec
|
93
|
-
stam_cur = stam_cur - 1
|
95
|
+
self.stam_cur = stam_cur - 1
|
94
96
|
end
|
95
97
|
|
96
98
|
def modify_name
|
@@ -111,113 +113,86 @@ module Gemwarrior
|
|
111
113
|
def list_inventory
|
112
114
|
inventory.list_contents
|
113
115
|
end
|
114
|
-
|
115
|
-
def loc_by_id(locations, id)
|
116
|
-
locations.each do |loc|
|
117
|
-
if loc.id.to_i.equal? id
|
118
|
-
return loc
|
119
|
-
end
|
120
|
-
end
|
121
|
-
return nil
|
122
|
-
end
|
123
|
-
|
124
|
-
def can_move?(direction)
|
125
|
-
cur_loc.has_loc_to_the?(direction)
|
126
|
-
end
|
127
|
-
|
116
|
+
|
128
117
|
def go(locations, direction)
|
129
118
|
case direction
|
130
|
-
when
|
131
|
-
|
132
|
-
when
|
133
|
-
|
134
|
-
when
|
135
|
-
|
136
|
-
when
|
137
|
-
|
138
|
-
end
|
139
|
-
unless direction.nil?
|
140
|
-
if can_move?(direction)
|
141
|
-
new_loc_id = cur_loc.locs_connected[direction.to_sym]
|
142
|
-
self.cur_loc = loc_by_id(locations, new_loc_id)
|
143
|
-
print_traveling_text
|
144
|
-
self.cur_loc.checked_for_monsters = false
|
145
|
-
self.cur_loc.describe
|
146
|
-
else
|
147
|
-
ERROR_GO_PARAM_INVALID
|
148
|
-
end
|
119
|
+
when 'north', 'n'
|
120
|
+
self.cur_coords = {:x => cur_coords[:x], :y => cur_coords[:y]+1}
|
121
|
+
when 'east', 'e'
|
122
|
+
self.cur_coords = {:x => cur_coords[:x]+1, :y => cur_coords[:y]}
|
123
|
+
when 'south', 's'
|
124
|
+
self.cur_coords = {:x => cur_coords[:x], :y => cur_coords[:y]-1}
|
125
|
+
when 'west', 'w'
|
126
|
+
self.cur_coords = {:x => cur_coords[:x]-1, :y => cur_coords[:y]}
|
149
127
|
end
|
128
|
+
print_traveling_text
|
150
129
|
end
|
151
130
|
|
152
|
-
def attack(
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
puts "#{monster.name} cries out: #{monster.battlecry}"
|
131
|
+
def attack(world, monster)
|
132
|
+
print_battle_line
|
133
|
+
puts "You decide to attack the #{monster.name}!"
|
134
|
+
|
135
|
+
puts "#{monster.name} cries out: #{monster.battlecry}"
|
158
136
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
137
|
+
# first strike!
|
138
|
+
if calculate_first_strike(monster)
|
139
|
+
puts "#{monster.name} strikes first!"
|
140
|
+
player_attacked_by(monster)
|
141
|
+
end
|
142
|
+
|
143
|
+
# main battle loop
|
144
|
+
loop do
|
145
|
+
if (monster.hp_cur <= 0)
|
146
|
+
monster_death(world, monster)
|
147
|
+
return
|
148
|
+
elsif (hp_cur <= 0 && !god_mode)
|
149
|
+
player_death(monster)
|
163
150
|
end
|
164
|
-
|
165
|
-
# main battle loop
|
166
|
-
loop do
|
167
|
-
if (monster.hp_cur <= 0)
|
168
|
-
monster_death(monster)
|
169
|
-
return
|
170
|
-
elsif (hp_cur <= 0 && !god_mode)
|
171
|
-
player_death(monster)
|
172
|
-
end
|
173
151
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
return
|
197
|
-
end
|
198
|
-
else
|
199
|
-
puts "You miss entirely!"
|
200
|
-
end
|
201
|
-
when 'look', 'l'
|
202
|
-
puts "#{monster.name}: #{monster.description}"
|
203
|
-
puts "Its got some distinguishing features, too: face is #{monster.face}, hands are #{monster.hands}, and general mood is #{monster.mood}."
|
204
|
-
when 'run', 'r'
|
205
|
-
if player_escape?(monster)
|
206
|
-
monster.hp_cur = monster.hp_max
|
207
|
-
puts "You successfully elude #{monster.name}!"
|
152
|
+
puts
|
153
|
+
puts "[Fight/Attack][Look][Run]"
|
154
|
+
puts "P :: #{hp_cur} HP\n"
|
155
|
+
puts "M :: #{monster.hp_cur} HP\n"
|
156
|
+
|
157
|
+
if ((monster.hp_cur.to_f / monster.hp_max.to_f) < 0.10)
|
158
|
+
puts "#{monster.name} is almost dead!\n"
|
159
|
+
end
|
160
|
+
|
161
|
+
puts 'What do you do?'
|
162
|
+
cmd = gets.chomp.downcase
|
163
|
+
|
164
|
+
# player action
|
165
|
+
case cmd
|
166
|
+
when 'fight', 'f', 'attack', 'a'
|
167
|
+
puts "You attack #{monster.name}#{cur_weapon_name}!"
|
168
|
+
dmg = calculate_mob_damage
|
169
|
+
if dmg > 0
|
170
|
+
puts "You wound it for #{dmg} point(s)!"
|
171
|
+
monster.take_damage(dmg)
|
172
|
+
if (monster.hp_cur <= 0)
|
173
|
+
monster_death(world, monster)
|
208
174
|
return
|
209
|
-
else
|
210
|
-
puts "You were not able to run away! :-("
|
211
175
|
end
|
212
176
|
else
|
213
|
-
puts
|
177
|
+
puts "You miss entirely!"
|
214
178
|
end
|
215
|
-
|
216
|
-
# monster
|
217
|
-
|
179
|
+
when 'look', 'l'
|
180
|
+
puts "#{monster.name}: #{monster.description}"
|
181
|
+
puts "Its got some distinguishing features, too: face is #{monster.face}, hands are #{monster.hands}, and general mood is #{monster.mood}."
|
182
|
+
when 'run', 'r'
|
183
|
+
if player_escape?(monster)
|
184
|
+
monster.hp_cur = monster.hp_max
|
185
|
+
puts "You successfully elude #{monster.name}!"
|
186
|
+
return
|
187
|
+
else
|
188
|
+
puts "You were not able to run away! :-("
|
189
|
+
end
|
190
|
+
else
|
191
|
+
puts ERROR_ATTACK_OPTION_INVALID
|
218
192
|
end
|
219
|
-
|
220
|
-
|
193
|
+
|
194
|
+
# monster action
|
195
|
+
player_attacked_by(monster)
|
221
196
|
end
|
222
197
|
end
|
223
198
|
|
@@ -225,17 +200,17 @@ module Gemwarrior
|
|
225
200
|
|
226
201
|
# COMBAT
|
227
202
|
def update_player_stats(monster)
|
228
|
-
self.xp = xp + monster.
|
229
|
-
self.rox = rox + monster.
|
203
|
+
self.xp = xp + monster.xp
|
204
|
+
self.rox = rox + monster.rox
|
230
205
|
end
|
231
206
|
|
232
|
-
def monster_death(monster)
|
207
|
+
def monster_death(world, monster)
|
233
208
|
puts "You have defeated #{monster.name}!"
|
234
|
-
puts "You have received #{monster.
|
235
|
-
puts "You have found #{monster.
|
209
|
+
puts "You have received #{monster.xp} XP!"
|
210
|
+
puts "You have found #{monster.rox} barterable rox on your slain opponent!"
|
236
211
|
print_battle_line
|
237
212
|
update_player_stats(monster)
|
238
|
-
|
213
|
+
world.location_by_coords(cur_coords).remove_monster(monster.name)
|
239
214
|
end
|
240
215
|
|
241
216
|
def player_death(monster)
|
@@ -319,7 +294,7 @@ module Gemwarrior
|
|
319
294
|
print "#{Matrext::process({ :phrase => ">>>", :sl => true })}"
|
320
295
|
print " *\n"
|
321
296
|
end
|
322
|
-
loc.join
|
297
|
+
return loc.join
|
323
298
|
end
|
324
299
|
|
325
300
|
# CHARACTER
|
@@ -335,6 +310,10 @@ module Gemwarrior
|
|
335
310
|
puts char_pic
|
336
311
|
end
|
337
312
|
|
313
|
+
def print_battle_line
|
314
|
+
puts '**************************************'
|
315
|
+
end
|
316
|
+
|
338
317
|
# INIT
|
339
318
|
def generate_name
|
340
319
|
name = []
|
@@ -347,10 +326,6 @@ module Gemwarrior
|
|
347
326
|
return name.join
|
348
327
|
end
|
349
328
|
|
350
|
-
def generate_desc
|
351
|
-
PLYR_DESC_DEFAULT
|
352
|
-
end
|
353
|
-
|
354
329
|
def generate_face
|
355
330
|
FACE_DESC[rand(0..FACE_DESC.length-1)]
|
356
331
|
end
|
@@ -362,17 +337,5 @@ module Gemwarrior
|
|
362
337
|
def generate_mood
|
363
338
|
MOOD_DESC[rand(0..MOOD_DESC.length-1)]
|
364
339
|
end
|
365
|
-
|
366
|
-
def generate_player_identity
|
367
|
-
self.name = generate_name
|
368
|
-
self.description = generate_desc
|
369
|
-
self.face = generate_face
|
370
|
-
self.hands = generate_hands
|
371
|
-
self.mood = generate_mood
|
372
|
-
end
|
373
|
-
|
374
|
-
def print_battle_line
|
375
|
-
puts '**************************************'
|
376
|
-
end
|
377
340
|
end
|
378
341
|
end
|