def roll_dice(): global bttn_clicks dice = ['\u2680', '\u2681', '\u2682', '\u2683', '\u2684', '\u2685'] d = { '\u2680': 1, '\u2681': 2, '\u2682': 3, '\u2683': 4, '\u2684': 5, '\u2685': 6 } die1 = random.choice(dice) die2 = random.choice(dice) ldice.configure(text=f'{die1} {die2}') cdice.create_window(350, 250, window=ldice) res = d[die1] + d[die2] label2.configure(text="You got " + str(res)) bttn_clicks += 1 label1['text'] = "Dice rolled: " + str(bttn_clicks) + " times" if (bttn_clicks == 10 and res != 12): rollbutton.configure(state='disabled') methods.update(cassname.get(), -100) elif (res == 12): rollbutton.configure(state='disabled') methods.update(cassname.get(), 600)
def restart(): global bttn_clicks methods.update(cassname.get(), -100) bttn_clicks = 0 label1.configure(text="") label2.configure(text="Not rolled yet") if idice: cdice.delete(idice) rollbutton.configure(state='normal')
def main(): ccards = copy.copy(cards) stand = False userCard = [] dealCard = [] methods.update(cassname.get(), -100) pygame.init() methods.update(cassname.get(), -100) screen = pygame.display.set_mode((1366, 768)) pygame.display.set_caption('Blackjack') font = pygame.font.SysFont('arial', 15) hitTxt = font.render('Hit', 1, black) standTxt = font.render('Stand', 1, black) restartTxt = font.render('Retry', 1, black) gameoverTxt = font.render('Match Complete', 1, white) userSum, userA, dealSum, dealA = choose(ccards, userCard, dealCard) background = pygame.Surface(screen.get_size()) background = background.convert() background.fill((0, 206, 209)) hitB = pygame.draw.rect(background, gray, (10, 445, 75, 25)) standB = pygame.draw.rect(background, gray, (95, 445, 75, 25)) while True: gameover = True if (userSum >= 21 and userA == 0) or len(userCard) == 5 else False if len(userCard) == 2 and userSum == 21: gameover = True elif len(dealCard) == 2 and dealSum == 21: gameover = True #checks for mouse clicks on buttons for event in pygame.event.get(): if event.type == QUIT: pygame.quit() elif event.type == pygame.MOUSEBUTTONDOWN and not ( gameover or stand) and hitB.collidepoint( pygame.mouse.get_pos()): card, cA = draw(ccards, userCard) userA += cA userSum += cardvaluee(card) print('User: %i', userSum) while userSum > 21 and userA > 0: userA -= 1 userSum -= 10 elif event.type == pygame.MOUSEBUTTONDOWN and not gameover and standB.collidepoint( pygame.mouse.get_pos()): stand = True while dealSum < 17: card, cA = draw(ccards, dealCard) dealA += cA dealSum += cardvaluee(card) print('Dealer: %i', dealSum) while dealSum > 21 and dealA > 0: dealA -= 1 dealSum -= 10 elif event.type == pygame.MOUSEBUTTONDOWN and ( gameover or stand) and restartB.collidepoint( pygame.mouse.get_pos()): #restarts the game, updating scores if userSum == dealSum: methods.update(cassname.get(), 0) elif userSum <= 21 and len(userCard) == 5: methods.update(cassname.get(), 300) elif userSum <= 21 and dealSum < userSum or dealSum > 21: methods.update(cassname.get(), 300) else: methods.update(cassname.get(), 0) gameover = False stand = False userCard = [] dealCard = [] ccards = copy.copy(cards) userSum, userA, dealSum, dealA = choose( ccards, userCard, dealCard) restartB = pygame.draw.rect(background, (192, 192, 192), (270, 225, 75, 25)) screen.blit(background, (0, 0)) screen.blit(hitTxt, (39, 448)) screen.blit(standTxt, (116, 448)) for card in dealCard: x = 10 + dealCard.index(card) * 110 screen.blit(card, (x, 10)) screen.blit(cBack, (120, 10)) for card in userCard: x = 10 + userCard.index(card) * 110 screen.blit(card, (x, 295)) if gameover or stand: screen.blit(gameoverTxt, (270, 200)) restartB = pygame.draw.rect(background, gray, (270, 225, 75, 25)) screen.blit(restartTxt, (287, 228)) screen.blit(dealCard[1], (120, 10)) pygame.display.update()
print("Invalid details") print() elif opt==2: try: account=input("Enter account name: ") password=input("Enter password: "******"AccountName = ",k[0]," Balance = ",k[1]," Password = "******" Email = ",k[3]) except: print("Invalid account details") print() elif opt==3: try: account=input("Enter account name: ") amount=int(input("Enter amount: ")) methods.update(account,amount) k=methods.money(account) print(amount,"added to account.") except: print("Invalid account details") print() elif opt==4: try: acc1=input("Enter account name of sender: ") acc2=input("Enter account name of receiver: ") amount=int(input("Enter amount: ")) k=methods.money(acc1) k=methods.money(acc2) methods.transfer(acc1,acc2,amount) print(amount,"transferred from",acc1,"to",acc2) except:
import methods from auth import logged_in, auth if __name__ == "__main__": while True: if not logged_in(): methods.login() else: while True: cmd = input('Enter command: ') if cmd == 'create': methods.create(auth["role"]) elif cmd == 'remove': methods.remove(auth["role"]) elif cmd == 'show': methods.show() elif cmd == 'showall': methods.showall() elif cmd == 'update': methods.update(auth["role"]) elif cmd == 'exit': exit() else: print('Command not found.') break