Advertisement
Guest User

Sample code to explain Divine Spirit bug

a guest
Jul 11th, 2015
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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: " << Attack << "/" << CurrentHP << std::endl;
  16.     }
  17.     void UseArmorPlating()
  18.     {
  19.         CurrentHP++;
  20.         MaxHP++;
  21.         std::cout << "Use AP: " << 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.  
  45. Output:
  46. Use AP: 1/2
  47. Use AP: 1/3
  48. Use DS: 1/6
  49. Use AP: 1/7
  50. Use DS: 1/14
  51. Use AP: 1/15
  52. Use DS: 1/30
  53. Use AP: 1/31
  54. Use DS: 1/62
  55. Use AP: 1/63
  56. Use DS: 1/126
  57. Use AP: 1/127
  58. Use DS: 1/254
  59. Use AP: 1/255
  60. Use DS: 1/510
  61. Use AP: 1/511
  62. Use DS: 1/1022
  63. Use AP: 1/1023
  64. Use DS: 1/2046
  65. Use AP: 1/2047
  66. Use DS: 1/4094
  67. Use AP: 1/4095
  68. Use DS: 1/8190
  69. Use AP: 1/8191
  70. Use DS: 1/16382
  71. Use AP: 1/16383
  72. Use DS: 1/32766
  73. Use AP: 1/32767
  74. Use DS: 1/65534
  75. Use AP: 1/65535
  76. Use DS: 1/131070
  77. Use AP: 1/131071
  78. Use DS: 1/262142
  79. Use AP: 1/262143
  80. Use DS: 1/524286
  81. Use AP: 1/524287
  82. Use DS: 1/1048574
  83. Use AP: 1/1048575
  84. Use DS: 1/2097150
  85. Use AP: 1/2097151
  86. Use DS: 1/4194302
  87. Use AP: 1/4194303
  88. Use DS: 1/8388606
  89. Use AP: 1/8388607
  90. Use DS: 1/16777214
  91. Use AP: 1/16777215
  92. Use DS: 1/33554430
  93. Use AP: 1/33554431
  94. Use DS: 1/67108863
  95. Use DS: 1/134217727
  96. Use DS: 1/268435455
  97. Use DS: 1/536870911
  98. Use DS: 1/1073741823
  99. Use DS: 1/2147483647
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement