destiny 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODRmODMyNTIyMDY2MjI1ZmM5YzNmYWYwZjY1NWRmYTYwZjY0YmIzYg==
4
+ ZDFhZDQ1ZTc0NzNkNjhkMjM2NGRmZjFkNDY2OWQwYWMzMzZiNzhiZQ==
5
5
  data.tar.gz: !binary |-
6
- OWNjOWYxYmYzN2JlZTlhNGViMDMxM2IzNTYyYTAyZTU2MjM3ZmEzNA==
6
+ NTVhZTM3NWRmODlhNjFjNTFlOTA4MDMyMGU1ZGNhZDZmYTY0MGM0MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWM1YjEzZjFlOWI2Y2EzNzE0YWQyMDlmYTczOWRlODVkMTM2ZTU0YWZjYTE0
10
- Nzk1ZGM1YzZmMjVlMTkxNDFhNzJiOGY4NDc4MGExMTFlMWViMzY5N2E0YTBm
11
- ODRiOWU2MTI3Y2ZlYjhjZTEyNGM3OTNkNDQzOWU2NzQwMTk4YjM=
9
+ ZjY4NGM0YzUzYzkwNGEzNmNmNmU3MmY2YzlkYzA5ZjNmN2ZmYTk3MGEyMjhj
10
+ OTIyYjQ1MzgwNGFlZGU2MTljYjFjYTJiZTY1OTU1ZTgzODM2YTMxYmY0OWRk
11
+ MDQxM2IwMjdjMzc3OTk2ODc1OWQ3ZjhlZGMzOGZmZGI3MDU5NWE=
12
12
  data.tar.gz: !binary |-
13
- ZmNhYWQ5NGMyZWU1MDg4MTA0ZGFlNGM5NjIzNmVkYzkwYjNjZDNkMzQ0NTUz
14
- NGViN2MxYmRjMjFkZWU0M2EwOTg4M2YyNTAzZmZiMDJkMDg1OTkxMzhkMWVl
15
- Yjc4NDBmMzA2ZThiN2Y1MzdhZjI2MWJjMGZiM2M2ZmI1NjM1OTM=
13
+ YjE4ODgzODc5NzA4Yjg3NmQ3NzE5OTM5NzNmMDkwOGYzYzM3MjcwYTIwN2Vj
14
+ OTk3OTJhMmE5NzQzMWQ4OGYxNzUwNmNkZGY4Nzg2NzRiNDFiMDQ4NGNkOTBm
15
+ ZTQyN2ZkMzFmZmYyZGU5YTIyN2M1MmU0ZDc0MTVlMzQ3OTgzODE=
data/bin/destiny CHANGED
@@ -5,15 +5,19 @@ Dir.chdir(File.dirname(__FILE__))
5
5
  require 'destiny'
6
6
 
7
7
  puts # formatting
8
- puts " " + "_"*43
9
- puts "| Welcome to the exciting world of Destiny! |"
10
- puts " " + "-"*43
8
+ puts " " + "_"*53
9
+ puts "|" + " "*53 + "|"
10
+ puts "| Welcome to the exciting world of Destiny! |"
11
+ puts "|" + " "*53 + "|"
12
+ puts " " + "-"*53
13
+ puts # formatting
11
14
  puts # formatting
12
15
  puts "Selectable options will normally be enclosed in []'s."
13
16
  puts # formatting
14
17
  if File.exists?('../lib/save_game.json')
15
18
  puts "Would you like to start a new game?"
16
19
  GameSelect.new.outcome
20
+ puts # formatting
17
21
  else
18
22
  GameSelect.new("yes").outcome
19
23
  end
data/lib/destiny.rb CHANGED
@@ -28,11 +28,7 @@ class GameSelect
28
28
  #rspec with user input is more tricky, this allows me to test
29
29
  @default = default
30
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")
31
+ yes_no
36
32
  end
37
33
 
38
34
  def outcome
@@ -6,6 +6,14 @@ module GameMechanics
6
6
  print ">> "
7
7
  end
8
8
 
9
+ def yes_no
10
+ #restrict input to valid answers, but don't worry about case
11
+ begin
12
+ puts "Please enter [yes] or [no]:"
13
+ prompt; @game_select = STDIN.gets.chomp.downcase
14
+ end while not (@game_select == "yes" or @game_select == "no")
15
+ end
16
+
9
17
  def save_data
10
18
  save_info = {
11
19
  role: @player.class,
@@ -50,15 +58,94 @@ module GameMechanics
50
58
  end
51
59
 
52
60
  def bar_top
53
- "_"*25 + " STATS " + "_"*25
61
+ "_"*27 + " STATS " + "_"*27
54
62
  end
55
63
 
56
64
  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}"
65
+ " Name: #{name} | XP: #{xp} | Lvl: #{lvl} | Coin: #{coin} | HP: #{cur_hp} | Mana: #{cur_mana}"
58
66
  end
59
67
 
60
68
  def bar_low
61
- "-"*58
69
+ "-"*61
70
+ end
71
+
72
+ def combat bad_guy
73
+ @bad_guy = bad_guy.new
74
+ puts @bad_guy.name + " says, you kill my father, now you will die!!" unless (@bad_guy.name == "ROUS" or @bad_guy.name == "Skeleton")
75
+ move = 0
76
+ until move == "2"
77
+ begin
78
+ puts # formatting
79
+ puts bar_low + "--"
80
+ puts " #{@player.name} - HP: #{@player.cur_hp} - Mana: #{@player.cur_mana} | - VS - | #{@bad_guy.name} - HP: #{@bad_guy.cur_hp} - Mana: #{@bad_guy.cur_mana}"
81
+ puts bar_low + "--"
82
+ puts # formatting
83
+ puts "#{@bad_guy.name} vs. #{@player.name}, what will you do?"
84
+ puts "[1]. Attack."
85
+ puts "[2]. Run."
86
+ prompt; move = gets.chomp
87
+ end while not (move == "1" or move == "2")
88
+ case
89
+ when move == "1"
90
+ puts # formatting
91
+ if @player.class.to_s == "Knight"
92
+ puts "#{@player.name} swings the mighty sword at the #{@bad_guy.name}."
93
+ puts # formatting
94
+ @dmg_dlt = dice(@player.dmg)
95
+ elsif @player.class.to_s == "Wizard"
96
+ begin
97
+ puts "How many magic darts will you shoot?"
98
+ puts "[1]."
99
+ puts "[2]."
100
+ puts "[3]."
101
+ prompt; darts = gets.chomp.to_i
102
+ end while not (darts == 1 or darts == 2 or darts == 3)
103
+ puts "#{@player.name} conjures #{darts} magic darts that zip toward the #{@bad_guy.name}."
104
+ @dmg_dlt = dice(@player.dmg) + darts # more darts more damage
105
+ @player.cur_mana = @player.cur_mana - darts # more darts more mana spent
106
+ end
107
+ puts "You deal #{@dmg_dlt} damage to the #{@bad_guy.name}"
108
+ puts # formatting
109
+ @bad_guy.cur_hp = @bad_guy.cur_hp - @dmg_dlt
110
+ if @bad_guy.cur_hp <= 0
111
+ puts "You have slain the #{@bad_guy.name} and won the day!"
112
+ # rewards for winning the battle!
113
+ @player.xp = @player.xp + @bad_guy.xp
114
+ @player.coin = @player.coin + @bad_guy.coin
115
+ save_data
116
+ return
117
+ else
118
+ puts "#{@bad_guy.name} viciously attacks #{@player.name}!"
119
+ puts # formatting
120
+ dmg_taken = dice(@bad_guy.dmg)
121
+ @player.cur_hp = @player.cur_hp - dmg_taken
122
+ puts "#{@bad_guy.name} hits YOU for #{dmg_taken} damage!"
123
+ puts "OUCH!"
124
+ puts #formatting
125
+ end
126
+ if @player.cur_hp <= 0
127
+ puts "You were killed by the #{@bad_guy.name}."
128
+ puts "Killed dead."
129
+ puts # formatting
130
+ puts "It happens to the best of us #{@player.name}."
131
+ puts "Fortunately for you, the game of Destiny never ends."
132
+ puts "The game will exit now and you can restart in town."
133
+ puts # formatting
134
+ puts "Better luck next time, eh?"
135
+ exit
136
+ end
137
+ when move == "2"
138
+ puts # formatting
139
+ puts "Sometimes the right thing to do is run."
140
+ puts "This is one of those times."
141
+ puts # formatting
142
+ puts "You shout what is that? and point frantically in the opposite direction."
143
+ puts "The #{@bad_guy.name} turns to look and you high tail it away!"
144
+ save_data
145
+ return
146
+ end
147
+ end
148
+
62
149
  end
63
150
 
64
151
  def dice(sides=6,&block)
@@ -72,22 +159,49 @@ module GameMechanics
72
159
  def random_encounter
73
160
  chance = dice(20)
74
161
  case
75
- when (1..5).include?(chance)
162
+ when (1..2).include?(chance)
76
163
  puts # formatting
77
164
  puts "You get the feeling you are being watched..."
78
165
  puts # formatting
79
- when (6..10).include?(chance)
166
+ when (3..4).include?(chance)
167
+ puts # formatting
168
+ puts "You notice a coin stuck in the dirt, pry it loose,"
169
+ puts "and place the coin in your wallet."
170
+ puts "Today must be your lucky day, #{@player.name}!"
171
+ @player.xp = @player.xp + 50
172
+ @player.coin = @player.coin + 1
173
+ puts # formatting
174
+ when (5..8).include?(chance)
80
175
  puts #format
81
176
  puts "A small goblin springs from the shadows and attacks!!"
82
177
  puts #format
83
- when (11..15).include?(chance)
178
+ combat(Goblin)
179
+ when (9..11).include?(chance)
84
180
  puts #format
85
181
  puts "You hear squeeking sounds. BIG squeeking sounds!"
86
182
  puts #format
87
- when (16..20).include?(chance)
183
+ combat(GiantRat)
184
+ when (12..15).include?(chance)
185
+ puts #format
186
+ puts "A kobold peers out of a hole in the wall and then snarls."
187
+ puts #format
188
+ combat(Kobold)
189
+ when (16..18).include?(chance)
190
+ puts #format
191
+ puts "Although you have never heard bones scrape across a floor"
192
+ puts "before, you know without a doubt what approaches..."
193
+ puts #format
194
+ combat(Skeleton)
195
+ when (19..20).include?(chance)
88
196
  puts # formatting
89
- puts "You step into a puddle of water and angrily lift your boot out."
197
+ trip_event = dice(3)
198
+ trip_part = "knee" if trip_event == 1
199
+ trip_part = "elbow" if trip_event == 2
200
+ trip_part = "hands" if trip_event == 3
201
+ puts "You stumble and scrape your #{trip_part}."
202
+ puts "You take 1 damage."
90
203
  puts # formatting
204
+ @player.cur_hp = @player.cur_hp - 1
91
205
  end
92
206
  end
93
207
 
data/lib/mobs.rb CHANGED
@@ -21,6 +21,8 @@ class Mobs
21
21
 
22
22
  end
23
23
 
24
+ # playable character roles
25
+
24
26
  class Knight < Mobs
25
27
 
26
28
  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")
@@ -31,7 +33,17 @@ end
31
33
 
32
34
  class Wizard < Mobs
33
35
 
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")
36
+ def initialize(str=8, agi=10, int=16, dmg=4, armor=4, hp=4, cur_hp=4, dodge=10, mana=16, cur_mana=16, xp=0, lvl=1, coin=0, name="Wizard")
37
+ super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
38
+ end
39
+
40
+ end
41
+
42
+ # Opponents below
43
+
44
+ class GiantRat < Mobs
45
+
46
+ def initialize(str=12, agi=10, int=4, dmg=4, armor=6, hp=8, cur_hp=8, dodge=10, mana=0, cur_mana=0, xp=200, lvl=1, coin=1, name="ROUS")
35
47
  super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
36
48
  end
37
49
 
@@ -39,15 +51,23 @@ end
39
51
 
40
52
  class Goblin < Mobs
41
53
 
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")
54
+ def initialize(str=10, agi=10, int=8, dmg=3, armor=6, hp=6, cur_hp=6, dodge=20, mana=2, cur_mana=2, xp=100, lvl=1, coin=1, name="Goblin")
43
55
  super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
44
56
  end
45
57
 
46
58
  end
47
59
 
48
- class GiantRat < Mobs
60
+ class Kobold < Mobs
61
+
62
+ def initialize(str=12, agi=8, int=8, dmg=4, armor=5, hp=6, cur_hp=6, dodge=10, mana=2, cur_mana=2, xp=150, lvl=1, coin=2, name="Kobold")
63
+ super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
64
+ end
65
+
66
+ end
67
+
68
+ class Skeleton < Mobs
49
69
 
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")
70
+ def initialize(str=12, agi=12, int=8, dmg=5, armor=6, hp=10, cur_hp=10, dodge=10, mana=0, cur_mana=0, xp=300, lvl=1, coin=4, name="Skeleton")
51
71
  super(str,agi,int,dmg,armor,hp,cur_hp,dodge,mana,cur_mana,xp,lvl,coin,name)
52
72
  end
53
73
 
data/lib/places.rb CHANGED
@@ -4,14 +4,14 @@
4
4
  class Town
5
5
 
6
6
  def initialize
7
- # only available as an option in the Dungeon (to return to)
7
+ # Town is only available as an option in the Dungeon (to return to)
8
+ # initialize is only called the first time, so this greeting is only seen once
8
9
  puts "These things always start the same way and your adventure is no exception..."
9
10
  puts "You walk into town, scanning each nook and cranny. Most faces are friendly,"
10
11
  puts "some are not..."
11
12
  end
12
13
 
13
14
  def choices
14
- save_file = 'lib/save_game.txt'
15
15
  move = 0
16
16
  until move == "3"
17
17
  begin
@@ -40,8 +40,8 @@ class Town
40
40
  when move == "2"
41
41
  Dungeon.new.choices
42
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
43
+ # save the player's stats before exit
44
+ save_data
45
45
  exit
46
46
  end
47
47
  end
@@ -64,11 +64,11 @@ class Dungeon
64
64
  puts "You have entered the dungeon! DUM DUM DUM!!"
65
65
  end
66
66
 
67
- def choices
67
+ def choices
68
68
  move = 0
69
+ load_data
69
70
  until move == "2"
70
71
  begin
71
- load_data
72
72
  puts # formatting
73
73
  puts bar_top
74
74
  puts stat_bar(@player.name, @player.xp, @player.lvl, @player.coin, @player.cur_hp, @player.cur_mana)
@@ -82,12 +82,12 @@ def choices
82
82
  case
83
83
  when move == "1"
84
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."
85
+ puts "You walk further into the dark, dank, dirty, dungeon,"
86
+ puts "smirking slightly at your awesome alliteration ability."
88
87
  puts # formatting
89
88
  random_encounter
90
89
  when move == "2"
90
+ save_data
91
91
  return
92
92
  end
93
93
  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.1
4
+ version: 0.0.2
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-06 00:00:00.000000000 Z
11
+ date: 2014-03-08 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