Forums

Confused On Combat Code

I'm copy pasting the email that I sent to my teacher about the problem I'm having because I didn't feel like retyping it. I can in fact PM someone the full code if they want it.

So as I think I mentioned to you before the last thing I need to code is the combat. I understand how to prompt the player on what attack choice they want to make. But don't know how to then tell the MonsterAI to respond and have it go back and forth like that until one is dead. My other concern is that I have multiple kinds of monsters and don't know how to clarify to the game which one the player is currently fighting. I have several responses that tell the player what they're fighting but if the game doesn't know it doesn't much matter.(Beyond this point the bolded print is my notes on the code and unbolded print is the code.

(AOL unindented the code I apologize in advance.) Code for combat

def combat(): 
    comchoice = raw_input("Will you swing your Longsword or use Star Slice?") 
    if comchoice == "Longsword": <---on this line I plan to tell the game to subtract however much damage the player did from the monsters health 
    if comchoice == "Trinomy": <---on this line I plan to tell the game to subtract however much damage the player did from the monsters health

I have a class for the monsters and several kinds of them Defining different kinds of monsters

Orc = Monster("Orc Marauder", 50, 300) 
Kobold = Monster("Kobold Rogue", 25, 150) 
Goblin = Monster("Goblin Runt", 10, 100) 
Fairy = Monster("Cursed Fairy Queen", 0, 666) 
Dragon = Monster("Dragon Lord", 999, 500)

The player chooses from three different paths and gets a randomly generated response from one of these. Coding the progression of the adventure

Response1 = "You continue forward until you reach another three way split. Which do you take?" 
Response2 = "You have encountered a psychotic Goblin Runt! Prepare for battle!" 
Response3 = "You have encountered a vicious Kobold Rogue! Prepare for battle!" 
Response4 = "You have encountered a mighty Orc Marauder! Prepare for battle!" 
Response5 = "You have come across a beautiful maiden with black wings. What will you do?" 
Response6 = "You have reached the goal of your journey! Before you stands the Dragon Lord! Gather all your might brave hero!" 
Response7 = "You have fled from battle. You rest and recover your HP!"

I believe I have all the pieces here to make this work properly. But I'm just not sure how to connect them all. The idea of making different "Combat" functions for each monster and attaching them to the responses ran through my head but I feel their should be a much simpler method. I'm also pretty sure just telling it Monster.health = Monster.health - AtkDamage wouldn't work because I need to specify that I'm talking about either the Orc, Kobold, Goblin etc.

Thank you in advance for any assistance you can give me. I'll send you the whole code in a separate email just in case you need it for reference.

Well... maybe you would pass the monster instance into the combat function? Or combat could be a method on the monster class?

I'm not even sure how to go about that. I've decided, after consultation from members of Reddit and no email back from my teacher, to just set this project aside and do something simpler. I'll return to this game concept when I know more about the language.