No Description

battle_test.c 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. #include <battle_test.h>
  2. #include <battle.h>
  3. #include <bpre.h>
  4. #include <debug.h>
  5. #include <battle_initiative.h>
  6. #include <abilities.h>
  7. #define TEST_AMOUNT 10000
  8. void test_speed() {
  9. print("Initiating Initiative Unit\nTest...\n");
  10. u8 pass = true;
  11. battle_participants[0].spd = 10;
  12. battle_participants[1].spd = 11;
  13. printf("bank_one.spd: %d\n", battle_participants[0].spd);
  14. printf("bank_two.spd: %d\n", battle_participants[1].spd);
  15. print("testing (await TWO):");
  16. enum init_enum result = get_first_to_strike(0, 1, 0);
  17. if (result == TWO)
  18. print("\xFE\x1 pass\n\xFE\x0");
  19. else {
  20. pass = false;
  21. print("\xFE\x2 fail\n\xFE\x0");
  22. }
  23. battle_participants[0].spd = 12;
  24. printf("bank_one.spd: %d\n", battle_participants[0].spd);
  25. printf("bank_two.spd: %d\n", battle_participants[1].spd);
  26. print("testing (await ONE):");
  27. result = get_first_to_strike(0, 1, 0);
  28. if (result == ONE)
  29. print("\xFE\x1 pass\n\xFE\x0");
  30. else {
  31. pass = false;
  32. print("\xFE\x2 fail\n\xFE\x0");
  33. }
  34. battle_participants[0].spd = 10;
  35. battle_participants[1].spd = 11;
  36. printf("bank_one.spd: %d\n", battle_participants[0].spd);
  37. printf("bank_two.spd: %d\n", battle_participants[1].spd);
  38. //trick room
  39. custom_battle_elements.ptr->field_affecting.trick_room = 1;
  40. print("activating trick room...\n");
  41. print("testing (await ONE):");
  42. result = get_first_to_strike(0, 1, 0);
  43. if (result == ONE)
  44. print("\xFE\x1 pass\n\xFE\x0");
  45. else {
  46. pass = false;
  47. print("\xFE\x2 fail\n\xFE\x0");
  48. }
  49. battle_participants[0].spd = 12;
  50. printf("bank_one.spd: %d\n", battle_participants[0].spd);
  51. printf("bank_two.spd: %d\n", battle_participants[1].spd);
  52. print("testing (await TWO):");
  53. result = get_first_to_strike(0, 1, 0);
  54. if (result == TWO)
  55. print("\xFE\x1 pass\n\xFE\x0");
  56. else {
  57. pass = false;
  58. print("\xFE\x2 fail\n\xFE\x0");
  59. }
  60. battle_participants[1].ability_id = ABILITY_STALL;
  61. print("stall test (+tr): ");
  62. result = get_first_to_strike(0, 1, 0);
  63. if (result == ONE)
  64. print("\xFE\x1 pass\n\xFE\x0");
  65. else {
  66. pass = false;
  67. print("\xFE\x2 fail\n\xFE\x0");
  68. }
  69. custom_battle_elements.ptr->field_affecting.trick_room = 0;
  70. print("stall test (-tr): ");
  71. result = get_first_to_strike(0, 1, 0);
  72. if (result == ONE)
  73. print("\xFE\x1 pass\n\xFE\x0");
  74. else {
  75. pass = false;
  76. print("\xFE\x2 fail\n\xFE\x0");
  77. }
  78. battle_participants[1].ability_id = 0;
  79. print("\nPRESS A TO CONTINUE...");
  80. wait_for_btn(1);
  81. debug_clean();
  82. print("speed value tests...\n");
  83. battle_participants[0].spd = 75;
  84. battle_participants[1].spd = 60;
  85. printf("bank_one.spd: %d\n", battle_participants[0].spd);
  86. printf("bank_two.spd: %d\n", battle_participants[1].spd);
  87. u16 speed_one = get_speed(0);
  88. u16 speed_two = get_speed(1);
  89. printf("unaffected speed: %d", speed_one);
  90. printf(": %d", speed_two);
  91. if (speed_one == 75 && speed_two == 60) {
  92. print(" \xFE\x1pass\xFE\x0\n");
  93. } else {
  94. print("\xFE\x02 fail\xFE\x0\n");
  95. pass = false;
  96. }
  97. battle_participants[0].status.flags.paralysis = 1;
  98. battle_participants[1].status.flags.paralysis = 1;
  99. speed_one = get_speed(0);
  100. speed_two = get_speed(1);
  101. printf("para speed: %d", speed_one);
  102. printf(": %d", speed_two);
  103. if (speed_one == 18 && speed_two == 15) {
  104. print(" \xFE\x1pass\xFE\x0\n");
  105. } else {
  106. print("\xFE\x02 fail\xFE\x0\n");
  107. pass = false;
  108. }
  109. battle_participants[0].spd_buff = 12;
  110. battle_participants[1].spd_buff = 12;
  111. speed_one = get_speed(0);
  112. speed_two = get_speed(1);
  113. printf("para/speed+6: %d", speed_one);
  114. printf(": %d", speed_two);
  115. if (speed_one == 75 && speed_two == 60) {
  116. print(" \xFE\x1pass\xFE\x0\n");
  117. } else {
  118. print("\xFE\x02 fail\xFE\x0\n");
  119. pass = false;
  120. }
  121. battle_participants[0].status.flags.paralysis = 0;
  122. battle_participants[1].status.flags.paralysis = 0;
  123. speed_one = get_speed(0);
  124. speed_two = get_speed(1);
  125. printf("speed+6: %d", speed_one);
  126. printf(": %d", speed_two);
  127. if (speed_one == 300 && speed_two == 240) {
  128. print(" \xFE\x1pass\xFE\x0\n");
  129. } else {
  130. print("\xFE\x02 fail\xFE\x0\n");
  131. pass = false;
  132. }
  133. battle_participants[0].spd_buff = 3;
  134. battle_participants[1].spd_buff = 3;
  135. speed_one = get_speed(0);
  136. speed_two = get_speed(1);
  137. printf("speed-3: %d", speed_one);
  138. printf(": %d", speed_two);
  139. if (speed_one == 30 && speed_two == 24) {
  140. print(" \xFE\x1pass\xFE\x0\n");
  141. } else {
  142. print("\xFE\x02 fail\xFE\x0\n");
  143. pass = false;
  144. }
  145. battle_participants[0].spd_buff = 6;
  146. battle_participants[1].spd_buff = 6;
  147. print("activating chemtrails...\n");
  148. battle_weather.flags.rain = 1;
  149. battle_weather.flags.sun = 1;
  150. battle_weather.flags.sandstorm = 1;
  151. u8 weather_pass = true;
  152. battle_participants[0].ability_id = ABILITY_CHLOROPHYLL;
  153. speed_one = get_speed(0);
  154. if (speed_one != 150)
  155. weather_pass = false;
  156. battle_participants[0].ability_id = ABILITY_SWIFT_SWIM;
  157. speed_one = get_speed(0);
  158. if (speed_one != 150)
  159. weather_pass = false;
  160. battle_participants[0].ability_id = ABILITY_SAND_RUSH;
  161. battle_participants[1].ability_id = ABILITY_SAND_RUSH;
  162. speed_one = get_speed(0);
  163. if (speed_one != 150)
  164. weather_pass = false;
  165. print("weather test:");
  166. print(weather_pass ? "\xFE\x1 pass\xFE\x0\n" : "\xFE\x2 fail\xFE\x0\n");
  167. if (!weather_pass)
  168. pass = false;
  169. print("tailwind + weather: ");
  170. custom_battle_elements.ptr->side_affecting[0].tailwind = 1;
  171. custom_battle_elements.ptr->side_affecting[0].tailwind_bank = 0;
  172. custom_battle_elements.ptr->side_affecting[1].tailwind = 1;
  173. custom_battle_elements.ptr->side_affecting[1].tailwind_bank = 1;
  174. speed_one = get_speed(0);
  175. speed_two = get_speed(1);
  176. if (speed_one == 300 && speed_two == 240) {
  177. print(" \xFE\x1pass\xFE\x0\n");
  178. } else {
  179. print("\xFE\x02 fail\xFE\x0\n");
  180. pass = false;
  181. }
  182. custom_battle_elements.ptr->side_affecting[0].tailwind = 0;
  183. custom_battle_elements.ptr->side_affecting[0].tailwind_bank = 0;
  184. custom_battle_elements.ptr->side_affecting[1].tailwind = 0;
  185. custom_battle_elements.ptr->side_affecting[1].tailwind_bank = 0;
  186. battle_weather.flags.rain = 0;
  187. battle_weather.flags.sun = 0;
  188. battle_weather.flags.sandstorm = 0;
  189. print("quick feet: ");
  190. battle_participants[0].ability_id = ABILITY_QUICK_FEET;
  191. battle_participants[1].ability_id = ABILITY_QUICK_FEET;
  192. battle_participants[0].status.flags.paralysis = 1;
  193. battle_participants[1].status.flags.poison = 1;
  194. speed_one = get_speed(0);
  195. speed_two = get_speed(1);
  196. u8 quick_feet_pass = true;
  197. if (speed_one == 112 && speed_two == 90) {
  198. battle_participants[0].status.flags.sleep = 1;
  199. battle_participants[1].status.flags.poison = 0;
  200. battle_participants[0].status.flags.paralysis = 0;
  201. speed_one = get_speed(0);
  202. speed_two = get_speed(1);
  203. if (!(speed_one == 75 && speed_two == 60)) {
  204. quick_feet_pass = false;
  205. }
  206. } else
  207. quick_feet_pass = false;
  208. if (quick_feet_pass) {
  209. print(" \xFE\x1pass\xFE\x0\n");
  210. } else {
  211. print("\xFE\x02 fail\xFE\x0\n");
  212. pass = false;
  213. }
  214. battle_participants[0].status.flags.sleep = 0;
  215. battle_participants[0].ability_id = 0;
  216. battle_participants[1].ability_id = 0;
  217. wait_for_btn(8);
  218. debug_clean();
  219. //stress
  220. battle_participants[0].spd = 20;
  221. battle_participants[1].spd = 20;
  222. printf("bank_one.spd: %d\n", battle_participants[0].spd);
  223. printf("bank_two.spd: %d\n", battle_participants[1].spd);
  224. int count_one = 0;
  225. int count_two = 0;
  226. for (int i = 0; i < TEST_AMOUNT; ++i) {
  227. result = get_first_to_strike(0, 1, 0);
  228. if (result == ONE)
  229. count_one++;
  230. else
  231. count_two++;
  232. }
  233. printf("tie stress test...\ncount \xFE\x1%d\xFE\x0 / ", count_one);
  234. printf(" \xFE\x2%d\xFE\x0\n", count_two);
  235. int ratio_one = (count_one * 100) / TEST_AMOUNT;
  236. int ratio_two = (count_two * 100) / TEST_AMOUNT;
  237. printf("%d%% / ", ratio_one);
  238. printf("%d%%\n", ratio_two);
  239. print("\nPRESS A TO CONTINUE...");
  240. wait_for_btn(1);
  241. debug_clean();
  242. if (pass)
  243. set_debug_background(0x3E0);
  244. else
  245. set_debug_background(0x1F);
  246. print("test complete\n(entering deadlock)");
  247. while (true) {
  248. }
  249. return;
  250. }