모바일 오유 바로가기
http://m.todayhumor.co.kr
분류 게시판
베스트
  • 베스트오브베스트
  • 베스트
  • 오늘의베스트
  • 유머
  • 유머자료
  • 유머글
  • 이야기
  • 자유
  • 고민
  • 연애
  • 결혼생활
  • 좋은글
  • 자랑
  • 공포
  • 멘붕
  • 사이다
  • 군대
  • 밀리터리
  • 미스터리
  • 술한잔
  • 오늘있잖아요
  • 투표인증
  • 새해
  • 이슈
  • 시사
  • 시사아카이브
  • 사회면
  • 사건사고
  • 생활
  • 패션
  • 패션착샷
  • 아동패션착샷
  • 뷰티
  • 인테리어
  • DIY
  • 요리
  • 커피&차
  • 육아
  • 법률
  • 동물
  • 지식
  • 취업정보
  • 식물
  • 다이어트
  • 의료
  • 영어
  • 맛집
  • 추천사이트
  • 해외직구
  • 취미
  • 사진
  • 사진강좌
  • 카메라
  • 만화
  • 애니메이션
  • 포니
  • 자전거
  • 자동차
  • 여행
  • 바이크
  • 민물낚시
  • 바다낚시
  • 장난감
  • 그림판
  • 학술
  • 경제
  • 역사
  • 예술
  • 과학
  • 철학
  • 심리학
  • 방송연예
  • 연예
  • 음악
  • 음악찾기
  • 악기
  • 음향기기
  • 영화
  • 다큐멘터리
  • 국내드라마
  • 해외드라마
  • 예능
  • 팟케스트
  • 방송프로그램
  • 무한도전
  • 더지니어스
  • 개그콘서트
  • 런닝맨
  • 나가수
  • 디지털
  • 컴퓨터
  • 프로그래머
  • IT
  • 안티바이러스
  • 애플
  • 안드로이드
  • 스마트폰
  • 윈도우폰
  • 심비안
  • 스포츠
  • 스포츠
  • 축구
  • 야구
  • 농구
  • 바둑
  • 야구팀
  • 삼성
  • 두산
  • NC
  • 넥센
  • 한화
  • SK
  • 기아
  • 롯데
  • LG
  • KT
  • 메이저리그
  • 일본프로야구리그
  • 게임1
  • 플래시게임
  • 게임토론방
  • 엑스박스
  • 플레이스테이션
  • 닌텐도
  • 모바일게임
  • 게임2
  • 던전앤파이터
  • 마비노기
  • 마비노기영웅전
  • 하스스톤
  • 히어로즈오브더스톰
  • gta5
  • 디아블로
  • 디아블로2
  • 피파온라인2
  • 피파온라인3
  • 워크래프트
  • 월드오브워크래프트
  • 밀리언아서
  • 월드오브탱크
  • 블레이드앤소울
  • 검은사막
  • 스타크래프트
  • 스타크래프트2
  • 베틀필드3
  • 마인크래프트
  • 데이즈
  • 문명
  • 서든어택
  • 테라
  • 아이온
  • 심시티5
  • 프리스타일풋볼
  • 스페셜포스
  • 사이퍼즈
  • 도타2
  • 메이플스토리1
  • 메이플스토리2
  • 오버워치
  • 오버워치그룹모집
  • 포켓몬고
  • 파이널판타지14
  • 배틀그라운드
  • 기타
  • 종교
  • 단어장
  • 자료창고
  • 운영
  • 공지사항
  • 오유운영
  • 게시판신청
  • 보류
  • 임시게시판
  • 메르스
  • 세월호
  • 원전사고
  • 2016리오올림픽
  • 2018평창올림픽
  • 코로나19
  • 2020도쿄올림픽
  • 게시판찾기
  • 오유인페이지
    개인차단 상태
    Naissance님의
    개인페이지입니다
    가입 : 11-09-16
    방문 : 695회
    닉네임변경 이력
    회원차단
    회원차단해제
    게시물ID : programmer_12938
    작성자 : Naissance
    추천 : 2
    조회수 : 472
    IP : 222.232.***.169
    댓글 : 1개
    등록시간 : 2015/08/25 08:40:21
    http://todayhumor.com/?programmer_12938 모바일
    파이썬 연습
    옵션
    • 창작글
    import random
    import math

    MaxLevel=100

    # Defining Arrays and Dictionaries...

    thingsToDo={
    "1":"Go to the field to hunt monsters",
    "2":"Get some rest"
    }

    levelHP={}
    for i in range(1,MaxLevel+1):
        levelHP[str(i)]=100+i*20

    levelMP={}
    for i in range(1,MaxLevel+1):
        levelMP[str(i)]=40+10*i

    requestedEXP={}
    for i in range(2,MaxLevel):
        requestedEXP[str(i)]=20+10*i

    # Defining Classes...

    class Entity(object):
        day=1
        def __init__(self,name):
            self.name=name
            self.level=1
            self.HP=100
            self.MP=50
            self.EXP=0
        def setHP(self, HP):
            self.HP=HP
        def setMP(self, MP):
            self.MP=MP
        def addHP(self, amountHP):
            self.HP+=amountHP
            if amountHP<=0:
                print("HP decreased by %d!!"%amountHP)
            else:
                print("HP increased by %d!!"%amountHP)
        def addMP(self, amountMP):
            self.MP+=amountMP
            if amountMP<=0:
                print("MP decreased by %d!!"%amountMP)
            else:
                print("MP increased by %d!!"%amountMP)
        def addEXP(self, amountEXP):
            self.EXP+=amountEXP
            if amountEXP<=0:
                print("EXP decreased by %d!!"%amountEXP)
            else:
                print("EXP increased by %d!!"%amountEXP)

    # Defining functions...

    def beginningMent():
        print("-- Custom RPG V 1.0 --")
        print("First, We need to make your own character")

    def makingCharacter():
        print("Input your character's name")
        userName=input("Type here... =")
        print("Your name is %s. Let the game begin..."%(userName))
        print("A Character instance has been created...")
        return Entity(userName)

    def printDay(player):
        print("   ")
        print("-- Day %d --"%player.day)

    def printStatus(player):
        print("LEVEL : %d"%player.level)
        print("HP : %d"%player.HP)
        print("MP : %d"%player.MP)
        print("EXP : %d out of %d"%(player.EXP, requestedEXP[str(player.level+1)]))

    def chooseSelection():
        for key, value in thingsToDo.items():
            print(key,value)
        userInput=input("Input the proper code")
        print("You've selected %s."%(userInput))
        for key, value in thingsToDo.items():
            if userInput==key:
                return key
        print("You've selected a wrong code")
        print("Try again")
        chooseSelection()

    def branch(code, player):
        if code=="1":
            hunt(player)
        elif code=="2":
            rest(player)

    def getFullHP(player):
        stringifiedLevel=str(player.level)
        amountOfFullHP=levelHP[stringifiedLevel]
        player.setHP(amountOfFullHP)

    def getFullMP(player):
        stringifiedLevel=str(player.level)
        amountOfFullMP=levelMP[stringifiedLevel]
        player.setMP(amountOfFullMP)

    def hunt(player):
        print("%s is going to the field to hunt some monsters"%player.name)
        for encounter in range(1,random.randint(3,5)):
            multiplyer=1
            if player.HP<10:
                print("Your HP is too low!")
                print("You are going home")
                player.day+=1
                return
            if player.MP<10:
                print("Your MP is too low!")
                print("Your power has been decreased!")
                multiplyer=0.8
            print("-- Encounter %d --"%encounter)
            print("A group of wild rats have appeared!!")
            winRate=random.randint(0,math.floor(5*multiplyer))
            if winRate==0:
                print("You have beaten by the wild rats!! What a shame!")
                player.addHP(random.randint(-30,-10))
                player.addMP(random.randint(-10,-5))
                break
            else:
                print("You have defeated the wild rats!! Congrats!")
                player.addHP(random.randint(-30,-10))
                player.addMP(random.randint(-10,-5))
                player.addEXP(random.randint(10,20))
        print("The hunting has finished!!")
        player.day+=1

    def rest(player):
        print("You got some rest!!")
        print("Your HP restored!")
        print("Your MP restored!")
        getFullHP(player)
        getFullMP(player)
        player.day+=1

    def checkLevel(player):
        if player.EXP>=requestedEXP[str(player.level+1)]:
            print("You've leveled up!!")
            print("from %d to %d"%(player.level,player.level+1))
            player.level+=1
            player.EXP=0

    def checkPlayerStatus(player):
        if player.HP<0:
            print("You have fatigued!!")
            print("You can't do anything today!")
            rest(player)

    # Main part...

    beginningMent()
    player=makingCharacter()

    while(True):
        printDay(player)
        checkLevel(player)
        checkPlayerStatus(player)
        printStatus(player)
        selection=chooseSelection()
        branch(selection, player)


    이 게시물을 추천한 분들의 목록입니다.
    [1] 2015/08/25 09:10:32  210.95.***.36  구차니  168644
    [2] 2016/01/23 07:56:20  211.36.***.108  음모파헤치기  539263
    푸르딩딩:추천수 3이상 댓글은 배경색이 바뀝니다.
    (단,비공감수가 추천수의 1/3 초과시 해당없음)

    죄송합니다. 댓글 작성은 회원만 가능합니다.

    번호 제 목 이름 날짜 조회 추천
    49
    Mirror's Edge - Still Alive [9] 펌글 Naissance 15/08/26 16:35 101 3
    48
    Portal 2 - If I were a core [2] 펌글 Naissance 15/08/26 16:34 40 0
    47
    KT Tunstall - Suddenly I see 펌글 Naissance 15/08/26 16:22 19 5
    46
    베지마이트 [3] 창작글 Naissance 15/08/26 16:14 43 0
    45
    Dear Cloud - Remember [1] 펌글 Naissance 15/08/25 21:41 21 4
    44
    디지털 오션에서 프로모션 쿠폰 나눠주고 있네요 [4] 창작글 Naissance 15/08/25 21:02 31 2
    43
    Kat DeLuna - Calling YOU [1] 펌글 Naissance 15/08/25 10:19 11 2
    파이썬 연습 [1] 창작글 Naissance 15/08/25 08:40 43 2
    41
    David Guetta - Play Hard 펌글 Naissance 15/08/24 21:48 17 3
    40
    대화할 때 제스처를 못하겠어요 [2] 창작글 Naissance 15/08/24 20:56 31 0
    39
    한국여자들이 생각하는 가장 이상적인 한국여자 [6] 펌글 Naissance 15/08/24 18:09 409 2
    38
    Zedd - Clarity 펌글 Naissance 15/08/24 16:49 16 4
    37
    Madeon - Pay no mind [1] 펌글 Naissance 15/08/24 12:55 22 5
    36
    에이즈에 걸린 10대가 레스토랑에서 식사를 하고 있다면 WWYD? [2] 펌글 Naissance 15/08/21 15:53 68 0
    35
    폭스 뉴스와 NBC 기자의 싸움 펌글 Naissance 15/08/20 17:08 50 0
    34
    Train - 50 Ways to say Goodbye [3] 펌글 Naissance 15/08/19 15:58 19 5
    33
    겨울왕국 검열판 [2] 펌글 Naissance 15/08/19 10:21 75 0
    32
    마이 롯데 텔레비전 [1] 펌글 Naissance 15/08/13 10:09 118 4
    31
    60초만에 보는 진화의 과정 [25] 펌글 Naissance 15/08/13 09:50 83 11
    30
    메르카토르 지도의 왜곡 [4] 펌글 Naissance 15/08/13 09:46 184 4
    29
    개인적으로 hwp같은 비표준 확장자는 사용을 자제해야 한다고 생각합니다. [11] 창작글 Naissance 15/08/12 13:18 142 4
    28
    굴림체 광고 창작글 Naissance 15/08/10 21:23 27 1
    27
    수도권지하철 4호선 노선도 영문번역 (뻘짓) [1] 창작글 Naissance 15/08/02 22:57 27 1
    26
    4개월만에 만난 어미개와 개새끼 [3] 펌글 Naissance 15/07/29 14:38 44 1
    25
    투블루 처녀작입니다. 창작글 Naissance 15/07/28 14:26 45 0
    24
    같이 알바하실 분 없나요... [8] Naissance 15/07/27 14:16 180 0
    23
    가까스로 위험을 피한 사람들 [5] Naissance 15/07/27 12:30 244 0
    22
    동양 청년들이 꿈을 잃는 이유 Naissance 15/07/14 18:46 36 0
    21
    블렌더로 구리 와이어 만들어봤어요 [3] 창작글 Naissance 15/06/27 17:42 20 11
    20
    블렌더로 어항 속에 빠진 목도리 만들어봤어요 창작글 Naissance 15/06/27 14:23 18 5
    [1] [2] [3]
    단축키 운영진에게 바란다(삭제요청/제안) 운영게 게시판신청 자료창고 보류 개인정보취급방침 청소년보호정책 모바일홈