How to use create_image method in localstack

Best Python code snippet using localstack_python

Final Card Game.py

Source:Final Card Game.py Github

copy

Full Screen

...238 imageCover = self.my_canvas.create_rectangle(40+(2*i*65), 40, 120+(2*i*65), 140, fill="light blue", outline="black")239 #assigning image to cards240 if aP =="2 of Clubs":241 card_image = self.Clubs_2242 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)243 elif aP == "3 of Clubs":244 card_image = self.Clubs_3245 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)246 elif aP == "4 of Clubs":247 card_image = self.Clubs_4248 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)249 elif aP == "5 of Clubs":250 card_image = self.Clubs_5251 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)252 elif aP == "6 of Clubs":253 card_image = self.Clubs_6254 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)255 elif aP == "7 of Clubs":256 card_image = self.Clubs_7257 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)258 elif aP == "8 of Clubs":259 card_image = self.Clubs_8260 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)261 elif aP == "9 of Clubs":262 card_image = self.Clubs_9263 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)264 elif aP == "10 of Clubs":265 card_image = self.Clubs_10266 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)267 elif aP == "Jack of Clubs":268 card_image = self.Clubs_Jack269 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)270 elif aP == "Queen of Clubs":271 card_image = self.Clubs_Queen272 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)273 elif aP == "King of Clubs":274 card_image = self.Clubs_King275 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)276 elif aP == "Ace of Clubs":277 card_image = self.Clubs_Ace278 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)279 elif aP =="2 of Hearts":280 card_image = self.Hearts_2281 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)282 elif aP == "3 of Hearts":283 card_image = self.Hearts_3284 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)285 elif aP == "4 of Hearts":286 card_image = self.Hearts_4287 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)288 elif aP == "5 of Hearts":289 card_image = self.Hearts_5290 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)291 elif aP == "6 of Hearts":292 card_image = self.Hearts_6293 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)294 elif aP == "7 of Hearts":295 card_image = self.Hearts_7296 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)297 elif aP == "8 of Hearts":298 card_image = self.Hearts_8299 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)300 elif aP == "9 of Hearts":301 card_image = self.Hearts_9302 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)303 elif aP == "10 of Hearts":304 card_image = self.Hearts_10305 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)306 elif aP == "Jack of Hearts":307 card_image = self.Hearts_Jack308 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)309 elif aP == "Queen of Hearts":310 card_image = self.Hearts_Queen311 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)312 elif aP == "King of Hearts":313 card_image = self.Hearts_King314 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)315 elif aP == "Ace of Hearts":316 card_image = self.Hearts_Ace317 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)318 elif aP =="2 of Diamonds":319 card_image = self.Diamonds_2320 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)321 elif aP == "3 of Diamonds":322 card_image = self.Diamonds_3323 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)324 elif aP == "4 of Diamonds":325 card_image = self.Diamonds_4326 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)327 elif aP == "5 of Diamonds":328 card_image = self.Diamonds_5329 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)330 elif aP == "6 of Diamonds":331 card_image = self.Diamonds_6332 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)333 elif aP == "7 of Diamonds":334 card_image = self.Diamonds_7335 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)336 elif aP == "8 of Diamonds":337 card_image = self.Diamonds_8338 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)339 elif aP == "9 of Diamonds":340 card_image = self.Diamonds_9341 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)342 elif aP == "10 of Diamonds":343 card_image = self.Diamonds_10344 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)345 elif aP == "Jack of Diamonds":346 card_image = self.Diamonds_Jack347 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)348 elif aP == "Queen of Diamonds":349 card_image = self.Diamonds_Queen350 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)351 elif aP == "King of Diamonds":352 card_image = self.Diamonds_King353 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)354 elif aP == "Ace of Diamonds":355 card_image = self.Diamonds_Ace356 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)357 if aP =="2 of Spades":358 card_image = self.Spades_2359 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)360 elif aP == "3 of Spades":361 card_image = self.Spades_3362 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)363 elif aP == "4 of Spades":364 card_image = self.Spades_4365 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)366 elif aP == "5 of Spades":367 card_image = self.Spades_5368 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)369 elif aP == "6 of Spades":370 card_image = self.Spades_6371 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)372 elif aP == "7 of Spades":373 card_image = self.Spades_7374 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)375 elif aP == "8 of Spades":376 card_image = self.Spades_8377 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)378 elif aP == "9 of Spades":379 card_image = self.Spades_9380 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)381 elif aP == "10 of Spades":382 card_image = self.Spades_10383 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)384 elif aP == "Jack of Spades":385 card_image = self.Spades_Jack386 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)387 elif aP == "Queen of Spades":388 card_image = self.Spades_Queen389 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)390 elif aP == "King of Spades":391 card_image = self.Spades_King392 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)393 elif aP == "Ace of Spades":394 card_image = self.Spades_Ace395 self.my_canvas.create_image(50+(2*i*65), 50, anchor = NW, image = card_image)396 for i in range(len(self.dealerList)):397 a1 = str(self.dealerList[i])398 #covering the existing image399 imageCover = self.my_canvas.create_rectangle(1080-(2*i*65), 40, 1160-(2*i*65), 140, fill="light blue", outline="black")400 #assigning image to cards401 if a1 =="2 of Clubs":402 card_image = self.Clubs_2403 self.my_canvas.create_image(1090-(2*i*70), 50, anchor = NW, image = card_image)404 elif a1 == "3 of Clubs":405 card_image = self.Clubs_3406 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)407 elif a1 == "4 of Clubs":408 card_image = self.Clubs_4409 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)410 elif a1 == "5 of Clubs":411 card_image = self.Clubs_5412 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)413 elif a1 == "6 of Clubs":414 card_image = self.Clubs_6415 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)416 elif a1 == "7 of Clubs":417 card_image = self.Clubs_7418 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)419 elif a1 == "8 of Clubs":420 card_image = self.Clubs_8421 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)422 elif a1 == "9 of Clubs":423 card_image = self.Clubs_9424 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)425 elif a1 == "10 of Clubs":426 card_image = self.Clubs_10427 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)428 elif a1 == "Jack of Clubs":429 card_image = self.Clubs_Jack430 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)431 elif a1 == "Queen of Clubs":432 card_image = self.Clubs_Queen433 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)434 elif a1 == "King of Clubs":435 card_image = self.Clubs_King436 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)437 elif a1 == "Ace of Clubs":438 card_image = self.Clubs_Ace439 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)440 elif a1 =="2 of Hearts":441 card_image = self.Hearts_2442 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)443 elif a1 == "3 of Hearts":444 card_image = self.Hearts_3445 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)446 elif a1 == "4 of Hearts":447 card_image = self.Hearts_4448 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)449 elif a1 == "5 of Hearts":450 card_image = self.Hearts_5451 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)452 elif a1 == "6 of Hearts":453 card_image = self.Hearts_6454 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)455 elif a1 == "7 of Hearts":456 card_image = self.Hearts_7457 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)458 elif a1 == "8 of Hearts":459 card_image = self.Hearts_8460 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)461 elif a1 == "9 of Hearts":462 card_image = self.Hearts_9463 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)464 elif a1 == "10 of Hearts":465 card_image = self.Hearts_10466 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)467 elif a1 == "Jack of Hearts":468 card_image = self.Hearts_Jack469 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)470 elif a1 == "Queen of Hearts":471 card_image = self.Hearts_Queen472 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)473 elif a1 == "King of Hearts":474 card_image = self.Hearts_King475 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)476 elif a1 == "Ace of Hearts":477 card_image = self.Hearts_Ace478 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)479 elif a1 =="2 of Diamonds":480 card_image = self.Diamonds_2481 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)482 elif a1 == "3 of Diamonds":483 card_image = self.Diamonds_3484 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)485 elif a1 == "4 of Diamonds":486 card_image = self.Diamonds_4487 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)488 elif a1 == "5 of Diamonds":489 card_image = self.Diamonds_5490 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)491 elif a1 == "6 of Diamonds":492 card_image = self.Diamonds_6493 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)494 elif a1 == "7 of Diamonds":495 card_image = self.Diamonds_7496 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)497 elif a1 == "8 of Diamonds":498 card_image = self.Diamonds_8499 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)500 elif a1 == "9 of Diamonds":501 card_image = self.Diamonds_9502 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)503 elif a1 == "10 of Diamonds":504 card_image = self.Diamonds_10505 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)506 elif a1 == "Jack of Diamonds":507 card_image = self.Diamonds_Jack508 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)509 elif a1 == "Queen of Diamonds":510 card_image = self.Diamonds_Queen511 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)512 elif a1 == "King of Diamonds":513 card_image = self.Diamonds_King514 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)515 elif a1 == "Ace of Diamonds":516 card_image = self.Diamonds_Ace517 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)518 if a1 =="2 of Spades":519 card_image = self.Spades_2520 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)521 elif a1 == "3 of Spades":522 card_image = self.Spades_3523 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)524 elif a1 == "4 of Spades":525 card_image = self.Spades_4526 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)527 elif a1 == "5 of Spades":528 card_image = self.Spades_5529 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)530 elif a1 == "6 of Spades":531 card_image = self.Spades_6532 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)533 elif a1 == "7 of Spades":534 card_image = self.Spades_7535 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)536 elif a1 == "8 of Spades":537 card_image = self.Spades_8538 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)539 elif a1 == "9 of Spades":540 card_image = self.Spades_9541 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)542 elif a1 == "10 of Spades":543 card_image = self.Spades_10544 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)545 elif a1 == "Jack of Spades":546 card_image = self.Spades_Jack547 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)548 elif a1 == "Queen of Spades":549 card_image = self.Spades_Queen550 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)551 elif a1 == "King of Spades":552 card_image = self.Spades_King553 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)554 elif a1 == "Ace of Spades":555 card_image = self.Spades_Ace556 self.my_canvas.create_image(1090-(2*i*65), 50, anchor = NW, image = card_image)557 #covering the second hand of the dealer. 558 if i ==1:559 self.imageCover = self.my_canvas.create_rectangle(1090-(2*i*65), 50, 1150-(2*i*65), 130, fill="black", outline="red")560 self.Playerplayed['text'] = str(self.playerList)561 #function assigned to Play button. Everytime it is called the lists for player and dealer is updated and the points are checked for winners. 562 def PLAY(self):563 self.officialdeck.shuffle()564 for i in range(1):565 self.takeTurn()566 if len(self.playerList)==2:567 self.play["state"]="disabled"568 self.checkBlackJack()569 self.createList()570 print(self.playerList)#used to check if the lists are created properly and consistent with the pictures shown on window.571 print(self.dealerList)572 #function assigned to stay button. Everytime it is called the lists for player and dealer is updated and the points are checked for winners.573 #it also gives the dealer necessary cards if the dealers total valyue is less than 17 after getting initial cards. 574 def STAY(self):575 self.determinant=1576 self.hit["state"] = "disabled"577 self.surrender["state"]="disabled"578 self.play["state"]="disabled"579 while self.Dlp <17:580 self.players[1].addCards(self.officialdeck.drawCards(1))581 self.createList()582 self.checkPointStay()583 self.DealerPlayed["text"] = str(self.dealerList)584 #function to calculate the player points585 def playerPoints(self):586 CardNamePlayer = self.playerList587 CardNameDealer = self.dealerList588 self.Plp = 0589 self.Dlp = 0590 for i in range(len(self.playerList)): 591 if CardNamePlayer[i][0]=="2":592 self.Plp = self.Plp+int(CardNamePlayer[i][0])593 if CardNamePlayer[i][0]=="3":594 self.Plp = self.Plp+int(CardNamePlayer[i][0])595 if CardNamePlayer[i][0]=="4":596 self.Plp = self.Plp+int(CardNamePlayer[i][0])597 if CardNamePlayer[i][0]=="5":598 self.Plp = self.Plp+int(CardNamePlayer[i][0])599 if CardNamePlayer[i][0]=="6":600 self.Plp = self.Plp+int(CardNamePlayer[i][0])601 if CardNamePlayer[i][0]=="7":602 self.Plp = self.Plp+int(CardNamePlayer[i][0])603 if CardNamePlayer[i][0]=="8":604 self.Plp = self.Plp+int(CardNamePlayer[i][0])605 if CardNamePlayer[i][0]=="9":606 self.Plp = self.Plp+int(CardNamePlayer[i][0])607 if CardNamePlayer[i][0:2]=="10":608 self.Plp = self.Plp+int(CardNamePlayer[i][0:2])609 if CardNamePlayer[i][0:4]=="Jack":610 self.Plp = self.Plp+10611 if CardNamePlayer[i][0:5]=="Queen":612 self.Plp = self.Plp + 10613 if CardNamePlayer[i][0:4]=="King":614 self.Plp = self.Plp+10615 if CardNamePlayer[i][0:3]=="Ace":616 self.Plp = self.Plp+11617 for i in range(len(self.dealerList)):618 if CardNameDealer[i][0]=="2":619 self.Dlp = self.Dlp+int(CardNameDealer[i][0])620 if CardNameDealer[i][0]=="3":621 self.Dlp = self.Dlp+int(CardNameDealer[i][0])622 if CardNameDealer[i][0]=="4":623 self.Dlp = self.Dlp+int(CardNameDealer[i][0])624 if CardNameDealer[i][0]=="5":625 self.Dlp = self.Dlp+int(CardNameDealer[i][0])626 if CardNameDealer[i][0]=="6":627 self.Dlp = self.Dlp+int(CardNameDealer[i][0])628 if CardNameDealer[i][0]=="7":629 self.Dlp = self.Dlp+int(CardNameDealer[i][0])630 if CardNameDealer[i][0]=="8":631 self.Dlp = self.Dlp+int(CardNameDealer[i][0])632 if CardNameDealer[i][0]=="9":633 self.Dlp = self.Dlp+int(CardNameDealer[i][0])634 if CardNameDealer[i][0:2]=="10":635 self.Dlp =self.Dlp + int(CardNameDealer[i][0:2])636 if CardNameDealer[i][0:4]=="Jack":637 self.Dlp = self.Dlp + 10638 if CardNameDealer[i][0:5]=="Queen":639 self.Dlp = self.Dlp + 10640 if CardNameDealer[i][0:4]=="King":641 self.Dlp = self.Dlp + 10642 if CardNameDealer[i][0:3]=="Ace":643 self.Dlp = self.Dlp + 11644 645 646647 print(self.Dlp)#check if the points are consistent with the shown cards.648 print(self.Plp)649 650 #funstion that checks whether the player has a blackjack or not. i.e. 21 in total value after getting initial cards. And it notifies the winner. 651 def checkBlackJack(self):652 if len(self.playerList)==2:653 if self.Plp == 21:654 messagebox.showinfo("BlackJack!", "You won the bet.")655 self.hit["state"]= "disabled"656 self.play["state"]="disabled"657 self.surrender["state"]="disabled"658 else:659 self.hit["state"]= "normal"660 self.surrender["state"]="normal"661 #function used to check points for results if the stay button is hit and notifies the winner or the looser. 662 def checkPointStay(self):663 if self.Dlp<=21:664 if self.Plp>self.Dlp:665 messagebox.showinfo("Winner!", "You won the bet.")666 elif self.Plp==self.Dlp:667 messagebox.showinfo("Tie!", "It's a tie.")668 else:669 messagebox.showinfo("Lost!", "You lost the bet.")670 if self.Dlp>21:671 if self.Plp<self.Dlp:672 messagebox.showinfo("Winner!", "You won the bet.")673 elif self.Plp==self.Dlp:674 messagebox.showinfo("Tie!", "It's a tie.")675 else:676 messagebox.showinfo("Lost!", "You lost the bet.")677 #function used in hit button to check is the player is busted or not. 678 def checkPointHit(self):679 if self.Plp>21:680 messagebox.showinfo("Bust!", "You lost the bet.")681 self.hit["state"]= "disabled"682 self.play["state"]="disabled"683 self.surrender["state"]="disabled"684 #hit function for hit button 685 def HIT(self):686 for i in range(1):687 self.players[0].addCards(self.officialdeck.drawCards(1))688 689 self.createList()690 self.checkPointHit()691 print(self.playerList)#checking the consistencies of list and images. 692 print(self.dealerList)693694695 #destroys the current window and creates a brand new game of blackjack on a new window 696 def RETRY(self): 697 self.window.destroy() 698 699 BlackJack(2)700 701 #just destroys the window and gets to initial window for choosing the ganmes. 702 def QUIT(self): 703 self.window.destroy()704 c=Choose_Game()705 c.window.mainloop()706#the war class. 707class War():708 def __init__(self,np):709 self.numplayers=np710 self.officialdeck=Deck(True,{"Spades":[1,1,1,1,1,1,1,1,1,1,1,1,1], "Hearts":[1,1,1,1,1,1,1,1,1,1,1,1,1], "Clubs":[1,1,1,1,1,1,1,1,1,1,1,1,1], "Diamonds":[1,1,1,1,1,1,1,1,1,1,1,1,1]}) #Expresses how many of each suit there is)711 712 self.players=[Deck(False),Deck(False)]713 self.playerTurn=0714 715716 #window where the games will be played will be played717 # create window and give title718 self.win = tk.Tk() 719 self.win.title("Welcome To Game Of WAR!")720721 # create a canvas on our window722 canvas_width = 1000723 canvas_height = 400724 self.my_canvas = tk.Canvas(self.win, width=canvas_width, height=canvas_height, bg="green")725 self.my_canvas.pack()726 #Uploading the image files.727 self.Clubs_2= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-2.png")728 self.Clubs_3= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-3.png")729 self.Clubs_4= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-4.png")730 self.Clubs_5= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-5.png")731 self.Clubs_6= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-6.png")732 self.Clubs_7= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-7.png")733 self.Clubs_8= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-8.png")734 self.Clubs_9= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-9.png")735 self.Clubs_10= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-10.png")736 self.Clubs_Jack= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-Jack.png")737 self.Clubs_Queen= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-Queen.png")738 self.Clubs_King= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-King.png")739 self.Clubs_Ace= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Clubs-Ace.png")740 self.Spades_2= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_2_ccexpress.png")741 self.Spades_3= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_3_ccexpress.png")742 self.Spades_4= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_4_ccexpress.png")743 self.Spades_5= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_5_ccexpress.png")744 self.Spades_6= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_6_ccexpress.png")745 self.Spades_7= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_7_ccexpress.png")746 self.Spades_8= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_8_ccexpress.png")747 self.Spades_9= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_9_ccexpress.png")748 self.Spades_10= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_10_ccexpress.png")749 self.Spades_Jack= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_Jack_ccexpress.png")750 self.Spades_Queen= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_Queen_ccexpress.png")751 self.Spades_King= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_King_ccexpress.png")752 self.Spades_Ace= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Spades_Ace_ccexpress.png")753 self.Hearts_2= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_2_ccexpress.png")754 self.Hearts_3= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_3_ccexpress.png")755 self.Hearts_4= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_4_ccexpress.png")756 self.Hearts_5= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_5_ccexpress.png")757 self.Hearts_6= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_6_ccexpress.png")758 self.Hearts_7= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_7_ccexpress.png")759 self.Hearts_8= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_8_ccexpress.png")760 self.Hearts_9= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_9_ccexpress.png")761 self.Hearts_10= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_10_ccexpress.png")762 self.Hearts_Jack= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_Jack_ccexpress.png")763 self.Hearts_Queen= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_Queen_ccexpress.png")764 self.Hearts_King= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_King_ccexpress.png")765 self.Hearts_Ace= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Hearts_Ace_ccexpress.png")766 self.Diamonds_2= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_2_ccexpress.png")767 self.Diamonds_3= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_3_ccexpress.png")768 self.Diamonds_4= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_4_ccexpress.png")769 self.Diamonds_5= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_5_ccexpress.png")770 self.Diamonds_6= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_6_ccexpress.png")771 self.Diamonds_7= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_7_ccexpress.png")772 self.Diamonds_8= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_8_ccexpress.png")773 self.Diamonds_9= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_9_ccexpress.png")774 self.Diamonds_10= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_10_ccexpress.png")775 self.Diamonds_Jack= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_Jack_ccexpress.png")776 self.Diamonds_Queen= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_Queen_ccexpress.png")777 self.Diamonds_King= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_King_ccexpress.png")778 self.Diamonds_Ace= PhotoImage(file = "C:\\Users\\iamin\\OneDrive\\Documents\\Academic\\Python\\Resized deck of cards\\deck png\\Diamonds_Ace_ccexpress.png")779 780781782 #dealer's cards are placed here783 self.DealerPlayed=tk.Message(self.win, text="Dealer's Card: ")784 self.DealerPlayed.pack(side = 'right')785 786 self.PlayerHand = tk.Message(self.win, text="Your Card: ") 787 self.PlayerHand.pack(side = 'left')788 #players cards are here789 self.Playerplayed = tk.Message(self.win, text="")790 self.Playerplayed.pack(side = 'left')791 #starts the game792 self.play = tk.Button(self.win, text="Start", command=self.PLAY)793 self.play.pack(side = 'top')794 #Player's turn795 self.player_draw = tk.Button(self.win, text="Player Draw",command=self.playerDraw)796 self.player_draw.pack(side ='left')797 #the player cannot draw without first starting a game798 self.player_draw["state"] = "disabled" 799 #Dealer's Turn800 self.dealer_draw = tk.Button(self.win, text="Dealer Draw",command=self.dealerDraw)801 self.dealer_draw.pack(side ='right')802 #the player gets to draw before the dealer. 803 self.dealer_draw["state"] = "disabled" 804 #destroys the existing window and creates a new one which starts a new game of war. 805 playAgain = tk.Button(self.win, text="Play Again",command=self.playAgain)806 playAgain.pack(side ='top')807 #the button to go for war will appear only if it's a tie. 808 self.something = tk.Button(self.win, text = "Go To War", command=self.goToWar)809 self.something.pack(side ='top')810 self.something["state"] = "disabled"811 #Button to surrender if it's a tie.812 self.surrender = tk.Button(self.win, text = "Surrender", command = self.Surrender)813 self.surrender.pack(side ='top')814 self.surrender["state"] = "disabled"815 #Button to quit the game816 Quit_Button = tk.Button(self.win, text="Quit",command=self.QUIT)#destroys the window817 Quit_Button.pack(side ='top')818819820 #The dealer and the player takes turns. 821 def takeTurn(self):822 drawn = self.officialdeck.drawCards(0)823 self.players[self.playerTurn].addCards(drawn)824 self.Playerplayed['text'] = (self.players[0])825 self.DealerPlayed["text"] = "Dealer's Card: " + str(self.players[1])826 self.playerTurn=(self.playerTurn+1)%self.numplayers827 828829 #Creating the frame that will contain the Buttons 830 def create_frames(self):831 card_frame=tk.Frame(self.window,width=300,height=300)832 card_frame.grid(row=1,column=1)833 button_frame = tk.Frame(self.window, width=100, height=100) 834 button_frame.grid(row=2, column=1)835 return card_frame,button_frame836837 #starts the game. 838 def PLAY(self):839 self.officialdeck.shuffle()840 for i in range(4):841 self.takeTurn()842843 self.play["state"]="disabled"844 self.player_draw["state"]="normal"845 self.dealer_draw["state"]="disabled"846847 #dealer draws a crad. 848 def dealerDraw(self):849 self.dealer_draw["state"]="normal"850 self.players[1].addCards(self.officialdeck.drawCards(1))851 self.DealerPlayed["text"] ="Dealer's Card: " + str(self.players[1])852 self.dealer_draw["state"]="disabled"853 CardNamePlayer = str(self.players[0])854 CardNameDealer = str(self.players[1])855 self.Card_of_Dealer()856 self.playerPoints()857 self.findingWinner()858 859 #determining player's and dealer's points.860 def playerPoints(self):861 CardNamePlayer = str(self.players[0])862 CardNameDealer = str(self.players[1])863 self.Plp = 0864 self.Dlp = 0865 if CardNamePlayer[0]=="2":866 self.Plp = int(CardNamePlayer[0])867 if CardNamePlayer[0]=="3":868 self.Plp = int(CardNamePlayer[0])869 if CardNamePlayer[0]=="4":870 self.Plp = int(CardNamePlayer[0])871 if CardNamePlayer[0]=="5":872 self.Plp = int(CardNamePlayer[0])873 if CardNamePlayer[0]=="6":874 self.Plp = int(CardNamePlayer[0])875 if CardNamePlayer[0]=="7":876 self.Plp = int(CardNamePlayer[0])877 if CardNamePlayer[0]=="8":878 self.Plp = int(CardNamePlayer[0])879 if CardNamePlayer[0]=="9":880 self.Plp = int(CardNamePlayer[0])881 if CardNamePlayer[0:2]=="10":882 self.Plp = int(CardNamePlayer[0:2])883 if CardNamePlayer[0:4]=="Jack":884 self.Plp = 11885 if CardNamePlayer[0:5]=="Queen":886 self.Plp = 12887 if CardNamePlayer[0:4]=="King":888 self.Plp = 13889 if CardNamePlayer[0:3]=="Ace":890 self.Plp = 14891 if CardNameDealer[0]=="2":892 self.Dlp = int(CardNameDealer[0])893 if CardNameDealer[0]=="3":894 self.Dlp = int(CardNameDealer[0])895 if CardNameDealer[0]=="4":896 self.Dlp = int(CardNameDealer[0])897 if CardNameDealer[0]=="5":898 self.Dlp = int(CardNameDealer[0])899 if CardNameDealer[0]=="6":900 self.Dlp = int(CardNameDealer[0])901 if CardNameDealer[0]=="7":902 self.Dlp = int(CardNameDealer[0])903 if CardNameDealer[0]=="8":904 self.Dlp = int(CardNameDealer[0])905 if CardNameDealer[0]=="9":906 self.Dlp = int(CardNameDealer[0])907 if CardNameDealer[0:2]=="10":908 self.Dlp = int(CardNameDealer[0:2])909 if CardNameDealer[0:4]=="Jack":910 self.Dlp = 11911 if CardNameDealer[0:5]=="Queen":912 self.Dlp = 12913 if CardNameDealer[0:4]=="King":914 self.Dlp = 13915 if CardNameDealer[0:3]=="Ace":916 self.Dlp = 14917 def Card_of_Player(self):918 #covering the existing image919 imageCover = self.my_canvas.create_rectangle(40, 40, 120, 140, fill="light blue", outline="black")920 #assigning image to cards921 a1 = str(self.players[0])922 if a1 =="2 of Clubs":923 card_image = self.Clubs_2924 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)925 elif a1 == "3 of Clubs":926 card_image = self.Clubs_3927 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)928 elif a1 == "4 of Clubs":929 card_image = self.Clubs_4930 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)931 elif a1 == "5 of Clubs":932 card_image = self.Clubs_5933 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)934 elif a1 == "6 of Clubs":935 card_image = self.Clubs_6936 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)937 elif a1 == "7 of Clubs":938 card_image = self.Clubs_7939 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)940 elif a1 == "8 of Clubs":941 card_image = self.Clubs_8942 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)943 elif a1 == "9 of Clubs":944 card_image = self.Clubs_9945 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)946 elif a1 == "10 of Clubs":947 card_image = self.Clubs_10948 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)949 elif a1 == "Jack of Clubs":950 card_image = self.Clubs_Jack951 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)952 elif a1 == "Queen of Clubs":953 card_image = self.Clubs_Queen954 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)955 elif a1 == "King of Clubs":956 card_image = self.Clubs_King957 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)958 elif a1 == "Ace of Clubs":959 card_image = self.Clubs_Ace960 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)961 elif a1 =="2 of Hearts":962 card_image = self.Hearts_2963 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)964 elif a1 == "3 of Hearts":965 card_image = self.Hearts_3966 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)967 elif a1 == "4 of Hearts":968 card_image = self.Hearts_4969 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)970 elif a1 == "5 of Hearts":971 card_image = self.Hearts_5972 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)973 elif a1 == "6 of Hearts":974 card_image = self.Hearts_6975 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)976 elif a1 == "7 of Hearts":977 card_image = self.Hearts_7978 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)979 elif a1 == "8 of Hearts":980 card_image = self.Hearts_8981 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)982 elif a1 == "9 of Hearts":983 card_image = self.Hearts_9984 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)985 elif a1 == "10 of Hearts":986 card_image = self.Hearts_10987 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)988 elif a1 == "Jack of Hearts":989 card_image = self.Hearts_Jack990 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)991 elif a1 == "Queen of Hearts":992 card_image = self.Hearts_Queen993 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)994 elif a1 == "King of Hearts":995 card_image = self.Hearts_King996 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)997 elif a1 == "Ace of Hearts":998 card_image = self.Hearts_Ace999 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1000 elif a1 =="2 of Diamonds":1001 card_image = self.Diamonds_21002 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1003 elif a1 == "3 of Diamonds":1004 card_image = self.Diamonds_31005 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1006 elif a1 == "4 of Diamonds":1007 card_image = self.Diamonds_41008 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1009 elif a1 == "5 of Diamonds":1010 card_image = self.Diamonds_51011 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1012 elif a1 == "6 of Diamonds":1013 card_image = self.Diamonds_61014 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1015 elif a1 == "7 of Diamonds":1016 card_image = self.Diamonds_71017 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1018 elif a1 == "8 of Diamonds":1019 card_image = self.Diamonds_81020 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1021 elif a1 == "9 of Diamonds":1022 card_image = self.Diamonds_91023 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1024 elif a1 == "10 of Diamonds":1025 card_image = self.Diamonds_101026 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1027 elif a1 == "Jack of Diamonds":1028 card_image = self.Diamonds_Jack1029 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1030 elif a1 == "Queen of Diamonds":1031 card_image = self.Diamonds_Queen1032 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1033 elif a1 == "King of Diamonds":1034 card_image = self.Diamonds_King1035 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1036 elif a1 == "Ace of Diamonds":1037 card_image = self.Diamonds_Ace1038 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1039 if a1 =="2 of Spades":1040 card_image = self.Spades_21041 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1042 elif a1 == "3 of Spades":1043 card_image = self.Spades_31044 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1045 elif a1 == "4 of Spades":1046 card_image = self.Spades_41047 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1048 elif a1 == "5 of Spades":1049 card_image = self.Spades_51050 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1051 elif a1 == "6 of Spades":1052 card_image = self.Spades_61053 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1054 elif a1 == "7 of Spades":1055 card_image = self.Spades_71056 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1057 elif a1 == "8 of Spades":1058 card_image = self.Spades_81059 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1060 elif a1 == "9 of Spades":1061 card_image = self.Spades_91062 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1063 elif a1 == "10 of Spades":1064 card_image = self.Spades_101065 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1066 elif a1 == "Jack of Spades":1067 card_image = self.Spades_Jack1068 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1069 elif a1 == "Queen of Spades":1070 card_image = self.Spades_Queen1071 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1072 elif a1 == "King of Spades":1073 card_image = self.Spades_King1074 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)1075 elif a1 == "Ace of Spades":1076 card_image = self.Spades_Ace1077 self.my_canvas.create_image(50, 50, anchor = NW, image = card_image)10781079 def Card_of_Dealer(self):1080 #covering the existing image1081 imageCover = self.my_canvas.create_rectangle(870, 40, 950, 140, fill="light blue", outline="black")1082 #assigning image to cards1083 a1 = str(self.players[1])1084 if a1 =="2 of Clubs":1085 card_image = self.Clubs_21086 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1087 elif a1 == "3 of Clubs":1088 card_image = self.Clubs_31089 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1090 elif a1 == "4 of Clubs":1091 card_image = self.Clubs_41092 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1093 elif a1 == "5 of Clubs":1094 card_image = self.Clubs_51095 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1096 elif a1 == "6 of Clubs":1097 card_image = self.Clubs_61098 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1099 elif a1 == "7 of Clubs":1100 card_image = self.Clubs_71101 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1102 elif a1 == "8 of Clubs":1103 card_image = self.Clubs_81104 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1105 elif a1 == "9 of Clubs":1106 card_image = self.Clubs_91107 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1108 elif a1 == "10 of Clubs":1109 card_image = self.Clubs_101110 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1111 elif a1 == "Jack of Clubs":1112 card_image = self.Clubs_Jack1113 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1114 elif a1 == "Queen of Clubs":1115 card_image = self.Clubs_Queen1116 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1117 elif a1 == "King of Clubs":1118 card_image = self.Clubs_King1119 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1120 elif a1 == "Ace of Clubs":1121 card_image = self.Clubs_Ace1122 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1123 elif a1 =="2 of Hearts":1124 card_image = self.Hearts_21125 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1126 elif a1 == "3 of Hearts":1127 card_image = self.Hearts_31128 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1129 elif a1 == "4 of Hearts":1130 card_image = self.Hearts_41131 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1132 elif a1 == "5 of Hearts":1133 card_image = self.Hearts_51134 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1135 elif a1 == "6 of Hearts":1136 card_image = self.Hearts_61137 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1138 elif a1 == "7 of Hearts":1139 card_image = self.Hearts_71140 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1141 elif a1 == "8 of Hearts":1142 card_image = self.Hearts_81143 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1144 elif a1 == "9 of Hearts":1145 card_image = self.Hearts_91146 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1147 elif a1 == "10 of Hearts":1148 card_image = self.Hearts_101149 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1150 elif a1 == "Jack of Hearts":1151 card_image = self.Hearts_Jack1152 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1153 elif a1 == "Queen of Hearts":1154 card_image = self.Hearts_Queen1155 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1156 elif a1 == "King of Hearts":1157 card_image = self.Hearts_King1158 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1159 elif a1 == "Ace of Hearts":1160 card_image = self.Hearts_Ace1161 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1162 elif a1 =="2 of Diamonds":1163 card_image = self.Diamonds_21164 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1165 elif a1 == "3 of Diamonds":1166 card_image = self.Diamonds_31167 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1168 elif a1 == "4 of Diamonds":1169 card_image = self.Diamonds_41170 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1171 elif a1 == "5 of Diamonds":1172 card_image = self.Diamonds_51173 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1174 elif a1 == "6 of Diamonds":1175 card_image = self.Diamonds_61176 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1177 elif a1 == "7 of Diamonds":1178 card_image = self.Diamonds_71179 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1180 elif a1 == "8 of Diamonds":1181 card_image = self.Diamonds_81182 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1183 elif a1 == "9 of Diamonds":1184 card_image = self.Diamonds_91185 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1186 elif a1 == "10 of Diamonds":1187 card_image = self.Diamonds_101188 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1189 elif a1 == "Jack of Diamonds":1190 card_image = self.Diamonds_Jack1191 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1192 elif a1 == "Queen of Diamonds":1193 card_image = self.Diamonds_Queen1194 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1195 elif a1 == "King of Diamonds":1196 card_image = self.Diamonds_King1197 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1198 elif a1 == "Ace of Diamonds":1199 card_image = self.Diamonds_Ace1200 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1201 if a1 =="2 of Spades":1202 card_image = self.Spades_21203 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1204 elif a1 == "3 of Spades":1205 card_image = self.Spades_31206 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1207 elif a1 == "4 of Spades":1208 card_image = self.Spades_41209 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1210 elif a1 == "5 of Spades":1211 card_image = self.Spades_51212 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1213 elif a1 == "6 of Spades":1214 card_image = self.Spades_61215 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1216 elif a1 == "7 of Spades":1217 card_image = self.Spades_71218 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1219 elif a1 == "8 of Spades":1220 card_image = self.Spades_81221 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1222 elif a1 == "9 of Spades":1223 card_image = self.Spades_91224 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1225 elif a1 == "10 of Spades":1226 card_image = self.Spades_101227 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1228 elif a1 == "Jack of Spades":1229 card_image = self.Spades_Jack1230 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1231 elif a1 == "Queen of Spades":1232 card_image = self.Spades_Queen1233 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1234 elif a1 == "King of Spades":1235 card_image = self.Spades_King1236 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1237 elif a1 == "Ace of Spades":1238 card_image = self.Spades_Ace1239 self.my_canvas.create_image(880, 50, anchor = NW, image = card_image)1240 1241 1242 #determining the winner if not tied.1243 def findingWinner(self):1244 v = "You won the bet!"1245 d = "You lost the bet!"1246 t = "It's a tie. Wanna go to WAR!"1247 if self.Plp > self.Dlp:1248 print(v)1249 messagebox.showinfo("Victory!", v)1250 if self.Plp<self.Dlp:1251 print(d)1252 messagebox.showinfo("Defeat!", d)1253 if self.Plp==self.Dlp: ...

Full Screen

Full Screen

display.py

Source:display.py Github

copy

Full Screen

...43 for j in range(8):44 _ = board[j*8+i]45 if sq == 0:46 if _ == "square":47 canva.create_image(i * 75, j * 75, anchor='nw', image=whitesquare)48 if _ == "K":49 canva.create_image(i * 75, j * 75, anchor='nw', image=WKWS)50 if _ == "P":51 canva.create_image(i * 75, j * 75, anchor='nw', image=WPWS)52 if _ == "Q":53 canva.create_image(i * 75, j * 75, anchor='nw', image=WQWS)54 if _ == "N":55 canva.create_image(i * 75, j * 75, anchor='nw', image=WNWS)56 if _ == "R":57 canva.create_image(i * 75, j * 75, anchor='nw', image=WRWS)58 if _ == "B":59 canva.create_image(i * 75, j * 75, anchor='nw', image=WBWS)60 if _ == "k":61 canva.create_image(i * 75, j * 75, anchor='nw', image=BKWS)62 if _ == "p":63 canva.create_image(i * 75, j * 75, anchor='nw', image=BPWS)64 if _ == "q":65 canva.create_image(i * 75, j * 75, anchor='nw', image=BQWS)66 if _ == "n":67 canva.create_image(i * 75, j * 75, anchor='nw', image=BNWS)68 if _ == "r":69 canva.create_image(i * 75, j * 75, anchor='nw', image=BRWS)70 if _ == "b":71 canva.create_image(i * 75, j * 75, anchor='nw', image=BBWS)72 sq += 173 elif sq == 1:74 if _ == "square":75 canva.create_image(i * 75, j * 75, anchor='nw', image=blacksquare)76 if _ == "K":77 canva.create_image(i * 75, j * 75, anchor='nw', image=WKBS)78 if _ == "P":79 canva.create_image(i * 75, j * 75, anchor='nw', image=WPBS)80 if _ == "Q":81 canva.create_image(i * 75, j * 75, anchor='nw', image=WQBS)82 if _ == "N":83 canva.create_image(i * 75, j * 75, anchor='nw', image=WNBS)84 if _ == "R":85 canva.create_image(i * 75, j * 75, anchor='nw', image=WRBS)86 if _ == "B":87 canva.create_image(i * 75, j * 75, anchor='nw', image=WBBS)88 if _ == "k":89 canva.create_image(i * 75, j * 75, anchor='nw', image=BKBS)90 if _ == "p":91 canva.create_image(i * 75, j * 75, anchor='nw', image=BPBS)92 if _ == "q":93 canva.create_image(i * 75, j * 75, anchor='nw', image=BQBS)94 if _ == "n":95 canva.create_image(i * 75, j * 75, anchor='nw', image=BNBS)96 if _ == "r":97 canva.create_image(i * 75, j * 75, anchor='nw', image=BRBS)98 if _ == "b":99 canva.create_image(i * 75, j * 75, anchor='nw', image=BBBS)100 sq -= 1101 if sq == 0:102 sq += 1103 else:...

Full Screen

Full Screen

Controller.py

Source:Controller.py Github

copy

Full Screen

1from tkinter import *2from Chessman import Chessman3photos = []4def create_image(path):5 img = PhotoImage(file = path)6 photos.append(img)7def make_arr():8 img_path = 'Chessman\\'9 create_image(img_path + 'BlackPeshka.gif')10 create_image(img_path + 'WhitePeshka.gif')11 create_image(img_path + 'BlackRock.gif')12 create_image(img_path + 'WhiteRock.gif')13 create_image(img_path + 'BlackKnite.gif')14 create_image(img_path + 'WhiteKnite.gif')15 create_image(img_path + 'BlackBishop.gif')16 create_image(img_path + 'WhiteBishop.gif')17 create_image(img_path + 'BlackQueen.gif')18 create_image(img_path + 'WhiteQueen.gif')19 create_image(img_path + 'BlackKing.gif')20 create_image(img_path + 'WhiteKing.gif')21 create_image(img_path + 'empty.gif')22 create_image(img_path + 'BlackPeshka_attack.gif')23 create_image(img_path + 'WhitePeshka_attack.gif')24 create_image(img_path + 'BlackRock_attack.gif')25 create_image(img_path + 'WhiteRock_attack.gif')26 create_image(img_path + 'BlackKnite_attack.gif')27 create_image(img_path + 'WhiteKnite_attack.gif')28 create_image(img_path + 'BlackBishop_attack.gif')29 create_image(img_path + 'WhiteBishop_attack.gif')30 create_image(img_path + 'BlackQueen_attack.gif')31 create_image(img_path + 'WhiteQueen_attack.gif')32 create_image(img_path + 'BlackKing_attack.gif')33 create_image(img_path + 'WhiteKing_attack.gif')34 create_image(img_path + 'empty_attack.gif')35player_index = 136class Controller():37 def __init__(self, position_x, position_y, board, frame):38 def change_position():39 '''!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!40 TODO:41 Вынести данную функцию отбельно42 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'''43 end = False44 global player_index45 if(self.button['text'] == '🟢'):46 self.chess.change_position\47 (self.button, self.chess_attack, self.x, self.y)48 end = True...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful