Guest User

Untitled

a guest
Aug 17th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace GetKcs2ResourceName
  5. {
  6. class Program
  7. {
  8. // note: $"{12:d4}" -> "0012"
  9.  
  10.  
  11. // resourceType = ["album_status", "banner", "card", "character_full", "character_up", "full", "supply_character"]
  12. public static string GetShipResourcePath(int shipID, bool isDamaged, string resourceType)
  13. {
  14. if (resourceType == "album_status")
  15. isDamaged = false;
  16.  
  17. // if (isEnemy(shipID))
  18. // isDamaged = false;
  19.  
  20. if (isDamaged)
  21. resourceType += "_dmg";
  22.  
  23. return $"<root>/resources/ship/{resourceType}/{shipID:d4}_{CreateKey(shipID, "ship_" + resourceType)}.png";
  24. }
  25.  
  26. // resourceType = ["btxt_flat", "card", "card_t", "item_character", "item_on", "item_up", "remodel", "statustop_item"]
  27. public static string GetEquipmentResourcePath(int equipmentID, string resourceType)
  28. {
  29. return $"<root>/resources/slot/{resourceType}/{equipmentID:d3}_{CreateKey(equipmentID, "slot_" + resourceType)}.png";
  30. }
  31.  
  32.  
  33. static readonly int[] resourceTable = new int[100]
  34. {
  35. 6657,5699,3371,8909,7719,
  36. 6229,5449,8561,2987,5501,
  37. 3127,9319,4365,9811,9927,
  38. 2423,3439,1865,5925,4409,
  39. 5509,1517,9695,9255,5325,
  40. 3691,5519,6949,5607,9539,
  41. 4133,7795,5465,2659,6381,
  42. 6875,4019,9195,5645,2887,
  43. 1213,1815,8671,3015,3147,
  44. 2991,7977,7045,1619,7909,
  45. 4451,6573,4545,8251,5983,
  46. 2849,7249,7449,9477,5963,
  47. 2711,9019,7375,2201,5631,
  48. 4893,7653,3719,8819,5839,
  49. 1853,9843,9119,7023,5681,
  50. 2345,9873,6349,9315,3795,
  51. 9737,4633,4173,7549,7171,
  52. 6147,4723,5039,2723,7815,
  53. 6201,5999,5339,4431,2911,
  54. 4435,3611,4423,9517,3243
  55. };
  56.  
  57. static string CreateKey(int id, string resourceType)
  58. {
  59. if (id == 0)
  60. return "";
  61.  
  62. var s = resourceType.ToCharArray().Sum(c => (int)c);
  63. var a = Math.Max(resourceType.Length, 1);
  64.  
  65. return (17 * (id + 7) * resourceTable[(s + id * a) % 100] % 8973 + 1000).ToString();
  66. }
  67.  
  68.  
  69. // example
  70. static void Main(string[] args)
  71. {
  72. for (int i = 1; i < 2000; i++)
  73. {
  74. Console.WriteLine($"{i,4}: {GetShipResourcePath(i, false, "full")}");
  75. }
  76.  
  77. for (int i = 1; i < 1000; i++)
  78. {
  79. Console.WriteLine($"{i,4}: {GetEquipmentResourcePath(i, "card")}");
  80. }
  81.  
  82. }
  83.  
  84. }
  85. }
Add Comment
Please, Sign In to add comment