I have an idea on how to do this, but I don't know how I would do it for purchasing 10 at a time.
Let's say you purchase 10 weapons... I want the cost of those weapons to increase by a certain percentage for each 10 that are purchased. If I have to I can just make it max 10 at a time, but would rather have them purchase any amount up to 1000 at a time, but also have the increases in the total amount. But to start with, I would like a simple solution to just purchasing 10 at a time and then the cost of the weapon to increase by a certain percentage for each 10 purchased.
$numberSold;
$cost;
//amount of increase per groups sold as a float (where 0.3 would be 30% increase, 0.05 would be 5%, etc.)
$increase = 0.08; //8% price increase for each 10 items
//determine how many groups of 10 were sold
$groupsSold = $numberSold / 10;
//round to lowest integer
$groupsSold = floor($groupsSold);
//now increase the price
for ($x = 0; $x < $groupsSold; $x++) {
$cost += $cost * $increase;
}
//cost has now increased cumulatively for each group of 10 bought
And what comes for the equations, it's just making the step-by-step logicality of a mathematical happening.
I don't think you are not good with equations, it's just that you are not yet fully familiar on how to get your thoughts written down in PHP, am I right?
The cost do not have to be in database, as long as it is defined before the new pricing loop done by Mr. Jacko.
But the quantities sold needs to be stored somewhere, unless you just do a one time purchase increaser.. example:
"I want to buy 1000 AXES for my underground dwarven army, booyaah!"
"One axe costs 10 gold coins, and every ten axes increases the axe cost amount with 10%, so that makes it.. *massive loopings* muchos Dollars!"
And only the gold reducing is updated to db.
Why so serious?
Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender