rajat_cj

BDFD • Connect Four

Jun 7th, 2022 (edited)
1,498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.70 KB | None | 0 0
  1. TETRIS for BDFD
  2. - Game by Rajat#1004
  3. - API by reset#8278
  4.  
  5. Code 1
  6. --------------------------------------------------------------------------------
  7. Trigger : ?connect4
  8. Language : BDScript 2
  9. Code :
  10.  
  11. $nomention
  12. $httpPost[https://api.resetxd.xyz/game/connect-4/create;{
  13.   "player1": "🟣",
  14.   "player2": "🔴",
  15.   "empty": "⬛"
  16. }]
  17. $onlyIf[$httpResult[success]!=some unknown error;‼️ API Down!]
  18. $if[$mentioned[1]!=]
  19. <a:red_loading:854368597853339648> <@$mentioned[1]>'s Turn
  20. $title[$username[$mentioned[1]]'s Turn]
  21. $newSelectMenu[$authorIDc4play$mentioned[1];1;1;Select Position]
  22. $addSelectMenuOption[$authorIDc4play$mentioned[1];Position 1;$httpResult[game_id] 0 2 1;;no;1️⃣]
  23. $addSelectMenuOption[$authorIDc4play$mentioned[1];Position 2;$httpResult[game_id] 1 2 1;;no;2️⃣]
  24. $addSelectMenuOption[$authorIDc4play$mentioned[1];Position 3;$httpResult[game_id] 2 2 1;;no;3️⃣]
  25. $addSelectMenuOption[$authorIDc4play$mentioned[1];Position 4;$httpResult[game_id] 3 2 1;;no;4️⃣]
  26. $addSelectMenuOption[$authorIDc4play$mentioned[1];Position 5;$httpResult[game_id] 4 2 1;;no;5️⃣]
  27. $addSelectMenuOption[$authorIDc4play$mentioned[1];Position 6;$httpResult[game_id] 5 2 1;;no;6️⃣]
  28. $addSelectMenuOption[$authorIDc4play$mentioned[1];Position 7;$httpResult[game_id] 6 2 1;;no;7️⃣]
  29. $else
  30. <a:red_loading:854368597853339648> <@$authorID>'s Turn
  31. $title[$username[$authorID]'s Turn]
  32. $newSelectMenu[c4withbot$authorID;1;1;Select Position]
  33. $addSelectMenuOption[c4withbot$authorID;Position 1;$httpResult[game_id] 0 0;;no;1️⃣]
  34. $addSelectMenuOption[c4withbot$authorID;Position 2;$httpResult[game_id] 1 0;;no;2️⃣]
  35. $addSelectMenuOption[c4withbot$authorID;Position 3;$httpResult[game_id] 2 0;;no;3️⃣]
  36. $addSelectMenuOption[c4withbot$authorID;Position 4;$httpResult[game_id] 3 0;;no;4️⃣]
  37. $addSelectMenuOption[c4withbot$authorID;Position 5;$httpResult[game_id] 4 0;;no;5️⃣]
  38. $addSelectMenuOption[c4withbot$authorID;Position 6;$httpResult[game_id] 5 0;;no;6️⃣]
  39. $addSelectMenuOption[c4withbot$authorID;Position 7;$httpResult[game_id] 6 0;;no;7️⃣]
  40. $endif
  41. $footer[Connect 4 to win]
  42. $color[aa8ed6]
  43. $description[🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳
  44. ⬛🟪$repeatMessage[9;⬛]🟪⬛
  45. ⬛🟪$repeatMessage[9;⬛]🟪⬛
  46. ⬛🟪$repeatMessage[9;⬛]🟪⬛
  47. ⬛🟪$repeatMessage[9;⬛]🟪⬛
  48. ⬛🟪$repeatMessage[9;⬛]🟪⬛
  49. ⬛🟪$repeatMessage[9;⬛]🟪⬛
  50. ⬛🟪⬛1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣⬛🟪⬛
  51. 🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳]
  52.  
  53.  
  54.  
  55. Code 2
  56. ---------------------------------------------------------------------------------------------
  57. Trigger : $onInteraction
  58. Language : BDScript 2
  59. Code :
  60.  
  61.  
  62. $nomention
  63. $suppressErrors[Having troubles? check this extra space after the `$.httpResult[board\];` part. There are 6 of these in the code and remove the ghost space after them https://cdn.discordapp.com/attachments/837219640874631197/984377616192663573/unknown.png]
  64. $if[$checkContains[$customID;c4play]==true]
  65. $textSplit[$replaceText[$customID;c4play; ;1] $message; ]
  66. $var[7;$replaceText[$replaceText[$splitText[5];1;🟥;1];2;🟪;1]]
  67. $var[9;$replaceText[$replaceText[$splitText[5];2;🟥;1];1;🟪;1]]
  68. $var[10;$replaceText[$replaceText[$var[7];🟥;dd2e44;1];🟪;aa8ed6;1]]
  69. $var[11;$replaceText[$replaceText[$var[7];🟥;aa8ed6;1];🟪;dd2e44;1]]
  70. $if[$authorID==$splitText[2]]
  71. $httpPost[https://api.resetxd.xyz/game/connect-4/drop;{
  72.   "game_id": "$splitText[3]",
  73.   "column": $splitText[4],
  74.   "player": $splitText[5]
  75. }]
  76. $removeComponent[$customID]
  77. $if[$httpResult[winner]==none]
  78. <a:red_loading:854368597853339648> <@$splitText[1]>s Turn
  79. $title[$username[$splitText[1]] is playing]
  80. $footer[Connect 4 to win]
  81. $color[$var[10]]
  82. $description[$repeatMessage[10;🔳]🔳🔳🔳
  83. ⬛$var[7]⬛$replaceText[$httpResult[board];$c[‼️‼️‼️‼️ Delete all the spaces after this comment if any ‼️‼️ 1/7]
  84. ;⬛$var[7]
  85. ⬛$var[7]⬛;-1]⬛$var[7]
  86. $repeatMessage[10;🔳]🔳🔳🔳
  87. ]
  88. $newSelectMenu[$splitText[2]c4play$splitText[1];1;1;Select Position]
  89. $addSelectMenuOption[$splitText[2]c4play$splitText[1];Position 1;$splitText[3] 0 $splitText[6] $splitText[5];;no;1️⃣]
  90. $addSelectMenuOption[$splitText[2]c4play$splitText[1];Position 2;$splitText[3] 1 $splitText[6] $splitText[5];;no;2️⃣]
  91. $addSelectMenuOption[$splitText[2]c4play$splitText[1];Position 3;$splitText[3] 2 $splitText[6] $splitText[5];;no;3️⃣]
  92. $addSelectMenuOption[$splitText[2]c4play$splitText[1];Position 4;$splitText[3] 3 $splitText[6] $splitText[5];;no;4️⃣]
  93. $addSelectMenuOption[$splitText[2]c4play$splitText[1];Position 5;$splitText[3] 4 $splitText[6] $splitText[5];;no;5️⃣]
  94. $addSelectMenuOption[$splitText[2]c4play$splitText[1];Position 6;$splitText[3] 5 $splitText[6] $splitText[5];;no;6️⃣]
  95. $addSelectMenuOption[$splitText[2]c4play$splitText[1];Position 7;$splitText[3] 6 $splitText[6] $splitText[5];;no;7️⃣]
  96. $else
  97. $var[9] **<@$authorID> Wins**
  98. $title[Game Ended]
  99. $footer[Connect 4 to win]
  100. $color[$var[11]]
  101. $description[$repeatMessage[10;🔳]🔳🔳🔳
  102. ⬛$var[9]⬛$replaceText[$httpResult[board];$c[‼️‼️‼️‼️ Delete all the spaces after this comment if any ‼️‼️ 2/7]
  103. ;⬛$var[9]
  104. ⬛$var[9]⬛;-1]⬛$var[9]
  105. $repeatMessage[10;🔳]🔳🔳🔳
  106. ]
  107. $channelSendMessage[$channelID;$var[7] <@$splitText[1]>, you lost!]
  108. $endif
  109. $else
  110. $ephemeral
  111. $removeComponent[$customID]
  112. ‼️ Hey it's <@$splitText[2]>'s turn!
  113. $endif
  114. $endif
  115. $if[$checkContains[$customID;c4withbot]==true]
  116. $textSplit[$replaceText[$customID;c4withbot;;1] $message; ]
  117. $if[$authorID==$splitText[1]]
  118. $httpPost[https://api.resetxd.xyz/game/connect-4/drop;{
  119.   "game_id": "$splitText[2]",
  120.   "column": $splitText[3],
  121.   "player": 1
  122. }]
  123. $if[$httpResult[winner]==none]
  124. $editMessage[$channelID;$messageID;<a:red_loading:854368597853339648> Bots Turn;Botuu is Playing;$repeatMessage[10;🔳]🔳🔳🔳
  125. ⬛🟥⬛$replaceText[$optOff[$httpResult[board]];$c[‼️‼️‼️‼️ Delete all the spaces after this comment if any ‼️‼️ 3/7]
  126. ;⬛🟥⬛
  127. ⬛🟥⬛;-1]⬛🟥⬛
  128. $repeatMessage[10;🔳]🔳🔳🔳;dd2e44;Connect 4 to win.]
  129.  
  130.  
  131. $var[data;$replaceText[$replaceText[$replaceText[$replaceText[$httpResult[board];⬛;0;-1];🔴;2;-1];🟣;1;-1];$c[‼️‼️‼️‼️ Delete all the spaces after this comment if any ‼️‼️ 4/7]
  132. ;;-1]]
  133. $var[predata;$cropText[$var[data];7;]]
  134. $var[data;$cropText[$var[predata]$var[data];49;]]
  135.  
  136.  
  137.  
  138. $httpGet[http://kevinalbs.com/connect4/back-end/index.php/getMoves?board_data=$var[data]&player=2]
  139. $var[count;0]
  140. $var[col;1]
  141. $try$if[$optOff[$httpResult[$var[col]]]>$optOff[$httpResult[$var[count]]]]
  142. $var[count;$var[col]]$endif$endtry$try
  143. $if[$optOff[$httpResult[$var[col]]]==$optOff[$httpResult[$var[count]]]]
  144. $var[count;$randomText[$var[count];$var[col]]]
  145. $endif$endtry$var[col;$sum[$var[col];1]]$try
  146. $if[$optOff[$httpResult[$var[col]]]>$optOff[$httpResult[$var[count]]]]
  147. $var[count;$var[col]]$endif$endtry$try
  148. $if[$optOff[$httpResult[$var[col]]]==$optOff[$httpResult[$var[count]]]]
  149. $var[count;$randomText[$var[count];$var[col]]]
  150. $endif$endtry$var[col;$sum[$var[col];1]]$try
  151. $if[$optOff[$httpResult[$var[col]]]>$optOff[$httpResult[$var[count]]]]
  152. $var[count;$var[col]]$endif$endtry$try
  153. $if[$optOff[$httpResult[$var[col]]]==$optOff[$httpResult[$var[count]]]]
  154. $var[count;$randomText[$var[count];$var[col]]]
  155. $endif$endtry$var[col;$sum[$var[col];1]]$try
  156. $if[$optOff[$httpResult[$var[col]]]>$optOff[$httpResult[$var[count]]]]
  157. $var[count;$var[col]]$endif$endtry$try
  158. $if[$optOff[$httpResult[$var[col]]]==$optOff[$httpResult[$var[count]]]]
  159. $var[count;$randomText[$var[count];$var[col]]]
  160. $endif$endtry$var[col;$sum[$var[col];1]]$try
  161. $if[$optOff[$httpResult[$var[col]]]>$optOff[$httpResult[$var[count]]]]
  162. $var[count;$var[col]]$endif$endtry$try
  163. $if[$optOff[$httpResult[$var[col]]]==$optOff[$httpResult[$var[count]]]]
  164. $var[count;$randomText[$var[count];$var[col]]]
  165. $endif$endtry$var[col;$sum[$var[col];1]]$try
  166. $if[$optOff[$httpResult[$var[col]]]>$optOff[$httpResult[$var[count]]]]
  167. $var[count;$var[col]]$endif$endtry$try
  168. $if[$optOff[$httpResult[$var[col]]]==$optOff[$httpResult[$var[count]]]]
  169. $var[count;$randomText[$var[count];$var[col]]]
  170. $endif$endtry
  171. $httpPost[https://api.resetxd.xyz/game/connect-4/drop;{
  172.   "game_id": "$splitText[2]",
  173.   "column": $var[count],
  174.   "player": 2
  175. }]
  176. $if[$optOff[$httpResult[winner]]==none]
  177. $editMessage[$channelID;$messageID;<a:loaddotbar:849050488640503829>•Your Turn <@$authorID>;$username is Playing;$repeatMessage[10;🔳]🔳🔳🔳
  178. ⬛🟪⬛$replaceText[$optOff[$httpResult[board]];$c[‼️‼️‼️‼️ Delete all the spaces after this comment if any ‼️‼️ 5/7]
  179. ;⬛🟪⬛
  180. ⬛🟪⬛;-1]⬛🟪⬛
  181. $repeatMessage[10;🔳]🔳🔳🔳;aa8ed6;Connect 4 to win.]
  182. $else
  183. **Game Ended**
  184. $title[Botu Won!]
  185. $description[$repeatMessage[10;🔳]🔳🔳🔳
  186. ⬛🟥⬛$replaceText[$optOff[$httpResult[board]];$c[‼️‼️‼️‼️ Delete all the spaces after this comment if any ‼️‼️ 6/7]
  187. ;⬛🟥⬛
  188. ⬛🟥⬛;-1]⬛🟥⬛
  189. $repeatMessage[10;🔳]🔳🔳🔳]
  190. $color[dd2e44]
  191. $footer[Connect 4 to win.]
  192. $removeComponent[$customID]
  193. $channelSendMessage[$channelID;<@$authorID>, you lost!]
  194. $endif
  195. $else
  196. **Game Ended**
  197. $title[You Won!]
  198. $description[$repeatMessage[10;🔳]🔳🔳🔳
  199. ⬛🟪⬛$replaceText[$optOff[$httpResult[board]];$c[‼️‼️‼️‼️ Delete all the spaces after this comment if any ‼️‼️ 7/7]
  200. ;⬛🟪⬛
  201. ⬛🟪⬛;-1]⬛🟪⬛
  202. $repeatMessage[10;🔳]🔳🔳🔳]
  203. $color[aa8ed6]
  204. $footer[Connect 4 to win.]
  205. $removeComponent[$customID]
  206. $channelSendMessage[$channelID;<@$authorID>, you won!]
  207. $endif
  208. $else
  209. $ephemeral
  210. $removeComponent[$customID]
  211. ‼️ Hey it's <@$splitText[1]>'s game. Not yours!
  212. $endif
  213. $endif
  214.  
Add Comment
Please, Sign In to add comment