Jump to content

Recommended Posts

Hi i use this scoring formula below for my cold fusion website. i am now re coding this into a php site.... could anyone explain how i would change the following line of code into php?

 

** itemPts = basePrice * quantity * eff% / 150

** drugPts = sqrt(drugVal) * 100 + drugVal

** cashPts = sqrt(cash) * 50 + cash

 

** ScorePotential = itemPts + drugPts + cashPts

** + NT/15

** + SC/15

** + PR * 1.5

** + (OffensiveTroops + MaxOffense) * (OffensiveBonus + 0.1) * 2 * (4 + streetcredlevel + notorietylevel)

** + (DefensiveRating + MaxDefense) * (DefensiveBonus + 0.1) * 2 * (4 + streetcredlevel + notorietylevel)

** + Hoes * (HoIncomeBonus + 0.1) * (1-HoDrugUseBonus) * 300

** + TotalGrown / 2

** + TotalSold / 2

** + (SoldiersKilled-SoldiersLost)/20

** + (drugsStolen-drugsLost)/500

** + (hoesStolen-hoesLost) * 4

** + (cashStolen-cashLost) / 1000

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/174801-help-converting-this-maths/
Share on other sites

  • 2 weeks later...

Most of that code is using the same math operators that PHP uses: plus (+), multiply (*), divide (/), and even the function for square root (sqrt()) is the same.

 

The only exception, as marvelade pointed out, is "eff%". I'm thinking that that is either a special operator in cold fusion or it is simply a variable and CF support the percent sign in variables.

 

So, just change the variables to PHP variables (and figure out the use of "eff%") and you should have something similar to this

 

$itemPts = $basePrice * $quantity * $effPercent / 150;
$drugPts = sqrt($drugVal) * 100 + $drugVal;
$cashPts = sqrt($cash) * 50 + $cash;

$ScorePotential = $itemPts + $drugPts + $cashPts
               + $NT/15
               + $SC/15
               + $PR * 1.5
               + ($OffensiveTroops + $MaxOffense) * ($OffensiveBonus + 0.1) * 2 * (4 + $streetcredlevel + $notorietylevel)
               + ($DefensiveRating + $MaxDefense) * ($DefensiveBonus + 0.1) * 2 * (4 + $streetcredlevel + $notorietylevel)
               + $Hoes * ($HoIncomeBonus + 0.1) * (1-$HoDrugUseBonus) * 300
               + $TotalGrown / 2
               + $TotalSold / 2
               + ($SoldiersKilled - $SoldiersLost) / 20
               + ($drugsStolen -$drugsLost) / 500
               + ($hoesStolen - $hoesLost) * 4
               + ($cashStolen - $cashLost) / 1000;

 

Personally I would create a variable for the following:

$personality = ($OffensiveBonus + 0.1) * 2 * (4 + $streetcredlevel + $notorietylevel);

(or some other description that is more appropriate)

 

And then use that variable on lines 5 & 6 for the definition of $ScorePotential for readability of the code

  • 2 months later...
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.