This repository has been archived on 2024-07-18. You can view files and clone it, but cannot push or open issues or pull requests.
lwb5/scripts/game/beta5/sale/library.inc

54 lines
1.1 KiB
PHP

<?php
class beta5_sale_library {
var $index = array(
'bid',
'buy',
'cancel',
'cancelTransfer',
'decline',
'getDirectSales',
'getFleetSale',
'getPlanetSale',
'getPublicSales',
'getSentOffers',
'sell'
);
function beta5_sale_library($lib) {
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
function getHistoryFrom($player) {
$q = $this->db->query("SELECT * FROM sale_history WHERE from_player=$player AND end_mode IS NOT NULL ORDER BY ended DESC,started DESC");
$rs = array();
while ($r = dbFetchHash($q)) {
array_push($rs,$r);
}
return $rs;
}
function getHistoryTo($player) {
$q = $this->db->query("SELECT * FROM sale_history WHERE to_player=$player AND mode<2 AND end_mode IS NOT NULL ORDER BY ended DESC,started DESC");
$rs = array();
while ($r = dbFetchHash($q)) {
array_push($rs,$r);
}
return $rs;
}
function isDirectOffer($pid, $oid) {
$q = $this->db->query(
"SELECT id FROM sale,private_offer WHERE offer=id AND to_player=$pid AND id=$oid "
. "AND (expires IS NULL OR UNIX_TIMESTAMP(NOW())-expires<0) AND finalized IS NULL"
);
return $q && (dbCount($q)==1);
}
}
?>