Ejemplo n.º 1
0
 /**
  * Recalculate the points.
  *
  * @return Bengine_Game_Cronjob_PointClean
  */
 protected function cleanPoints()
 {
     Hook::event("CleanPointsBegin");
     $_result = Core::getQuery()->select("user", "userid");
     foreach ($_result->fetchAll() as $_row) {
         $points = 0;
         $fpoints = 0;
         $dpoints = 0;
         $result = Core::getQuery()->select("planet", "planetid", "", Core::getDB()->quoteInto("userid = ?", $_row["userid"]));
         foreach ($result->fetchAll() as $row) {
             $points += Bengine_Game_PointRenewer::getBuildingPoints($row["planetid"]);
             $points += Bengine_Game_PointRenewer::getFleetPoints($row["planetid"]);
             $fpoints += Bengine_Game_PointRenewer::getFleetPoints_Fleet($row["planetid"]);
             $dpoints += Bengine_Game_PointRenewer::getDefensePoints($row["planetid"]);
         }
         $result->closeCursor();
         $points += Bengine_Game_PointRenewer::getResearchPoints($_row["userid"]);
         $points += Bengine_Game_PointRenewer::getFleetEventPoints($_row["userid"]);
         $fpoints += Bengine_Game_PointRenewer::getFleetEvent_Fleet($_row["userid"]);
         $rpoints = Bengine_Game_PointRenewer::getResearchPoints_r($_row["userid"]);
         Core::getQuery()->update("user", array("points" => $points, "fpoints" => $fpoints, "rpoints" => $rpoints, "dpoints" => $dpoints), "userid = ?", array($_row["userid"]));
     }
     $_result->closeCursor();
     return $this;
 }
Ejemplo n.º 2
0
/**
 * Deletes all planet data.
 *
 * @param integer $id		Planet id
 * @param integer $userid	User id
 * @param boolean $ismoon	Planet is moon
 *
 * @return void
 */
function deletePlanet($id, $userid, $ismoon)
{
    $points = Bengine_Game_PointRenewer::getBuildingPoints($id);
    $points += Bengine_Game_PointRenewer::getFleetPoints($id);
    $fpoints = Bengine_Game_PointRenewer::getFleetPoints_Fleet($id);
    $dpoints = Bengine_Game_PointRenewer::getDefensePoints($id);
    if (!$ismoon) {
        $result = Core::getQuery()->select("galaxy", "moonid", "", Core::getDB()->quoteInto("planetid = ?", $id));
        $row = $result->fetchRow();
        if ($row["moonid"]) {
            deletePlanet($row["moonid"], $userid, 1);
        }
    }
    Core::getDB()->query("UPDATE " . PREFIX . "user SET points = points - ?, fpoints = fpoints - ?, dpoints = dpoints - ? WHERE userid = ?", array($points, $fpoints, $dpoints, $userid));
    Core::getQuery()->update("planet", array("userid" => null), "planetid = ?", array($id));
    if ($ismoon) {
        Core::getQuery()->update("galaxy", array("moonid" => null), "moonid = ?", array($id));
    } else {
        Core::getQuery()->update("galaxy", array("destroyed" => 1), "planetid = ?", array($id));
    }
    Hook::event("DeletePlanet", array($id, $userid, $ismoon));
    return;
}