~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 ' ?'