Jump to content

Recommended Posts

Like a lot of other people I am working on MMO (Kingdom Building Type).  I am pretty much doing it in order to help me learn PHP with an end goal.  In other words, I am a n00b when it comes to PHP.  The question I have is I am trying to build my combat function and I would like to make it rather complicated and I am having a problem trying to figure out the easiest way to do it.  I could use an easy formula to figure it out, but like I said I am trying to learn and I think a more realistic type combat would be cool.

 

This is what I am trying to do...

 

I would like to actually have every solider from each army engage in combat.  Basically...

 

Army A (200 lvl 5 soldiers, 300 lvl 3 soldiers, 500 lvl 1 soldiers, 700 Average Weapons, 500 Poor Weapons, 1000 Poor Armor)

Army B (500 lvl 4 soldiers, 500 Elite Weapons, 500 Elite Armor)

 

So far I have a function that fills an array with what each solider is caring (giving the best weapons and armor to the highest lvl soldiers).  I also have a function that takes two arrays (one for each solider) and returns an array with the solider that survived, died, and how many hit points he has left.

 

All that was the easy part.  What I am trying to figure out now is how do I basically have all the solider fight each other and give me the results of the battle, for example...

Army A (100 lvl 5 soldiers survived and solider X defeated Z many opponents and is the hero of the battle)

Army B (all died and solider X defeated Z many opponents and almost turned the tide)

 

In addition, I would like to also figure out a way to make it even more realistic.  If Army A has 1000 soldiers and Army B has 500, you must assume Army B troops would be getting beaten on by two troops at a time at first.  How would I go about doing that?

 

I am not expecting anyone to help me with writing the code.  All I am hoping for is a point in the right direction.  I am sure I could do this with a ton of conditionals, but with me be so new to PHP I would hate to create a ton of script if there was an easier way (I created a round() function and couldn't figure out why it wouldn't work until I found out a round() function was already built in to PHP).

 

Thank you for your help in advance.

 

Link to comment
https://forums.phpfreaks.com/topic/53781-need-help-with-function/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.