기
~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 ' 갈까?'