Inventory - Add


SUBMITTED BY: DavidEid

DATE: Aug. 6, 2017, 9:14 a.m.

FORMAT: C#

SIZE: 4.2 kB

HITS: 351

  1. public bool Add(uint id, byte plus, byte times, bool bound = false)
  2. {
  3. try
  4. {
  5. Database.ConquerItemInformation infos = new Database.ConquerItemInformation(id, plus);
  6. while (times > 0)
  7. {
  8. if (Count <= 39)
  9. {
  10. Owner.SpiltStack = true;
  11. ConquerItem item = new Network.GamePackets.ConquerItem(true);
  12. item.ID = id;
  13. item.Bound = bound;
  14. item.Plus = plus;
  15. item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
  16. Add(item, Enums.ItemUse.CreateAndAdd);
  17. Owner.SpiltStack = false;
  18. }
  19. else
  20. {
  21. return false;
  22. }
  23. times--;
  24. }
  25. }
  26. catch (Exception e)
  27. {
  28. Program.SaveException(e);
  29. }
  30. return true;
  31. }
  32. public bool AddBoundItem(uint id, byte plus, byte times, bool bound = true)
  33. {
  34. try
  35. {
  36. Database.ConquerItemInformation infos = new Database.ConquerItemInformation(id, plus);
  37. while (times > 0)
  38. {
  39. if (Count <= 39)
  40. {
  41. Owner.SpiltStack = true;
  42. ConquerItem item = new ConquerItem(true);
  43. item.ID = id;
  44. item.Plus = plus;
  45. item.Bound = bound;
  46. item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
  47. item.Color = (Conquer_Online_Server.Game.Enums.Color)Kernel.Random.Next(4, 8);
  48. Add(item, Enums.ItemUse.CreateAndAdd);
  49. Owner.SpiltStack = false;
  50. }
  51. else
  52. {
  53. return false;
  54. }
  55. times--;
  56. }
  57. }
  58. catch (Exception e)
  59. {
  60. Program.SaveException(e);
  61. }
  62. return true;
  63. }
  64. public bool AddTime(uint id, uint TimeLeft, bool bound = false, bool bless = false)
  65. {
  66. try
  67. {
  68. Database.ConquerItemInformation infos = new Database.ConquerItemInformation(id, 0);
  69. if (Count <= 39)
  70. {
  71. ConquerItem item;
  72. item = new ConquerItem(true);
  73. {
  74. item.ID = id;
  75. if (id >= 730001 && id <= 730009)
  76. {
  77. item.Plus = (byte)(id - 730000);
  78. }
  79. else item.Plus = 0;
  80. if (bless == true)
  81. item.Bless = 1;
  82. item.Enchant = 0;
  83. item.Bound = bound;
  84. item.DayStamp = DateTime.Now;
  85. TimeSpan span1 = new TimeSpan(item.DayStamp.AddSeconds(item.Days).Ticks);
  86. TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks);
  87. item.TimeLeftInMinutes = (uint)(span1.TotalSeconds - span2.TotalSeconds);
  88. item.Durability = item.MaximDurability = infos.BaseInformation.Durability;
  89. };
  90. this.Add(item, Enums.ItemUse.CreateAndAdd);
  91. Database.ConquerItemTable.Update_Free(item, Owner);
  92. Database.ConquerItemTable.UpdateBless(item);
  93. Database.ConquerItemTable.UpdateBound(item, Owner);
  94. }
  95. else
  96. {
  97. return false;
  98. }
  99. }
  100. catch (Exception e)
  101. {
  102. Program.SaveException(e);
  103. }
  104. return true;
  105. }

comments powered by Disqus