zarta 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 +4 -4
- data/lib/zarta/dungeon.rb +23 -10
- data/lib/zarta/enemy.rb +1 -1
- data/lib/zarta/main.rb +12 -3
- data/lib/zarta/player.rb +13 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59db8341293c8f1215d868efa4b444c18db4b992
|
4
|
+
data.tar.gz: 6fd00faecdbc8bb913be54ac27b39987751ecf9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a8acc7a5f6283adcc14c963b7b0ca84cfdd6caee4c8eaae210720a3e6de32c5cbbaa8eae2fe48e7330c68b155c8940225c89d2ed5706056e2d2c7bdebf372fd
|
7
|
+
data.tar.gz: 3f114eb88958b3662819fa8bc8c1bf5b66a7129f368293d2e40894ec54311a6114451555404fb70aaefd8f31cd46f95bdb4a656c1777dd31c1fef42873735464
|
data/lib/zarta/dungeon.rb
CHANGED
@@ -36,24 +36,37 @@ module Zarta
|
|
36
36
|
# The current room
|
37
37
|
attr_accessor :room
|
38
38
|
|
39
|
+
# The game's score
|
40
|
+
attr_accessor :score
|
41
|
+
|
42
|
+
# The highest scoring player
|
43
|
+
attr_accessor :high_score_player
|
44
|
+
|
45
|
+
# The game's high score
|
46
|
+
attr_accessor :high_score
|
47
|
+
|
39
48
|
def initialize
|
40
49
|
load_yaml_files
|
41
50
|
|
42
|
-
@name
|
43
|
-
@description
|
44
|
-
@max_level
|
45
|
-
@level
|
46
|
-
@stairs_time
|
47
|
-
@player
|
48
|
-
@room
|
51
|
+
@name = 'The Legendary Dungeon of ZARTA'
|
52
|
+
@description = 'The testiest test dungeon that ever tested!'
|
53
|
+
@max_level = 10
|
54
|
+
@level = 1
|
55
|
+
@stairs_time = 0
|
56
|
+
@player = Zarta::Player.new(self)
|
57
|
+
@room = Zarta::Room.new(self)
|
58
|
+
@score = 0
|
59
|
+
@high_score_player = @high_score_list[:player_name]
|
60
|
+
@high_score = @high_score_list[:high_score]
|
49
61
|
end
|
50
62
|
|
51
63
|
# Moved him out for clarity and ease of editing. I know enemy isn't plural.
|
52
64
|
# It bugs me as well. It's on my list.
|
53
65
|
def load_yaml_files
|
54
|
-
@room_list
|
55
|
-
@weapon_list
|
56
|
-
@enemy_list
|
66
|
+
@room_list = YAML.load_file(__dir__ + '/rooms.yml')
|
67
|
+
@weapon_list = YAML.load_file(__dir__ + '/weapons.yml')
|
68
|
+
@enemy_list = YAML.load_file(__dir__ + '/enemy.yml')
|
69
|
+
@high_score_list = YAML.load_file(__dir__ + '/high_score.yml')
|
57
70
|
end
|
58
71
|
end
|
59
72
|
|
data/lib/zarta/enemy.rb
CHANGED
data/lib/zarta/main.rb
CHANGED
@@ -6,15 +6,15 @@ require 'artii'
|
|
6
6
|
BOSS_RARITY = 5
|
7
7
|
ENEMY_CHANCE_BASE = 40
|
8
8
|
ENEMY_CHANCE_MOD = 5
|
9
|
-
ENEMY_LEVEL_MAX_MOD =
|
9
|
+
ENEMY_LEVEL_MAX_MOD = 4
|
10
10
|
ENEMY_LEVEL_MIN_MOD = 2
|
11
|
-
ENEMY_MAX_HEALTH_MOD =
|
11
|
+
ENEMY_MAX_HEALTH_MOD = 4
|
12
12
|
FLEE_CHANCE = 0.5
|
13
13
|
HEALTH_INCREASE = 3
|
14
14
|
MAX_NEXT_ROOMS = 4
|
15
15
|
MIN_NEXT_ROOMS = 2
|
16
16
|
NEXT_LEVEL_XP = 10
|
17
|
-
SPAWN_CHANCE_MOD =
|
17
|
+
SPAWN_CHANCE_MOD = 4
|
18
18
|
STAIRS_CHANCE = 5
|
19
19
|
WEAPON_CHANCE_BASE = 5
|
20
20
|
WEAPON_CHANCE_MOD = 5
|
@@ -172,6 +172,7 @@ module Zarta
|
|
172
172
|
t << [@player.name, "LVL: #{@player.level}"]
|
173
173
|
t << [display_health, display_xp]
|
174
174
|
t << [display_weapon, display_dungeon_level]
|
175
|
+
t << [current_score, high_score]
|
175
176
|
end
|
176
177
|
|
177
178
|
def display_health
|
@@ -195,6 +196,14 @@ module Zarta
|
|
195
196
|
"Dungeon Level: #{@dungeon.level}/#{@dungeon.max_level}"
|
196
197
|
end
|
197
198
|
|
199
|
+
def current_score
|
200
|
+
"Current Score: #{@dungeon.score}"
|
201
|
+
end
|
202
|
+
|
203
|
+
def high_score
|
204
|
+
"High Score: #{@dungeon.high_score_player} - #{@dungeon.high_score}"
|
205
|
+
end
|
206
|
+
|
198
207
|
# Pretty straightforward but I have plans for the room description
|
199
208
|
# generation to be far more interesting. So check back here sometime in the
|
200
209
|
# next millenium.
|
data/lib/zarta/player.rb
CHANGED
@@ -19,7 +19,7 @@ module Zarta
|
|
19
19
|
attr_accessor :weapon
|
20
20
|
|
21
21
|
def initialize(dungeon)
|
22
|
-
@name = '
|
22
|
+
@name = ''
|
23
23
|
@health = [100, 100]
|
24
24
|
@level = 1
|
25
25
|
@xp = 0
|
@@ -163,11 +163,22 @@ module Zarta
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def gain_xp
|
166
|
-
xp_gained = @enemy.level + @
|
166
|
+
xp_gained = @enemy.level + @dungeon.level
|
167
167
|
@xp += xp_gained
|
168
|
+
score(xp_gained)
|
168
169
|
xp_gained
|
169
170
|
end
|
170
171
|
|
172
|
+
def score(xp)
|
173
|
+
@dungeon.score += xp
|
174
|
+
return unless @dungeon.score > @dungeon.high_score
|
175
|
+
puts 'New High Score!'
|
176
|
+
new_high_score = { player_name: @name, high_score: @dungeon.score }
|
177
|
+
File.open(__dir__ + '/high_score.yml', 'r+') do |file|
|
178
|
+
file.write(new_high_score.to_yaml)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
171
182
|
def level_up
|
172
183
|
@xp -= @level * NEXT_LEVEL_XP
|
173
184
|
@level += 1
|