etw_math 1.0.1 → 1.2.0

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/example.rb +9 -1
  3. data/lib/etw_math.rb +52 -4
  4. data/test.rb +21 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d86434b8a584f7010ab5af15c06808ac7303d954bdb7497f388ca904ab3c7ff2
4
- data.tar.gz: a9426882c4e1d820517cdc6fd68ad6ff235bc882e167d398b7c2164586bfa277
3
+ metadata.gz: 2a6bc32aa40fd9881fd07c4504ec0ec8bd62391395216c6bdae1d63ae3f67a88
4
+ data.tar.gz: fd2bde9416a952dca7fed4b0e492db218d8b8ad4252e81ba0ea25bcc3b86f353
5
5
  SHA512:
6
- metadata.gz: 2f60687998b6b2a479c282f78fa4eb5b5b4884ffbd008342b89f9b71382dce10ed5008fc4a154a92983695544fbbd8e6bb1e4f2f30e75e4938a45b575c11cf8a
7
- data.tar.gz: 28b38734754ef876e4c4727cbe4a3eeb8dce3fe1b1d4867c79bdbd3581d9d336600b949249773335d4afd38b46d77aea68cd8ed9a9521627ff029aacfd27ea2a
6
+ metadata.gz: 42cbf495e7ec47ba887ae8c002ac554881b99abeca3f10121fb85693271887ce9e36119f748afbded820bff94d04bdaad2f2b0da373e7774cc47030d25a508d8
7
+ data.tar.gz: b34240e9f07ecb3cb8ac77eb97773b94b695893220c0e2b339eede77a19ee7180dd91cbdffb2636b87e3fd5b6d9ef2ced443d4e1286a8677d1a8f05d8ca36774
data/example.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # example.rb - EtwMath examples
2
- # Copyright (C) 2025 Lazy Villain
2
+ # Copyright (C) 2025-2026 Lazy Villain
3
3
  # https://github.com/LazyAntihero/etw_math
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without
@@ -49,6 +49,14 @@ puts "\nMax size at size level 100 size is:"
49
49
  puts EtwMath.size_at_level(100)
50
50
  puts "\nSize level for a max size of 505,000 is:"
51
51
  puts EtwMath.level_at_size(505000)
52
+ puts "\nActual size level for a max size of 509,999 is:"
53
+ puts EtwMath.actual_level_at_size(509999)
54
+ puts "\nNearest size level for a max size of 510,999 is:"
55
+ puts EtwMath.nearest_level_at_size(510999)
56
+ puts "\nEat speed level for an eat speed value of 5.4:"
57
+ puts EtwMath.eat_speed_level(5.4)
58
+ puts "\nEat speed value for an eat speed level of 23:"
59
+ puts EtwMath.eat_speed_value(23)
52
60
  puts "\nOptimal size level for a multi of 100 using a factor of 5.5 is:"
53
61
  puts EtwMath.optimal_size_level_threshold(100, 5.5)
54
62
  puts "\nOptimal multi for a size level of 550 using a ratio of 5.5 is:"
data/lib/etw_math.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # etw_math.rb - Various mathematical formulas for Roblox - Eat the World (ETW)
2
- # Copyright (C) 2025 Lazy Villain
2
+ # Copyright (C) 2025-2026 Lazy Villain
3
3
  # https://github.com/LazyAntihero/etw_math
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
28
28
  # This class contains various methods that perform Eat the World calculations
29
29
  class EtwMath
30
30
  # EtwMath version
31
- VERSION = "1.0.1"
31
+ VERSION = "1.2.0"
32
32
 
33
33
  # Number of seconds in 1 day
34
34
  SECONDS_PER_DAY = 86400
@@ -174,8 +174,8 @@ class EtwMath
174
174
  format_number(50 * level ** 2 + 50 * level)
175
175
  end
176
176
 
177
- # Calculates size level
178
- # @param level [Integer] Maximum size
177
+ # Calculates size level (floor)
178
+ # @param size [Integer] Maximum size
179
179
  # @return [String, Boolean] String representation of an integer or false if input is invalid or division by zero occurs
180
180
  # @example
181
181
  # EtwMath.level_at_size(505000) # 100
@@ -188,6 +188,54 @@ class EtwMath
188
188
  end
189
189
  end
190
190
 
191
+ # Calculates actual size level (float)
192
+ # @param size [Integer] Maximum size
193
+ # @return [String, Boolean] String representation of an integer or false if input is invalid or division by zero occurs
194
+ # @example
195
+ # EtwMath.actual_level_at_size(509999) # 100.496
196
+ def self.actual_level_at_size(size)
197
+ return false if !input_valid?(size)
198
+ begin
199
+ format_number(((-50 + Math.sqrt(2500 + 200 * size)) / 100).round(3), true)
200
+ rescue # division by zero
201
+ return false
202
+ end
203
+ end
204
+
205
+ # Calculates nearest size level (rounded)
206
+ # @param size [Integer] Maximum size
207
+ # @return [String, Boolean] String representation of an integer or false if input is invalid or division by zero occurs
208
+ # @example
209
+ # EtwMath.nearest_level_at_size(505000) # 100
210
+ def self.nearest_level_at_size(size)
211
+ return false if !input_valid?(size)
212
+ begin
213
+ format_number(((-50 + Math.sqrt(2500 + 200 * size)) / 100).round)
214
+ rescue # division by zero
215
+ return false
216
+ end
217
+ end
218
+
219
+ # Calculates eat speed value
220
+ # @param eat_speed_level [Integer] Eat speed level
221
+ # @return [String, Boolean] String representation of a float or false if input is invalid
222
+ # @example
223
+ # EtwMath.eat_speed_value(31) # 7.0
224
+ def self.eat_speed_value(eat_speed_level)
225
+ return false if !input_valid?(eat_speed_level)
226
+ format_number(0.2 * eat_speed_level + 0.8, true)
227
+ end
228
+
229
+ # Calculates eat speed level
230
+ # @param eat_speed_value [Float] Eat speed value
231
+ # @return [String, Boolean] String representation of an integer or false if input is invalid
232
+ # @example
233
+ # EtwMath.eat_speed_level(7.0) # 31
234
+ def self.eat_speed_level(eat_speed_value)
235
+ return false if !input_valid?(eat_speed_value)
236
+ format_number(5 * eat_speed_value - 4)
237
+ end
238
+
191
239
  # Calculates optimal size level threshold
192
240
  # @param multi [Integer] Multiplier level
193
241
  # @param ratio [Numeric] Ratio
data/test.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # test.rb - EtwMath unit tests
2
- # Copyright (C) 2025 Lazy Villain
2
+ # Copyright (C) 2025-2026 Lazy Villain
3
3
  # https://github.com/LazyAntihero/etw_math
4
4
  #
5
5
  # Redistribution and use in source and binary forms, with or without
@@ -106,6 +106,26 @@ class EtwMathTests < Minitest::Test
106
106
  assert(!EtwMath.level_at_size(-1))
107
107
  end
108
108
 
109
+ def test_actual_level_at_size
110
+ assert_equal("100.496", EtwMath.actual_level_at_size(509999))
111
+ assert(!EtwMath.actual_level_at_size(-1))
112
+ end
113
+
114
+ def test_nearest_level_at_size
115
+ assert_equal("101", EtwMath.nearest_level_at_size(510999))
116
+ assert(!EtwMath.nearest_level_at_size(-1))
117
+ end
118
+
119
+ def test_eat_speed_value
120
+ assert_equal("5.4", EtwMath.eat_speed_value(23))
121
+ assert(!EtwMath.eat_speed_value(-1))
122
+ end
123
+
124
+ def test_eat_speed_level
125
+ assert_equal("23", EtwMath.eat_speed_level(5.4))
126
+ assert(!EtwMath.eat_speed_level(-1))
127
+ end
128
+
109
129
  def test_optimal_size_level_threshold
110
130
  assert_equal("550", EtwMath.optimal_size_level_threshold(100, 5.5))
111
131
  assert(!EtwMath.optimal_size_level_threshold(-1, -1))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etw_math
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lazy Villain