U E D R , A S I H C RSS

데블스캠프2005/월요일/Blue Dragon

러 보물


~cpp 
# -*- coding: cp949 -*-

import random

class Room:
    def __init__(self):
        self.place = ['루', '', '공대', '매동', '문']
        
class User:
    def __init__(self):
        self.aRoom = Room()
        self.place = '문'
        self.hasKey = False
        self.name = '명'
        self.hp = 100
        self.aDragon = BlueDragon(self)
        self.aTrasure = Trasure()

    def setName(self, name):
        self.name = name
        
    def checkPlace(self):
        if self.place == '' and not self.aDragon.die:
            self.aDragon.attack()

        if self.place == '매동':
            print '보물를 발견다.'
            if not self.aTrasure.open:
                if self.hasKey:
                    print '보물다.'
                    self.aTrasure.open = True
                    print '다. 보물 발견다.'
                    print '게 끝냅다.'

                else:
                    print '/'
                
    def move(self):
        print self.name, '',
        for room in self.aRoom.place:
            if room != self.place:
               print room,',',
                
        print '   다.'

        place = raw_input("디로 ?")
        self.place = place

        print self.name, self.place , '다.'
        self.checkPlace()

                
    def attack(self):
        if self.place != '':
            return
        print ' 공격다.'
        
        self.aDragon.hp -= random.randrange(100)
        print ' hp는 ', self.aDragon.hp, '다.'

        if self.aDragon.hp <= 0:
            self.aDragon.die = True
            print '다.'
            print '다.'
            self.hasKey = True
        else:
            self.aDragon.attack()
        

class BlueDragon:
    def __init__(self, user):
        self.name = '룡'
        self.die = False
        self.aUser = user
        self.hp = 100

    def attack(self):
        print '당다.'
        self.aUser.hp -= random.randrange(100)
        print '당 hp는 ', self.aUser.hp, '다.'
        
        if self.aUser.hp <= 0:
            print '당 다.'
            print 'Game Over'


class Trasure:
    def __init__(self):
        self.name = '보물'
        self.open = False

        

if __name__ == '__main__':
    print '당   다.'
    print '나가고,  나다닙다.'
    print '디로 ?'

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:01
Processing time 0.0075 sec