etw_math 1.0.1 → 1.1.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.
- checksums.yaml +4 -4
- data/example.rb +5 -1
- data/lib/etw_math.rb +32 -4
- data/test.rb +11 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20deadb5cf831be70936304753c265e4522e20ca041bd2ebdd31f121aa40faf1
|
|
4
|
+
data.tar.gz: 1e96e0b936a0547e4fe8d054b31097d017a2ca8a1bbe045f68d7a1dcc6733674
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9b14a2044d690064e31e6b4eca0f12e681f94bf0e32f01a515872645faea5f4839576170b354989e4f313875317a278bbad23bb6c3cd18d1734b85ab91fd755
|
|
7
|
+
data.tar.gz: ef7c626db1ea858c2edf414ea53fa6ec886f09a1cd25168b84b74325a9bd78c9bdbfad776ff2388e3ed012346fe7e9724bf5a1ac47cec47bf3c695a511cc201a
|
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,10 @@ 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)
|
|
52
56
|
puts "\nOptimal size level for a multi of 100 using a factor of 5.5 is:"
|
|
53
57
|
puts EtwMath.optimal_size_level_threshold(100, 5.5)
|
|
54
58
|
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
|
|
31
|
+
VERSION = "1.1.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
|
|
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,34 @@ 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
|
+
|
|
191
219
|
# Calculates optimal size level threshold
|
|
192
220
|
# @param multi [Integer] Multiplier level
|
|
193
221
|
# @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,16 @@ 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
|
+
|
|
109
119
|
def test_optimal_size_level_threshold
|
|
110
120
|
assert_equal("550", EtwMath.optimal_size_level_threshold(100, 5.5))
|
|
111
121
|
assert(!EtwMath.optimal_size_level_threshold(-1, -1))
|