texugo-engine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.md +70 -0
- data/lib/armour.rb +34 -0
- data/lib/books.rb +13 -0
- data/lib/characters.rb +51 -0
- data/lib/commands.rb +327 -0
- data/lib/denofshadows.rb +200 -0
- data/lib/games/.gitkeep +0 -0
- data/lib/hamlet.rb +115 -0
- data/lib/items.rb +59 -0
- data/lib/maps.rb +26 -0
- data/lib/middleton.rb +239 -0
- data/lib/modules.rb +169 -0
- data/lib/monsters.rb +106 -0
- data/lib/northshire.rb +160 -0
- data/lib/play.rb +218 -0
- data/lib/player.rb +65 -0
- data/lib/rand_fight.rb +120 -0
- data/lib/ridgedale.rb +43 -0
- data/lib/shop.rb +144 -0
- data/lib/spells.rb +53 -0
- data/lib/timer.rb +12 -0
- data/lib/weapons.rb +17 -0
- data/texugo-engine.gemspec +16 -0
- metadata +72 -0
data/lib/modules.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
module Inn
|
2
|
+
def rest
|
3
|
+
puts "It will be 15 gold to rest here. will you rest? (yes or no)"
|
4
|
+
puts "You have #{$player.gold}"
|
5
|
+
puts ''
|
6
|
+
response = gets.chomp.downcase
|
7
|
+
puts''
|
8
|
+
if response == 'yes' && $player.gold >= 15
|
9
|
+
$player.gold -= 15
|
10
|
+
sleep
|
11
|
+
elsif response == 'yes' && $player.gold < 15
|
12
|
+
puts 'You set your coin purse on the counter but the distinct lack of coins rustling'
|
13
|
+
puts 'makes your ears grow red with embarassment. You look at the innkeeper who is'
|
14
|
+
puts 'looking back at you with an impatient glare. If only you were better at'
|
15
|
+
puts 'managing your money.'
|
16
|
+
elsif response == 'no'
|
17
|
+
puts 'Have a good day.'
|
18
|
+
else
|
19
|
+
puts "'I don't know what you are trying to say'"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Shop
|
25
|
+
def buy
|
26
|
+
puts inventory
|
27
|
+
puts ''
|
28
|
+
inventory = [self.weapons, self.items, self.spells, self.armour]
|
29
|
+
puts "You have #{$player.gold} gold"
|
30
|
+
puts 'What would you like to purchase?'
|
31
|
+
puts "('back' to return to shop)"
|
32
|
+
puts ''
|
33
|
+
puts '-'*10
|
34
|
+
puts 'items'.center(10)
|
35
|
+
puts '-'*10
|
36
|
+
self.items.each do |item|
|
37
|
+
puts item.to_s + ' - ' + Items_price[item].to_s + ' gold'
|
38
|
+
end
|
39
|
+
puts '-'*10
|
40
|
+
puts 'spells'.center(10)
|
41
|
+
puts '-'*10
|
42
|
+
self.spells.each do |spell|
|
43
|
+
puts spell.to_s + ' - ' + Spells_price[spell].to_s + ' gold'
|
44
|
+
end
|
45
|
+
puts '-'*10
|
46
|
+
puts 'weapons'.center(10)
|
47
|
+
puts '-'*10
|
48
|
+
self.weapons.each do |weapon|
|
49
|
+
puts "#{weapon.to_s.upcase} - #{Weapons_price[weapon].to_s} gold"
|
50
|
+
puts "Damage rating: #{Weapon_id[weapon].damage.to_s}"
|
51
|
+
end
|
52
|
+
puts '-'*10
|
53
|
+
puts 'armour'.center(10)
|
54
|
+
puts '-'*10
|
55
|
+
self.armour.each do |armour|
|
56
|
+
puts "#{armour.to_s.upcase} - #{Armour_price[armour].to_s} gold"
|
57
|
+
puts "Defense rating: #{Armour_id[armour].rating.to_s}"
|
58
|
+
puts "Armour type: #{Armour_id[armour].type.to_s}"
|
59
|
+
end
|
60
|
+
puts ''
|
61
|
+
purchase = ''
|
62
|
+
while true
|
63
|
+
purchase = gets.chomp
|
64
|
+
break if purchase == 'back'
|
65
|
+
if(self.items.include? purchase) || (self.weapons.include? purchase) || (self.spells.include? purchase) || (self.armour.include? purchase)
|
66
|
+
if self.items.include? purchase
|
67
|
+
if ($player.gold) >= (Items_price[purchase])
|
68
|
+
$player.inventory << purchase
|
69
|
+
$player.gold -= Items_price[purchase]
|
70
|
+
elsif $player.gold < Items_price[purchase]
|
71
|
+
puts 'Not enough gold'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
if self.weapons.include? purchase
|
75
|
+
if $player.gold >= Weapons_price[purchase]
|
76
|
+
$player.inventory << Weapon_id[purchase]
|
77
|
+
$player.gold -= Weapons_price[purchase]
|
78
|
+
elsif $player.gold < Weapons_price[purchase]
|
79
|
+
puts 'Not enough gold'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
if self.spells.include? purchase
|
83
|
+
if $player.gold >= Spells_price[purchase]
|
84
|
+
$player.spells << purchase
|
85
|
+
$player.gold -= Spells_price[purchase]
|
86
|
+
else
|
87
|
+
puts 'Not enough gold'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if self.armour.include? purchase
|
91
|
+
if $player.gold >= Armour_price[purchase]
|
92
|
+
$player.inventory << Armour_id[purchase]
|
93
|
+
$player.gold -= Armour_price[purchase]
|
94
|
+
else $player.gold < Armour_price[purchase]
|
95
|
+
puts 'Not enough gold'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
puts ''
|
99
|
+
puts 'you have ' + $player.gold.to_s + ' left.'
|
100
|
+
puts ''
|
101
|
+
puts 'Would you like anything else?'
|
102
|
+
puts ''
|
103
|
+
else
|
104
|
+
puts 'No such item in inventory'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
puts ''
|
108
|
+
puts $player.position[0].look
|
109
|
+
end
|
110
|
+
|
111
|
+
def sell
|
112
|
+
puts ''
|
113
|
+
puts 'what would you like to sell?'
|
114
|
+
puts "('back' to return to shop)"
|
115
|
+
puts''
|
116
|
+
sell = ''
|
117
|
+
while true
|
118
|
+
puts inventory
|
119
|
+
puts ''
|
120
|
+
loop = 0
|
121
|
+
sell = gets.chomp
|
122
|
+
break if sell == 'back'
|
123
|
+
if ($player.inventory.include? sell) && (Spellbook_id.has_key? sell)
|
124
|
+
$player.inventory.delete_at($player.inventory.index(sell))
|
125
|
+
$player.gold += (Spells_price[Spellbook_id[sell].spell]/2)
|
126
|
+
end
|
127
|
+
$player.inventory.each do |item|
|
128
|
+
if item == sell && ((Key_Items.has_key? sell) == false)
|
129
|
+
$player.inventory.delete_at($player.inventory.index(item))
|
130
|
+
$player.gold += (Items_price[item]/2)
|
131
|
+
puts "Your gold is now #{$player.gold}"
|
132
|
+
loop += 1
|
133
|
+
break
|
134
|
+
elsif (item.class == Weapon) || (item.class == Armour)
|
135
|
+
if item.name == sell
|
136
|
+
$player.inventory.delete_at($player.inventory.index(item))
|
137
|
+
$player.gold += (Weapons_price[item.name]/2) if item.class == Weapon
|
138
|
+
$player.gold += (Armour_price[item.name]/2) if item.class == Armour
|
139
|
+
puts "Your gold is now #{$player.gold}"
|
140
|
+
if item.class == Weapon
|
141
|
+
temp = []
|
142
|
+
$player.inventory.each do |item|
|
143
|
+
(temp << item) if (item == Weapon_id[sell])
|
144
|
+
end
|
145
|
+
$player.weapon.delete_at 0 if temp.length == 0
|
146
|
+
end
|
147
|
+
if item.class == Armour
|
148
|
+
temp = []
|
149
|
+
$player.inventory.each do |item|
|
150
|
+
(temp << item) if (item == Armour_id[sell])
|
151
|
+
end
|
152
|
+
$player.armour.delete_at $player.armour.index(item).to_i if temp.length == 0
|
153
|
+
end
|
154
|
+
loop += 1
|
155
|
+
break
|
156
|
+
end
|
157
|
+
elsif item == sell && (Key_Items.has_key? sell)
|
158
|
+
puts 'You cannot sell key items'
|
159
|
+
loop += 1
|
160
|
+
end
|
161
|
+
end
|
162
|
+
puts 'You do not have an item by that name' if loop == 0
|
163
|
+
puts ''
|
164
|
+
puts 'Would you like to sell anything else?'
|
165
|
+
end
|
166
|
+
puts ''
|
167
|
+
puts $player.position[0].look
|
168
|
+
end
|
169
|
+
end
|
data/lib/monsters.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
class Ghoul
|
2
|
+
attr_accessor :name, :life , :strength , :experience
|
3
|
+
|
4
|
+
def initialize(name = self.class, life = 30,strength = 2, experience = 15)
|
5
|
+
@name = name
|
6
|
+
@life = life
|
7
|
+
@strength = strength
|
8
|
+
@experience = experience
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Human
|
13
|
+
attr_accessor :name, :life, :strength, :experience
|
14
|
+
|
15
|
+
def initialize(name = self.class, life = 70, strength = 4, experience = 30)
|
16
|
+
@name = name
|
17
|
+
@life = life
|
18
|
+
@strength = strength
|
19
|
+
@experience = experience
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
class Undead
|
25
|
+
attr_accessor :name, :life, :strength, :experience
|
26
|
+
|
27
|
+
def initialize(name = self.class, life = 250, strength = 12, experience = 350)
|
28
|
+
@name = name
|
29
|
+
@life = life
|
30
|
+
@strength = strength
|
31
|
+
@experience = experience
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class Spector
|
36
|
+
attr_accessor :name, :life, :strength, :experience
|
37
|
+
|
38
|
+
def initialize(name = self.class, life = 15, strength = 5, experience = 50)
|
39
|
+
@name = name
|
40
|
+
@life = life
|
41
|
+
@strength = strength
|
42
|
+
@experience = experience
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Imp
|
47
|
+
attr_accessor :name, :life, :strength, :experience
|
48
|
+
|
49
|
+
def initialize(name = self.class, life = 80, strength = 5, experience = 80)
|
50
|
+
@name = name
|
51
|
+
@life = life
|
52
|
+
@strength = strength
|
53
|
+
@experience = experience
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Orc
|
58
|
+
attr_accessor :name, :life, :strength, :experience
|
59
|
+
|
60
|
+
def initialize(name = self.class, life = 80, strength = 6, experience = 100)
|
61
|
+
@name = name
|
62
|
+
@life = life
|
63
|
+
@strength = strength
|
64
|
+
@experience = experience
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class Troll
|
69
|
+
attr_accessor :name, :life, :strength, :experience
|
70
|
+
|
71
|
+
def initialize(name = self.class, life = 100, strength = 8, experience = 100)
|
72
|
+
@name = name
|
73
|
+
@life = life
|
74
|
+
@strength = strength
|
75
|
+
@experience = experience
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Siren
|
80
|
+
attr_accessor :name, :life, :strength, :experience
|
81
|
+
|
82
|
+
def initialize(name = self.class, life = 150, strength = 10, experience = 200)
|
83
|
+
@name = name
|
84
|
+
@life = life
|
85
|
+
@strength = strength
|
86
|
+
@experience = experience
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class Demon
|
91
|
+
attr_accessor :name, :life, :strength, :experience
|
92
|
+
|
93
|
+
def initialize (name = self.class, life = 200, strength = 12, experience = 300)
|
94
|
+
@name = name
|
95
|
+
@life = life
|
96
|
+
@strength = strength
|
97
|
+
@experience = experience
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
#Bosses
|
102
|
+
|
103
|
+
|
104
|
+
RestlessSpirit = Ghoul.new('Restless Spirit', 50, 4, 20)
|
105
|
+
Bal = Demon.new('Bal', 1500, 250000000000000000000000000000000000000000000000000000000000000000000000, 1000)
|
106
|
+
|
data/lib/northshire.rb
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
require_relative 'modules'
|
2
|
+
require_relative 'monsters'
|
3
|
+
require_relative 'characters'
|
4
|
+
|
5
|
+
class Northshre
|
6
|
+
attr_accessor :name, :locations, :visit, :fightchance, :monsters
|
7
|
+
|
8
|
+
def initialize(name = 'Northshire', locations = {'inn' => NorthshireInn, 'shop' => NorthshireShop, 'tavern' => NorthshireTavern, 'house' => NorthshireHouse}, visit = 0, fight_chance = 12, monsters = 1)
|
9
|
+
@name = name
|
10
|
+
@locations = locations
|
11
|
+
@visit = visit
|
12
|
+
@fightchance = fight_chance
|
13
|
+
@monsters = monsters
|
14
|
+
end
|
15
|
+
|
16
|
+
def introduction
|
17
|
+
puts "You come upon a small town. The buildings here, though seemingly in full"
|
18
|
+
puts "operation, have not been maintained well. You suspect this town doesnt get much"
|
19
|
+
puts "trade or travellers. The people of this town seem to move slugishly, as if it"
|
20
|
+
puts "were with great reluctance that they arive to wherever they are heading. The"
|
21
|
+
puts "town itself had a depressed air about it and you find yourself experiencing an"
|
22
|
+
puts "intense meloncholy merely by being there. You hope your time in this town will"
|
23
|
+
puts "be short as you set off to discover what the town holds"
|
24
|
+
end
|
25
|
+
|
26
|
+
def look
|
27
|
+
puts "The lack of care and maintanance of the buildings immediatly stand out to you,"
|
28
|
+
puts "but, inspite of this, their functions are easily recognizable. Along the"
|
29
|
+
puts "gravelled road is a row of buildings. Of those buildings you notice a shop and"
|
30
|
+
puts "a tavern right next to it. Further down the road is you notice an inn."
|
31
|
+
puts "(shop, tavern, inn)"
|
32
|
+
end
|
33
|
+
|
34
|
+
def monster
|
35
|
+
return Human.new("Mugger")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Northshire_inn
|
40
|
+
attr_accessor :name, :commands
|
41
|
+
|
42
|
+
include Inn
|
43
|
+
|
44
|
+
def initialize(name = 'Northshire Inn', commands = ['leave', 'look', 'rest'])
|
45
|
+
@name = name
|
46
|
+
@commands = commands
|
47
|
+
end
|
48
|
+
|
49
|
+
def leave
|
50
|
+
$player.position.delete_at (0)
|
51
|
+
end
|
52
|
+
|
53
|
+
def introduction
|
54
|
+
puts 'You walk into the inn. The interior is just as bleak as the rest of the town.'
|
55
|
+
puts "You see the innkeeper - a sad looking man - who asks if you would like a room."
|
56
|
+
puts "(rest)"
|
57
|
+
end
|
58
|
+
|
59
|
+
def look
|
60
|
+
puts 'You see the innkeeper behind a wooden counter. Their is little light here, but'
|
61
|
+
puts 'enough to see that the walls are bare. There is nothing of any interest here.'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Northshire_shop
|
66
|
+
attr_accessor :name, :commands ,:items, :weapons, :spells, :armour
|
67
|
+
|
68
|
+
include Shop
|
69
|
+
|
70
|
+
def initialize(name = 'Northshire Shop', commands = ['buy', 'sell','leave'], items = ['potion', 'mana'], weapons = ['club'], spells = ['holy', 'heal'], armour = ['hat', 'wicker shield', 'leather gloves', 'chain helmet'])
|
71
|
+
@name = name
|
72
|
+
@items = items
|
73
|
+
@weapons = weapons
|
74
|
+
@spells = spells
|
75
|
+
@armour = armour
|
76
|
+
@commands = commands
|
77
|
+
end
|
78
|
+
|
79
|
+
def introduction
|
80
|
+
puts 'A man sits behind the counter. He offers no welcome or assitance, but just'
|
81
|
+
puts 'looks as you stand there.'
|
82
|
+
end
|
83
|
+
|
84
|
+
def look
|
85
|
+
puts 'The shops interior matches the depressing nature of the whole town. There are'
|
86
|
+
puts 'not many items that you can see, and what you can see is not very impressive.'
|
87
|
+
puts '(buy or sell)'
|
88
|
+
end
|
89
|
+
|
90
|
+
def leave
|
91
|
+
$player.position.delete_at (0)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class Northshire_tavern
|
96
|
+
attr_accessor :name, :commands, :inventory
|
97
|
+
|
98
|
+
def initialize(name = 'Northshire Tavern', commands = ['leave', 'talk'], inventory = [Martin])
|
99
|
+
@name = name
|
100
|
+
@commands = commands
|
101
|
+
@inventory = inventory
|
102
|
+
end
|
103
|
+
|
104
|
+
def introduction
|
105
|
+
puts 'You walk into the tavern, noticing that there are very few patrons. The bar,'
|
106
|
+
puts 'behind which you see a rough looking man with sunken eyes, is splintered and'
|
107
|
+
puts 'faded. One man, off in the corner, stares at you.'
|
108
|
+
unless self.inventory.length == 0
|
109
|
+
puts self.inventory[0].name
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def leave
|
115
|
+
$player.position.delete_at (0)
|
116
|
+
end
|
117
|
+
|
118
|
+
def talk
|
119
|
+
if self.inventory.include? (Martin)
|
120
|
+
$player.party << Martin
|
121
|
+
self.inventory.delete_at(self.inventory.index(Martin))
|
122
|
+
puts ''
|
123
|
+
puts 'Martin joins your party.'
|
124
|
+
else
|
125
|
+
puts 'There is no one here worth talking to'
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
class Northshire_house
|
132
|
+
attr_accessor :name, :commands, :visit
|
133
|
+
|
134
|
+
def initialize (name = 'Northshire House', commands = ['leave'], visit = 0)
|
135
|
+
@name = name
|
136
|
+
@commands = commands
|
137
|
+
@visit = visit
|
138
|
+
end
|
139
|
+
|
140
|
+
def introduction
|
141
|
+
unless ($player.party.include? Martin) || (self.visit != 0)
|
142
|
+
puts self.visit
|
143
|
+
self.leave
|
144
|
+
puts 'You cannot enter'
|
145
|
+
else
|
146
|
+
self.visit += 1 if self.visit == 0
|
147
|
+
puts 'you are here'
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def leave
|
152
|
+
$player.position.delete_at (0)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
NorthshireHouse = Northshire_house.new
|
157
|
+
NorthshireTavern = Northshire_tavern.new
|
158
|
+
NorthshireShop = Northshire_shop.new
|
159
|
+
NorthshireInn = Northshire_inn.new
|
160
|
+
Northshire = Northshre.new
|
data/lib/play.rb
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
require_relative 'player'
|
2
|
+
require_relative 'maps'
|
3
|
+
require_relative 'spells'
|
4
|
+
require_relative 'items'
|
5
|
+
require_relative 'armour'
|
6
|
+
require_relative 'weapons'
|
7
|
+
require_relative 'characters'
|
8
|
+
require_relative 'hamlet'
|
9
|
+
require_relative 'middleton'
|
10
|
+
require_relative 'denofshadows'
|
11
|
+
require_relative 'northshire'
|
12
|
+
require_relative 'ridgedale'
|
13
|
+
require_relative 'commands'
|
14
|
+
require_relative 'rand_fight'
|
15
|
+
|
16
|
+
require_relative 'books'
|
17
|
+
|
18
|
+
o = ''
|
19
|
+
while true
|
20
|
+
puts 'would you like to load?'
|
21
|
+
o = gets.chomp
|
22
|
+
if o == 'yes'
|
23
|
+
puts "Which character would you like to load?"
|
24
|
+
puts ''
|
25
|
+
Dir.glob("**/") do |dir|
|
26
|
+
str = dir
|
27
|
+
str = str.sub 'games/', ''
|
28
|
+
puts str.sub '/', ''
|
29
|
+
end
|
30
|
+
name = gets.chomp
|
31
|
+
if File.directory?("games/#{name}")
|
32
|
+
File.open("games/#{name}/#{name}") do |file|
|
33
|
+
$player = Marshal.load(file)
|
34
|
+
end
|
35
|
+
|
36
|
+
$player.party.each do |char|
|
37
|
+
File.open("games/#{$player.name}/#{char.name}") do |file|
|
38
|
+
char = Marshal.load(file)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
$player.party.each do |char|
|
43
|
+
File.open("games/#{$player.name}/#{char.name}", "w+") do |file|
|
44
|
+
Marshal.dump(char, file)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
$player.maps.each do |area|
|
49
|
+
File.open("games/#{$player.name}/#{area.name}") do |file|
|
50
|
+
area = Marshal.load(file)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
$player.visited.each do |location|
|
55
|
+
location.each do |place|
|
56
|
+
File.open("games/#{$player.name}/#{place.name}") do |file|
|
57
|
+
place = Marshal.load(file)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
puts ''
|
62
|
+
if $player.position.length > 0
|
63
|
+
puts "#{$player.position[0].name}"
|
64
|
+
puts ''
|
65
|
+
puts $player.position[0].look
|
66
|
+
end
|
67
|
+
break
|
68
|
+
else
|
69
|
+
puts 'Please enter a valid character'
|
70
|
+
end
|
71
|
+
elsif o == 'no'
|
72
|
+
puts ''
|
73
|
+
puts 'Please enter a name for your character.'
|
74
|
+
name = gets.chomp
|
75
|
+
|
76
|
+
def attribute_total(stats)
|
77
|
+
stats[:strength] + stats[:endurance] + stats[:agility] + stats[:intelligence]
|
78
|
+
end
|
79
|
+
|
80
|
+
player_attribute = {:strength => 0, :endurance => 0, :agility => 0, :intelligence => 0}
|
81
|
+
until attribute_total(player_attribute) == 20
|
82
|
+
puts ''
|
83
|
+
puts 'you have 20 points to distribute between strength, agility, intelligence'
|
84
|
+
puts 'and endurance'
|
85
|
+
puts ''
|
86
|
+
player_attribute.each do |attribute, value|
|
87
|
+
while true
|
88
|
+
puts ''
|
89
|
+
puts 'please enter a value for ' + attribute.to_s
|
90
|
+
puts ''
|
91
|
+
stat = gets.to_i
|
92
|
+
if (stat > 0 && stat <= 17)
|
93
|
+
player_attribute[attribute] = stat
|
94
|
+
break
|
95
|
+
end
|
96
|
+
puts 'please enter a number between 1 and 17' if (stat <= 0 || stat > 17)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
puts 'You only have 20 points to distribute!!!' if attribute_total(player_attribute) > 20
|
100
|
+
puts 'Please distribute all of the points.' if attribute_total(player_attribute) < 20
|
101
|
+
end
|
102
|
+
|
103
|
+
$player = Player.new(name,player_attribute[:strength], player_attribute[:endurance], player_attribute[:agility], player_attribute[:intelligence])
|
104
|
+
|
105
|
+
$player.maps << Hamletmap
|
106
|
+
$player.area << Hamlet
|
107
|
+
$player.visited << Hamletloc
|
108
|
+
Dir.mkdir("games/#{$player.name}")
|
109
|
+
File.open("games/#{$player.name}/#{$player.name}", "w+") do |file|
|
110
|
+
Marshal.dump($player, file)
|
111
|
+
end
|
112
|
+
$player.maps.each do |area|
|
113
|
+
File.open("games/#{$player.name}/#{area.name}", "w+") do |file|
|
114
|
+
Marshal.dump(area.location, file)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
$player.visited.each do |location|
|
118
|
+
location.each do |place|
|
119
|
+
File.open("games/#{$player.name}/#{place.name}", "w+") do |file|
|
120
|
+
Marshal.dump(place, file)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
puts ''
|
125
|
+
puts ''
|
126
|
+
puts ''
|
127
|
+
puts 'You awake to find yourself in a deserted hamlet. The buildings here'
|
128
|
+
puts 'look as though it has been many years since anyone had lived here.'
|
129
|
+
puts 'You wonder how it is you came here and quickly realize that you cannot'
|
130
|
+
puts 'recall anything from before this moment. It is as if you have just awaken'
|
131
|
+
puts 'from a dreamless sleep that has lasted since your birth. As you try harder'
|
132
|
+
puts 'to recall any detail of your life before now, you feel the back of your'
|
133
|
+
puts 'right hand begin to burn. You look down at it to see that some sort of'
|
134
|
+
puts 'symbol has been carved in it. The circular scar contains within it several'
|
135
|
+
puts 'smaller designs that are all aligned. You rub your hand as the questions'
|
136
|
+
puts 'begin to pile up in your mind. You decide that standing here is not going'
|
137
|
+
puts 'to ease your mind and decide to explore the buildings.'
|
138
|
+
puts ''
|
139
|
+
puts ''
|
140
|
+
puts Hamlet.look
|
141
|
+
break
|
142
|
+
else
|
143
|
+
puts 'i dont know what you are trying to say'
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
k = ''
|
148
|
+
|
149
|
+
|
150
|
+
while true
|
151
|
+
while true
|
152
|
+
break if $player.life <= 0
|
153
|
+
position = $player.position[0]
|
154
|
+
puts 'you are standing outside' unless $player.position.length > 0
|
155
|
+
puts ''
|
156
|
+
k = gets.chomp
|
157
|
+
puts''
|
158
|
+
break if k == 'exit'
|
159
|
+
if ($player.position.length > 0) && (position.commands.include? k)
|
160
|
+
$player.position[0].send(k)
|
161
|
+
elsif ($player.position.length == 0) && (Commands_outside.include? k)
|
162
|
+
send(k)
|
163
|
+
else
|
164
|
+
puts 'please enter a valid command'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
break if $player.life > 0
|
168
|
+
if $player.life <= 0
|
169
|
+
puts 'You Are Dead!!!!!!!'
|
170
|
+
puts ''
|
171
|
+
puts 'would you like to continue?'
|
172
|
+
j = ''
|
173
|
+
while true
|
174
|
+
j = gets.chomp
|
175
|
+
if j.downcase == 'yes'
|
176
|
+
File.open("games/#{$player.name}/#{$player.name}") do |file|
|
177
|
+
$player = Marshal.load(file)
|
178
|
+
end
|
179
|
+
|
180
|
+
$player.party.each do |char|
|
181
|
+
File.open("games/#{$player.name}/#{char.name}") do |file|
|
182
|
+
char = Marshal.load(file)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
$player.party.each do |char|
|
187
|
+
File.open("games/#{$player.name}/#{char.name}", "w+") do |file|
|
188
|
+
Marshal.dump(char, file)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
$player.maps.each do |area|
|
193
|
+
File.open("games/#{$player.name}/#{area.name}") do |file|
|
194
|
+
area = Marshal.load(file)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
$player.visited.each do |location|
|
199
|
+
location.each do |place|
|
200
|
+
File.open("games/#{$player.name}/#{place.name}") do |file|
|
201
|
+
place = Marshal.load(file)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
puts "You awake in the #{$player.position[0].name}" unless $player.position.length == 0
|
206
|
+
puts ''
|
207
|
+
puts $player.position[0].look unless $player.position.length == 0
|
208
|
+
break
|
209
|
+
elsif j.downcase == 'no'
|
210
|
+
break
|
211
|
+
else
|
212
|
+
puts 'I do not know that command'
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
break if $player.life <= 0
|
217
|
+
end
|
218
|
+
puts 'Game Over!!!!'
|