Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created August 17, 2018 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuroyoro/85a07eb8b202a29bd9f96963828ef8a7 to your computer and use it in GitHub Desktop.
Save yuroyoro/85a07eb8b202a29bd9f96963828ef8a7 to your computer and use it in GitHub Desktop.
Congrats toward to HTML5
#!/usr/bin/env ruby
arr = {
resource: [6657, 5699, 3371, 8909, 7719, 6229, 5449, 8561, 2987, 5501, 3127, 9319, 4365, 9811, 9927, 2423, 3439, 1865, 5925, 4409, 5509, 1517, 9695, 9255, 5325, 3691, 5519, 6949, 5607, 9539, 4133, 7795, 5465, 2659, 6381, 6875, 4019, 9195, 5645, 2887, 1213, 1815, 8671, 3015, 3147, 2991, 7977, 7045, 1619, 7909, 4451, 6573, 4545, 8251, 5983, 2849, 7249, 7449, 9477, 5963, 2711, 9019, 7375, 2201, 5631, 4893, 7653, 3719, 8819, 5839, 1853, 9843, 9119, 7023, 5681, 2345, 9873, 6349, 9315, 3795, 9737, 4633, 4173, 7549, 7171, 6147, 4723, 5039, 2723, 7815, 6201, 5999, 5339, 4431, 2911, 4435, 3611, 4423, 9517, 3243],
voice: [2475, 6547, 1471, 8691, 7847, 3595, 1767, 3311, 2507, 9651, 5321, 4473, 7117, 5947, 9489, 2669, 8741, 6149, 1301, 7297, 2975, 6413, 8391, 9705, 2243, 2091, 4231, 3107, 9499, 4205, 6013, 3393, 6401, 6985, 3683, 9447, 3287, 5181, 7587, 9353, 2135, 4947, 5405, 5223, 9457, 5767, 9265, 8191, 3927, 3061, 2805, 3273, 7331]
}
def createKey(s)
s.codepoints.inject(:+)
end
def suffix(arr, e, i)
r = e.to_s.match(/\d+/)[0].to_i
s = createKey(i)
a = (i.nil? || i.length == 0) ? 1 : i.length
y = (s + r * a) % 100
res = arr[:resource]
x = res[y]
(17 * (r + 7) * x % 8973 + 1e3).to_i.to_s
end
def calculate_asset_path(arr, shipid, type, dmg)
a = type + (dmg ? "_dmg" : "")
u = "ship_" + a
suf = suffix(arr, shipid, u)
ids = "%04d" % shipid
"resources/ship/" + a + "/" + ids + "_" + suf + ".png"
end
calculate_asset_path(arr, 498, "banner", false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment