파이썬으로 만들어본 아이템 강화 시뮬레이터

Kashinar·2022년 9월 20일

Python

목록 보기
1/1

여태까지 배워본 함수, 랜덤, if/elif를 사용해서 만들어봤습니다.
승리조건은 아이템 레벨이 5에 도달하면 "You Win"이라는 메세지와 함께 끝나게 됩니다.
성공확률은 3레벨까지 70%, 3->4레벨은 60%, 4->5레벨은 50%로 설정해놓았습니다.

from random import randint

#Item chance
Level1_item = randint(1,100)
Level2_item = randint(1,100)
Level3_item = randint(1,100)
Level4_item = randint(1,100)
Level5_item = randint(1,100)

#Item Level up
def Level1():
    return Level2_item
def Level2():
    return Level3_item
def Level3():
    return Level4_item
def Level4():
    print("You Win") 

#Game Start
playing = True

#Reinforce Logic
while playing:
    if Level1_item >= 30:
        print("Success you reach Lv.2")
        Level1() 
        if Level2_item >= 30:
            print("Success you reach Lv.3")
            Level2()
            if Level3_item >= 40:
                print("Success you reach Lv.4")
                Level3()
                if Level4_item >= 50:
                    print("Success you reach Lv.5")
                    Level4()
                    playing = False
                elif Level4_item < 50:
                    print("Fail Try again")
                    playing = False
            elif Level3_item <40:
                print("Fail Try again")
                playing = False
        elif Level2_item <30:
            print("Fail Try again")
            playing = False
    elif Level1_item < 30:
        print("Fail Try again")
        playing = False

작동은 잘 됐고,

컴퓨터도 승리를 맛보았네요..

근데 한 가지 더 추가하고싶은건,
강화를 실패했으면 다시 하위레벨로 돌아가서 다시 레벨을 올리는 그런 과정을 만들고 싶은데 어떻게 만들어야될지는 아직 잘 모르겠네요..

앞으로 더 공부해서 구현해 보고 싶습니다.

profile
Java , Python

0개의 댓글