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










