๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ | Python/ํŒŒ์ด์ฌ ์ดˆ๊ฐ„๋‹จ ํ”„๋กœ์ ํŠธ

์ฃผ์‚ฌ์œ„ ๋ฒ ํŒ… ๊ฒŒ์ž„

by KASSID 2021. 11. 3.

๋ชฉ์ฐจ

    728x90

    ์Šคํ„ฐ๋””ํ•˜๋ฉด์„œ ๋ฐฑ์ค€๋ธŒ๋ก ์ฆˆ๋ฌธ์ œ์— ์žˆ๋˜ ๊ฒƒ์„ ์‘์šฉํ•ด์„œ ๋ฒ ํŒ… ๊ฒŒ์ž„์„ ๋งŒ๋“ค์–ด๋ณด์ž!

    ๋ผ๊ณ  ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ์ฆ‰ํฅ์ ์œผ๋กœ ๋งŒ๋“ค์–ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

    from random import *
    import time
    dice_list=[]
    point = 1000
    game = 1
    cnt = 1
    print('-์ฃผ์‚ฌ์œ„ ๊ฒŒ์ž„-')
    print('''
    [๊ทœ์น™]
    1~6 ์ฃผ์‚ฌ์œ„ 3๊ฐœ์˜ ๊ฒฐ๊ณผ์— ๋ฒ ํŒ…ํ•˜๋ผ!
    ์Šน๋ฆฌ ์‹œ ํ•ด๋‹น ํฌ์ธํŠธ ํš๋“
    ์‹œ์ž‘ ํฌ์ธํŠธ 1000p
    
    [์Šน๋ฆฌ ํฌ์ธํŠธ]
    ๊ฐ™์€ ๋ˆˆ 3๊ฐœ  : ๋ฒ ํŒ…ํฌ์ธํŠธ +(๊ฐ™์€ ๋ˆˆ)×1,0000p
    ๊ฐ™์€ ๋ˆˆ 2๊ฐœ  : ๋ฒ ํŒ…ํฌ์ธํŠธ +(๊ฐ™์€ ๋ˆˆ)×200p
    ๋ชจ๋‘ ๋‹ค๋ฅธ ๋ˆˆ : ๋ฒ ํŒ…ํฌ์ธํŠธ  + (๊ฐ€์žฅ ํฐ ๋ˆˆ)×100p
    
    [๋ฆฌ์Šคํฌ]
    ๊ฐ™์€ ๋ˆˆ 3๊ฐœ  : ๋‚จ์€ ํฌ์ธํŠธ์˜ 75%
    ๊ฐ™์€ ๋ˆˆ 2๊ฐœ  : ๋‚จ์€ ํฌ์ธํŠธ์˜ 50%
    ๋ชจ๋‘ ๋‹ค๋ฅธ ๋ˆˆ : ๋‚จ์€ ํฌ์ธํŠธ์˜ 50%
    ''')
    
    while True:
                game = input("๊ฒŒ์ž„์„ ์‹œ์ž‘ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? (Y/N) : ").upper()
                if game == 'Y':
                    game = 1
                    break
                elif game == 'N':
                    game = 0
                    break
                else :
                    print("๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
                    continue
    while game == 1:
        print("ใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…ก")
        print(f"(Game-{cnt}) ์‹œ์ž‘! (ํ˜„์žฌ ํฌ์ธํŠธ : {point}p)\n((1) ๊ฐ™์€ ๋ˆˆ 3๊ฐœ | (2) ๊ฐ™์€ ๋ˆˆ 2๊ฐœ | (3) ๋ชจ๋‘ ๋‹ค๋ฅธ ๋ˆˆ) ",end='')
    
        while True:
            start_bet = input(": ")
            if start_bet == '1' or start_bet == '2' or start_bet == '3':
                break
            else:
                print("๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
                continue
    
        while True: #๋ฒ ํŒ…ํ•˜๊ธฐ
            betting_money= int(input(f"๋ฒ ํŒ…ํ•  ํฌ์ธํŠธ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. (ํ˜„์žฌ ๋ณด์œ  ํฌ์ธํŠธ {point}p): "))
            if point >= betting_money:
                point -= betting_money
                break
            else :
                print("ํฌ์ธํŠธ๋ฅผ ์ž˜๋ชป ์ž…๋ ฅํ•˜์…จ์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
                continue
    
        for i in range(3): # ์ฃผ์‚ฌ์œ„ ๋˜์ง€๊ธฐ
            throw_dice = randint(1,6)
            dice_list.append(throw_dice)
        
        print("๊ณผ์—ฐ ์ฃผ์‚ฌ์œ„ ๋ˆˆ์€?")
        for i in range(3):
            print('|', end=' ')
            time.sleep(0.7)
            print(f'[{dice_list[i]}]', end=' ')
            time.sleep(0.7)
        print("|")
    
        dice_overlap = set(dice_list)
        dice_list.sort()
        if str(len(dice_overlap))==start_bet:
            print("๋ฒ ํŒ… ์„ฑ๊ณต!")
            
            if len(dice_overlap)==3: #๋ชจ๋‘ ๋‹ค๋ฅธ ๋ˆˆ
                earn = dice_list[-1]*100+betting_money
                point += earn
                print(f"ํš๋“ ํฌ์ธํŠธ : {earn}p")
    
            elif len(dice_overlap)==2: #๊ฐ™์€ ๋ˆˆ 2๊ฐœ
                earn = dice_list[1]*200+betting_money
                point += earn
                print(f"ํš๋“ ํฌ์ธํŠธ : {earn}p")
            else: # ๊ฐ™์€ ๋ˆˆ 3๊ฐœ
                earn = dice_list[0]*10000+betting_money
                point += earn
                print(f"ํš๋“ ํฌ์ธํŠธ : {earn}p")
            dice_list.clear()
            while True:
                print(f'ํ˜„์žฌ ํฌ์ธํŠธ : {point}p')
                more_game = input("๊ฒŒ์ž„์„ ๊ณ„์†ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? (Y/N) : ").upper()
                if more_game == 'Y':
                    cnt += 1
                    break
                elif more_game == 'N':
                    game = 0
                    break
                else :
                    print("๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
                    continue
        else :
            dice_list.clear()
            print("์ €๋Ÿฐ.. ํ‹€๋ ธ์Šต๋‹ˆ๋‹ค.")
            if point <= 0:
                print('๋ชจ๋“  ํฌ์ธํŠธ๋ฅผ ์žƒ์—ˆ์Šต๋‹ˆ๋‹ค.\n-GAME OVER-')
                game = 0
                break
            if start_bet=='1':
                risk = int(point*0.75)
                print(f"๋‚จ์€ ํฌ์ธํŠธ์˜ 75%({risk}p)๋ฅผ ์žƒ์Šต๋‹ˆ๋‹ค.")
                point -= risk
            elif start_bet=='2':
                risk = int(point*0.5)
                print(f"๋‚จ์€ ํฌ์ธํŠธ์˜ 50%({risk}p)๋ฅผ ์žƒ์Šต๋‹ˆ๋‹ค.")
                point -= risk
            else : 
                risk = int(point*0.5)
                print(f"๋‚จ์€ ํฌ์ธํŠธ์˜ 50%({risk}p)๋ฅผ ์žƒ์Šต๋‹ˆ๋‹ค.")
                point -= risk
            while True:
                print(f'ํ˜„์žฌ ํฌ์ธํŠธ : {point}')
                more_game = input("๊ฒŒ์ž„์„ ๊ณ„์†ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ? (Y/N) : ").upper()
                if more_game == 'Y':
                    cnt += 1
                    break
                elif more_game == 'N':
                    game = 0
                    break
                else :
                    print("๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
                    continue
            
    print("ใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…กใ…ก")        
    print(f"์ตœ์ข… ํฌ์ธํŠธ : {point}p")

     

    ๋Œ“๊ธ€