destiny 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/bin/destiny +21 -15
- data/lib/destiny.rb +105 -105
- data/lib/game_mechanics.rb +93 -93
- data/lib/mobs.rb +54 -54
- data/lib/places.rb +96 -96
- metadata +4 -5
- data/lib/save_game.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODRmODMyNTIyMDY2MjI1ZmM5YzNmYWYwZjY1NWRmYTYwZjY0YmIzYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OWNjOWYxYmYzN2JlZTlhNGViMDMxM2IzNTYyYTAyZTU2MjM3ZmEzNA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWM1YjEzZjFlOWI2Y2EzNzE0YWQyMDlmYTczOWRlODVkMTM2ZTU0YWZjYTE0
|
10
|
+
Nzk1ZGM1YzZmMjVlMTkxNDFhNzJiOGY4NDc4MGExMTFlMWViMzY5N2E0YTBm
|
11
|
+
ODRiOWU2MTI3Y2ZlYjhjZTEyNGM3OTNkNDQzOWU2NzQwMTk4YjM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZmNhYWQ5NGMyZWU1MDg4MTA0ZGFlNGM5NjIzNmVkYzkwYjNjZDNkMzQ0NTUz
|
14
|
+
NGViN2MxYmRjMjFkZWU0M2EwOTg4M2YyNTAzZmZiMDJkMDg1OTkxMzhkMWVl
|
15
|
+
Yjc4NDBmMzA2ZThiN2Y1MzdhZjI2MWJjMGZiM2M2ZmI1NjM1OTM=
|
data/bin/destiny
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
puts
|
8
|
-
puts " " + "
|
9
|
-
puts
|
10
|
-
puts "
|
11
|
-
puts
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
Dir.chdir(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require 'destiny'
|
6
|
+
|
7
|
+
puts # formatting
|
8
|
+
puts " " + "_"*43
|
9
|
+
puts "| Welcome to the exciting world of Destiny! |"
|
10
|
+
puts " " + "-"*43
|
11
|
+
puts # formatting
|
12
|
+
puts "Selectable options will normally be enclosed in []'s."
|
13
|
+
puts # formatting
|
14
|
+
if File.exists?('../lib/save_game.json')
|
15
|
+
puts "Would you like to start a new game?"
|
16
|
+
GameSelect.new.outcome
|
17
|
+
else
|
18
|
+
GameSelect.new("yes").outcome
|
19
|
+
end
|
20
|
+
Town.new.choices
|
21
|
+
|
data/lib/destiny.rb
CHANGED
@@ -1,105 +1,105 @@
|
|
1
|
-
require "json"
|
2
|
-
require "game_mechanics"
|
3
|
-
require "mobs"
|
4
|
-
require "places"
|
5
|
-
|
6
|
-
include GameMechanics
|
7
|
-
|
8
|
-
def choose_name
|
9
|
-
puts #formatting
|
10
|
-
puts "Please enter your new character's name:"
|
11
|
-
prompt; gets.chomp
|
12
|
-
end
|
13
|
-
|
14
|
-
def read_one_line(file_name, line_number)
|
15
|
-
File.open(file_name) do |file|
|
16
|
-
current_line = 1
|
17
|
-
file.each_line do |line|
|
18
|
-
return line.chomp if line_number == current_line
|
19
|
-
current_line += 1
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class GameSelect
|
25
|
-
attr_accessor :game_select
|
26
|
-
|
27
|
-
def initialize default="default"
|
28
|
-
#rspec with user input is more tricky, this allows me to test
|
29
|
-
@default = default
|
30
|
-
return @game_select = @default if @default != "default"
|
31
|
-
#restrict input to valid answers, but don't worry about case
|
32
|
-
begin
|
33
|
-
puts "Please enter [yes] or [no]:"
|
34
|
-
prompt; @game_select = STDIN.gets.chomp.downcase
|
35
|
-
end while not (@game_select == "yes" or @game_select == "no")
|
36
|
-
end
|
37
|
-
|
38
|
-
def outcome
|
39
|
-
if @game_select == "yes"
|
40
|
-
# this is purely for rspec
|
41
|
-
return "Starting a new game, please answer the following questions:" if @default != "default"
|
42
|
-
begin
|
43
|
-
puts # formatting
|
44
|
-
puts "_"*50
|
45
|
-
puts "Starting a new game, please answer the following questions:"
|
46
|
-
puts "Whould you like to play as a knight or wizard?"
|
47
|
-
puts "[1]. Knight"
|
48
|
-
puts "[2]. Wizard"
|
49
|
-
prompt; class_choice = gets.chomp
|
50
|
-
end while not (class_choice == "1" or class_choice == "2")
|
51
|
-
begin
|
52
|
-
player_name = choose_name
|
53
|
-
puts #formatting
|
54
|
-
puts "You have chosen #{player_name} as your character's name. Is this correct?"
|
55
|
-
puts "Please enter [yes] to confirm."
|
56
|
-
prompt; confirm_name = STDIN.gets.chomp.downcase
|
57
|
-
end while not (confirm_name == "yes")
|
58
|
-
if class_choice == "1"
|
59
|
-
@player = Knight.new
|
60
|
-
elsif class_choice == "2"
|
61
|
-
@player = Wizard.new
|
62
|
-
end
|
63
|
-
# Set player name, write attributes to save file, then return player to binary
|
64
|
-
@player.name = "#{player_name}"
|
65
|
-
save_data
|
66
|
-
# Intro for new players
|
67
|
-
puts #formatting
|
68
|
-
puts "Prepare ye, #{@player.name} for great adventure!"
|
69
|
-
puts "Ye are a young #{@player.class} with magnificent deeds ahead of ye!"
|
70
|
-
puts # formatting
|
71
|
-
@player
|
72
|
-
elsif @game_select == "no"
|
73
|
-
# for rspec
|
74
|
-
return "Loading the existing game." if @default != "default"
|
75
|
-
puts # formatting
|
76
|
-
puts "Loading the existing game."
|
77
|
-
puts # formatting
|
78
|
-
@player = load_data
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
class NewGame
|
85
|
-
attr_accessor :save_slot, :char_name
|
86
|
-
|
87
|
-
def initialize new_game
|
88
|
-
@new_game = new_game
|
89
|
-
end
|
90
|
-
|
91
|
-
def answer_was game_select="yes"
|
92
|
-
@game_select = game_select
|
93
|
-
#should probably be a case statement that verifies that only yes, y, no, or n was entered
|
94
|
-
# and ignores caps (lower and upper are valid)
|
95
|
-
if @game_select == "yes"
|
96
|
-
puts # formatting
|
97
|
-
puts "Starting a new game, please enter character name:"
|
98
|
-
# @character_name = gets
|
99
|
-
else
|
100
|
-
# Here I will display both save slots with the character names.
|
101
|
-
"Please select a game to load:"
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
1
|
+
require "json"
|
2
|
+
require "game_mechanics"
|
3
|
+
require "mobs"
|
4
|
+
require "places"
|
5
|
+
|
6
|
+
include GameMechanics
|
7
|
+
|
8
|
+
def choose_name
|
9
|
+
puts #formatting
|
10
|
+
puts "Please enter your new character's name:"
|
11
|
+
prompt; gets.chomp
|
12
|
+
end
|
13
|
+
|
14
|
+
def read_one_line(file_name, line_number)
|
15
|
+
File.open(file_name) do |file|
|
16
|
+
current_line = 1
|
17
|
+
file.each_line do |line|
|
18
|
+
return line.chomp if line_number == current_line
|
19
|
+
current_line += 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class GameSelect
|
25
|
+
attr_accessor :game_select
|
26
|
+
|
27
|
+
def initialize default="default"
|
28
|
+
#rspec with user input is more tricky, this allows me to test
|
29
|
+
@default = default
|
30
|
+
return @game_select = @default if @default != "default"
|
31
|
+
#restrict input to valid answers, but don't worry about case
|
32
|
+
begin
|
33
|
+
puts "Please enter [yes] or [no]:"
|
34
|
+
prompt; @game_select = STDIN.gets.chomp.downcase
|
35
|
+
end while not (@game_select == "yes" or @game_select == "no")
|
36
|
+
end
|
37
|
+
|
38
|
+
def outcome
|
39
|
+
if @game_select == "yes"
|
40
|
+
# this is purely for rspec
|
41
|
+
# return "Starting a new game, please answer the following questions:" if @default != "default"
|
42
|
+
begin
|
43
|
+
puts # formatting
|
44
|
+
puts "_"*50
|
45
|
+
puts "Starting a new game, please answer the following questions:"
|
46
|
+
puts "Whould you like to play as a knight or wizard?"
|
47
|
+
puts "[1]. Knight"
|
48
|
+
puts "[2]. Wizard"
|
49
|
+
prompt; class_choice = gets.chomp
|
50
|
+
end while not (class_choice == "1" or class_choice == "2")
|
51
|
+
begin
|
52
|
+
player_name = choose_name
|
53
|
+
puts #formatting
|
54
|
+
puts "You have chosen #{player_name} as your character's name. Is this correct?"
|
55
|
+
puts "Please enter [yes] to confirm."
|
56
|
+
prompt; confirm_name = STDIN.gets.chomp.downcase
|
57
|
+
end while not (confirm_name == "yes")
|
58
|
+
if class_choice == "1"
|
59
|
+
@player = Knight.new
|
60
|
+
elsif class_choice == "2"
|
61
|
+
@player = Wizard.new
|
62
|
+
end
|
63
|
+
# Set player name, write attributes to save file, then return player to binary
|
64
|
+
@player.name = "#{player_name}"
|
65
|
+
save_data
|
66
|
+
# Intro for new players
|
67
|
+
puts #formatting
|
68
|
+
puts "Prepare ye, #{@player.name} for great adventure!"
|
69
|
+
puts "Ye are a young #{@player.class} with magnificent deeds ahead of ye!"
|
70
|
+
puts # formatting
|
71
|
+
@player
|
72
|
+
elsif @game_select == "no"
|
73
|
+
# for rspec
|
74
|
+
return "Loading the existing game." if @default != "default"
|
75
|
+
puts # formatting
|
76
|
+
puts "Loading the existing game."
|
77
|
+
puts # formatting
|
78
|
+
@player = load_data
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
class NewGame
|
85
|
+
attr_accessor :save_slot, :char_name
|
86
|
+
|
87
|
+
def initialize new_game
|
88
|
+
@new_game = new_game
|
89
|
+
end
|
90
|
+
|
91
|
+
def answer_was game_select="yes"
|
92
|
+
@game_select = game_select
|
93
|
+
#should probably be a case statement that verifies that only yes, y, no, or n was entered
|
94
|
+
# and ignores caps (lower and upper are valid)
|
95
|
+
if @game_select == "yes"
|
96
|
+
puts # formatting
|
97
|
+
puts "Starting a new game, please enter character name:"
|
98
|
+
# @character_name = gets
|
99
|
+
else
|
100
|
+
# Here I will display both save slots with the character names.
|
101
|
+
"Please select a game to load:"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
data/lib/game_mechanics.rb
CHANGED
@@ -1,94 +1,94 @@
|
|
1
|
-
module GameMechanics
|
2
|
-
|
3
|
-
@@save_file = 'lib/save_game.json'
|
4
|
-
|
5
|
-
def prompt
|
6
|
-
print ">> "
|
7
|
-
end
|
8
|
-
|
9
|
-
def save_data
|
10
|
-
save_info = {
|
11
|
-
role: @player.class,
|
12
|
-
cur_hp: @player.cur_hp,
|
13
|
-
cur_mana: @player.cur_mana,
|
14
|
-
xp: @player.xp,
|
15
|
-
lvl: @player.lvl,
|
16
|
-
coin: @player.coin,
|
17
|
-
name: @player.name
|
18
|
-
}
|
19
|
-
File.open(@@save_file, "w") do |f|
|
20
|
-
f.write(save_info.to_json)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def load_data
|
25
|
-
load_info = JSON.parse(File.read(@@save_file))
|
26
|
-
role = load_info['role']
|
27
|
-
if role == "Knight"
|
28
|
-
@player = Knight.new
|
29
|
-
elsif role == "Wizard"
|
30
|
-
@player = Wizard.new
|
31
|
-
end
|
32
|
-
# Set attributes based off information in load_info
|
33
|
-
@player.cur_hp = load_info['cur_hp']
|
34
|
-
@player.cur_mana = load_info['cur_mana']
|
35
|
-
@player.xp = load_info['xp']
|
36
|
-
@player.lvl = load_info['lvl']
|
37
|
-
@player.coin = load_info['coin']
|
38
|
-
@player.name = load_info['name']
|
39
|
-
@player
|
40
|
-
# I was trying to do the above assignments with iteration, there has to be a way!
|
41
|
-
# load_info.each do |attribute, value|
|
42
|
-
# @player.#{attribute} = value unless attribute == "role"
|
43
|
-
# end
|
44
|
-
end
|
45
|
-
|
46
|
-
def restore_player
|
47
|
-
@player.cur_hp = @player.hp
|
48
|
-
@player.cur_mana = @player.mana
|
49
|
-
save_data
|
50
|
-
end
|
51
|
-
|
52
|
-
def bar_top
|
53
|
-
"_"*25 + " STATS " + "_"*25
|
54
|
-
end
|
55
|
-
|
56
|
-
def stat_bar name, xp, lvl, coin, cur_hp, cur_mana
|
57
|
-
"Name: #{name} | XP: #{xp} | Lvl: #{lvl} | Coin: #{coin} | HP: #{cur_hp} | Mana: #{cur_mana}"
|
58
|
-
end
|
59
|
-
|
60
|
-
def bar_low
|
61
|
-
"-"*58
|
62
|
-
end
|
63
|
-
|
64
|
-
def dice(sides=6,&block)
|
65
|
-
if block_given?
|
66
|
-
block.call(rand(1..sides))
|
67
|
-
else
|
68
|
-
rand(1..sides)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def random_encounter
|
73
|
-
chance = dice(20)
|
74
|
-
case
|
75
|
-
when (1..5).include?(chance)
|
76
|
-
puts # formatting
|
77
|
-
puts "You get the feeling you are being watched..."
|
78
|
-
puts # formatting
|
79
|
-
when (6..10).include?(chance)
|
80
|
-
puts #format
|
81
|
-
puts "A small goblin springs from the shadows and attacks!!"
|
82
|
-
puts #format
|
83
|
-
when (11..15).include?(chance)
|
84
|
-
puts #format
|
85
|
-
puts "You hear squeeking sounds. BIG squeeking sounds!"
|
86
|
-
puts #format
|
87
|
-
when (16..20).include?(chance)
|
88
|
-
puts # formatting
|
89
|
-
puts "You step into a puddle of water and angrily lift your boot out."
|
90
|
-
puts # formatting
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
1
|
+
module GameMechanics
|
2
|
+
|
3
|
+
@@save_file = '../lib/save_game.json'
|
4
|
+
|
5
|
+
def prompt
|
6
|
+
print ">> "
|
7
|
+
end
|
8
|
+
|
9
|
+
def save_data
|
10
|
+
save_info = {
|
11
|
+
role: @player.class,
|
12
|
+
cur_hp: @player.cur_hp,
|
13
|
+
cur_mana: @player.cur_mana,
|
14
|
+
xp: @player.xp,
|
15
|
+
lvl: @player.lvl,
|
16
|
+
coin: @player.coin,
|
17
|
+
name: @player.name
|
18
|
+
}
|
19
|
+
File.open(@@save_file, "w") do |f|
|
20
|
+
f.write(save_info.to_json)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def load_data
|
25
|
+
load_info = JSON.parse(File.read(@@save_file))
|
26
|
+
role = load_info['role']
|
27
|
+
if role == "Knight"
|
28
|
+
@player = Knight.new
|
29
|
+
elsif role == "Wizard"
|
30
|
+
@player = Wizard.new
|
31
|
+
end
|
32
|
+
# Set attributes based off information in load_info
|
33
|
+
@player.cur_hp = load_info['cur_hp']
|
34
|
+
@player.cur_mana = load_info['cur_mana']
|
35
|
+
@player.xp = load_info['xp']
|
36
|
+
@player.lvl = load_info['lvl']
|
37
|
+
@player.coin = load_info['coin']
|
38
|
+
@player.name = load_info['name']
|
39
|
+
@player
|
40
|
+
# I was trying to do the above assignments with iteration, there has to be a way!
|
41
|
+
# load_info.each do |attribute, value|
|
42
|
+
# @player.#{attribute} = value unless attribute == "role"
|
43
|
+
# end
|
44
|
+
end
|
45
|
+
|
46
|
+
def restore_player
|
47
|
+
@player.cur_hp = @player.hp
|
48
|
+
@player.cur_mana = @player.mana
|
49
|
+
save_data
|
50
|
+
end
|
51
|
+
|
52
|
+
def bar_top
|
53
|
+
"_"*25 + " STATS " + "_"*25
|
54
|
+
end
|
55
|
+
|
56
|
+
def stat_bar name, xp, lvl, coin, cur_hp, cur_mana
|
57
|
+
"Name: #{name} | XP: #{xp} | Lvl: #{lvl} | Coin: #{coin} | HP: #{cur_hp} | Mana: #{cur_mana}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def bar_low
|
61
|
+
"-"*58
|
62
|
+
end
|
63
|
+
|
64
|
+
def dice(sides=6,&block)
|
65
|
+
if block_given?
|
66
|
+
block.call(rand(1..sides))
|
67
|
+
else
|
68
|
+
rand(1..sides)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def random_encounter
|
73
|
+
chance = dice(20)
|
74
|
+
case
|
75
|
+
when (1..5).include?(chance)
|
76
|
+
puts # formatting
|
77
|
+
puts "You get the feeling you are being watched..."
|
78
|
+
puts # formatting
|
79
|
+
when (6..10).include?(chance)
|
80
|
+
puts #format
|
81
|
+
puts "A small goblin springs from the shadows and attacks!!"
|
82
|
+
puts #format
|
83
|
+
when (11..15).include?(chance)
|
84
|
+
puts #format
|
85
|
+
puts "You hear squeeking sounds. BIG squeeking sounds!"
|
86
|
+
puts #format
|
87
|
+
when (16..20).include?(chance)
|
88
|
+
puts # formatting
|
89
|
+
puts "You step into a puddle of water and angrily lift your boot out."
|
90
|
+
puts # formatting
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
94
|
end
|
data/lib/mobs.rb
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
class Mobs
|
2
|
-
|
3
|
-
attr_accessor :str, :agi, :int, :dmg, :armor, :hp, :cur_hp, :dodge, :mana, :cur_mana, :xp, :lvl, :coin, :name
|
4
|
-
|
5
|
-
def initialize(str, agi, int, dmg, armor, hp, cur_hp, dodge, mana, cur_mana, xp, lvl, coin, name="MOB")
|
6
|
-
@str = str
|
7
|
-
@agi = agi
|
8
|
-
@int = int
|
9
|
-
@dmg = dmg
|
10
|
-
@armor = armor
|
11
|
-
@hp = hp
|
12
|
-
@cur_hp = cur_hp
|
13
|
-
@dodge = dodge
|
14
|
-
@mana = mana
|
15
|
-
@cur_mana = cur_mana
|
16
|
-
@xp = xp
|
17
|
-
@lvl = lvl
|
18
|
-
@coin = coin
|
19
|
-
@name = name
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
class Knight < Mobs
|
25
|
-
|
26
|
-
def initialize(str=14, agi=12, int=8, dmg=6, armor=10, hp=8, cur_hp=8, dodge=20, mana=8, cur_mana=8, xp=0, lvl=1, coin=0, name="Knight")
|
27
|
-
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
class Wizard < Mobs
|
33
|
-
|
34
|
-
def initialize(str=8, agi=10, int=16, dmg=3, armor=4, hp=4, cur_hp=4, dodge=10, mana=24, cur_mana=24, xp=0, lvl=1, coin=0, name="Wizard")
|
35
|
-
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
class Goblin < Mobs
|
41
|
-
|
42
|
-
def initialize(str=10, agi=10, int=8, dmg=3, armor=6, hp=3, cur_hp=3, dodge=20, mana=2, cur_mana=2, xp=0, lvl=1, coin=0, name="Goblin")
|
43
|
-
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
class GiantRat < Mobs
|
49
|
-
|
50
|
-
def initialize(str=12, agi=10, int=4, dmg=3, armor=6, hp=3, cur_hp=3, dodge=10, mana=0, cur_mana=0, xp=0, lvl=1, coin=0, name="ROUS")
|
51
|
-
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
1
|
+
class Mobs
|
2
|
+
|
3
|
+
attr_accessor :str, :agi, :int, :dmg, :armor, :hp, :cur_hp, :dodge, :mana, :cur_mana, :xp, :lvl, :coin, :name
|
4
|
+
|
5
|
+
def initialize(str, agi, int, dmg, armor, hp, cur_hp, dodge, mana, cur_mana, xp, lvl, coin, name="MOB")
|
6
|
+
@str = str
|
7
|
+
@agi = agi
|
8
|
+
@int = int
|
9
|
+
@dmg = dmg
|
10
|
+
@armor = armor
|
11
|
+
@hp = hp
|
12
|
+
@cur_hp = cur_hp
|
13
|
+
@dodge = dodge
|
14
|
+
@mana = mana
|
15
|
+
@cur_mana = cur_mana
|
16
|
+
@xp = xp
|
17
|
+
@lvl = lvl
|
18
|
+
@coin = coin
|
19
|
+
@name = name
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
class Knight < Mobs
|
25
|
+
|
26
|
+
def initialize(str=14, agi=12, int=8, dmg=6, armor=10, hp=8, cur_hp=8, dodge=20, mana=8, cur_mana=8, xp=0, lvl=1, coin=0, name="Knight")
|
27
|
+
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class Wizard < Mobs
|
33
|
+
|
34
|
+
def initialize(str=8, agi=10, int=16, dmg=3, armor=4, hp=4, cur_hp=4, dodge=10, mana=24, cur_mana=24, xp=0, lvl=1, coin=0, name="Wizard")
|
35
|
+
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
class Goblin < Mobs
|
41
|
+
|
42
|
+
def initialize(str=10, agi=10, int=8, dmg=3, armor=6, hp=3, cur_hp=3, dodge=20, mana=2, cur_mana=2, xp=0, lvl=1, coin=0, name="Goblin")
|
43
|
+
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
class GiantRat < Mobs
|
49
|
+
|
50
|
+
def initialize(str=12, agi=10, int=4, dmg=3, armor=6, hp=3, cur_hp=3, dodge=10, mana=0, cur_mana=0, xp=0, lvl=1, coin=0, name="ROUS")
|
51
|
+
super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
data/lib/places.rb
CHANGED
@@ -1,96 +1,96 @@
|
|
1
|
-
# This file will contain the various places the player can go
|
2
|
-
# Town, Tavern, Dungeon and options in each
|
3
|
-
|
4
|
-
class Town
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
# only available as an option in the Dungeon (to return to)
|
8
|
-
puts "These things always start the same way and your adventure is no exception..."
|
9
|
-
puts "You walk into town, scanning each nook and cranny. Most faces are friendly,"
|
10
|
-
puts "some are not..."
|
11
|
-
end
|
12
|
-
|
13
|
-
def choices
|
14
|
-
save_file = 'lib/save_game.txt'
|
15
|
-
move = 0
|
16
|
-
until move == "3"
|
17
|
-
begin
|
18
|
-
load_data
|
19
|
-
puts # formatting
|
20
|
-
puts bar_top
|
21
|
-
puts stat_bar(@player.name, @player.xp, @player.lvl, @player.coin, @player.cur_hp, @player.cur_mana)
|
22
|
-
puts bar_low
|
23
|
-
puts # formatting
|
24
|
-
puts "Please choose where you will head next:"
|
25
|
-
puts "[1]. Ye Old Tavern"
|
26
|
-
puts "[2]. Dungeon"
|
27
|
-
puts "[3]. Exit game"
|
28
|
-
prompt; move = gets.chomp
|
29
|
-
end while not (move == "1" or move == "2" or move == "3")
|
30
|
-
case
|
31
|
-
when move == "1"
|
32
|
-
# Put this in Tavern class???
|
33
|
-
# also Tavern should restore the cur_hp and cur_mana to max values!
|
34
|
-
puts # formatting
|
35
|
-
puts "You enter the tavern. The air is thick with smoke, but you find a place"
|
36
|
-
puts "near a window and after a bowl of hearty soup and a bit of rest, you feel"
|
37
|
-
puts "greatly replenished."
|
38
|
-
puts # formatting
|
39
|
-
restore_player
|
40
|
-
when move == "2"
|
41
|
-
Dungeon.new.choices
|
42
|
-
when move == "3"
|
43
|
-
# This needs to save the players stats before exit
|
44
|
-
# Should probably convert the read from file to restore stats to a module
|
45
|
-
exit
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
class Tavern
|
53
|
-
|
54
|
-
# only available as an option in the Town
|
55
|
-
# This class will essentially "heal" the player by restoring mana and hp
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
class Dungeon
|
60
|
-
|
61
|
-
# can go here from town, will spawn random encounters, etc.
|
62
|
-
def initialize
|
63
|
-
puts # formatting
|
64
|
-
puts "You have entered the dungeon! DUM DUM DUM!!"
|
65
|
-
end
|
66
|
-
|
67
|
-
def choices
|
68
|
-
move = 0
|
69
|
-
until move == "2"
|
70
|
-
begin
|
71
|
-
load_data
|
72
|
-
puts # formatting
|
73
|
-
puts bar_top
|
74
|
-
puts stat_bar(@player.name, @player.xp, @player.lvl, @player.coin, @player.cur_hp, @player.cur_mana)
|
75
|
-
puts bar_low
|
76
|
-
puts # formatting
|
77
|
-
puts "Now #{@player.name}, what will you do next?"
|
78
|
-
puts "[1]. Go deeper into the dungeon."
|
79
|
-
puts "[2]. Return to town."
|
80
|
-
prompt; move = gets.chomp
|
81
|
-
end while not (move == "1" or move == "2")
|
82
|
-
case
|
83
|
-
when move == "1"
|
84
|
-
puts # formatting
|
85
|
-
puts "You walk further into the dark, dank,"
|
86
|
-
puts "dirty, dungeon, smirking slightly"
|
87
|
-
puts "at your awesome alliteration ability."
|
88
|
-
puts # formatting
|
89
|
-
random_encounter
|
90
|
-
when move == "2"
|
91
|
-
return
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
1
|
+
# This file will contain the various places the player can go
|
2
|
+
# Town, Tavern, Dungeon and options in each
|
3
|
+
|
4
|
+
class Town
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
# only available as an option in the Dungeon (to return to)
|
8
|
+
puts "These things always start the same way and your adventure is no exception..."
|
9
|
+
puts "You walk into town, scanning each nook and cranny. Most faces are friendly,"
|
10
|
+
puts "some are not..."
|
11
|
+
end
|
12
|
+
|
13
|
+
def choices
|
14
|
+
save_file = 'lib/save_game.txt'
|
15
|
+
move = 0
|
16
|
+
until move == "3"
|
17
|
+
begin
|
18
|
+
load_data
|
19
|
+
puts # formatting
|
20
|
+
puts bar_top
|
21
|
+
puts stat_bar(@player.name, @player.xp, @player.lvl, @player.coin, @player.cur_hp, @player.cur_mana)
|
22
|
+
puts bar_low
|
23
|
+
puts # formatting
|
24
|
+
puts "Please choose where you will head next:"
|
25
|
+
puts "[1]. Ye Old Tavern"
|
26
|
+
puts "[2]. Dungeon"
|
27
|
+
puts "[3]. Exit game"
|
28
|
+
prompt; move = gets.chomp
|
29
|
+
end while not (move == "1" or move == "2" or move == "3")
|
30
|
+
case
|
31
|
+
when move == "1"
|
32
|
+
# Put this in Tavern class???
|
33
|
+
# also Tavern should restore the cur_hp and cur_mana to max values!
|
34
|
+
puts # formatting
|
35
|
+
puts "You enter the tavern. The air is thick with smoke, but you find a place"
|
36
|
+
puts "near a window and after a bowl of hearty soup and a bit of rest, you feel"
|
37
|
+
puts "greatly replenished."
|
38
|
+
puts # formatting
|
39
|
+
restore_player
|
40
|
+
when move == "2"
|
41
|
+
Dungeon.new.choices
|
42
|
+
when move == "3"
|
43
|
+
# This needs to save the players stats before exit
|
44
|
+
# Should probably convert the read from file to restore stats to a module
|
45
|
+
exit
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
class Tavern
|
53
|
+
|
54
|
+
# only available as an option in the Town
|
55
|
+
# This class will essentially "heal" the player by restoring mana and hp
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
class Dungeon
|
60
|
+
|
61
|
+
# can go here from town, will spawn random encounters, etc.
|
62
|
+
def initialize
|
63
|
+
puts # formatting
|
64
|
+
puts "You have entered the dungeon! DUM DUM DUM!!"
|
65
|
+
end
|
66
|
+
|
67
|
+
def choices
|
68
|
+
move = 0
|
69
|
+
until move == "2"
|
70
|
+
begin
|
71
|
+
load_data
|
72
|
+
puts # formatting
|
73
|
+
puts bar_top
|
74
|
+
puts stat_bar(@player.name, @player.xp, @player.lvl, @player.coin, @player.cur_hp, @player.cur_mana)
|
75
|
+
puts bar_low
|
76
|
+
puts # formatting
|
77
|
+
puts "Now #{@player.name}, what will you do next?"
|
78
|
+
puts "[1]. Go deeper into the dungeon."
|
79
|
+
puts "[2]. Return to town."
|
80
|
+
prompt; move = gets.chomp
|
81
|
+
end while not (move == "1" or move == "2")
|
82
|
+
case
|
83
|
+
when move == "1"
|
84
|
+
puts # formatting
|
85
|
+
puts "You walk further into the dark, dank,"
|
86
|
+
puts "dirty, dungeon, smirking slightly"
|
87
|
+
puts "at your awesome alliteration ability."
|
88
|
+
puts # formatting
|
89
|
+
random_encounter
|
90
|
+
when move == "2"
|
91
|
+
return
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: destiny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kody Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Role playing game with distinct classes and character development
|
14
14
|
email: kodywilson@gmail.com
|
@@ -22,7 +22,6 @@ files:
|
|
22
22
|
- lib/game_mechanics.rb
|
23
23
|
- lib/mobs.rb
|
24
24
|
- lib/places.rb
|
25
|
-
- lib/save_game.json
|
26
25
|
homepage: http://rubygems.org/gems/destiny
|
27
26
|
licenses:
|
28
27
|
- MIT
|
@@ -33,12 +32,12 @@ require_paths:
|
|
33
32
|
- lib
|
34
33
|
required_ruby_version: !ruby/object:Gem::Requirement
|
35
34
|
requirements:
|
36
|
-
- -
|
35
|
+
- - ! '>='
|
37
36
|
- !ruby/object:Gem::Version
|
38
37
|
version: '0'
|
39
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
39
|
requirements:
|
41
|
-
- -
|
40
|
+
- - ! '>='
|
42
41
|
- !ruby/object:Gem::Version
|
43
42
|
version: '0'
|
44
43
|
requirements: []
|
data/lib/save_game.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"role":"Wizard","xp":0,"lvl":1,"coin":0,"name":"Gizard"}
|