룡 무러 보물기
~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 '디로 까?'