Nov-21-2019, 01:09 PM
Hello
I'm extremely new to coding, I started learning Python two days ago. And I'm working on a simple text based battle game, while following a tutorial.
I want to add a "weapon" or "item" to the player dic:
This "weapon" is supposed to increase the "player['attack']" by lets say "10" attack points, therefor making the new attack value 35+10=45.
I'm also thinking of giving the enemy you are fighting a disarm ability, which will remove the "weapon" from the player and therefor return the attack value to it's original, "35".
This is the code for how the enemy's health is lowered once I attack him:
My question is, what would be the most efficent way to code the "weapon" which will increase the "player['attack']" by 10, and have another code remove the "weapon" element from the player dic.
Thanks :)
I'm extremely new to coding, I started learning Python two days ago. And I'm working on a simple text based battle game, while following a tutorial.
I want to add a "weapon" or "item" to the player dic:
1 |
player = { 'name' : 'Timmy' , 'health' : 100 , 'attack' : 35 , 'heal' : 16 } |
I'm also thinking of giving the enemy you are fighting a disarm ability, which will remove the "weapon" from the player and therefor return the attack value to it's original, "35".
This is the code for how the enemy's health is lowered once I attack him:
1 |
monster[ 'health' ] = monster[ 'health' ] - player[ 'attack' ] |
Thanks :)