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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dda7511ef167bd6776d0da74d168cb2d99b17635
|
4
|
+
data.tar.gz: ceb694fe92e5528d0ec89a1e312a1878b0058e5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce465c7fd3627748fdd14891dd203fe96606a39dedf287889ab49e947a3b11492d8a902adabc78273e554cda6fda32a9e9f899468f469d3c028118a095a9f636
|
7
|
+
data.tar.gz: 50f552b9b60c672ed408e9928aa2019aa6850090ac012f9cc9d82f6d4e96c306f17e763d266b402ef8c0ef5e1ecacb8b5cb57718344b1825e522f3a461cc6945
|
data/bin/gemwarrior
CHANGED
File without changes
|
@@ -2,26 +2,21 @@
|
|
2
2
|
# Creature base class
|
3
3
|
|
4
4
|
require_relative 'entity'
|
5
|
-
require_relative '../inventory'
|
6
5
|
|
7
6
|
module Gemwarrior
|
8
7
|
class Creature < Entity
|
9
|
-
attr_accessor :
|
10
|
-
:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
self.hp_max = options[:hp_max]
|
23
|
-
|
24
|
-
self.inventory = options[:inventory]
|
25
|
-
end
|
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
|
26
21
|
end
|
27
22
|
end
|
@@ -3,18 +3,12 @@
|
|
3
3
|
|
4
4
|
module Gemwarrior
|
5
5
|
class Entity
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
self.id = options[:id]
|
10
|
-
self.name = options[:name]
|
11
|
-
self.description = options[:description]
|
12
|
-
end
|
13
|
-
|
6
|
+
attr_accessor :name,
|
7
|
+
:description
|
8
|
+
|
14
9
|
def status
|
15
10
|
status_text = name.ljust(20).upcase
|
16
11
|
status_text << "#{description}\n"
|
17
|
-
status_text.to_s
|
18
12
|
end
|
19
13
|
end
|
20
14
|
end
|
@@ -5,18 +5,11 @@ require_relative 'entity'
|
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
7
|
class Item < Entity
|
8
|
-
attr_accessor :
|
9
|
-
:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
self.description = options[:description]
|
15
|
-
self.atk_lo = options[:atk_lo]
|
16
|
-
self.atk_hi = options[:atk_hi]
|
17
|
-
self.takeable = options[:takeable]
|
18
|
-
self.equippable = options[:equippable]
|
19
|
-
self.equipped = options[:equipped]
|
20
|
-
end
|
8
|
+
attr_accessor :atk_lo,
|
9
|
+
:atk_hi,
|
10
|
+
:takeable,
|
11
|
+
:useable,
|
12
|
+
:equippable,
|
13
|
+
:equipped
|
21
14
|
end
|
22
15
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/bed.rb
|
2
|
+
# Item::Bed
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Bed < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'bed'
|
10
|
+
self.description = 'The place where you sleep when you are not adventuring.'
|
11
|
+
self.atk_lo = nil
|
12
|
+
self.atk_hi = nil
|
13
|
+
self.takeable = false
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = false
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/feather.rb
|
2
|
+
# Item::Feather
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Feather < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'feather'
|
10
|
+
self.description = 'A blue and green feather. It is soft and tender, unlike the craven bird that probably shed it.'
|
11
|
+
self.atk_lo = nil
|
12
|
+
self.atk_hi = nil
|
13
|
+
self.takeable = true
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = false
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/gun.rb
|
2
|
+
# Item::Gun
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Gun < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'gun'
|
10
|
+
self.description = 'Pew pew goes this firearm, you suspect.'
|
11
|
+
self.atk_lo = 3
|
12
|
+
self.atk_hi = 5
|
13
|
+
self.takeable = true
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = true
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/stalactite.rb
|
2
|
+
# Item::Stalactite
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Stalactite < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'stalactite'
|
10
|
+
self.description = 'Long protrusion of cave adornment, broken off and fallen to the ground, where the stalagmites sneer at it from.'
|
11
|
+
self.atk_lo = 2
|
12
|
+
self.atk_hi = 3
|
13
|
+
self.takeable = true
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = true
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/stone.rb
|
2
|
+
# Item::Stone
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Stone < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'stone'
|
10
|
+
self.description = 'A small, sharp mega pebble, suitable for tossing in amusement, and perhaps combat.'
|
11
|
+
self.atk_lo = 2
|
12
|
+
self.atk_hi = 3
|
13
|
+
self.takeable = true
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = true
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/tree.rb
|
2
|
+
# Item::Tree
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Tree < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'tree'
|
10
|
+
self.description = 'A mighty representation of nature, older than your father\'s father\'s second great-uncle.'
|
11
|
+
self.atk_lo = nil
|
12
|
+
self.atk_hi = nil
|
13
|
+
self.takeable = false
|
14
|
+
self.useable = false
|
15
|
+
self.equippable = false
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -12,62 +12,24 @@ module Gemwarrior
|
|
12
12
|
DANGER_LEVEL = {:none => 0, :low => 15, :moderate => 30, :high => 55, :assured => 100}
|
13
13
|
|
14
14
|
## ERRORS
|
15
|
-
ERROR_LOCATION_ITEM_REMOVE_INVALID
|
16
|
-
ERROR_LOCATION_DESCRIBE_ENTITY_INVALID
|
15
|
+
ERROR_LOCATION_ITEM_REMOVE_INVALID = 'That item cannot be removed as it does not exist here.'
|
16
|
+
ERROR_LOCATION_DESCRIBE_ENTITY_INVALID = 'You do not see that here.'
|
17
17
|
|
18
|
-
attr_accessor :
|
19
|
-
:
|
18
|
+
attr_accessor :coords, :locs_connected, :danger_level, :items,
|
19
|
+
:monsters_available, :monsters_abounding, :checked_for_monsters
|
20
20
|
|
21
21
|
def initialize(options)
|
22
|
-
self.
|
23
|
-
self.
|
24
|
-
self.
|
25
|
-
self.locs_connected = options
|
26
|
-
self.danger_level = options
|
27
|
-
self.items = options
|
28
|
-
self.monsters_available = options
|
22
|
+
self.name = options.fetch(:name)
|
23
|
+
self.description = options.fetch(:description)
|
24
|
+
self.coords = options.fetch(:coords)
|
25
|
+
self.locs_connected = options.fetch(:locs_connected)
|
26
|
+
self.danger_level = options.fetch(:danger_level)
|
27
|
+
self.items = options.fetch(:items)
|
28
|
+
self.monsters_available = options.fetch(:monsters_available)
|
29
29
|
self.monsters_abounding = []
|
30
30
|
self.checked_for_monsters = false
|
31
31
|
end
|
32
|
-
|
33
|
-
def describe
|
34
|
-
desc_text = ""
|
35
|
-
desc_text << "[ #{name} ]\n"
|
36
|
-
desc_text << description
|
37
|
-
unless checked_for_monsters?
|
38
|
-
populate_monsters
|
39
|
-
end
|
40
|
-
unless list_items.nil?
|
41
|
-
desc_text << list_items
|
42
|
-
end
|
43
|
-
unless list_monsters.nil?
|
44
|
-
desc_text << list_monsters
|
45
|
-
end
|
46
|
-
desc_text << list_paths
|
47
32
|
|
48
|
-
return desc_text
|
49
|
-
end
|
50
|
-
|
51
|
-
def describe_entity(entity_name)
|
52
|
-
if items.map(&:name).include?(entity_name)
|
53
|
-
items.each do |i|
|
54
|
-
if i.name.eql?(entity_name)
|
55
|
-
return "#{i.description}"
|
56
|
-
end
|
57
|
-
end
|
58
|
-
elsif
|
59
|
-
if monsters_abounding.map(&:name).include?(entity_name)
|
60
|
-
monsters_abounding.each do |m|
|
61
|
-
if m.name.eql?(entity_name)
|
62
|
-
return "#{m.description}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
else
|
67
|
-
ERROR_LOCATION_DESCRIBE_ENTITY_INVALID
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
33
|
def remove_item(item_name)
|
72
34
|
if items.map(&:name).include?(item_name)
|
73
35
|
items.reject! { |item| item.name == item_name }
|
@@ -77,19 +39,23 @@ module Gemwarrior
|
|
77
39
|
end
|
78
40
|
|
79
41
|
def remove_monster(name)
|
80
|
-
|
81
|
-
monsters_abounding.reject! { |monster| monster.name == name }
|
82
|
-
end
|
42
|
+
monsters_abounding.reject! { |monster| monster.name == name }
|
83
43
|
end
|
84
44
|
|
85
45
|
def has_loc_to_the?(direction)
|
46
|
+
case direction
|
47
|
+
when 'n'
|
48
|
+
direction = 'north'
|
49
|
+
when 'e'
|
50
|
+
direction = 'east'
|
51
|
+
when 's'
|
52
|
+
direction = 'south'
|
53
|
+
when 'w'
|
54
|
+
direction = 'west'
|
55
|
+
end
|
86
56
|
locs_connected[direction.to_sym]
|
87
57
|
end
|
88
58
|
|
89
|
-
def has_monster_to_attack?(name)
|
90
|
-
monsters_abounding.map(&:name).include?(name.downcase)
|
91
|
-
end
|
92
|
-
|
93
59
|
def monster_by_name(name)
|
94
60
|
monsters_abounding.each do |m|
|
95
61
|
if m.name.eql?(name)
|
@@ -98,12 +64,24 @@ module Gemwarrior
|
|
98
64
|
end
|
99
65
|
end
|
100
66
|
|
101
|
-
private
|
102
|
-
|
103
67
|
def checked_for_monsters?
|
104
68
|
checked_for_monsters
|
105
69
|
end
|
106
70
|
|
71
|
+
def has_monster?
|
72
|
+
found = false
|
73
|
+
unless danger_level.eql?(:none)
|
74
|
+
max = DANGER_LEVEL[danger_level]
|
75
|
+
trigger_values = 0..max
|
76
|
+
actual_value = rand(1..100)
|
77
|
+
|
78
|
+
if trigger_values.include?(actual_value)
|
79
|
+
found = true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
return found
|
83
|
+
end
|
84
|
+
|
107
85
|
def list_items
|
108
86
|
return "\n >> Shiny object(s): #{items.map(&:name).join(', ')}" if items.length > 0
|
109
87
|
end
|
@@ -115,32 +93,18 @@ module Gemwarrior
|
|
115
93
|
def list_paths
|
116
94
|
valid_paths = []
|
117
95
|
locs_connected.each do |key, value|
|
118
|
-
|
96
|
+
if value
|
119
97
|
valid_paths.push(key.to_s)
|
120
98
|
end
|
121
99
|
end
|
122
100
|
return "\n >> Paths: #{valid_paths.join(', ')}"
|
123
101
|
end
|
124
102
|
|
125
|
-
def has_monster?
|
126
|
-
found = false
|
127
|
-
unless danger_level.eql?(:none)
|
128
|
-
max = DANGER_LEVEL[danger_level]
|
129
|
-
trigger_values = 0..max
|
130
|
-
actual_value = rand(1..100)
|
131
|
-
|
132
|
-
if trigger_values.include?(actual_value)
|
133
|
-
found = true
|
134
|
-
end
|
135
|
-
end
|
136
|
-
return found
|
137
|
-
end
|
138
|
-
|
139
103
|
def populate_monsters
|
140
104
|
self.checked_for_monsters = true
|
141
105
|
if has_monster?
|
142
106
|
self.monsters_abounding = []
|
143
|
-
|
107
|
+
monsters_abounding.push(monsters_available[rand(0..monsters_available.length-1)])
|
144
108
|
else
|
145
109
|
return nil
|
146
110
|
end
|
@@ -5,44 +5,21 @@ require_relative 'creature'
|
|
5
5
|
|
6
6
|
module Gemwarrior
|
7
7
|
class Monster < Creature
|
8
|
-
attr_accessor :
|
9
|
-
|
10
|
-
|
11
|
-
def initialize(options)
|
12
|
-
self.id = options[:id]
|
13
|
-
self.name = options[:name]
|
14
|
-
self.description = options[:description]
|
15
|
-
self.face = options[:face]
|
16
|
-
self.hands = options[:hands]
|
17
|
-
self.mood = options[:mood]
|
18
|
-
|
19
|
-
self.level = options[:level]
|
20
|
-
self.hp_cur = options[:hp_cur]
|
21
|
-
self.hp_max = options[:hp_max]
|
22
|
-
|
23
|
-
self.atk_lo = options[:atk_lo]
|
24
|
-
self.atk_hi = options[:atk_hi]
|
25
|
-
self.dexterity = options[:dexterity]
|
26
|
-
|
27
|
-
self.inventory = options[:inventory]
|
28
|
-
self.rox_to_give = options[:rox_to_give]
|
29
|
-
self.xp_to_give = options[:xp_to_give]
|
30
|
-
|
31
|
-
self.battlecry = options[:battlecry]
|
32
|
-
end
|
33
|
-
|
8
|
+
attr_accessor :battlecry
|
9
|
+
|
34
10
|
def describe
|
35
|
-
status_text = name.upcase.ljust(
|
11
|
+
status_text = name.upcase.ljust(20)
|
36
12
|
status_text << "LEVEL: #{level.to_s.rjust(2)}, "
|
37
|
-
status_text << "HP: #{hp_cur.to_s.rjust(3)}/#{hp_max.to_s.rjust(3)}
|
38
|
-
status_text << "ATK: #{atk_lo.to_s.rjust(2)}-#{atk_hi.to_s.rjust(2)}
|
39
|
-
status_text << "
|
40
|
-
status_text << "
|
41
|
-
status_text << "
|
42
|
-
status_text << "
|
43
|
-
status_text << "
|
13
|
+
status_text << "HP: #{hp_cur.to_s.rjust(3)}/#{hp_max.to_s.rjust(3)} "
|
14
|
+
status_text << "ATK: #{atk_lo.to_s.rjust(2)}-#{atk_hi.to_s.rjust(2)} "
|
15
|
+
status_text << "DEF: #{defense.to_s.rjust(2)} "
|
16
|
+
status_text << "DEX: #{dexterity.to_s.rjust(2)} "
|
17
|
+
status_text << "INV: #{inventory.list_contents} "
|
18
|
+
status_text << "ROX: #{rox.to_s.rjust(3)} "
|
19
|
+
status_text << "XP: #{xp.to_s.rjust(3)} "
|
20
|
+
status_text << "FACE: #{face.ljust(10)} "
|
21
|
+
status_text << "HANDS: #{hands.ljust(11)} "
|
44
22
|
status_text << "MOOD: #{mood.ljust(10)}\n"
|
45
|
-
status_text.to_s
|
46
23
|
end
|
47
24
|
|
48
25
|
def take_damage(dmg)
|