Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Map(self, keyboard):
- """ View of characted being moved to new location. """
- class Character():
- def Character(object):
- C = player(hero)
- hero = {'name' : 'Hero',
- 'lvl' : 1,
- 'xp' : 0,
- 'lvlNext' : 25,
- 'stats' : {'str' : 1,
- 'dex' : 1,
- 'int' : 1,
- 'hp' : 30,
- 'atk' : [5, 12]}}
- def update(self, C, map):
- """ Move player based on keys pressed. """
- if keyboard.is_pressed(K_w, C, map):
- self.C
- self.map
- self.y -= 1
- if keyboard.is_pressed(K_s, C, map):
- self.C
- self.map
- self.y += 1
- if keyboard.is_pressed(K_a, C, map):
- self.C
- self.map
- self.x -= 1
- if keyboard.is_preseed(K_d, C, map):
- self.C
- self.map
- self.x += 1
- else:
- print(" Waiting for your move. ")
- class Enemy():
- def Enemy(object):
- f = enemy(fly)
- fly = {'name' : 'Fly',
- 'lvl' : 1,
- 'reward' : 25,
- 'xp' : 0,
- 'lvlNext' : 25,
- 'stats' : {'str': 1,
- 'int' : 1,
- 'hp' : 30,
- 'atk' : [5, 12]}}
- def move(self, f, map):
- """ Mov
- class Wall()
- def Wall(object):
- P = wall(solid)
- solid = ['name' : 'Solid',
- 'Function' :
- c = chest
- d = door
- DD = door
- map = """
- PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
- P|-----------------------------------------------------|P
- P| |--------| |-------|------------| |---------------|P
- P| | |PPDPPPPPPPP| | | |P
- P| C| |P P| f | | |P
- P| | |P f P| | | |P
- P| | |P P| d d |P
- P| | |P P| | | |P
- P| | |P P| | | |P
- P| | |P P| | | cccc |P
- P| | |PPPPPPPPPPP| | | c c |P
- P|__d_______|P|_________d___________| |____cccc_______|P
- PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPDDPPPPPPPPPPPPPPPPPP
- """
- class Keyboard(self, character, map):
- """ Key board controls. """
- def update(self):
- """ Move hero based on keys pressed. """
- if keyboard.is_pressed(K_w, p, map):
- self.y -= 1
- if keyboard.is_pressed(K_s, p, map):
- self.y += 1
- if keyboard.is_pressed(K_a, p, map):
- self.x -= 1
- if keyboard.is_preseed(K_d, p, map):
- self.x += 1
- hero = {'name' : 'Hero',
- 'lvl' : 1,
- 'xp' : 0,
- 'lvlNext' : 45,
- 'stats' : {'str' : 4,
- 'dex' : 2,
- 'int' : 10,
- 'hp' : 100,
- 'atk' : [5, 12]}}
- fly = {'name' : 'Fly',
- 'lvl' : 5,
- 'reward' : 25,
- 'xp' : 0,
- 'lvlNext' : 25,
- 'stats' : {'str': 5,
- 'int' : 4,
- 'hp' : 13,
- 'atk' : [5, 12]}}
- def level(char):
- nStr, nDex, nInt = 0, 0, 0
- while char['xp'] >= char['lvlNext']:
- char['lvl'] += 1
- char['xp'] = char['xp'] - char['lvlNext']
- char['lvlNext'] = round(char['lvlNext'] * 1.5)
- nStr += 1
- nDex += 1
- nInt += 1
- print('level:', char['lvl'])
- print('STR {} +{} DEX {} +{} INT {} +{}'.format(char['stats']['str'], nStr,
- char['stats']['dex'], nDex,
- char['stats']['int'], nInt))
- char['stats']['str'] += nStr
- char['stats']['dex'] += nDex
- char['stats']['int'] += nInt
- from random import randint
- def takeDmg(attacker, defender):
- dmg = randint(attacker['stats']['atk'][0], attacker['stats']['atk'][1])
- defender['stats']['hp'] = defender['stats']['hp'] - dmg
- if defender['stats']['hp'] <= 0:
- print('{} has been slain'.format(defender['name']))
- hero['xp'] += fly['reward']
- level(hero)
- input('Press any key to quite.')
- exit(0)
- else:
- print('{} takes {} damage!'.format(defender['name'], dmg))
- def commands(player, enemy):
- while True:
- print('----------------------')
- cmd = input('Do you want to attack? yes/no: ').lower()
- if 'yes' in cmd:
- takeDmg(player, enemy)
- elif 'no' in cmd:
- print('{} takes the opportunity to attack!'.format(enemy['name']))
- takeDmg(enemy, player)
- else:
- pass
- commands(hero, fly)
Advertisement
Add Comment
Please, Sign In to add comment