Added full source code
This commit is contained in:
commit
33f8586698
1377 changed files with 123808 additions and 0 deletions
scripts/game/main/vacation
45
scripts/game/main/vacation/library.inc
Normal file
45
scripts/game/main/vacation/library.inc
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
class main_vacation_library {
|
||||
var $index = array(
|
||||
'canSet',
|
||||
'start',
|
||||
'leave'
|
||||
);
|
||||
|
||||
function main_vacation_library($lib) {
|
||||
$this->lib = $lib;
|
||||
$this->db = $this->lib->game->db;
|
||||
}
|
||||
|
||||
|
||||
function isOnVacation($uid) {
|
||||
$q = $this->db->query("SELECT COUNT(*) FROM account WHERE id=$uid AND status='VAC'");
|
||||
list($onVac) = dbFetchArray($q);
|
||||
return ($onVac == 1);
|
||||
}
|
||||
|
||||
|
||||
function getStatus($uid) {
|
||||
$q = $this->db->query("SELECT status,vac_start,vac_credits FROM account WHERE id=$uid");
|
||||
if ($q && dbCount($q) == 1) {
|
||||
return dbFetchHash($q);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function setStart($uid) {
|
||||
$vs = time() + 86400;
|
||||
$this->db->query("UPDATE account SET vac_start=$vs WHERE id=$uid AND status='STD'");
|
||||
logText("Account $uid requested vacation mode");
|
||||
}
|
||||
|
||||
|
||||
function resetStart($uid) {
|
||||
$this->db->query("UPDATE account SET vac_start=NULL WHERE id=$uid AND status='STD'");
|
||||
logText("Account $uid cancelled request for vacation mode");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
31
scripts/game/main/vacation/library/canSet.inc
Normal file
31
scripts/game/main/vacation/library/canSet.inc
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
class main_vacation_canSet {
|
||||
|
||||
function main_vacation_canSet($lib) {
|
||||
$this->lib = $lib;
|
||||
$this->db = $this->lib->game->db;
|
||||
}
|
||||
|
||||
function run($uid) {
|
||||
$q = $this->db->query("SELECT t FROM account_log WHERE account=$uid AND action='VEND'");
|
||||
if (!$q) {
|
||||
return false;
|
||||
} elseif (dbCount($q) > 0) {
|
||||
list($last) = dbFetchArray($q);
|
||||
if (!(time() - $last > 604800 /* 7 * 24 * 3600 */ )) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$q = $this->db->query("SELECT vac_credits,quit_ts FROM account WHERE id=$uid");
|
||||
if (!($q && dbCount($q) == 1)) {
|
||||
return false;
|
||||
}
|
||||
list($cred,$quit) = dbFetchArray($q);
|
||||
|
||||
return is_null($quit) && ($cred > 0);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
31
scripts/game/main/vacation/library/leave.inc
Normal file
31
scripts/game/main/vacation/library/leave.inc
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
class main_vacation_leave {
|
||||
|
||||
function main_vacation_leave($lib) {
|
||||
$this->lib = $lib;
|
||||
$this->db = $this->lib->game->db;
|
||||
$this->accounts =& $this->lib->game->getLib('main/account');
|
||||
}
|
||||
|
||||
function run($uid) {
|
||||
foreach (config::getGames() as $game) {
|
||||
if ($game->name == 'main') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$lib = $game->getLib();
|
||||
$pid = $lib->call('doesUserPlay', $uid);
|
||||
if (!is_null($pid)) {
|
||||
$lib->call('leaveVacation', $pid);
|
||||
}
|
||||
}
|
||||
|
||||
$this->accounts->call('log', $uid, 've');
|
||||
$this->db->query("UPDATE account SET status='STD' WHERE id=$uid");
|
||||
|
||||
logText("Account $uid has left vacation mode");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
31
scripts/game/main/vacation/library/start.inc
Normal file
31
scripts/game/main/vacation/library/start.inc
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
class main_vacation_start {
|
||||
|
||||
function main_vacation_start($lib) {
|
||||
$this->lib = $lib;
|
||||
$this->db = $this->lib->game->db;
|
||||
$this->accounts = $this->lib->game->getLib('main/account');
|
||||
}
|
||||
|
||||
function run($uid) {
|
||||
foreach (config::getGames() as $game) {
|
||||
if ($game->name == 'main') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$lib = $game->getLib();
|
||||
$pid = $lib->call('doesUserPlay', $uid);
|
||||
if (!is_null($pid)) {
|
||||
$lib->call('startVacation', $pid);
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->query("UPDATE account SET status='VAC',vac_start=NULL,vac_credits=vac_credits-1 WHERE id=$uid");
|
||||
$this->accounts->call('log', $uid, 'vs');
|
||||
|
||||
logText("Account $uid has entered vacation mode");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Reference in a new issue