lwb5-in-2025/scripts/game/beta5/tech/library/declineOffer.inc

35 lines
943 B
PHP
Raw Normal View History

2016-01-10 11:01:49 +01:00
<?php
class beta5_tech_declineOffer {
2024-12-31 10:42:58 +01:00
function __construct($lib) {
2016-01-10 11:01:49 +01:00
$this->lib = $lib;
$this->db = $this->lib->game->db;
}
// Declines a research offer
function run($pid, $oid) {
$q = $this->db->query("SELECT * FROM research_assistance WHERE offer_to=$pid AND id=$oid AND (UNIX_TIMESTAMP(NOW())-moment<=86400)");
if (!($q && dbCount($q)==1)) {
return 4;
}
$r = dbFetchHash($q);
if (!is_null($r['accepted'])) {
return $r['accepted'] == 't' ? 2 : 3;
}
$this->db->query("UPDATE research_assistance SET accepted=FALSE WHERE id=$oid");
$tm = time();
$this->db->query("INSERT INTO message(player,sent_on,mtype,ftype,is_new) VALUES(".$r['player'].",$tm,'resdipl','INT',TRUE)");
$q = $this->db->query("SELECT id FROM message WHERE player=".$r['player']." AND sent_on=$tm AND ftype='INT'");
list($mid) = dbFetchArray($q);
$this->db->query("INSERT INTO msg_resdipl VALUES($mid,$oid,2)");
return 0;
}
}
?>