| | |
RPG Battle Simulation
![]() |
Here is an example I was thinking of ...
Need to improve the battle descriptions, maybe draw on a sentence lists with random.choice() to get some variety in there.
One could change the my_hitlist depending on the weapon carried, or change the mo_hitlist depending on the nastiness of the monster.
If you carry fancy armor the hits could be deminished in severity.
Let me know what you think.
python Syntax (Toggle Plain Text)
import random import time def delay(seconds): time.sleep(seconds) def shuffle_hitlists(my_hitlist, mo_hitlist): """shuffle the two lists and return the result""" random.shuffle(my_hitlist) random.shuffle(mo_hitlist) return my_hitlist, mo_hitlist def battle(my_hitlist, mo_hitlist, my_strength, mo_strength): # player starts swinging first for k in range(len(my_hitlist)): my_hit = my_hitlist[k] mo_hit = mo_hitlist[k] # your turn if my_hit == 1: print "Scratched him good!" mo_strength -= 1 elif my_hit == 2: print "Sliced him deep! Blood and guts!" mo_strength -= 2 elif my_hit == 3: print "Excellent hit! He is screaming with pain!" mo_strength -= 3 else: # my_hit == 0: print "You missed!" if mo_strength <= 0: print "The monster is dead!" break delay(2) # monster's turn if mo_hit == 1: print "You got scratched! It will heal quickly!" my_strength -= 1 elif mo_hit == 2: print "Ouch, received a deep slice!" my_strength -= 2 elif mo_hit == 3: print "You are hit and in pain! Loosing blood!" my_strength -= 3 else: # mo_hit == 0 print "The monster missed!" delay(2) if my_strength < 5: print "You are weak and wounded, better withdraw!" break if mo_strength > 0: print "The fleeing monster's strength is down to", mo_strength print "You still have a strength of", my_strength my_hitlist = [1, 0, 2, 1, 3, 0, 3, 1] mo_hitlist = [1, 0, 2, 0, 3, 0, 1, 1] my_strength = 20 mo_strength = 10 my_hitlist, mo_hitlist = shuffle_hitlists(my_hitlist, mo_hitlist) print my_hitlist, '\n', mo_hitlist # test battle(my_hitlist, mo_hitlist, my_strength, mo_strength)
One could change the my_hitlist depending on the weapon carried, or change the mo_hitlist depending on the nastiness of the monster.
If you carry fancy armor the hits could be deminished in severity.
Let me know what you think.
May 'the Google' be with you!
That's a good idea. I'm curious how turn-based games when you fight a monster work. I'm guessing no one here has worked on that sort of thing. =\
The hitlist type thing just doesn't seem like a great way to do it. I guess you could cycle it if the program hit the end of it, but I don't know... hmmm.
Thoughts from others?
The hitlist type thing just doesn't seem like a great way to do it. I guess you could cycle it if the program hit the end of it, but I don't know... hmmm.
Thoughts from others?
-1
#3 2 Days Ago
•
•
•
•
That's a good idea. I'm curious how turn-based games when you fight a monster work. I'm guessing no one here has worked on that sort of thing. =\
The hitlist type thing just doesn't seem like a great way to do it. I guess you could cycle it if the program hit the end of it, but I don't know... hmmm.
Thoughts from others?
If at first you don't succeed... run the code again.
![]() |
Similar Threads
- RPG Battle Action (Python)
- Rpg (Python)
- RP Battle Simulator (Java)
- global or function? (Python)
- Round Robin Algorithm Simulation (C++)
- Enhancing a Text based RPG (C++)
Other Threads in the Python Forum
- Previous Thread: Renaming Files Help
- Next Thread: RPG Battle Action
| Thread Tools | Search this Thread |
alarm ansi app assignment avogadro backend beginner binary bluetooth character cipher cmd customdialog cx-freeze data decimals dictionary directory dynamic error exe file float format function generator getvalue gnu graphics halp heads homework http ideas import input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse number numbers output parsing path pointer prime programming progressbar push py2exe pygame python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh statistics string strings sudokusolver sum text thread threading time tlapse tuple tutorial ubuntu unicode urllib urllib2 variable variables ventrilo vigenere web webservice wikipedia write wxpython xlib






