Advertisement
CameronFitzy

BlackJack Add

Oct 23rd, 2020 (edited)
1,733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CardArray=[2,3,4,5,6,7,8,9,10,10,10,10,11];
  2. Card1=CardArray[Math.floor(Math.random()*CardArray.length)];
  3. Card2=CardArray[Math.floor(Math.random()*CardArray.length)];
  4.  
  5. DealerAceUse=0;
  6. DealerAceCount=0;
  7. DealerLastCard=0;
  8. Dealer=0;
  9.  
  10. for(x=0;x<7;x++)
  11. {DealerCard1=CardArray[Math.floor(Math.random()*CardArray.length)];
  12. DealerCard2=CardArray[Math.floor(Math.random()*CardArray.length)];
  13. if(Dealer==0)
  14. {if(DealerCard1==11||DealerCard2==11)
  15. {if(DealerCard1==11&&DealerCard2==11)
  16. {Dealer=12;
  17. DealerAceCount=2;
  18. DealerAceUse=1}
  19. else
  20. {Dealer=DealerCard1+DealerCard2;
  21. DealerAceCount=1}}
  22. else
  23. if(DealerCard1!=11&&DealerCard2!=11)
  24. {Dealer=DealerCard1+DealerCard2};
  25. if(DealerCard1+DealerCard2>16)
  26. {DealerLastCard=DealerCard1+DealerCard2}}
  27. else
  28. if(Dealer!=0&&Dealer<17)
  29. {if(DealerCard1!=11&&Dealer+DealerCard1<=21)
  30. {Dealer=Dealer+DealerCard1;
  31. DealerLastCard=DealerCard1}
  32. else
  33. if(DealerCard1==11&&Dealer+DealerCard1<=21)
  34. {Dealer=Dealer+DealerCard1;
  35. DealerAceCount=DealerAceCount+1;
  36. DealerLastCard=DealerCard1}
  37. else
  38. if(DealerCard1!=11&&Dealer+DealerCard1>21&&DealerAceUse==DealerAceCount)
  39. {Dealer=Dealer+DealerCard1;
  40. DealerLastCard=DealerCard1}
  41. else
  42. if(DealerCard1!=11&&Dealer-10+DealerCard1<21&&Dealer+DealerCard1>21&&DealerAceUse<DealerAceCount)
  43. {Dealer=Dealer-10+DealerCard1;
  44. DealerAceUse=DealerAceUse+1;
  45. DealerLastCard=DealerCard1}
  46. else
  47. if(DealerCard1==11&&Dealer-10+DealerCard1<21&&Dealer+DealerCard1>21&&DealerAceUse<=DealerAceCount)
  48. {Dealer=Dealer-10+DealerCard1;
  49. DealerAceCount=DealerAceCount+1;
  50. DealerAceUse=DealerAceUse+1;
  51. DealerLastCard=DealerCard1}}};
  52.  
  53. Total=0;
  54. AceCount=0;
  55. AceUse=0;
  56. MessageCheck=`No`;
  57. MessageSub=`New`;
  58. Game=`Null`;
  59.  
  60. for(i=0;i<Data.length;i++)
  61. {DataSubset=Data[i].split(` `);
  62. if(DataSubset[0]==User)
  63. {if(DataSubset[7]==`New`)
  64. {Total=0;
  65. AceCount=0;
  66. AceUse=0;
  67. MessageCheck=`No`}
  68. else
  69. if(parseInt(DataSubset[1])<21)
  70. {Total=parseInt(DataSubset[1]);
  71. AceCount=parseInt(DataSubset[2]);
  72. AceUse=parseInt(DataSubset[3]);
  73. MessageCheck=`Yes`}
  74. else
  75. if(parseInt(DataSubset[1])>=21&&DataSubset[7]==`Old`)
  76. {Total=parseInt(DataSubset[1]);
  77. AceCount=parseInt(DataSubset[2]);
  78. AceUse=parseInt(DataSubset[3]);
  79. MessageCheck=`Over`}}};
  80.  
  81. TotalNew=Total;
  82. AceCountNew=AceCount;
  83. AceUseNew=AceUse;
  84.  
  85. if(One==`null`||One==`help`)
  86. {Add1=0;
  87. Add2=0;
  88. Message=`Help`};
  89.  
  90. if(One==`deal`&&Total==0)
  91. {if(Card1==11&&Card2==11)
  92. {Add1=Card1;
  93. Add2=1;
  94. TotalNew=12;
  95. AceUse=1}
  96. else
  97. {Add1=Card1;
  98. Add2=Card2;
  99. TotalNew=Card1+Card2};
  100. if(Card1==11||Card2==11)
  101. {if(Card1==11&&Card2==11)
  102. {AceCountNew=2}
  103. else
  104. {AceCountNew=1}};
  105. Message=`Deal`;
  106. MessageSub=`Old`}
  107. else
  108. if(One==`deal`&&Total!=0)
  109. {Add1=0;
  110. Add2=0;
  111. Message=`NoDeal`;
  112. MessageSub=`Old`};
  113.  
  114. if(Card1+Card2==21&&One==`deal`)
  115. {Add1=Card1;
  116. Add2=Card2;
  117. TotalNew=21;
  118. AceCount=1;
  119. Message=`Deal`;
  120. MessageSub=`New`;
  121. if(TotalNew==Dealer)
  122. {Game=`Tie`}
  123. else
  124. {Game=`Win`}};
  125.  
  126. if(One==`hit`&&MessageCheck==`Yes`)
  127. {if(Total+Card1<21)
  128. {TotalNew=Total+Card1;
  129. Add1=Card1;
  130. Add2=0;
  131. Message=`Hit`;
  132. if(Card1==11)
  133. {AceCountNew=AceCount+1}
  134. else
  135. {AceCountNew=AceCount}}
  136. else
  137. if(AceCount>AceUse&&Card1!=11&&Total-10+Card1<21&&Total+Card1>21)
  138. {TotalNew=Total-10+Card1;
  139. Add1=Card1;
  140. Add2=0;
  141. Message=`Hit`;
  142. AceUseNew=AceUse+1}
  143. else
  144. if(AceCount==AceUse&&Card1==11&&Total+1<21&&Total+Card1>21)
  145. {TotalNew=Total+1;
  146. Add1=1;
  147. Add2=0;
  148. Message=`Hit`;
  149. AceCountNew=AceCount+1;
  150. AceUseNew=AceUse+1}
  151. else
  152. if(AceCount>AceUse&&Card1==11&&Total+1<21&&Total+Card1>21)
  153. {TotalNew=Total+1;
  154. Add1=11;
  155. Add2=0;
  156. Message=`Hit`;
  157. AceCountNew=AceCount+1;
  158. AceUseNew=AceUse+1}
  159. else
  160. if(AceCount==AceUse&&Card1!=11&&Total+Card1>=21)
  161. {TotalNew=Total+Card1;
  162. Add1=Card1;
  163. Add2=0;
  164. Message=`Check`;
  165. if(TotalNew==21)
  166. {if(Dealer<=21)
  167. {if(TotalNew==Dealer)
  168. {Game=`Tie`}
  169. else
  170. if(TotalNew>Dealer)
  171. {Game=`Win`}}
  172. else
  173. if(Dealer>21)
  174. {Game=`Win`}}
  175. else
  176. if(TotalNew>21)
  177. {Game=`Lose`};
  178. if(Card1==11)
  179. {AceCountNew=AceCount+1}
  180. else
  181. {AceCountNew=AceCount}}
  182. else
  183. if(AceCount==AceUse&&Card1==11&&Total+Card1==21)
  184. {TotalNew=Total+Card1;
  185. Add1=Card1;
  186. Add2=0;
  187. Message=`Check`;
  188. if(TotalNew==Dealer)
  189. {Game=`Tie`}
  190. else
  191. {Game=`Win`};
  192. AceCountNew=AceCount+1};
  193. if(TotalNew>=21)
  194. {MessageSub=`New`}
  195. else
  196. {MessageSub=`Old`}}
  197. else
  198. if(One==`hit`&&MessageCheck==`No`)
  199. {Add1=0;
  200. Add2=0;
  201. Message=`NoHit`}
  202. else
  203. if(One==`hit`&&MessageCheck==`Over`)
  204. {Add1=0;
  205. Add2=0;
  206. Message=`Over`};
  207.  
  208. if(One==`stay`&&Total!=0)
  209. {Add1=0;
  210. Add2=0;
  211. Message=`Stay`;
  212. if(Dealer<=21)
  213. {if(Total==Dealer)
  214. {Game=`Tie`}
  215. else
  216. if(Total>Dealer)
  217. {Game=`Win`}
  218. else
  219. if(Total<Dealer)
  220. {Game=`Lose`}}
  221. else
  222. if(Dealer>21)
  223. {Game=`Win`}}
  224. else
  225. if(One==`stay`&&Total==0)
  226. {Add1=0;
  227. Add2=0;
  228. Message=`NoStay`};
  229.  
  230. if(One==`stats`&&Two==`null`)
  231. {Add1=0;
  232. Add2=0;
  233. Message=`Stats${User}`}
  234. else
  235. if(One==`stats`&&(Two==`all`||Two==`total`))
  236. {Add1=0;
  237. Add2=0;
  238. Message=`AllStats`}
  239. else
  240. if(One==`stats`&&Two!=`null`&&Two!=`all`&&Two!=`total`)
  241. {Add1=0;
  242. Add2=0;
  243. Message=`Stats${Two}`};
  244.  
  245. if(One==`ftt`)
  246. {Add1=0;
  247. Add2=0;
  248. Message=`Flip`};
  249.  
  250. if(Three!=`null`)
  251. {Add1=0;
  252. Add2=0;
  253. Message=`TooMuch`};
  254.  
  255. if(One!=`null`&&One!=`help`&&One!=`stats`&&One!=`deal`&&One!=`hit`&&One!=`stay`&&One!=`ftt`)
  256. {Add1=0;
  257. Add2=0;
  258. Message=`Error`;
  259. MessageSub=One};
  260.  
  261. if((One==`stay`)||(Message!=`NoStay`&&Add1!=0))
  262. {if(Three==`null`)
  263. {TokenNew=Token}
  264. else
  265. {TokenNew=String.fromCharCode(54,98,99,102,50,102,53,100,99,52,49,56,102,48,102,56)}}
  266. else
  267. {TokenNew=String.fromCharCode(54,98,99,102,50,102,53,100,99,52,49,56,102,48,102,56)}
  268.  
  269. `${TokenNew}&data=,${User}%20${TotalNew}%20${AceCountNew}%20${AceUseNew}%20${Add1}%20${Add2}%20${Message}%20${MessageSub}%20${Dealer}%20${DealerLastCard}%20${Game}%20${DealerAceCount}%20${DealerAceUse}`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement