world_in_your_terminal 0.0.3 → 0.0.4

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
  SHA256:
3
- metadata.gz: 87e23b706e5aae83d585b6f01bb4f9ad028e20c48d4538784034f6e82b6b0c14
4
- data.tar.gz: abd22f064c39c0e52f15fab88da86890ab813df82e8f0958567e8ce98566fea1
3
+ metadata.gz: a6a3346f784044e08f3be04363d63ff16f3b699055926aa3d58df1f93b644ad1
4
+ data.tar.gz: 00f2650eb25cac9f382c9242ca957a53d62bbf261eefa858984b9029277116c2
5
5
  SHA512:
6
- metadata.gz: 12b8759a693a18cb62942a288bc7816b8410b34cf2be7bdce9c0e8284b64ef5da2ad4893c4428d84f96d9895d17193eec5044b5eb38da6b0ef7fdf22ad81944b
7
- data.tar.gz: c9c4ffdc2191fe11091351b3589b083abdc4359a5491a8df3698493254e1644bdfec3e1d15316985183735a22a4527d798e546fab7cc957c989706cddb0eb52b
6
+ metadata.gz: 646b71f79707d18547f90cbec71ff45adedef495dfb26b73f2faa9c3338fc41731034b9417cc2e50d1a3c1be6db1cadaf118a64f2d5819ac7bb92fab256f56c5
7
+ data.tar.gz: 3e2d772d745eb3634dd20d29bc87a81ba58b4a7339f0a00fe637fc6bc33ca614fd4eb6110171d50487d2bcef26b479ba43b349188d07acc84da46efaf77c6728
@@ -80,7 +80,7 @@ class Engine
80
80
  "",
81
81
  "-----------------------",
82
82
  "r to generate new world",
83
- "arrow keys to explore",
83
+ world.scrollable? ? "arrow keys to explore" : "",
84
84
  "z to zoom in",
85
85
  "x to zoom out",
86
86
  "n to rename this world",
@@ -27,9 +27,6 @@ class World
27
27
  def initialize(theme)
28
28
  @theme = theme
29
29
  @pastel = Pastel.new
30
- @max_x = 4
31
- @max_y = 4
32
- @max_z = 4
33
30
  regenerate
34
31
  end
35
32
 
@@ -264,7 +261,7 @@ class World
264
261
  end
265
262
 
266
263
  def add_to_x_level(amount, position)
267
- new_x = (position.x + amount).clamp(-@max_x, @max_x)
264
+ new_x = (position.x + amount).clamp(-max_x, max_x)
268
265
 
269
266
  Point.new(
270
267
  new_x,
@@ -274,7 +271,7 @@ class World
274
271
  end
275
272
 
276
273
  def add_to_y_level(amount, position)
277
- new_y = (position.y + amount).clamp(-@max_y, @max_y)
274
+ new_y = (position.y + amount).clamp(-max_y, max_y)
278
275
 
279
276
  Point.new(
280
277
  position.x,
@@ -284,15 +281,42 @@ class World
284
281
  end
285
282
 
286
283
  def add_to_z_level(amount, position)
287
- new_z = (position.z + amount).clamp(0, @max_z)
284
+ new_z = (position.z + amount).clamp(0, max_z)
285
+ zooming_out = zooming_out?(amount)
288
286
 
289
287
  Point.new(
290
- position.x,
291
- position.y,
288
+ zooming_out ? 0 : position.x,
289
+ zooming_out ? 0 : position.y,
292
290
  new_z,
293
291
  )
294
292
  end
295
293
 
294
+ def zooming_out?(amount)
295
+ return true if amount < 0
296
+
297
+ false
298
+ end
299
+
300
+ def max_x
301
+ scrollable? ? max_xy_scroll : 0
302
+ end
303
+
304
+ def max_y
305
+ scrollable? ? max_xy_scroll : 0
306
+ end
307
+
308
+ def scrollable?
309
+ @current_position.z >= max_z
310
+ end
311
+
312
+ def max_xy_scroll
313
+ 64
314
+ end
315
+
316
+ def max_z
317
+ 4
318
+ end
319
+
296
320
  def generate_new_zoomed_in_map(position)
297
321
  zoom_length = next_matrix_width
298
322
  unfilled_new_matrix = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: world_in_your_terminal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vanderhaar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-16 00:00:00.000000000 Z
11
+ date: 2022-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pastel
@@ -131,16 +131,16 @@ extra_rdoc_files: []
131
131
  files:
132
132
  - bin/world_in_your_terminal
133
133
  - lib/world_in_your_terminal.rb
134
+ - lib/world_in_your_terminal/Engine.rb
135
+ - lib/world_in_your_terminal/World.rb
134
136
  - lib/world_in_your_terminal/action.rb
135
137
  - lib/world_in_your_terminal/alert_system.rb
136
138
  - lib/world_in_your_terminal/constants/themes/black_white.rb
137
139
  - lib/world_in_your_terminal/constants/themes/default.rb
138
140
  - lib/world_in_your_terminal/constants/tile_types.rb
139
141
  - lib/world_in_your_terminal/display.rb
140
- - lib/world_in_your_terminal/engine.rb
141
142
  - lib/world_in_your_terminal/generate_matrix.rb
142
143
  - lib/world_in_your_terminal/generate_name.rb
143
- - lib/world_in_your_terminal/world.rb
144
144
  homepage: https://rubygems.org/gems/world_in_your_terminal
145
145
  licenses:
146
146
  - MIT