So does anybody have any advice on whether any of the following functions and variables should be private, public, abstract, etc...
<?php
class kingpin {
// $userid will be passed from another script
public $userid;
public $name;
public $health;
public $maxHealth;
public $stamina;
public $maxStamina;
public $attack;
public $defence;
public $level;
public $xp;
public $threshold;
public $cash;
public $bank;
public $friends = array();
public $weapons = array();
// $missionxp will be passed from another script
public $missionxp;
public function __construct() {
// use variables,
// create kingpin from db
// require_once('dbconn.php');
}
public function deactivate() {
// move kingpin from normal db
// to inactive users db
}
public function chooseWeapons() {
// choose strongest of weapons
}
public function fightPot() {
// calculate fight potential of user
// say, $level * $weaponsTotal * $attack
}
public function oppFightPot() {
// calculate fight potential of opponent
// say, $level * $weaponsTotal * $defence
}
public function fight($opponent) {
// is opponent dead or too weak to fight?
// if so, throw error
// is user dead or too weak to fight?
// if so, throw error
// multiply fightpotential by random number
// display weapons used
// do same for opponent
// is users total more than opponents total?
// display who won
}
public function save() {
// save variables to db
}
public function setStats() {
// change stats
// ie, $attack, $defence, $maxStamina, $maxHealth
}
public function getStats() {
// get stats
// ie, $attack, $defence, $maxStamina, $maxHealth
}
public function addXP($missionxp) {
// add xp from mission to current $xp variable
$xp = $xp + $missionxp;
// level up?
// $threshold should increase in relation to $level
$threshold = $level * 20 + 10;
if ($xp >= $threshold) {
$level++;
echo 'Congratulations! You have reached Level $level! <br>';
}
$this->getStats();
}
} // end of class
$kingpin = new kingpin();
?>
It's a game, as you might have guessed, and I'm planning to store the details in a db.
Thank you