Advertisement
Kovitikus

Untitled

Aug 9th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.69 KB | None | 0 0
  1.     # staves = char.db.staves
  2.     # d_skill = char.db.staves.get(skill)
  3.  
  4.     # # Check for stave skills.
  5.     # if skillset == 'staves':
  6.     #     if not staves['total_sp'] >= sp_cost:
  7.     #         char.msg('You do not have enough skill points to learn this skill.')
  8.     #         return
  9.     #     if not d_skill:
  10.     #         staves[skill] = {'rank': 0, 'rb': 0}
  11.     #     rank = staves[skill]['rank']
  12.     #     rank += 1
  13.     #     staves[skill]['rank'] = rank
  14.     #     staves['total_sp'] -= sp_cost
  15.     #     staves[skill]['rb'] = rb[rank - 1]
  16.     #     staves['total_ranks'] += 1
  17.     #     char.msg(f"You have spent {sp_cost} to learn rank {rank} of {skillset} {skill}, earning the rank bonus of {staves[skill]['rb']}.")
  18.  
  19.     # d_skill = skillset.get(skill)
  20.     # d_skillset = char.attributes.get(skillset)
  21.  
  22.     skillset = f"char.db.{skillset}" #This really didn't work!
  23.     total_sp = skillset['total_sp']
  24.     if not total_sp >= sp_cost:
  25.         char.msg('You do not have enough skill points to learn this skill.')
  26.         return
  27.     # Mostly it's this if not statement checking for the skill that gives me trouble.
  28.     # I've tried getting skillset as an object and a dictionary.
  29.     # Such as: char.attributes.get(key=skillset, return_obj=True) and char.attributes.get(skillset)
  30.     if not skillset.get(skill):
  31.         skillset[skill] = {'rank': 0, 'rb': 0}
  32.     rank = skillset[skill]['rank']
  33.     rank += 1
  34.     skillset[skill]['rank'] = rank
  35.     skillset['total_sp'] -= sp_cost
  36.     skillset[skill]['rb'] = rb[rank - 1]
  37.     skillset['total_ranks'] += 1
  38.     char.msg(f"You have spent {sp_cost} to learn rank {rank} of {skillset} {skill}, earning the rank bonus of {skillset[skill]['rb']}.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement