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.0083 sec