Advertisement
Kalidor_Vorlich

battle v0.1

Aug 7th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.01 KB | None | 0 0
  1. from characterCreation import *
  2. from beings import Enemy
  3. import random
  4.  
  5. playerHP = 0
  6. playerMP= 0
  7. playerStrength = 0
  8. enemyStrength = 0
  9. enemyHP =0
  10. enemyMP=0
  11. enemyStrength=0
  12. enemyDexterity=0
  13. enemyVitality=0
  14. enemyAgility=0
  15. enemyInteligence=0
  16. enemyMind=0
  17. enemyCharisma =0
  18.  
  19. #Check Player stats
  20. """Creates Player stats based on race, mainjob and level"""
  21. def playerStats():
  22.     print('NOW IN PLAYERSTATS()')
  23.     playerHP = player.race['stats']['hp'] + player.mainjob['hp'] + int ((player.level/100)*100)
  24.     playerMP = player.race['stats']['mp'] + player.mainjob['mp'] + int ((player.level/100)*100)
  25.     playerStrength = player.race['stats']['strength'] + int ((player.level/100)*100)
  26.     playerDexterity = player.race['stats']['dexterity'] + int ((player.level/100)*100)
  27.     playerVitality = player.race['stats']['vitality'] + int ((player.level/100)*100)
  28.     playerAgility = player.race['stats']['agility'] + int ((player.level/100)*100)
  29.     playerInteligence = player.race['stats']['intelligence'] + int ((player.level/100)*100)
  30.     playerMind = player.race['stats']['mind'] + int ((player.level/100)*100)
  31.     playerCharisma = player.race['stats']['charisma'] + int ((player.level/100)*100)
  32.     print("playerStrength = ",playerStrength)
  33.     print(player.mainjob['name'])
  34.     print("playerHP = ",playerHP)
  35.     print("playerMP = ",playerMP)
  36.     return playerHP,playerMP,playerStrength,playerDexterity,playerVitality,playerAgility,playerInteligence,playerMind,playerCharisma
  37.  
  38. #Enemy - race, name, level, mainjob, support job, gold, inventory
  39. enemy1 = Enemy(elf,"Goblin", 25,white_mage, "Warrior",52,inventory = [('Matted Fur',70),('High Quality Fur',10)])
  40. enemy2 = Enemy(dwarf,"Orc", 25,warrior, "Warrior",52,inventory = [('Matted Fur',70),('High Quality Fur',10)])
  41.  
  42. #Check Enemy stats
  43. def enemyStats(enemy):
  44.     """Creates Enemy stats based on race, mainjob and level"""
  45.     print('NOW IN ENEMYSTATS()')
  46.     enemyHP = enemy.race['stats']['hp'] + enemy.mainjob['hp'] + int ((enemy.level/100)*100)
  47.     enemyMP = enemy.race['stats']['mp'] + enemy.mainjob['mp'] + int ((enemy.level/100)*100)
  48.     enemyStrength = enemy.race['stats']['strength'] + int ((enemy.level/100)*100)
  49.     enemyDexterity = enemy.race['stats']['dexterity'] + int ((enemy.level/100)*100)
  50.     enemyVitality = enemy.race['stats']['vitality'] + int ((enemy.level/100)*100)
  51.     enemyAgility = enemy.race['stats']['agility'] + int ((enemy.level/100)*100)
  52.     enemyInteligence = enemy.race['stats']['intelligence'] + int ((enemy.level/100)*100)
  53.     enemyMind = enemy.race['stats']['mind'] + int ((enemy.level/100)*100)
  54.     enemyCharisma = enemy.race['stats']['charisma'] + int ((enemy.level/100)*100)
  55.     print("enemyStrength = ",enemyStrength)
  56.     return enemyHP,enemyMP,enemyStrength,enemyDexterity,enemyVitality,enemyAgility,enemyInteligence,enemyMind,enemyCharisma
  57.  
  58.  
  59.  
  60. #Enemy Encounter
  61. def enemyEncounter(enemy):
  62.     """Not currently called"""
  63.     """Reads in enemy instantiation and checks playerStrength against enemyStrength"""
  64.     print('NOW IN ENEMYENCOUNTER()')
  65.     print("a wild ", enemy.name, "has appeared")
  66.     playerStats()
  67.     enemyStats(enemy)
  68.     if playerStrength >= enemyStrength:
  69.         print(player.name, " Wins!")
  70.         print(playerHP)
  71.         print(playerMP)
  72.    
  73.  
  74.     elif enemyStrength >= playerStrength:
  75.         print(enemy.name, " Wins!")
  76.  
  77. #Display Actions
  78. """Not currently called"""
  79. def display_actions():
  80.     """Will display list of actions taken from player.mainjob spell list"""
  81.     print('NOW IN DISPLAY_ACTIONS()')
  82.     print("Which action will you take?")
  83.     for i in player.mainjob['spelllist']:
  84.         print(i)
  85.  
  86. #display_actions()
  87. #enemyEncounter(enemy2)
  88. playerStats()
  89. enemyStats(enemy1)
  90.  
  91.  
  92. ### -- BATTLE -- ###
  93. '''
  94.     • Read enemy
  95.     • Decide who turn initially
  96.         ○ While playerHP >0 and enemyHP >0:
  97.             § Turn = turn + 1
  98.             § Display actions
  99.             § Choose action
  100.             § Calculate actions numbers
  101.            § Update relevant numbers
  102. '''
  103. print('NOW IN BATTLE')
  104. number = random.randint(1,2)
  105. if number == 1:
  106.     player_turn = True
  107. else:
  108.     player_turn = False
  109. while playerHP >= 0 or enemyHP >= 0: #FOR SOME REASON ITS READING PLAYER HP AS 0
  110.     if player_turn == True:
  111.             print("Which action will you take?")
  112.             for i in player.mainjob['spelllist']:
  113.                 print(i)
  114.             action = input()
  115.             if action in (player.mainjob['spelllist']):
  116.                 action = player.mainjob['spelllist'][action]
  117.                 if action['effect'] == 'damage':
  118.                     enemyHP = enemyHP - action['amount']
  119.                     print("PlayerHP = ",playerHP)
  120.                     print('EnemyHP = ', enemyHP)
  121.                 elif action['effect'] == 'healing':
  122.                     playerHP = playerHP + action['amount']
  123.                     print("PlayerHP = ",playerHP)
  124.                     print('EnemyHP = ', enemyHP)
  125.             player_turn = False
  126.     elif player_turn == False:
  127.         print("Enemy attacks")
  128.         player_turn = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement