GetReady Posted September 19, 2009 Share Posted September 19, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/174801-help-converting-this-maths/ Share on other sites More sharing options...
marvelade Posted September 30, 2009 Share Posted September 30, 2009 Just put dollar signs in front of the variables, remove the stars and turn on E_WARNING; that should tell you when a non-declared variable is used. I don't know what eff% means in CF tho. If you have more questions, just shoot grtz, Marv Quote Link to comment https://forums.phpfreaks.com/topic/174801-help-converting-this-maths/#findComment-927540 Share on other sites More sharing options...
Psycho Posted October 6, 2009 Share Posted October 6, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/174801-help-converting-this-maths/#findComment-931574 Share on other sites More sharing options...
GetReady Posted December 21, 2009 Author Share Posted December 21, 2009 Thanks, just recently being able to check this, had an urgent matter crop up, worked a treat, thanks guys! Quote Link to comment https://forums.phpfreaks.com/topic/174801-help-converting-this-maths/#findComment-981864 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.