Advertisement
Guest User

Sample code to explain Divine Spirit bug

a guest
Jul 11th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.15 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. class Minion
  4. {
  5. private:
  6.     int Attack, CurrentHP, MaxHP;
  7. public:
  8.     Minion(int atk, int hp) : Attack(atk), CurrentHP(hp), MaxHP(hp) { }
  9.  
  10.     void UseDivineSpirit()
  11.     {
  12.         float temp = CurrentHP;
  13.         CurrentHP += (int)temp;
  14.         MaxHP += (int)temp;
  15.         std::cout << "Use DS - Hitpoints now: " << Attack << "/" << CurrentHP << std::endl;
  16.     }
  17.     void UseArmorPlating()
  18.     {
  19.         CurrentHP++;
  20.         MaxHP++;
  21.         std::cout << "Use AP - Hitpoints now: " << Attack << "/" << CurrentHP << std::endl;
  22.     }
  23. };
  24.  
  25. int main()
  26. {
  27.     Minion wisp(1, 1);
  28.     wisp.UseArmorPlating();  // Now a 1/2 wisp
  29.     for (int i = 0; i < 23; i++)  // Repeat Armor Plating and Divine Spirit 23 times
  30.     {
  31.         wisp.UseArmorPlating();
  32.         wisp.UseDivineSpirit();
  33.     }  // Wisp is now a 1/33554430
  34.     wisp.UseArmorPlating();  // Now a 1/33554431 wisp
  35.     wisp.UseDivineSpirit();  // Now a 1/67108863 wisp
  36.     wisp.UseDivineSpirit();  // Now a 1/134217727 wisp
  37.     wisp.UseDivineSpirit();  // Now a 1/268435455 wisp
  38.     wisp.UseDivineSpirit();  // Now a 1/536870911 wisp
  39.     wisp.UseDivineSpirit();  // Now a 1/1073741823 wisp
  40.     wisp.UseDivineSpirit();  // Now a 1/2147483647 wisp
  41.     return 0;
  42. }
  43.  
  44. Output:
  45. Use AP: 1/2
  46. Use AP: 1/3
  47. Use DS: 1/6
  48. Use AP: 1/7
  49. Use DS: 1/14
  50. Use AP: 1/15
  51. Use DS: 1/30
  52. Use AP: 1/31
  53. Use DS: 1/62
  54. Use AP: 1/63
  55. Use DS: 1/126
  56. Use AP: 1/127
  57. Use DS: 1/254
  58. Use AP: 1/255
  59. Use DS: 1/510
  60. Use AP: 1/511
  61. Use DS: 1/1022
  62. Use AP: 1/1023
  63. Use DS: 1/2046
  64. Use AP: 1/2047
  65. Use DS: 1/4094
  66. Use AP: 1/4095
  67. Use DS: 1/8190
  68. Use AP: 1/8191
  69. Use DS: 1/16382
  70. Use AP: 1/16383
  71. Use DS: 1/32766
  72. Use AP: 1/32767
  73. Use DS: 1/65534
  74. Use AP: 1/65535
  75. Use DS: 1/131070
  76. Use AP: 1/131071
  77. Use DS: 1/262142
  78. Use AP: 1/262143
  79. Use DS: 1/524286
  80. Use AP: 1/524287
  81. Use DS: 1/1048574
  82. Use AP: 1/1048575
  83. Use DS: 1/2097150
  84. Use AP: 1/2097151
  85. Use DS: 1/4194302
  86. Use AP: 1/4194303
  87. Use DS: 1/8388606
  88. Use AP: 1/8388607
  89. Use DS: 1/16777214
  90. Use AP: 1/16777215
  91. Use DS: 1/33554430
  92. Use AP: 1/33554431
  93. Use DS: 1/67108863
  94. Use DS: 1/134217727
  95. Use DS: 1/268435455
  96. Use DS: 1/536870911
  97. Use DS: 1/1073741823
  98. Use DS: 1/2147483647
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement