texugo-engine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODk4YmU1YWNhMGJmOTUzZmQzOWZhNjdkMzFlMWZjMmQwN2UwN2I5Zg==
5
+ data.tar.gz: !binary |-
6
+ YjgyM2ZjMWM0YWRlZDVlZmU4OGFlY2ViOTlhOWYwZTA3NGNiM2IxNA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZjBkZTc3NjNiZWRjNTUxZjEwMGQ3MGY4ZWRjNjJjYmU5ZGZhNzVmZjBkMTg2
10
+ MDc2YTQ4Y2VkZmM4NTkwYTNlMDE0NTlmYjZkOWFkZmVkZGFkMTU2NjFjNWE5
11
+ MGUzOThhZmViZjJkZjBiZTE2MjAwNzRkZTdkOTkyNzQ3NDI1YzQ=
12
+ data.tar.gz: !binary |-
13
+ NGYzNmRiNjljZWFkNzU1YzZlY2QzYjBiNjhlY2RmNjk1MTRmODMyYTQzNjE4
14
+ YmUyNmJmZTIyNGIyYTMyMGJlNmEyODFjYTZiM2VkMTgzYWZlN2M3NTY1Mjc3
15
+ NWIzODY3NTg3OTI0MTI0MTNiMzA5NjE0MTdhY2RkOWZkOGM4NzI=
@@ -0,0 +1,70 @@
1
+ Texugo Engine
2
+ ============
3
+
4
+ Origem do nome
5
+ --------------
6
+
7
+ *Tex*: Se refere a texto, já que se trata de uma engine para jogos baseados em texto.
8
+
9
+ *Ugo*: Se refere a vômito.
10
+
11
+ *Texugo*: Homenagem ao nosso amigo @BrunoGrasselli
12
+
13
+ Jogar
14
+ -----
15
+
16
+ Para jogar, rode `play.rb` :smile:
17
+
18
+ Comandos
19
+ --------
20
+
21
+ Apenas um overview pois, comandos adicionais serão providos pelo prompt.
22
+
23
+ #### Sair do jogo
24
+
25
+ Type `exit` closes game when not in combat
26
+
27
+ For all commands that require specification (using items, moving places, etc)
28
+ type the command first, return, and then type the specification.
29
+
30
+ i.e.
31
+
32
+ cast *return*
33
+ (screen displays) what would you like to cast?
34
+ fire *return*
35
+
36
+ (when outside):
37
+
38
+ look - gives description of your surroundings
39
+
40
+ move - allows travel within town/dungeon.
41
+
42
+ travel - allows travel between towns/dungeons
43
+
44
+ inventory - displays inventory
45
+
46
+ stats - displays player stats/attributes
47
+
48
+ use - allows use of item
49
+
50
+ party - displays party along with party members stats/attributes.
51
+
52
+
53
+
54
+ (when "inside"):
55
+
56
+ look - gives description of your surroundings
57
+
58
+ leave - returns player to "outside"
59
+
60
+ take - takes an item that is in the room
61
+
62
+ (when in a fight):
63
+
64
+ hit - melee attack
65
+
66
+ cast - allows the use of a spell
67
+
68
+ use - allows the use of items
69
+
70
+ inventory - displays inventory
@@ -0,0 +1,34 @@
1
+ class Armour
2
+ attr_accessor :name, :rating, :type
3
+
4
+ def initialize(name, rating, type)
5
+ @name = name
6
+ @rating = rating
7
+ @type = type
8
+ end
9
+ end
10
+
11
+ None = Armour.new('', 0, '')
12
+ Hat = Armour.new('hat' , 1, 'head gear')
13
+ Leather = Armour.new('leather vest' , 3, 'body gear')
14
+ Shield = Armour.new('wicker shield' , 2, 'shield')
15
+ Shoes = Armour.new('leather shoes' , 1, 'foot gear')
16
+ Gloves = Armour.new('leather gloves', 1, 'gloves')
17
+ Chain_Helm = Armour.new('chain helmet', 5, 'head gear')
18
+ Chain_Mail= Armour.new('chain mail', 10, 'body gear')
19
+ Steel_Buckler = Armour.new('steel buckler', 7, 'shield')
20
+ Boots = Armour.new('heavy boots', 5, 'foot gear')
21
+ Chain_Gloves = Armour.new('chain gauntlets', 5, 'gloves')
22
+ Plate_Helm = Armour.new('plated helmet', 13, 'head gear')
23
+ Plate_Mail = Armour.new('plate mail', 17, 'body gear')
24
+ Tower_Shield = Armour.new('tower shield', 15, 'shield')
25
+ Plate_Boots = Armour.new('plated boots', 13, 'foot gear')
26
+ Plate_Gloves = Armour.new('plated gauntlets', 13, 'gloves')
27
+
28
+
29
+ Armour_id = {Hat.name => Hat, Leather.name => Leather, Shield.name => Shield, Shoes.name => Shoes, Gloves.name => Gloves,
30
+ Chain_Helm.name => Chain_Helm, Chain_Mail.name => Chain_Mail, Steel_Buckler.name => Steel_Buckler, Boots.name => Boots, Chain_Gloves.name => Chain_Gloves,
31
+ Plate_Helm.name => Plate_Helm, Plate_Mail.name => Plate_Mail, Tower_Shield.name => Tower_Shield, Plate_Boots.name => Plate_Boots, Plate_Gloves.name => Plate_Gloves}
32
+ Armour_price = {'hat' => 15, 'leather vest' => 45, 'leather gloves' => 15, 'wicker shield' => 30, 'leather shoes' => 15,
33
+ 'chain helmet' => 125, 'chain mail' => 250, 'steel buckler' => 200, 'heavy boots' => 125, 'chain gauntlets' => 125, 'plated helmet' => 300,
34
+ 'plate mail' => 500, 'tower shield' => 375, 'plated boots' => 300, 'plated gauntlets' => 300}
@@ -0,0 +1,13 @@
1
+ class Spellbook
2
+ attr_accessor :name, :spell
3
+
4
+ def initialize (name, spell)
5
+ @name = name
6
+ @spell = spell
7
+ end
8
+ end
9
+
10
+ BookofHeal = Spellbook.new('book of heal', 'heal')
11
+ BookofHoly = Spellbook.new('book of holy', 'holy')
12
+
13
+ Spellbook_id = { 'book of heal' => BookofHeal, 'book of holy' => BookofHoly}
@@ -0,0 +1,51 @@
1
+ require_relative 'weapons'
2
+ require_relative 'armour'
3
+ require_relative 'spells'
4
+
5
+ class Character
6
+ attr_accessor :name, :strength, :endurance, :agility, :intelligence, :life, :magic, :level, :experience, :spells, :armour, :weapon
7
+
8
+ def initialize(name, strength, endurance, agility, intelligence, level, experience, weapon = '', headgear = None, feet =None, hands = None, shield = None, armour = None)
9
+ @name = name
10
+ @strength = strength
11
+ @endurance = endurance
12
+ @agility = agility
13
+ @intelligence = intelligence
14
+ @level = level
15
+ @experience = experience
16
+ @life = endurance * 10
17
+ @magic = intelligence * 3
18
+ @spells = ['heal']
19
+ @armour = [headgear, feet, hands, shield, armour]
20
+ @weapon = [weapon]
21
+ end
22
+
23
+ def armour_rating
24
+ initial_rating = 0
25
+ self.armour.each do |armour|
26
+ initial_rating += (armour.rating)
27
+ end
28
+ return initial_rating
29
+ end
30
+
31
+ def attribute
32
+ {:strength => strength, :endurance => endurance, :agility => agility, :intelligence => intelligence}.each do |attribute, value|
33
+ puts attribute.to_s.capitalize + ': ' + value.to_s
34
+ end
35
+ end
36
+
37
+ def stats
38
+ puts '='*10
39
+ self.attribute
40
+ puts ''
41
+ puts "Level: #{self.level.to_s}"
42
+ puts "Health: #{self.life.to_s} / #{(self.endurance*10).to_s}"
43
+ puts "Magic: #{self.magic.to_s} / #{(self.intelligence*3).to_s}"
44
+ puts "Current experience: #{self.experience.to_s}"
45
+ puts "Exp. until next level: #{((50 *self.level * self.level) - (self.experience)).to_s}"
46
+ puts ''
47
+ end
48
+ end
49
+
50
+ Martin = Character.new('Martin', 6, 10, 7, 5, 3, 449, Club, Hat, Leather, Shield)
51
+ require_relative 'northshire'
@@ -0,0 +1,327 @@
1
+ Commands_outside = ['use','inventory', 'equip', 'move', 'travel', 'look', 'stats', 'party']
2
+ Commands_fight = ['use','cast','hit','inventory']
3
+
4
+ require_relative 'hamlet'
5
+ require_relative 'middleton'
6
+ require_relative 'denofshadows'
7
+ require_relative 'books'
8
+ def inventory(player = $player)
9
+ invtry = []
10
+ maplist = []
11
+ player.maps.each do |map|
12
+ maplist << map.name
13
+ end
14
+ player.inventory.each do |item|
15
+ invtry << item unless (item.class == Weapon) || (item.class == Armour) || (item.class == Keyitem) || (item.class == Spellbook)
16
+ invtry << item.name if (item.class == Weapon) || (item.class == Armour) || (item.class == Keyitem) || (item.class == Spellbook)
17
+ end
18
+ puts '='*10
19
+ puts "Your maps".center(10)
20
+ puts "="*10
21
+ puts maplist
22
+ puts '='*10
23
+ puts 'your inventory'.center(10)
24
+ puts '='*10
25
+ puts invtry.sort!
26
+ puts '='*10
27
+ puts ''
28
+ end
29
+
30
+ def party
31
+ puts '='*10
32
+ puts 'party'.center(10)
33
+ puts '='*10
34
+ puts 'Your party is empty' if $player.party.length == 0
35
+ $player.party.each do |char|
36
+ puts char.name
37
+ puts char.stats
38
+ end
39
+ puts '='*10
40
+ end
41
+
42
+
43
+ def stats
44
+ puts ''
45
+ puts '='*10
46
+ puts '='*10
47
+ puts ''
48
+ puts 'Attributes'.center(10)
49
+ puts '='*10
50
+ $player.attribute
51
+ puts ''
52
+ puts "Level: #{$player.level.to_s}"
53
+ puts "Health: #{$player.life.to_s} / #{($player.endurance*10).to_s}"
54
+ puts "Magic: #{$player.magic.to_s} / #{($player.intelligence*3).to_s}"
55
+ puts "Current experience: #{$player.experience.to_s}"
56
+ puts "Exp. until next level: #{((50 *$player.level * $player.level) - ($player.experience)).to_s}"
57
+ puts "Gold: #{$player.gold.to_s}"
58
+ puts ''
59
+ puts 'Spells'.center(10)
60
+ puts '='*10
61
+ puts $player.spells
62
+ puts ''
63
+ puts '='*10
64
+ puts '='*10
65
+ puts ''
66
+ end
67
+
68
+
69
+
70
+ def equip (player = $player)
71
+ invtry = []
72
+ player.inventory.each do |item|
73
+ invtry << item.name if (item.class == Weapon) || (item.class == Armour)
74
+ end
75
+ puts ''
76
+ puts ''
77
+ puts 'what would you like to equip?'
78
+ puts "('done' to return)"
79
+ puts ''
80
+ puts invtry
81
+ response = ''
82
+ while true
83
+ puts 'Current Equipment:'.center(10)
84
+ puts "="*10
85
+ puts "Weapon: #{player.weapon[0].name.capitalize}" unless player.weapon.length == 0
86
+ puts "Weapon: empty" if player.weapon.length == 0
87
+ player.armour.each do |article|
88
+ puts "#{(article.type).capitalize}: #{article.name.capitalize}"
89
+ end
90
+ puts "="*10
91
+ puts ''
92
+ response = gets.chomp
93
+ break if response == 'done'
94
+ if invtry.include? response
95
+ if Weapon_id.has_key? response
96
+ player.weapon.delete_at 0 unless player.weapon.length == 0
97
+ player.weapon << Weapon_id[response]
98
+ elsif Armour_id.has_key? response
99
+ player.armour.each do |armour|
100
+ player.armour.delete_at (player.armour.index(armour)) if armour.type == Armour_id[response].type
101
+ end
102
+ player.armour << Armour_id[response]
103
+ end
104
+ else
105
+ puts 'You do not have that item'
106
+ end
107
+ puts ''
108
+ puts 'what else would you like to equip?'
109
+ end
110
+
111
+ end
112
+
113
+
114
+ def use(inventory = $player.inventory)
115
+ puts 'what would you like to use'
116
+ g =gets.chomp
117
+ puts 'no such item in inventory' unless (inventory.include? g)
118
+ if inventory.include? g
119
+ send(g) unless Spellbook_id.has_key? g
120
+ $player.spells << Spellbook_id[g].spell if Spellbook_id.has_key? g
121
+ puts "Learned #{Spellbook_id[g].spell.to_s}" if Spellbook_id.has_key? g
122
+ inventory.delete_at(inventory.index(g))
123
+ end
124
+ end
125
+
126
+ def cast(spell_book = $player.spells)
127
+ puts 'what would you like to cast?'
128
+ spell =gets.chomp
129
+ puts 'You do not know that spell' unless spell_book.include? spell
130
+ if spell_book.include? spell
131
+ send(spell)
132
+ end
133
+ end
134
+
135
+ def hit(offense = $player, defense = @monster)
136
+ if offense.weapon.length == 0
137
+ bonus = 0
138
+ else
139
+ bonus = offense.weapon[0].damage
140
+ end
141
+ roll = offense.agility * (rand (6) + 1)
142
+ defense.life -= (offense.strength * (rand(6) + 1)) + bonus if roll >= 10 && defense.class != Spector
143
+ puts ''
144
+ if roll < 10
145
+ puts 'Your clumsy swing misses!' if offense == $player
146
+ puts "#{offense.name}'s swing misses!" unless offense == $player
147
+ elsif defense.class == Spector
148
+ puts 'The attack has no effect' if offense == $player
149
+ puts "#{offense.name}'s attack has no effect" unless offense == $player
150
+ else
151
+ puts 'You land a blow square on the monsters head' if offense == $player
152
+ puts "#{offense.name}'s lands a blow square on the monsters head" unless offense == $player
153
+ end
154
+ puts ''
155
+ end
156
+
157
+ def move
158
+ puts 'move where?'
159
+ puts "('done' to return)"
160
+ response = ''
161
+ while true
162
+ response = gets.chomp
163
+ break if response == 'done'
164
+ if $player.area[0].locations.has_key? response
165
+ $player.position << $player.area[0].locations[response]
166
+ roll = (rand(10) + 1)
167
+ if (roll >= $player.area[0].fightchance) && ($player.area[0].monsters == 0)
168
+ fight
169
+ elsif (roll >= $player.area[0].fightchance) && ($player.area[0].monsters != 0)
170
+ fight($player.area[0].monster)
171
+ end
172
+ break
173
+ end
174
+ puts 'please enter a valid location' unless $player.area[0].locations.has_key? response
175
+ end
176
+ puts "You are in #{$player.position[0].name}" unless $player.position.length == 0
177
+ puts 'You are standing outside' if $player.position.length == 0
178
+ puts ''
179
+ puts $player.position[0].introduction unless $player.position.length == 0
180
+ end
181
+
182
+ def travel
183
+ puts 'Travel where?'
184
+ puts "('done' to return)"
185
+ response = ''
186
+ while true
187
+ response = gets.chomp
188
+ break if response == 'done'
189
+ $player.maps.each do |map|
190
+ if map.name == response
191
+ roll1 = (rand(10) + 1)
192
+ roll2 = (rand(10) + 1)
193
+ roll3 = (rand(10) + 1)
194
+ fight if roll1 > 4
195
+ break if $player.life <= 0
196
+ fight if roll2 > 4
197
+ break if $player.life <= 0
198
+ fight if roll3 > 4
199
+ break if $player.life <= 0
200
+ puts map.location.introduction
201
+ map.location.visit += 1 if map.location.visit == 0
202
+ $player.area.delete_at(0)
203
+ $player.area << map.location
204
+ end
205
+ end
206
+ break
207
+ end
208
+ puts "You are in #{$player.area[0].name}" unless $player.life <= 0
209
+ puts ''
210
+ end
211
+
212
+ def sleep
213
+ puts 'rest well'
214
+ puts ''
215
+ timer
216
+ puts 'zZz'
217
+ timer
218
+ puts 'ZzZ'
219
+ timer
220
+ puts 'zZz'
221
+ timer
222
+ puts ''
223
+ $player.life = ($player.endurance * 10)
224
+ $player.magic = ($player.intelligence * 3)
225
+ $player.party.each do |char|
226
+ char.life = (char.endurance * 10)
227
+ char.magic = (char.intelligence * 3)
228
+ end
229
+ puts 'You are well rested!'
230
+ File.open("games/#{$player.name}/#{$player.name}", "w+") do |file|
231
+ Marshal.dump($player, file)
232
+ end
233
+
234
+ $player.party.each do |char|
235
+ File.open("games/#{$player.name}/#{char.name}", "w+") do |file|
236
+ Marshal.dump(char, file)
237
+ end
238
+ end
239
+
240
+ $player.maps.each do |area|
241
+ File.open("games/#{$player.name}/#{area.name}", "w+") do |file|
242
+ Marshal.dump(area.location, file)
243
+ end
244
+ end
245
+
246
+ $player.visited.each do |location|
247
+ location.each do |place|
248
+ File.open("games/#{$player.name}/#{place.name}", "w+") do |file|
249
+ Marshal.dump(place, file)
250
+ end
251
+ end
252
+ end
253
+
254
+ end
255
+
256
+ def take
257
+ puts 'what would you like to take?'
258
+ response = ''
259
+ while true
260
+ response = gets.chomp
261
+ break if (response == 'done' || response == 'nothing')
262
+ if $player.position[0].inventory.include? response
263
+ $player.inventory << response if Items.include? response
264
+ $player.inventory << Weapon_id[response] if Weapon_id.has_key? response
265
+ $player.inventory << Armour_id[response] if Armour_id.has_key? response
266
+ $player.inventory << Key_Items[response] if Key_Items.has_key? response
267
+ $player.inventory << response if Spellbook_id.has_key? response
268
+ $player.gold += response.amount if response == 'coin purse'
269
+ $player.position[0].inventory.delete_at($player.position[0].inventory.index(response))
270
+ puts "taken #{response}"
271
+ break
272
+ elsif response == 'map'
273
+ map = 0
274
+ $player.position[0].inventory.each do |item|
275
+ if item.class == Maps
276
+ map += 1
277
+ $player.maps << item
278
+ $player.position[0].inventory.delete_at($player.position[0].inventory.index(item))
279
+ puts "taken #{response}"
280
+ end
281
+ end
282
+ puts 'There are no maps here' if map == 0
283
+ break
284
+ elsif response == 'purse'
285
+ purse = 0
286
+ $player.position[0].inventory.each do |item|
287
+ if item.class == Purse
288
+ purse += 1
289
+ $player.gold += item.amount
290
+ $player.position[0].inventory.delete_at($player.position[0].inventory.index(item))
291
+ puts "taken #{item.amount} gold"
292
+ end
293
+ end
294
+ puts 'There is no coin purse here' if purse == 0
295
+ break
296
+ else
297
+ puts 'there is not an item here by that name'
298
+ end
299
+ end
300
+ end
301
+
302
+ def look
303
+ if $player.position.length == 0
304
+ puts $player.area[0].look
305
+ end
306
+ end
307
+
308
+ def loot
309
+ roll_1 =(1 + rand(6))
310
+ roll_2 =(1 + rand(6))
311
+ if roll_1 + roll_2 >= 8
312
+ roll_3 = rand(3)
313
+ if roll_3 == 0
314
+ item = Items[rand(4)]
315
+ $player.inventory << item
316
+ puts 'recieved ' + item.to_s
317
+ elsif roll_3 == 1
318
+ item = Items[rand(4)]
319
+ $player.inventory << item
320
+ puts 'recieved ' + item.to_s
321
+ elsif roll_3 == 2
322
+ item = Items[rand(4)]
323
+ $player.inventory << item
324
+ puts 'recieved ' + item.to_s
325
+ end
326
+ end
327
+ end