Advertisement
jpvieiraa

Batalha de peões

Mar 23rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <style type="text/css">
  3.  
  4. table, td,tr{
  5. border:2px solid black;
  6. margin: auto;
  7. font-size: 70px;
  8. text-align: center;
  9. vertical-align: middle;
  10. border-collapse: collapse;
  11. }
  12. td{
  13. width: 90px;
  14. height:90px;
  15. }
  16. html{
  17. font-family: 'Permanent Marker', cursive;
  18. background-image: linear-gradient(125deg,#FFFF00,#FF4000,#5FB404,#00BFFF);
  19. background-size: 800% 800%;
  20. animation: animacao 5s infinite;
  21. text-align: center;
  22.  
  23. }
  24. @keyframes animacao{
  25. 0%{
  26. background-position: 0% 50%;
  27. }
  28. 50%{
  29. background-position: 100% 50%;
  30. }
  31. 100%{
  32. background-position: 0% 50%;
  33. }
  34. }
  35. h1{
  36. color:white;
  37. }
  38. .pretas{
  39. background-color: white;
  40. }
  41. .brancas{
  42. background-color: lightgrey;
  43. }
  44. input{
  45. width: 400px;
  46. height: 100px;
  47. font-size:50px;
  48. }
  49. </style>
  50. <html>
  51. <head>
  52. <title>BATALHA DE PEÕES</title>
  53. </head>
  54. <body>
  55. <meta charset="utf-8">
  56. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  57. <h1>BATALHA DE PEÕES</h1>
  58. <table>
  59. <tr>
  60. <td onClick="joga(1);"class="brancas" id="1">&nbsp;</td>
  61. <td onClick="joga(2);"class="pretas" id="2">&nbsp;</td>
  62. <td onClick="joga(3);"class="brancas" id="3">&nbsp;</td>
  63. <td onClick="joga(4);"class="pretas" id="4">&nbsp;</td>
  64. <td onClick="joga(5);"class="brancas" id="5">&nbsp;</td>
  65. <td onClick="joga(6);"class="pretas" id="6">&nbsp;</td>
  66. <td onClick="joga(7);"class="brancas" id="7">&nbsp;</td>
  67. <td onClick="joga(8);"class="pretas" id="8">&nbsp;</td>
  68. </tr>
  69. <tr>
  70. <td onClick="joga(9);" class="pretas" id="9"> &#9823; </td>
  71. <td onClick="joga(10);" class="brancas" id="10">&#9823;</td>
  72. <td onClick="joga(11);" class="pretas" id="11">&#9823;</td>
  73. <td onClick="joga(12);" class="brancas" id="12">&#9823;</td>
  74. <td onClick="joga(13);" class="pretas" id="13">&#9823;</td>
  75. <td onClick="joga(14);" class="brancas" id="14">&#9823;</td>
  76. <td onClick="joga(15);" class="pretas" id="15">&#9823;</td>
  77. <td onClick="joga(16);" class="brancas" id="16">&#9823;</td>
  78. </tr>
  79. <tr>
  80. <td onClick="joga(17);" class="brancas"id="17">&nbsp;</td>
  81. <td onClick="joga(18);" class="pretas" id="18">&nbsp;</td>
  82. <td onClick="joga(19);" class="brancas"id="19">&nbsp;</td>
  83. <td onClick="joga(20);" class="pretas" id="20">&nbsp;</td>
  84. <td onClick="joga(21);" class="brancas"id="21">&nbsp;</td>
  85. <td onClick="joga(22);" class="pretas" id="22">&nbsp;</td>
  86. <td onClick="joga(23);" class="brancas"id="23">&nbsp;</td>
  87. <td onClick="joga(24);" class="pretas" id="24">&nbsp;</td>
  88. </tr>
  89. <tr>
  90. <td onClick="joga(25);" class="pretas" id="25">&nbsp;</td>
  91. <td onClick="joga(26);" class="brancas"id="26">&nbsp;</td>
  92. <td onClick="joga(27);" class="pretas" id="27">&nbsp;</td>
  93. <td onClick="joga(28);" class="brancas"id="28">&nbsp;</td>
  94. <td onClick="joga(29);" class="pretas" id="29">&nbsp;</td>
  95. <td onClick="joga(30);" class="brancas"id="30">&nbsp;</td>
  96. <td onClick="joga(31);" class="pretas" id="31">&nbsp;</td>
  97. <td onClick="joga(32);" class="brancas"id="32">&nbsp;</td>
  98. </tr>
  99. <tr>
  100. <td onClick="joga(33);" class="brancas"id="33">&nbsp;</td>
  101. <td onClick="joga(34);" class="pretas" id="34">&nbsp;</td>
  102. <td onClick="joga(35);" class="brancas"id="35">&nbsp;</td>
  103. <td onClick="joga(36);" class="pretas" id="36">&nbsp;</td>
  104. <td onClick="joga(37);" class="brancas"id="37">&nbsp;</td>
  105. <td onClick="joga(38);" class="pretas" id="38">&nbsp;</td>
  106. <td onClick="joga(39);" class="brancas"id="39">&nbsp;</td>
  107. <td onClick="joga(40);" class="pretas" id="40">&nbsp;</td>
  108. </tr>
  109. <tr>
  110. <td onClick="joga(41);" class="pretas" id="41">&nbsp;</td>
  111. <td onClick="joga(42);" class="brancas"id="42">&nbsp;</td>
  112. <td onClick="joga(43);" class="pretas" id="43">&nbsp;</td>
  113. <td onClick="joga(44);" class="brancas"id="44">&nbsp;</td>
  114. <td onClick="joga(45);" class="pretas" id="45">&nbsp;</td>
  115. <td onClick="joga(46);" class="brancas"id="46">&nbsp;</td>
  116. <td onClick="joga(47);" class="pretas" id="47">&nbsp;</td>
  117. <td onClick="joga(48);" class="brancas"id="48">&nbsp;</td>
  118. </tr>
  119. <tr>
  120. <td onClick="joga(49);" class="brancas"id="49">&#9817;</td>
  121. <td onClick="joga(50);" class="pretas" id="50">&#9817;</td>
  122. <td onClick="joga(51);" class="brancas"id="51">&#9817;</td>
  123. <td onClick="joga(52);" class="pretas" id="52">&#9817;</td>
  124. <td onClick="joga(53);" class="brancas"id="53">&#9817;</td>
  125. <td onClick="joga(54);" class="pretas" id="54">&#9817;</td>
  126. <td onClick="joga(55);" class="brancas"id="55">&#9817;</td>
  127. <td onClick="joga(56);" class="pretas" id="56">&#9817;</td>
  128. </tr>
  129. <tr>
  130. <td onClick="joga(57);"class="pretas" id="57">&nbsp;</td>
  131. <td onClick="joga(58);"class="brancas" id="58">&nbsp;</td>
  132. <td onClick="joga(59);"class="pretas" id="59">&nbsp;</td>
  133. <td onClick="joga(60);"class="brancas" id="60">&nbsp;</td>
  134. <td onClick="joga(61);"class="pretas" id="61">&nbsp;</td>
  135. <td onClick="joga(62);"class="brancas" id="62">&nbsp;</td>
  136. <td onClick="joga(63);"class="pretas" id="63">&nbsp;</td>
  137. <td onClick="joga(64);"class="brancas" id="64">&nbsp;</td>
  138. </tr>
  139.  
  140. </table>
  141. <br>
  142. <input type="button"id="clica"value="REINICIA JOGO" onclick="reinicia();" name="">
  143. <script type="text/javascript">
  144. var jogada=1;
  145. var i,c,x,a,verde=0,diagonal=0;
  146. var jogo=new Array(100);
  147. //colocar o background-color nos sítios adequados
  148. for(i=1;i<=64;i++){
  149. jogo[i]=0;
  150. }
  151. for(i=1;i<=64;i++){
  152. if(i==49 || i==55 || i==51|| i==53){
  153. jogo[i]=1;
  154. }
  155. if(i==50 || i==52 || i==54|| i==56){
  156. jogo[i]=2;
  157. }
  158. if(i==9 || i==11 || i==13|| i==15){
  159. jogo[i]=3;
  160. }
  161. if(i==10 || i==12 || i==14|| i==16){
  162. jogo[i]=4;
  163. }
  164. }
  165. function joga(x){
  166. if(jogada==1){
  167. if(verde==0){
  168. if(jogo[x]==1 || jogo[x]==2){
  169. if(x<=56 && x>= 49){
  170. if(x==49){
  171. if(jogo[x-7]==3 || jogo[x-7]==4){
  172. document.getElementById(x-7).style.backgroundColor = 'lightgreen';
  173. verde=1;
  174. c=x;
  175. }
  176. }
  177. if(x==56){
  178. if(jogo[x-9]==3 || jogo[x-9]==4){
  179. document.getElementById(x-9).style.backgroundColor = 'lightgreen';
  180. verde=1;
  181. c=x;
  182. }
  183. }
  184. if(x!=49 && x!=56){
  185. if(jogo[x-7]==3 || jogo[x-7]==4){
  186. document.getElementById(x-7).style.backgroundColor = 'lightgreen';
  187. }
  188. if(jogo[x-9]==3 || jogo[x-9]==4){
  189. document.getElementById(x-9).style.backgroundColor = 'lightgreen';
  190. }
  191. }
  192. if(jogo[x-8]==3 || jogo[x-8]==4 || jogo[x-8]==1 || jogo[x-8]==2){
  193. verde=0;
  194. alert('Não pode jogar em nenhuma casa!');
  195. }
  196. else if(jogo[x-16]==3 || jogo[x-16]==4 || jogo[x-8]==1 || jogo[x-8]==2){
  197. document.getElementById(x-8).style.backgroundColor = "lightgreen";
  198. verde=1;
  199. c=x;
  200. }
  201. else{
  202. document.getElementById(x-8).style.backgroundColor = "lightgreen";
  203. document.getElementById(x-16).style.backgroundColor = "lightgreen";
  204. verde=1;
  205. c=x;
  206. }
  207. }
  208. else{
  209. if(x==9 ||x==17 ||x==25 ||x==33 ||x==41){
  210. if(jogo[x-7]==3 || jogo[x-7]==4){
  211. document.getElementById(x-7).style.backgroundColor = 'lightgreen';
  212. verde=1;
  213. c=x;
  214. diagonal=1;
  215. }
  216. }
  217. else if(x==16 || x==24 || x==32 || x==40 || x==48){
  218. if(jogo[x-9]==3 || jogo[x-9]==4){
  219. document.getElementById(x-9).style.backgroundColor = 'lightgreen';
  220. verde=1;
  221. c=x;
  222. diagonal=1;
  223. }
  224. }
  225. else{
  226. if(jogo[x-9]==3 || jogo[x-9]==4){
  227. document.getElementById(x-9).style.backgroundColor = 'lightgreen';
  228. verde=1;
  229. c=x;
  230. diagonal=1;
  231. }
  232. if(jogo[x-7]==3 || jogo[x-7]==4){
  233. document.getElementById(x-7).style.backgroundColor = 'lightgreen';
  234. verde=1;
  235. c=x;
  236. diagonal=1;
  237. }
  238. }
  239. if((jogo[x-8]==3 || jogo[x-8]==4 || jogo[x-8]==1 || jogo[x-8]==2) && diagonal==0){
  240. verde=0;
  241. alert('Não pode jogar em nenhuma casa!');
  242. }
  243. else if((jogo[x-8]==3 || jogo[x-8]==4 || jogo[x-8]==1 || jogo[x-8]==2) && diagonal==1){
  244. c=x;
  245. verde=1;
  246. diagonal=0;
  247. }
  248. else{
  249. document.getElementById(x-8).style.backgroundColor = "lightgreen";
  250. c=x;
  251. verde=1;
  252. }
  253. }
  254. }
  255. }
  256.  
  257. else{
  258. if(document.getElementById(x).style.backgroundColor == "lightgreen"){
  259.  
  260. if(jogo[c]==1){
  261. if((c==9 ||c==17 ||c==25 ||c==33 ||c==41||c==49) && x>=9){
  262. document.getElementById(x).innerHTML='&#9817';
  263. document.getElementById(c).innerHTML='&nbsp';
  264. document.getElementById(c-16).style.backgroundColor = 'lightgrey';
  265. document.getElementById(c-8).style.backgroundColor = 'white';
  266. document.getElementById(c-7).style.backgroundColor = 'lightgrey';
  267. }
  268. else if((c==16 ||c==24 ||c==32 ||c==40 ||c==48 || c==56) && x>=9){
  269. document.getElementById(x).innerHTML='&#9817';
  270. document.getElementById(c).innerHTML='&nbsp';
  271. document.getElementById(c-8).style.backgroundColor = 'lightgrey';
  272. document.getElementById(c-16).style.backgroundColor = 'white';
  273. document.getElementById(c-9).style.backgroundColor = 'lightgrey';
  274. }
  275. else if(x>=9){
  276. document.getElementById(x).innerHTML='&#9817';
  277. document.getElementById(c).innerHTML='&nbsp';
  278. document.getElementById(c-8).style.backgroundColor = 'white';
  279. document.getElementById(c-16).style.backgroundColor = 'lightgrey';
  280. document.getElementById(c-7).style.backgroundColor = 'lightgrey';
  281. document.getElementById(c-9).style.backgroundColor = 'lightgrey';
  282. }
  283. else{
  284. document.getElementById(x).innerHTML='&#9817';
  285. document.getElementById(c).innerHTML='';
  286. document.getElementById(x).style.backgroundColor = 'red';
  287. }
  288. jogada=2;
  289. verde=0;
  290. if(c-x==8){
  291. jogo[x]=2;
  292. }
  293. else{
  294. jogo[x]=1;
  295. }
  296. jogo[c]=0;
  297.  
  298. }
  299. else if(jogo[c]==2){
  300. if((c==9 ||c==17 ||c==25 ||c==33 ||c==41||c==49) && x>=9){
  301. document.getElementById(x).innerHTML='&#9817';
  302. document.getElementById(c).innerHTML='&nbsp';
  303. document.getElementById(c-8).style.backgroundColor = 'lightgrey';
  304. document.getElementById(c-16).style.backgroundColor = 'white';
  305. document.getElementById(c-7).style.backgroundColor = 'white';
  306. }
  307. else if((c==16 ||c==24 ||c==32 ||c==40 ||c==48 || c==56) && x>=9){
  308. document.getElementById(x).innerHTML='&#9817';
  309. document.getElementById(c).innerHTML='&nbsp';
  310. document.getElementById(c-8).style.backgroundColor = 'lightgrey';
  311. document.getElementById(c-16).style.backgroundColor = 'white';
  312. document.getElementById(c-9).style.backgroundColor = 'white';
  313. }
  314. else if(x>=9){
  315. document.getElementById(x).innerHTML='&#9817';
  316. document.getElementById(c).innerHTML='&nbsp';
  317. document.getElementById(c-8).style.backgroundColor = 'lightgrey';
  318. document.getElementById(c-16).style.backgroundColor = 'white';
  319. document.getElementById(c-7).style.backgroundColor = 'white';
  320. document.getElementById(c-9).style.backgroundColor = 'white';
  321. }
  322. else{
  323. document.getElementById(x).innerHTML='&#9817';
  324. document.getElementById(c).innerHTML='';
  325. document.getElementById(x).style.backgroundColor = 'red';
  326. }
  327. jogada=2;
  328. verde=0;
  329. if(c-x==8){
  330. jogo[x]=1;
  331. }
  332. else{
  333. jogo[x]=2;
  334. }
  335. jogo[c]=0;
  336. }
  337.  
  338. }
  339. if(c==x && jogo[x]==1){
  340. if(c==9 ||c==17 ||c==25 ||c==33 ||c==41||c==49){
  341. document.getElementById(x-8).style.backgroundColor = 'white';
  342. document.getElementById(x-16).style.backgroundColor = 'lightgrey';
  343. document.getElementById(x-7).style.backgroundColor = 'lightgrey';
  344. }
  345. else if(c==16 ||c==24 ||c==32 ||c==40 ||c==48 || c==56){
  346. document.getElementById(x-8).style.backgroundColor = 'white';
  347. document.getElementById(x-16).style.backgroundColor = 'lightgrey';
  348. document.getElementById(x-9).style.backgroundColor = 'lightgrey';
  349. }
  350. else{
  351. document.getElementById(x-8).style.backgroundColor = 'white';
  352. document.getElementById(x-16).style.backgroundColor = 'lightgrey';
  353. document.getElementById(x-7).style.backgroundColor = 'lightgrey';
  354. document.getElementById(x-9).style.backgroundColor = 'lightgrey';
  355. }
  356. verde=0;
  357. }
  358. else if(c==x && jogo[x]==2){
  359. if(c==9 ||c==17 ||c==25 ||c==33 ||c==41||c==49){
  360. document.getElementById(x-8).style.backgroundColor = 'lightgrey';
  361. document.getElementById(x-16).style.backgroundColor = 'white';
  362. document.getElementById(x-7).style.backgroundColor = 'white';
  363. }
  364. else if(c==16 ||c==24 ||c==32 ||c==40 ||c==48 || c==56){
  365. document.getElementById(x-8).style.backgroundColor = 'lightgrey';
  366. document.getElementById(x-16).style.backgroundColor = 'white';
  367. document.getElementById(x-9).style.backgroundColor = 'white';
  368. }
  369. else{
  370. document.getElementById(x-8).style.backgroundColor = 'lightgrey';
  371. document.getElementById(x-16).style.backgroundColor = 'white';
  372. document.getElementById(x-7).style.backgroundColor = 'white';
  373. document.getElementById(x-9).style.backgroundColor = 'white';
  374. }
  375. verde=0;
  376. }
  377. verifica();
  378. }
  379.  
  380. }
  381. else{
  382. if(verde==0){
  383. if(jogo[x]==3 || jogo[x]==4){
  384. if(x<=16 && x>= 9){
  385. if(x==9){
  386. if(jogo[x+9]==1 || jogo[x+9]==2){
  387. document.getElementById(x+9).style.backgroundColor = 'lightgreen';
  388. verde=1;
  389. c=x;
  390. }
  391. }
  392. if(x==16){
  393. if(jogo[x+7]==1 || jogo[x+7]==2){
  394. document.getElementById(x+7).style.backgroundColor = 'lightgreen';
  395. verde=1;
  396. c=x;
  397. }
  398. }
  399. if(x!=16 && x!=9){
  400. if(jogo[x+9]==1 || jogo[x+9]==2){
  401. document.getElementById(x+9).style.backgroundColor = 'lightgreen';
  402. }
  403. if(jogo[x+7]==1 || jogo[x+7]==2){
  404. document.getElementById(x+7).style.backgroundColor = 'lightgreen';
  405. }
  406. }
  407. if(jogo[x+8]==1 || jogo[x+8]==2 || jogo[x+8]==1 || jogo[x+8]==2){
  408. verde=0;
  409. alert('Não pode jogar em nenhuma casa!');
  410. }
  411. else if(jogo[x+16]==3 || jogo[x+16]==4 || jogo[x+16]==1 || jogo[x+16]==2){
  412. document.getElementById(x+8).style.backgroundColor = "lightgreen";
  413. verde=1;
  414. c=x;
  415. }
  416. else{
  417. document.getElementById(x+8).style.backgroundColor = "lightgreen";
  418. document.getElementById(x+16).style.backgroundColor = "lightgreen";
  419. verde=1;
  420. c=x;
  421. }
  422. }
  423. else{
  424. if(x==9 ||x==17 ||x==25 ||x==33 ||x==41){
  425. if(jogo[x+9]==1 || jogo[x+9]==2){
  426. document.getElementById(x+9).style.backgroundColor = 'lightgreen';
  427. verde=1;
  428. c=x;
  429. diagonal=1;
  430. }
  431. }
  432. if(x==16 || x==24 || x==32 || x==40 || x==48){
  433. if(jogo[x+7]==1 || jogo[x+7]==2){
  434. document.getElementById(x+7).style.backgroundColor = 'lightgreen';
  435. verde=1;
  436. c=x;
  437. diagonal=1;
  438. }
  439. }
  440. else{
  441. if(jogo[x+7]==1 || jogo[x+7]==2){
  442. document.getElementById(x+7).style.backgroundColor = 'lightgreen';
  443. verde=1;
  444. c=x;
  445. diagonal=1;
  446. }
  447. if(jogo[x+9]==1 || jogo[x+9]==2){
  448. document.getElementById(x+9).style.backgroundColor = 'lightgreen';
  449. verde=1;
  450. c=x;
  451. diagonal=1;
  452. }
  453. }
  454. if((jogo[x+8]==3 || jogo[x+8]==4 || jogo[x+8]==1 || jogo[x+8]==2) && diagonal==0){
  455. verde=0;
  456. alert('Não pode jogar em nenhuma casa!');
  457. }
  458. else if((jogo[x+8]==3 || jogo[x+8]==4 || jogo[x+8]==1 || jogo[x+8]==2) && diagonal==1){
  459. c=x;
  460. verde=1;
  461. diagonal=0;
  462. }
  463. else{
  464. document.getElementById(x+8).style.backgroundColor = "lightgreen";
  465. c=x;
  466. verde=1;
  467. }
  468. }
  469. }
  470. }
  471.  
  472. else{
  473. if(document.getElementById(x).style.backgroundColor == "lightgreen"){
  474. verifica();
  475. if(jogo[c]==4){
  476. if((c==9 ||c==17 ||c==25 ||c==33 ||c==41) && x<=58){
  477. document.getElementById(x).innerHTML='&#9823';
  478. document.getElementById(c).innerHTML='&nbsp';
  479. document.getElementById(c+8).style.backgroundColor = 'white';
  480. document.getElementById(c+16).style.backgroundColor = 'lightgrey';
  481. document.getElementById(c+9).style.backgroundColor = 'lightgrey';
  482. }
  483. else if((x==16 || x==24 || x==32 || x==40 || x==48) && x<=58){
  484. document.getElementById(x).innerHTML='&#9823';
  485. document.getElementById(c).innerHTML='&nbsp';
  486. document.getElementById(c+8).style.backgroundColor = 'white';
  487. document.getElementById(c+16).style.backgroundColor = 'lightgrey';
  488. document.getElementById(c+7).style.backgroundColor = 'lightgrey';
  489. }
  490. else if(x<=58){
  491. document.getElementById(x).innerHTML='&#9823';
  492. document.getElementById(c).innerHTML='&nbsp';
  493. document.getElementById(c+8).style.backgroundColor = 'white';
  494. document.getElementById(c+16).style.backgroundColor = 'lightgrey';
  495. document.getElementById(c+7).style.backgroundColor = 'lightgrey';
  496. document.getElementById(c+9).style.backgroundColor = 'lightgrey';
  497. }
  498. else{
  499. document.getElementById(x).innerHTML='&#9817';
  500. document.getElementById(c).innerHTML='';
  501. document.getElementById(x).style.backgroundColor = 'red';
  502. }
  503. jogada=1;
  504. verde=0;
  505. if(x-c==8){
  506. jogo[x]=3;
  507. }
  508. else{
  509. jogo[x]=4;
  510. }
  511. jogo[c]=0;
  512. }
  513. else if(jogo[c]==3){
  514. if((c==9 ||c==17 ||c==25 ||c==33 ||c==41) && x<=58){
  515. document.getElementById(x).innerHTML='&#9823';
  516. document.getElementById(c).innerHTML='&nbsp';
  517. document.getElementById(c+8).style.backgroundColor = 'lightgrey';
  518. document.getElementById(c+16).style.backgroundColor = 'white';
  519. document.getElementById(c+9).style.backgroundColor = 'white';
  520. }
  521. else if((x==16 || x==24 || x==32 || x==40 || x==48) && x<=58){
  522. document.getElementById(x).innerHTML='&#9823';
  523. document.getElementById(c).innerHTML='&nbsp';
  524. document.getElementById(c+8).style.backgroundColor = 'lightgrey';
  525. document.getElementById(c+16).style.backgroundColor = 'white';
  526. document.getElementById(c+7).style.backgroundColor = 'white';
  527. }
  528. else if(x<=58){
  529. document.getElementById(x).innerHTML='&#9823';
  530. document.getElementById(c).innerHTML='&nbsp';
  531. document.getElementById(c+8).style.backgroundColor = 'lightgrey';
  532. document.getElementById(c+16).style.backgroundColor = 'white';
  533. document.getElementById(c+7).style.backgroundColor = 'white';
  534. document.getElementById(c+9).style.backgroundColor = 'white';
  535. }
  536. else{
  537. document.getElementById(x).innerHTML='&#9817';
  538. document.getElementById(c).innerHTML='';
  539. document.getElementById(x).style.backgroundColor = 'red';
  540. }
  541. jogada=1;
  542. verde=0;
  543. if(x-c==8){
  544. jogo[x]=4;
  545. }
  546. else{
  547. jogo[x]=3;
  548. }
  549. jogo[c]=0;
  550. }
  551. }
  552. if(c==x && jogo[x]==4){
  553. if(c==9 ||c==17 ||c==25 ||c==33 ||c==41||c==49){
  554. document.getElementById(x+8).style.backgroundColor = 'white';
  555. document.getElementById(x+16).style.backgroundColor = 'lightgrey';
  556. document.getElementById(x+9).style.backgroundColor = 'lightgrey';
  557. }
  558. else if(c==16 ||c==24 ||c==32 ||c==40 ||c==48 || c==56){
  559. document.getElementById(x+8).style.backgroundColor = 'white';
  560. document.getElementById(x+16).style.backgroundColor = 'lightgrey';
  561. document.getElementById(x+9).style.backgroundColor = 'lightgrey';
  562. }
  563. else{
  564. document.getElementById(x+8).style.backgroundColor = 'white';
  565. document.getElementById(x+16).style.backgroundColor = 'lightgrey';
  566. document.getElementById(x+7).style.backgroundColor = 'lightgrey';
  567. document.getElementById(x+9).style.backgroundColor = 'lightgrey';
  568. }
  569. verde=0;
  570. }
  571. else if(c==x && jogo[x]==3){
  572. if(c==9 ||c==17 ||c==25 ||c==33 ||c==41||c==49){
  573. document.getElementById(x+8).style.backgroundColor = 'lightgrey';
  574. document.getElementById(x+16).style.backgroundColor = 'white';
  575. document.getElementById(x+9).style.backgroundColor = 'white';
  576. }
  577. else if(c==16 ||c==24 ||c==32 ||c==40 ||c==48 || c==56){
  578. document.getElementById(x+8).style.backgroundColor = 'lightgrey';
  579. document.getElementById(x+16).style.backgroundColor = 'white';
  580. document.getElementById(x+7).style.backgroundColor = 'white';
  581. }
  582. else{
  583. document.getElementById(x+8).style.backgroundColor = 'lightgrey';
  584. document.getElementById(x+16).style.backgroundColor = 'white';
  585. document.getElementById(x+7).style.backgroundColor = 'white';
  586. document.getElementById(x+9).style.backgroundColor = 'white';
  587. }
  588. verde=0;
  589. }
  590. verifica();
  591. }
  592.  
  593. }
  594. }
  595. function verifica(){
  596. for(i=1;i<=7;i++){
  597. if(jogo[i]==1 || jogo[i]==2){
  598. alert('O JOGADADOR COM AS PEÇAS BRANCAS GANHOU! MUITOS PARABÉNS!');
  599. jogada=0;
  600.  
  601. }
  602. }
  603. for(i=57;i<=64;i++){
  604. if(jogo[i]==3 || jogo[i]==4){
  605. alert('O JOGADADOR COM AS PEÇAS PRETAS GANHOU! MUITOS PARABÉNS!');
  606. jogada=0;
  607. }
  608. }
  609. }
  610. function reinicia(){
  611. for(i=1;i<=64;i++){
  612. jogo[i]=0;
  613. document.getElementById(i).innerHTML="";
  614. }
  615. for(i=1;i<=64;i++){
  616. if(i==49 || i==55 || i==51|| i==53){
  617. jogo[i]=1;
  618. }
  619. if(i==50 || i==52 || i==54|| i==56){
  620. jogo[i]=2;
  621. }
  622. if(i==9 || i==11 || i==13|| i==15){
  623. jogo[i]=3;
  624. }
  625. if(i==10 || i==12 || i==14|| i==16){
  626. jogo[i]=4;
  627. }
  628. }
  629. for(i=9;i<=16;i++){
  630. document.getElementById(i).innerHTML="&#9823";
  631. }
  632. for(i=49;i<=56;i++){
  633. document.getElementById(i).innerHTML="&#9817";
  634. }
  635. jogada=1;
  636. for(i=1;i<=8;i++){
  637. if(i%2==0){
  638. document.getElementById(i).style.backgroundColor = 'white';
  639. }
  640. else{
  641. document.getElementById(i).style.backgroundColor = 'lightgrey';
  642. }
  643. }
  644. for(i=9;i<=16;i++){
  645. if(i%2==0){
  646. document.getElementById(i).style.backgroundColor = 'lightgrey';
  647. }
  648. else{
  649. document.getElementById(i).style.backgroundColor = 'white';
  650. }
  651. }
  652. for(i=17;i<=24;i++){
  653. if(i%2==0){
  654. document.getElementById(i).style.backgroundColor = 'white';
  655. }
  656. else{
  657. document.getElementById(i).style.backgroundColor = 'lightgrey';
  658. }
  659. }
  660. for(i=25;i<=32;i++){
  661. if(i%2==0){
  662. document.getElementById(i).style.backgroundColor = 'lightgrey';
  663. }
  664. else{
  665. document.getElementById(i).style.backgroundColor = 'white';
  666. }
  667. }
  668. for(i=33;i<=40;i++){
  669. if(i%2==0){
  670. document.getElementById(i).style.backgroundColor = 'white';
  671. }
  672. else{
  673. document.getElementById(i).style.backgroundColor = 'lightgrey';
  674. }
  675. }
  676. for(i=41;i<=48;i++){
  677. if(i%2==0){
  678. document.getElementById(i).style.backgroundColor = 'lightgrey';
  679. }
  680. else{
  681. document.getElementById(i).style.backgroundColor = 'white';
  682. }
  683. }
  684. for(i=49;i<=56;i++){
  685. if(i%2==0){
  686. document.getElementById(i).style.backgroundColor = 'white';
  687. }
  688. else{
  689. document.getElementById(i).style.backgroundColor = 'lightgrey';
  690. }
  691. }
  692. for(i=57;i<=64;i++){
  693. if(i%2==0){
  694. document.getElementById(i).style.backgroundColor = 'lightgrey';
  695. }
  696. else{
  697. document.getElementById(i).style.backgroundColor = 'white';
  698. }
  699. }
  700. }
  701. </script>
  702. </body>
  703. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement