mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 23:06:18 +00:00
#1470 misc
This commit is contained in:
parent
ef7eff1cc9
commit
8b3ea34c5a
8 changed files with 66 additions and 36 deletions
|
@ -1,5 +1,13 @@
|
|||
<?php
|
||||
class AVLTree {
|
||||
/*---------------------------
|
||||
AVL trees are balanced B-Trees. Please refer to http://en.wikipedia.org/wiki/AVL_tree
|
||||
|
||||
This implementation allows the functions insert, find and remove. Please
|
||||
note, that remove does not rebalance the tree, since node removal is
|
||||
quite rare in this project.
|
||||
---------------------------*/
|
||||
|
||||
private $root;
|
||||
private $debug;
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
function AchCategory($id,$cult = null,$civ = null) {
|
||||
global $DBc,$_USER;
|
||||
|
||||
$civ = mysql_real_escape_string($civ);
|
||||
$cult = mysql_real_escape_string($cult);
|
||||
|
||||
if($cult == null) {
|
||||
$cult = $_USER->getCult();
|
||||
}
|
||||
|
@ -24,7 +27,8 @@
|
|||
|
||||
$this->id = mysql_real_escape_string($id);
|
||||
|
||||
$res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND (aa_parent IS NULL OR NOT EXISTS (SELECT * FROM ach_perk WHERE ap_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$_USER->getID()."' AND app_perk=ap_id))) AND (aa_tie_race IS NULL OR aa_tie_race='".$_USER->getRace()."') AND (aa_tie_cult IS NULL OR aa_tie_cult='".mysql_real_escape_string($cult)."') AND (aa_tie_civ IS NULL OR aa_tie_civ='".mysql_real_escape_string($civ)."') ORDER by aal_name ASC");
|
||||
$res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND (aa_parent IS NULL OR NOT EXISTS (SELECT * FROM ach_perk WHERE ap_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$_USER->getID()."' AND app_perk=ap_id))) AND (aa_tie_race IS NULL OR aa_tie_race LIKE '".$_USER->getRace()."') AND (aa_tie_cult IS NULL OR aa_tie_cult LIKE '".$cult."') AND (aa_tie_civ IS NULL OR aa_tie_civ LIKE '".$civ."') ORDER by aal_name ASC");
|
||||
#parent!!!!
|
||||
|
||||
$sz = sizeof($res);
|
||||
for($i=0;$i<$sz;$i++) {
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<?php
|
||||
abstract class AchList extends Parentum {
|
||||
/*---------------------------
|
||||
This class organizes nodes to distinguish between "open" and "done" nodes.
|
||||
|
||||
child_open and child_done refer to the index set in Parentum::nodes[]
|
||||
---------------------------*/
|
||||
|
||||
protected $child_done = array();
|
||||
protected $child_open = array();
|
||||
|
||||
|
@ -43,11 +49,7 @@
|
|||
|
||||
final function removeChildDone($idx) {
|
||||
echo "try removing done child: ".$idx;
|
||||
#$res = array_search($idx,$this->child_done);
|
||||
#if($res != false) {
|
||||
# unset($this->child_done[$res]);
|
||||
# echo " ... done<br>";
|
||||
#}
|
||||
|
||||
foreach($this->child_done as $key=>$elem) {
|
||||
if($elem == $idx) {
|
||||
unset($this->child_done[$key]);
|
||||
|
@ -75,11 +77,6 @@
|
|||
final function removeChildOpen($idx) {
|
||||
echo "try removing open child: ".$idx;
|
||||
|
||||
#$res = array_search($idx,$this->child_open);
|
||||
#if($res != false) {
|
||||
# unset($this->child_open[$res]);
|
||||
# echo " ... done<br>";
|
||||
#}
|
||||
foreach($this->child_open as $key=>$elem) {
|
||||
if($elem == $idx) {
|
||||
unset($this->child_open[$key]);
|
||||
|
@ -90,25 +87,7 @@
|
|||
echo var_export($this->child_open,true);
|
||||
}
|
||||
|
||||
/*final function unsetOpen($idx) {
|
||||
foreach($this->child_open as $key=>$elem) {
|
||||
if($elem == $idx) {
|
||||
unset($this->child_open[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final function unsetDone($idx) {
|
||||
foreach($this->child_done as $key=>$elem) {
|
||||
if($elem == $idx) {
|
||||
unset($this->child_done[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
#OVERRIDE Parentum::removeChild()
|
||||
#@OVERRIDE Parentum::removeChild()
|
||||
function removeChild($id) {
|
||||
$n = parent::removeChild($id);
|
||||
if($n != false && $n != null) {
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<?php
|
||||
trait InDev {
|
||||
/*---------------------------
|
||||
This trait provides basic functionality used to
|
||||
handle "in development" flags.
|
||||
---------------------------*/
|
||||
|
||||
protected $dev;
|
||||
|
||||
function inDev() {
|
||||
|
@ -9,5 +14,20 @@
|
|||
function getDev() {
|
||||
return $this->dev;
|
||||
}
|
||||
|
||||
function setInDev($tf) {
|
||||
if($tf == true) {
|
||||
$this->setDev(1);
|
||||
}
|
||||
else {
|
||||
$this->setDev(0);
|
||||
}
|
||||
|
||||
$this->update();
|
||||
}
|
||||
|
||||
function setDev($d) {
|
||||
$this->dev = $d;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,5 +1,16 @@
|
|||
<?php
|
||||
class NodeIterator {
|
||||
/*---------------------------
|
||||
The NodeIterator can be used just like a foreach() loop to iterate
|
||||
arrays.
|
||||
|
||||
Sample:
|
||||
$iter = new NodeIterator(array());
|
||||
while($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
// ...
|
||||
}
|
||||
---------------------------*/
|
||||
private $nodes;
|
||||
private $curr;
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<?php
|
||||
trait Node {
|
||||
/*---------------------------
|
||||
This trait provides basic functionality common to nodes.
|
||||
|
||||
Every node has an id, and InDeX and a parent.
|
||||
---------------------------*/
|
||||
|
||||
protected $idx;
|
||||
protected $id;
|
||||
protected $parent;
|
||||
|
|
|
@ -42,10 +42,6 @@
|
|||
return $tmp;
|
||||
}
|
||||
|
||||
#function drawTree() {
|
||||
# $this->avl->inorder();
|
||||
#}
|
||||
|
||||
function removeChild($id) {
|
||||
if($this->isEmpty()) {
|
||||
return null;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<?php
|
||||
interface Tieable {
|
||||
/*---------------------------
|
||||
The Tieable interface is needed to define methods required
|
||||
by Parentum classes that have child nodes that vary depending
|
||||
on a user's cult of civ allegiance.
|
||||
---------------------------*/
|
||||
|
||||
function isTiedCult();
|
||||
|
||||
function isTiedCiv();
|
||||
|
|
Loading…
Reference in a new issue