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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ca56c38e74daf18c8ca66174fdc0edbd2cab7a2
4
- data.tar.gz: 4b69ae07c7a64cf98143f145e4f363bb8ac7ea87
3
+ metadata.gz: 59db8341293c8f1215d868efa4b444c18db4b992
4
+ data.tar.gz: 6fd00faecdbc8bb913be54ac27b39987751ecf9a
5
5
  SHA512:
6
- metadata.gz: 04ec21909bb132f207238401b54e9ba7afb07a38040c8c584811513aebe6242aaf8d3f36e5f303095233516c280d120cfcf1fd3f8e6e5beb0064fffddc263bc3
7
- data.tar.gz: f2b2811e023f6392d0f44c871c9285d1aa4c2e035f59e2f269d428792d96b4cf674b2cf6c638c8b6f9a40b9f020152ae8f364bd52bffc352fc45d00e189dbaca
6
+ metadata.gz: 0a8acc7a5f6283adcc14c963b7b0ca84cfdd6caee4c8eaae210720a3e6de32c5cbbaa8eae2fe48e7330c68b155c8940225c89d2ed5706056e2d2c7bdebf372fd
7
+ data.tar.gz: 3f114eb88958b3662819fa8bc8c1bf5b66a7129f368293d2e40894ec54311a6114451555404fb70aaefd8f31cd46f95bdb4a656c1777dd31c1fef42873735464
@@ -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 = 'The Legendary Dungeon of ZARTA'
43
- @description = 'The testiest test dungeon that ever tested!'
44
- @max_level = 10
45
- @level = 1
46
- @stairs_time = 0
47
- @player = Zarta::Player.new(self)
48
- @room = Zarta::Room.new(self)
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 = YAML.load_file(__dir__ + '/rooms.yml')
55
- @weapon_list = YAML.load_file(__dir__ + '/weapons.yml')
56
- @enemy_list = YAML.load_file(__dir__ + '/enemy.yml')
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
 
@@ -42,7 +42,7 @@ module Zarta
42
42
  end
43
43
 
44
44
  def spawn_chance
45
- rand(1..((@player.level + @dungeon.level) * SPAWN_CHANCE_MOD))
45
+ rand(1..(@player.level + SPAWN_CHANCE_MOD))
46
46
  end
47
47
 
48
48
  def set_level
@@ -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 = 3
9
+ ENEMY_LEVEL_MAX_MOD = 4
10
10
  ENEMY_LEVEL_MIN_MOD = 2
11
- ENEMY_MAX_HEALTH_MOD = 2
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 = 1.2
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.
@@ -19,7 +19,7 @@ module Zarta
19
19
  attr_accessor :weapon
20
20
 
21
21
  def initialize(dungeon)
22
- @name = 'Testy McTestface'
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 + @level + @dungeon.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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zarta
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
  - Chris Robertson