mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-12 04:44:48 +00:00
51 lines
No EOL
1.2 KiB
PHP
51 lines
No EOL
1.2 KiB
PHP
<?php
|
|
class CSRObjective extends AchObjective implements CSR {
|
|
use CSRDispatcher;
|
|
|
|
#private $nodes;
|
|
|
|
function CSRObjective($data,$parent) {
|
|
parent::__construct($data,$parent);
|
|
|
|
global $DBc;
|
|
|
|
$res = $DBc->sqlQuery("SELECT atom_id FROM ach_atom WHERE atom_objective='".$this->getID()."'");
|
|
$sz = sizeof($res);
|
|
for($i=0;$i<$sz;$i++) {
|
|
$this->addChild($this->makeChild($res[$i]));
|
|
}
|
|
}
|
|
|
|
protected function makeChild($d) {
|
|
return new CSRAtom($d,$this);
|
|
}
|
|
|
|
function grant($pid) {
|
|
global $DBc;
|
|
|
|
$DBc->sqlQuery("INSERT INTO ach_player_objective (apo_objective,apo_player,apo_date) VALUES ('".$this->getID()."','".$pid."','".time()."')");
|
|
$this->done = 1;
|
|
$this->progress = $this->value;
|
|
|
|
$iter = $this->getIterator();
|
|
while($iter->hasNext()) {
|
|
$curr = $iter->getNext();
|
|
$curr->grant($pid);
|
|
}
|
|
}
|
|
|
|
function deny($pid) {
|
|
global $DBc;
|
|
|
|
$DBc->sqlQuery("DELETE FROM ach_player_objective WHERE apo_objective='".$this->getID()."' AND apo_player='".$pid."'");
|
|
$this->done = 0;
|
|
$this->progress = 0;
|
|
|
|
$iter = $this->getIterator();
|
|
while($iter->hasNext()) {
|
|
$curr = $iter->getNext();
|
|
$curr->deny($pid);
|
|
}
|
|
}
|
|
}
|
|
?>
|