Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function initSkylab()
- {
- $qry = $this->con->prepare("SELECT * FROM skylab WHERE UserID = :uID");
- $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
- if ($qry->execute()) {
- if ($qry->rowCount () != 0) {
- $result = $qry->fetchAll(PDO::FETCH_ASSOC);
- $time = new DateTime();
- $time = $time->getTimestamp();
- //todo finish transports here
- $basicmod_arr = explode("|", $result[0]['basicmod']);
- $this->mod_basic['level'] = $basicmod_arr[0];
- $this->mod_basic['status'] = $basicmod_arr[1];
- $this->mod_basic['upgrade_finished'] = $basicmod_arr[2];
- $storagemod_arr = explode("|", $result[0]['storagemod']);
- $this->mod_store['level'] = $storagemod_arr[0];
- $this->mod_store['status'] = $storagemod_arr[1];
- $this->mod_store['upgrade_finished'] = $storagemod_arr[2];
- $solarmod_arr = explode("|", $result[0]['solarmod']);
- $this->mod_solar['level'] = $solarmod_arr[0];
- $this->mod_solar['status'] = $solarmod_arr[1];
- $this->mod_solar['upgrade_finished'] = $solarmod_arr[2];
- $prometiumcol_arr = explode("|", $result[0]['prometiumcol']);
- $this->collector_prometium['level'] = $prometiumcol_arr[0];
- $this->collector_prometium['status'] = $prometiumcol_arr[1];
- $this->collector_prometium['upgrade_finished'] = $prometiumcol_arr[2];
- $enduriumcol_arr = explode("|", $result[0]['enduriumcol']);
- $this->collector_endurium['level'] = $enduriumcol_arr[0];
- $this->collector_endurium['status'] = $enduriumcol_arr[1];
- $this->collector_endurium['upgrade_finished'] = $enduriumcol_arr[2];
- $terbiumcol_arr = explode("|", $result[0]['terbiumcol']);
- $this->collector_terbium['level'] = $terbiumcol_arr[0];
- $this->collector_terbium['status'] = $terbiumcol_arr[1];
- $this->collector_terbium['upgrade_finished'] = $terbiumcol_arr[2];
- $prometidref_arr = explode("|", $result[0]['prometidref']);
- $this->refine_prometid['level'] = $prometidref_arr[0];
- $this->refine_prometid['status'] = $prometidref_arr[1];
- $this->refine_prometid['upgrade_finished'] = $prometidref_arr[2];
- $duraniumref_arr = explode("|", $result[0]['duraniumref']);
- $this->refine_duranium['level'] = $duraniumref_arr[0];
- $this->refine_duranium['status'] = $duraniumref_arr[1];
- $this->refine_duranium['upgrade_finished'] = $duraniumref_arr[2];
- $promeriumref_arr = explode("|", $result[0]['promeriumref']);
- $this->refine_promerium['level'] = $promeriumref_arr[0];
- $this->refine_promerium['status'] = $promeriumref_arr[1];
- $this->refine_promerium['upgrade_finished'] = $promeriumref_arr[2];
- $sepromref_arr = explode("|", $result[0]['sepromref']);
- $this->refine_seprom['level'] = $sepromref_arr[0];
- $this->refine_seprom['status'] = $sepromref_arr[1];
- $this->refine_seprom['upgrade_finished'] = $sepromref_arr[2];
- $xenogen_arr = explode("|", $result[0]['xenogen']);
- $this->generator_xeno['level'] = $xenogen_arr[0];
- $this->generator_xeno['status'] = $xenogen_arr[1];
- $this->generator_xeno['upgrade_finished'] = $xenogen_arr[2];
- $qryr = $this->con->prepare("SELECT * FROM skylab_ressources WHERE LabID = :uID");
- $qryr->bindParam(':uID', $this->uid, PDO::PARAM_INT);
- if ($qryr->execute()) {
- $ress = $qryr->fetchAll(PDO::FETCH_ASSOC);
- $ress_array = array(
- "prometium" => $ress[0]['prometium'],
- "endurium" => $ress[0]['endurium'],
- "terbium" => $ress[0]['terbium'],
- "prometid" => $ress[0]['prometid'],
- "duranium" => $ress[0]['duranium'],
- "xenomit" => $ress[0]['xenomit'],
- "promerium" => $ress[0]['promerium'],
- "seprom" => $ress[0]['seprom']
- );
- $this->ressources_array = $ress_array;
- // update ressources here
- // check the upgrades after update ressources
- //
- if($this->mod_basic['status'] == 2 && $this->mod_basic['upgrade_finished'] != 0){
- if($time >= $this->mod_basic['upgrade_finished']){
- $this->mod_basic['level'] = $this->mod_basic['level']+1;
- $this->mod_basic['status'] = 1;
- $this->mod_basic['upgrade_finished'] = 0;
- $data = implode("|", $this->mod_basic);
- $type = "basicmod";
- $qry = $this->con->prepare("UPDATE skylab SET {$type} = :data WHERE UserID = :uID");
- $qry->bindParam(':uID', $this->uid, PDO::PARAM_INT);
- $qry->bindParam(':data', $data, PDO::PARAM_STR);
- $qry->execute();
- }
- }
- return TRUE;
- }
- } else {
- $time = new DateTime();
- $time = $time->getTimestamp();
- // level|status|finished-timestamp
- $qrys = $this->con->prepare("INSERT INTO `skylab`
- (`LabID`, `UserID`, `lastvisit`, `basicmod`, `solarmod`, `storagemod`,
- `prometiumcol`, `enduriumcol`, `terbiumcol`, `prometidref`, `duraniumref`,
- `promeriumref`, `xenogen`, `sepromref`)
- VALUES
- (:uID, :uID, :lv, '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0', '1|1|0')");
- $qrys->bindParam(':uID', $this->uid, PDO::PARAM_INT);
- $qrys->bindParam(':lv', $time, PDO::PARAM_INT);
- $qrys->execute();
- $qryr = $this->con->prepare("INSERT INTO `skylab_ressources`
- (`LabID`, `prometium`, `endurium`, `terbium`, `prometid`, `duranium`, `xenomit`, `promerium`, `seprom`)
- VALUES
- (:uID, 50000, 50000, 50000, 0, 0, 0, 0, 0)");
- $qryr->bindParam(':uID', $this->uid, PDO::PARAM_INT);
- $qryr->execute();
- self::initSkylab();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement