Jump to content

Recommended Posts

Ok I have a small project at work to keep some of the employees entertained while they do their job and I am having troubles balancing the attack/defend portion of the game.

I base their initial attack/defend power on their level.  They gain experience based on various aspects of the website they use in their daily tasks.

What I am having troubles is when they attack each other. They earn 'soldiers' to fight/defend with so those numbers can vary. What is the best way to determine who wins in the battle?

Ex:

Player1 is lvl 10 with 1000 troops
Player2 is lvl 8 with 800 troops

Obviously Player1 is stronger than Player 2

Player1 is lvl 12 with 1200 troops
Player2 is lvl 8 with 1500 troops

Who should win this?

I'm just fuzzy on the logic.  Also I plan on having bonuses like +1 to offense or +1 to defense.

On a side note I currently add a small bonus modifier if a player is attacking another player who is higher level. IE Attacker Level > Defender Level.  Hoping that it isnt total hopeless for a lower level character to attack a higher level.

Make sense?
Link to comment
https://forums.phpfreaks.com/topic/29710-calculating-attacksdefends/
Share on other sites

Make a function that calculates an attack score based like this: [code]function calculate($level,$troops,$bonus=false)
{
$result = pow(sqrt(pow(($level*22),2)/($troops*18)+$troops/100),3);
if($bonus==true)
{
$result *= 1.25;
$result += 3;
}
$result = round($result);

return $result;
}[/code]

Highest score wins. The bonus is given if you are attacking a higher leveled person.

Example 1: Player1 wins (P1: 45; P2: 43) - bonus to Player2
Example 2: Player2 wins (P1: 59; P2: 84) - bonus to Player2

Edit: Here is the formula:
[img]http://img223.imageshack.us/img223/5219/formulayx1.png[/img]
and for the bonus:
[img]http://img134.imageshack.us/img134/6052/formula2tv3.png[/img]
(S: Score; T: Troops; L: Level)
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.