mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-17 13:01:42 +00:00
#1470 documentation update
This commit is contained in:
parent
f9e03406f1
commit
ae59aa9a2d
27 changed files with 122 additions and 343 deletions
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 9.7 KiB |
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
* The DataDispatcher is used to route data to atoms that requested it.
|
||||
* At first atoms will be registered. Later, when data comes in, it will be passed on to them.
|
||||
*/
|
||||
|
||||
class DataDispatcher {
|
||||
private $value;
|
||||
private $entity;
|
||||
|
@ -10,6 +15,8 @@
|
|||
$this->event = array();
|
||||
}
|
||||
|
||||
//registering atoms
|
||||
|
||||
function registerValue($name,$callback) {
|
||||
if(!is_array($this->value[$name])) {
|
||||
$this->value[$name] = array();
|
||||
|
@ -31,6 +38,8 @@
|
|||
$this->event[$name][] = $callback;
|
||||
}
|
||||
|
||||
//unregistering atoms
|
||||
|
||||
function unregisterValue($name,$callback) {
|
||||
$res = array_search($callback,$this->value[$name],true);
|
||||
if($res !== false) {
|
||||
|
@ -52,6 +61,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
//dispatching data
|
||||
|
||||
function dispatchValue($key,$val) {
|
||||
if(is_array($this->value[$key])) {
|
||||
foreach($this->value[$key] as $callback) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* This class is the wrapper for all loaded datasources. It will store them and pass the "drive" command on to them.
|
||||
*/
|
||||
class DataSourceHandler {
|
||||
private $source;
|
||||
|
||||
|
@ -10,7 +13,7 @@
|
|||
$this->source[] = $src;
|
||||
}
|
||||
|
||||
function drive($cid) {
|
||||
function drive($cid) { // tell the datasources to start reading data
|
||||
foreach($this->source as $elem) {
|
||||
$elem->drive($cid);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
* Unlike normal values, entities may contain several values. This is their wrapper.
|
||||
*/
|
||||
abstract class Entity {
|
||||
private $name;
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
* Logging, logging, logging....
|
||||
*/
|
||||
|
||||
class Logfile {
|
||||
private $logfile;
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
* Just to make sure every datasource has a drive() function...
|
||||
*/
|
||||
|
||||
abstract class SourceDriver {
|
||||
abstract function drive($cid);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
* The ValueCache allows to store data that persists outside from actual atom evaluation. One might want to check
|
||||
* if a value changes by xx since the last time parsing it, just as an example.
|
||||
*/
|
||||
class ValueCache {
|
||||
private $char;
|
||||
|
||||
|
@ -6,17 +10,17 @@
|
|||
$this->char = false;
|
||||
}
|
||||
|
||||
function setChar($c) {
|
||||
function setChar($c) { // select the character
|
||||
$this->char = $c;
|
||||
}
|
||||
|
||||
function writeData($key,$val) {
|
||||
function writeData($key,$val) { // write to cache
|
||||
global $DBc;
|
||||
|
||||
$DBc->sendSQL("INSERT INTO ach_player_valuecache (apv_name,apv_player,apv_value,apv_date) VALUES ('".$this->user."','".$DBc->mre($key)."','".$DBc->mre($val)."','".time()."') ON DUPLICATE KEY UPDATE apv_value='".$DBc->mre($val)."', apv_date='".time()."'","NONE");
|
||||
}
|
||||
|
||||
function getData($key) {
|
||||
function getData($key) { // read from cache
|
||||
global $DBc;
|
||||
|
||||
$res = $DBc->sendSQL("SELECT apv_value as value, apv_date as date FROM ach_player_valuecache WHERE apv_name='".$DBc->mre($key)."' AND apv_player='".$this->char."'","ARRAY");
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
/*
|
||||
* MySQL connection class
|
||||
*/
|
||||
class mySQL {
|
||||
var $DBc;
|
||||
var $DBstats;
|
||||
var $cached;
|
||||
|
||||
function mre($in) {
|
||||
function mre($in) { // shorter than "mysql_real_escape_string"
|
||||
if(is_array($in)) {
|
||||
foreach($in as $key=>$elem) {
|
||||
$in[$key] = mysql_real_escape_string(stripslashes($elem));
|
||||
|
@ -16,20 +19,21 @@
|
|||
return $in;
|
||||
}
|
||||
|
||||
function mySQL($err=false) {
|
||||
function mySQL($err=false) { // constructor
|
||||
$this->DBstats = array();
|
||||
$this->DBc = false;
|
||||
//set error handling
|
||||
if($err === "DIE" || $err === "PRINT" || $err === "ALERT" || $err === "HIDE" || $err === "LOG") {
|
||||
$this->DBerror = $err;
|
||||
}
|
||||
else {
|
||||
$this->DBerror = "HIDE";
|
||||
}
|
||||
$this->resetStats();
|
||||
$this->resetStats(); // reset stats counter
|
||||
$this->cached = false;
|
||||
}
|
||||
|
||||
function connect($ip,$user,$pass,$db=false) {
|
||||
function connect($ip,$user,$pass,$db=false) { // connect
|
||||
$this->DBc = mysql_pconnect($ip,$user,$pass) or $this->error(mysql_error());
|
||||
if($this->DBc && $db) {
|
||||
$this->database($db);
|
||||
|
@ -37,7 +41,7 @@
|
|||
$this->resetStats();
|
||||
}
|
||||
|
||||
function database($db) {
|
||||
function database($db) { // set database
|
||||
if(!$this->DBc) {
|
||||
return false;
|
||||
}
|
||||
|
@ -49,14 +53,11 @@
|
|||
$this->DBstats['error'] = 0;
|
||||
}
|
||||
|
||||
function getStats() {
|
||||
function getStats() { // return stats
|
||||
return $this->DBstats;
|
||||
}
|
||||
|
||||
function sendSQL($query,$handling="PLAIN",$buffer=false) { // can be INSERT, DELETE, UPDATE, ARRAY, NONE, PLAIN
|
||||
#if($this->cached !== false) {
|
||||
#$this->unlinkSql($this->cached);
|
||||
#}
|
||||
if(!$this->DBc) {
|
||||
return false;
|
||||
}
|
||||
|
@ -68,8 +69,6 @@
|
|||
$res = mysql_query($query,$this->DBc) or $this->error(mysql_error(),$query);
|
||||
}
|
||||
|
||||
#$this->cached = $res;
|
||||
|
||||
$this->DBstats['query']++;
|
||||
|
||||
if($res) {
|
||||
|
@ -95,7 +94,6 @@
|
|||
else {
|
||||
return $res;
|
||||
}
|
||||
//mysql_free_result($res);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -131,7 +129,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
private function error($error,$query = false) {
|
||||
private function error($error,$query = false) { // error handler
|
||||
global $log;
|
||||
|
||||
$this->DBstats['error']++;
|
||||
|
|
|
@ -1,22 +1,4 @@
|
|||
<?php
|
||||
function logf($txt,$nl = true) {
|
||||
global $logfile;
|
||||
if($logfile) {
|
||||
if($nl) {
|
||||
$txt .= "\n";
|
||||
}
|
||||
$logfile->append("[".date('H:i:s',time())."] ".$txt);
|
||||
}
|
||||
}
|
||||
|
||||
function logi($txt,$i = 1) {
|
||||
$tmp = "";
|
||||
for($v=0;$v<$i;$v++) {
|
||||
$tmp .= " ";
|
||||
}
|
||||
return $tmp."> ".$txt;
|
||||
}
|
||||
|
||||
function dateTime_to_timestamp($dt) {
|
||||
#2012-05-12 00:26:40
|
||||
$tmp = explode(" ",$dt);
|
||||
|
@ -31,7 +13,7 @@
|
|||
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($c, CURLOPT_URL, $URL);
|
||||
$contents = curl_exec($c);
|
||||
$err = curl_getinfo($c,CURLINFO_HTTP_CODE);
|
||||
#$err = curl_getinfo($c,CURLINFO_HTTP_CODE);
|
||||
curl_close($c);
|
||||
if ($contents) return $contents;
|
||||
else return FALSE;
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
* This is an example for evaluation scripts taken from the Ryzom Armory and adapted... it is a mess!
|
||||
*/
|
||||
|
||||
@include_once("script/include_InPoly_class.php");
|
||||
|
||||
function in_region($pos,$where) {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
* This is the XML parser. It is set to extract most of the useful information from XML files generated from PDR
|
||||
*/
|
||||
|
||||
$BASE_PATH = dirname(__FILE__);
|
||||
|
||||
require_once($BASE_PATH."/entity/FactionPoints_entity.php");
|
||||
|
@ -11,7 +15,7 @@
|
|||
require_once($BASE_PATH."/entity/PhysCharacs_entity.php");
|
||||
require_once($BASE_PATH."/entity/PhysScores_entity.php");
|
||||
require_once($BASE_PATH."/entity/SkillPoints_entity.php");
|
||||
require_once($BASE_PATH."/entity/Skills_entity.php");
|
||||
#require_once($BASE_PATH."/entity/Skills_entity.php");
|
||||
require_once($BASE_PATH."/entity/SpentSkillPoints_entity.php");
|
||||
require_once($BASE_PATH."/entity/Position_entity.php");
|
||||
require_once($BASE_PATH."/entity/Gear_entity.php");
|
||||
|
@ -19,7 +23,6 @@
|
|||
require_once($BASE_PATH."/entity/MissionList_entity.php");
|
||||
|
||||
class PDRtoXMLdriver extends SourceDriver {
|
||||
private $conf;
|
||||
private $ignore;
|
||||
private $ignore_block;
|
||||
private $lock;
|
||||
|
@ -31,11 +34,6 @@
|
|||
private $skills;
|
||||
|
||||
function PDRtoXMLdriver() {
|
||||
require_once("conf.php");
|
||||
|
||||
$this->conf = $_CONF;
|
||||
|
||||
|
||||
$this->lock = 0;
|
||||
$this->open = null;
|
||||
$this->entity = null;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?php
|
||||
$_CONF = array();
|
||||
|
||||
$_CONF['xml_dir'] = ".";
|
||||
|
||||
?>
|
BIN
code/web/app/app_achievements/_doc/ER & Class Schema.pdf
Normal file
BIN
code/web/app/app_achievements/_doc/ER & Class Schema.pdf
Normal file
Binary file not shown.
Binary file not shown.
|
@ -1,211 +0,0 @@
|
|||
-- phpMyAdmin SQL Dump
|
||||
-- version 3.3.3
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Erstellungszeit: 28. Mai 2012 um 21:07
|
||||
-- Server Version: 5.1.46
|
||||
-- PHP-Version: 5.3.2
|
||||
|
||||
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8 */;
|
||||
|
||||
--
|
||||
-- Datenbank: `app_achievements`
|
||||
--
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_achievement`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_achievement` (`aa_id`, `aa_category`, `aa_parent`, `aa_tie_race`, `aa_tie_cult`, `aa_tie_civ`, `aa_image`) VALUES
|
||||
(1, 1, NULL, NULL, NULL, NULL, ''),
|
||||
(2, 1, NULL, NULL, NULL, NULL, ''),
|
||||
(3, 1, NULL, NULL, NULL, NULL, ''),
|
||||
(4, 1, NULL, NULL, NULL, NULL, '');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_achievement_lang`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_achievement_lang` (`aal_achievement`, `aal_lang`, `aal_name`) VALUES
|
||||
(1, 'en', 'Kill the Bait'),
|
||||
(2, 'en', 'Grill the Bill'),
|
||||
(3, 'en', 'Killing Spree'),
|
||||
(4, 'en', 'The Burning Desert');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_atom`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_atom` (`atom_id`, `atom_objective`, `atom_mandatory`, `atom_ruleset`, `atom_primary`) VALUES
|
||||
(1, 13, 0, '', 0);
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_category`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_category` (`ac_id`, `ac_parent`, `ac_order`, `ac_image`) VALUES
|
||||
(1, NULL, 20, ''),
|
||||
(2, NULL, 40, ''),
|
||||
(3, 1, 2000, ''),
|
||||
(4, 1, 2000, ''),
|
||||
(5, 1, 2000, ''),
|
||||
(6, NULL, 70, ''),
|
||||
(7, NULL, 30, ''),
|
||||
(8, NULL, 50, ''),
|
||||
(9, NULL, 10, ''),
|
||||
(10, 1, 2000, ''),
|
||||
(11, 1, 2010, ''),
|
||||
(12, 8, 5000, ''),
|
||||
(13, 8, 5000, ''),
|
||||
(14, 8, 5000, ''),
|
||||
(15, 8, 5000, ''),
|
||||
(16, 6, 7010, ''),
|
||||
(17, 6, 7020, ''),
|
||||
(18, 6, 7200, ''),
|
||||
(19, 7, 3010, ''),
|
||||
(20, 7, 3010, ''),
|
||||
(21, 7, 3020, ''),
|
||||
(22, 7, 3020, ''),
|
||||
(23, 7, 3020, ''),
|
||||
(24, 7, 3030, ''),
|
||||
(25, 7, 3040, ''),
|
||||
(26, 7, 3020, ''),
|
||||
(27, 6, 7100, ''),
|
||||
(28, NULL, 60, ''),
|
||||
(29, 28, 6010, ''),
|
||||
(30, 28, 6020, ''),
|
||||
(31, NULL, 80, '');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_category_lang`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_category_lang` (`acl_category`, `acl_lang`, `acl_name`) VALUES
|
||||
(1, 'en', 'Exploration'),
|
||||
(2, 'en', 'Occupations'),
|
||||
(3, 'en', 'Aeden Aqueous'),
|
||||
(4, 'en', 'Burning Desert'),
|
||||
(5, 'en', 'Witherings'),
|
||||
(6, 'en', 'The Saga of Ryzom'),
|
||||
(7, 'en', 'Fame'),
|
||||
(8, 'en', 'Skills'),
|
||||
(9, 'en', 'General'),
|
||||
(10, 'en', 'Verdant Heights'),
|
||||
(11, 'en', 'Prime Roots'),
|
||||
(12, 'en', 'Craft'),
|
||||
(13, 'en', 'Fight'),
|
||||
(14, 'en', 'Harvest'),
|
||||
(15, 'en', 'Magic'),
|
||||
(16, 'en', 'Episode I'),
|
||||
(17, 'en', 'Episode II'),
|
||||
(18, 'en', 'Legacy'),
|
||||
(19, 'en', 'Civilizations'),
|
||||
(20, 'en', 'Higher Powers'),
|
||||
(21, 'en', 'Aeden Aqueous'),
|
||||
(22, 'en', 'Burning Desert'),
|
||||
(23, 'en', 'Verdant Heights'),
|
||||
(24, 'en', 'The Nexus'),
|
||||
(25, 'en', 'Prime Roots'),
|
||||
(26, 'en', 'Witherings'),
|
||||
(27, 'en', 'Encyclopedia'),
|
||||
(28, 'en', 'PvP'),
|
||||
(29, 'en', 'Civilizations'),
|
||||
(30, 'en', 'Higher Powers'),
|
||||
(31, 'en', 'Ryzom Ring');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_objective`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_objective` (`ao_id`, `ao_perk`, `ao_condition`, `ao_value`, `ao_display`) VALUES
|
||||
(1, 1, 'all', NULL, 'simple'),
|
||||
(2, 1, 'all', NULL, 'simple'),
|
||||
(3, 1, 'all', NULL, 'simple'),
|
||||
(4, 1, 'all', NULL, 'simple'),
|
||||
(5, 1, 'all', NULL, 'simple'),
|
||||
(6, 2, 'all', NULL, 'hidden'),
|
||||
(7, 3, 'all', 30, 'value'),
|
||||
(8, 4, 'all', NULL, 'meta'),
|
||||
(9, 4, 'all', NULL, 'meta'),
|
||||
(10, 4, 'all', NULL, 'meta'),
|
||||
(11, 4, 'all', NULL, 'meta'),
|
||||
(12, 4, 'all', NULL, 'meta'),
|
||||
(13, 3, 'all', 30, 'value');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_objective_lang`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_objective_lang` (`aol_objective`, `aol_lang`, `aol_name`) VALUES
|
||||
(1, 'en', 'Kill A'),
|
||||
(2, 'en', 'Kill B'),
|
||||
(3, 'en', 'Kill C'),
|
||||
(4, 'en', 'Kill D'),
|
||||
(5, 'en', 'Kill E'),
|
||||
(7, 'en', 'Kill 30 random Yubos'),
|
||||
(8, 'en', 'Meta A'),
|
||||
(9, 'en', 'Meta B'),
|
||||
(10, 'en', 'Meta C'),
|
||||
(11, 'en', 'Meta D'),
|
||||
(12, 'en', 'Meta E'),
|
||||
(13, 'en', 'Kill 30 random Gingos');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_perk`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_perk` (`ap_id`, `ap_achievement`, `ap_parent`, `ap_value`) VALUES
|
||||
(1, 1, NULL, 50),
|
||||
(2, 2, NULL, 10),
|
||||
(3, 3, NULL, 10),
|
||||
(4, 4, NULL, 20),
|
||||
(5, 2, NULL, 10),
|
||||
(6, 2, NULL, 10);
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_perk_lang`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_perk_lang` (`apl_perk`, `apl_lang`, `apl_name`) VALUES
|
||||
(1, 'en', 'Murder every boss listed below'),
|
||||
(2, 'en', 'Grill "Bill the Vile"'),
|
||||
(3, 'en', 'Kill 30 of each mob type listed below'),
|
||||
(4, 'en', 'Explore all regions of the Burning Desert'),
|
||||
(5, 'en', 'Grill "Peter the Pan"'),
|
||||
(6, 'en', 'Grill "Ivan the Slayer"');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_player_atom`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_player_atom` (`apa_atom`, `apa_player`, `apa_date`, `apa_expire`) VALUES
|
||||
(1, 1, 0, '');
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_player_objective`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_player_objective` (`apo_objective`, `apo_player`, `apo_date`) VALUES
|
||||
(4, 1, 500),
|
||||
(7, 1, 500),
|
||||
(11, 1, 500);
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_player_perk`
|
||||
--
|
||||
|
||||
INSERT INTO `ach_player_perk` (`app_perk`, `app_player`, `app_date`) VALUES
|
||||
(2, 1, 600),
|
||||
(5, 1, 100);
|
||||
|
||||
--
|
||||
-- Daten für Tabelle `ach_player_valuecache`
|
||||
--
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
$this->AVLpreorder($this->root);
|
||||
}
|
||||
|
||||
private function AVLpreorder($p) {
|
||||
private function AVLpreorder($p) { // recursive; output preorder representation
|
||||
if($p != null) {
|
||||
echo $p->getID().", ";
|
||||
$this->AVLpreorder($p->getLeft());
|
||||
|
@ -32,7 +32,7 @@
|
|||
$this->AVLinorder($this->root);
|
||||
}
|
||||
|
||||
private function AVLinorder($p) {
|
||||
private function AVLinorder($p) { // recursive; output postorder representation
|
||||
if($p != null) {
|
||||
$this->AVLinorder($p->getLeft());
|
||||
echo $p->getID().", ";
|
||||
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
function insert($node) {
|
||||
function insert($node) { // insert a new node
|
||||
if($this->root == null) {
|
||||
$this->root = new AVLTreeNode($node);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
function remove($id) {
|
||||
function remove($id) { // remove a node
|
||||
$n = $this->AVLfind($id,$this->root);
|
||||
|
||||
if($n != null) {
|
||||
|
@ -59,8 +59,7 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
function find($id) {
|
||||
#echo "<br>search!";
|
||||
function find($id) { // find a node
|
||||
$res = $this->AVLfind($id,$this->root);
|
||||
if($res != null) {
|
||||
return $res->getNode();
|
||||
|
@ -68,10 +67,8 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
private function AVLfind($id,$n) {
|
||||
#echo "<br>".$id;
|
||||
private function AVLfind($id,$n) { // recursive; search for a node
|
||||
if($n != null) {
|
||||
#echo "<br>searching for ".$id." compare to ".$n->getID();
|
||||
if($n->getID() != $id) {
|
||||
if($n->getID() > $id) {
|
||||
$n = $this->AVLfind($id,$n->getLeft());
|
||||
|
@ -85,7 +82,7 @@
|
|||
return $n;
|
||||
}
|
||||
|
||||
private function AVLremove($r,$n) {
|
||||
private function AVLremove($r,$n) { // remove a node from the actual tree
|
||||
if($n->getLeft() == null || $n->getRight() == null) {
|
||||
$s = $n;
|
||||
}
|
||||
|
@ -121,7 +118,7 @@
|
|||
return $r;
|
||||
}
|
||||
|
||||
private function AVLinsert($r,$n) {
|
||||
private function AVLinsert($r,$n) { // insert a node into the actual tree
|
||||
if($r == null) {
|
||||
$r = $n;
|
||||
}
|
||||
|
@ -129,12 +126,12 @@
|
|||
if($n->getID() < $r->getID()) {
|
||||
$r->setLeft($this->AVLinsert($r->getLeft(),$n));
|
||||
|
||||
$r = $this->balance($r);
|
||||
$r = $this->balance($r); // rebalance
|
||||
}
|
||||
elseif($n->getID() > $r->getID()) {
|
||||
$r->setRight($this->AVLinsert($r->getRight(),$n));
|
||||
|
||||
$r = $this->balance($r);
|
||||
$r = $this->balance($r); // rebalance
|
||||
}
|
||||
|
||||
$r->setHeight(max($r->getHeightLeft(),$r->getHeightRight())+1);
|
||||
|
@ -143,8 +140,7 @@
|
|||
return $r;
|
||||
}
|
||||
|
||||
private function balance($r) {
|
||||
#return $r;
|
||||
private function balance($r) { // do a rebalancation of the tree
|
||||
if($r->bal() == -2) {
|
||||
$lc = $r->getLeft();
|
||||
if($lc->getHeightLeft() >= $lc->getHeightRight()) {
|
||||
|
@ -168,8 +164,7 @@
|
|||
return $r;
|
||||
}
|
||||
|
||||
private function Successor($r) {
|
||||
#echo "succ: ".$r->getID();
|
||||
private function Successor($r) { // find the successor for a node
|
||||
if($r->getRight() != null) {
|
||||
return $this->Minimum($r->getRight());
|
||||
}
|
||||
|
@ -184,7 +179,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
private function Minimum($r) {
|
||||
private function Minimum($r) { // find the minimum of a tree
|
||||
if($r == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -201,6 +196,8 @@
|
|||
return $p;
|
||||
}
|
||||
|
||||
//rotations
|
||||
|
||||
private function RotateToRight($r) {
|
||||
if($this->debug) {
|
||||
echo "rotaRight<br>";
|
||||
|
@ -238,8 +235,14 @@
|
|||
$r->setRight($this->RotateToRight($r->getRight()));
|
||||
return $this->RotateToLeft($r);
|
||||
}
|
||||
|
||||
//end rotations
|
||||
}
|
||||
|
||||
/*
|
||||
* AVL tree nodes
|
||||
*/
|
||||
|
||||
class AVLTreeNode {
|
||||
private $height;
|
||||
private $left;
|
||||
|
@ -249,10 +252,10 @@
|
|||
|
||||
function AVLTreeNode($node) {
|
||||
$this->height = 0;
|
||||
$this->left = null;
|
||||
$this->right = null;
|
||||
$this->node = $node;
|
||||
$this->parent = null;
|
||||
$this->left = null; // left child
|
||||
$this->right = null; // right child
|
||||
$this->node = $node; // actual data stored
|
||||
$this->parent = null; // parent node
|
||||
}
|
||||
|
||||
function getParent() {
|
||||
|
@ -289,7 +292,7 @@
|
|||
return $this->right->getHeight();
|
||||
}
|
||||
|
||||
function bal() {
|
||||
function bal() { // calculate value to eval balancing
|
||||
$r = -1;
|
||||
$l = -1;
|
||||
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
* The Achievement class that holds one achievement. It is able to load one an the same task an treat is as both,
|
||||
* open and done.
|
||||
*/
|
||||
|
||||
class AchAchievement extends AchList {
|
||||
#########################
|
||||
# PHP 5.3 compatible
|
||||
|
@ -44,9 +49,9 @@
|
|||
|
||||
parent::__construct();
|
||||
|
||||
$this->setParent($parent);
|
||||
$this->setParent($parent); // real parent node
|
||||
$this->setID($data['aa_id']);
|
||||
$this->parent_id = $data['aa_parent'];
|
||||
$this->parent_id = $data['aa_parent']; // id of parent
|
||||
$this->category = $data['aa_category'];
|
||||
$this->tie_race = $data['aa_tie_race'];
|
||||
$this->tie_civ = $data['aa_tie_civ'];
|
||||
|
@ -72,7 +77,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
function parentDone() {
|
||||
function parentDone() { // check if the parent is complete
|
||||
if($this->parent_id == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -83,19 +88,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
#@override Parentum::makeChild()
|
||||
protected function makeChild($a) {
|
||||
return new AchTask($a,$this);
|
||||
}
|
||||
|
||||
function unlockedByParent() {
|
||||
if($this->parent_id != null) {
|
||||
$tmp = $this->parent->getChildByID($this->parent_id);
|
||||
return ($tmp->hasOpen() == false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getParentID() {
|
||||
return $this->parent_id;
|
||||
}
|
||||
|
@ -120,7 +117,7 @@
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
function getValueDone() {
|
||||
function getValueDone() { // calculate the yubopoints that are already done
|
||||
$val = 0;
|
||||
$iter = $this->getDone();
|
||||
while($iter->hasNext()) {
|
||||
|
@ -130,7 +127,7 @@
|
|||
return $val;
|
||||
}
|
||||
|
||||
function getValueOpen() {
|
||||
function getValueOpen() { // get the yubopoints of the next open task
|
||||
$iter = $this->getOpen();
|
||||
if($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
|
@ -139,7 +136,7 @@
|
|||
return 0;
|
||||
}
|
||||
|
||||
function fillTemplate($insert = array()) {
|
||||
function fillTemplate($insert = array()) { // fill the naming template with given value
|
||||
if($this->template == null) {
|
||||
return implode(";",$insert);
|
||||
}
|
||||
|
@ -170,7 +167,7 @@
|
|||
return ($this->sticky == 1);
|
||||
}
|
||||
|
||||
function isHeroic() {
|
||||
function isHeroic() { // check parent category if it is heroic
|
||||
return $this->parent->isHeroic();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
/*
|
||||
* Category class that is loading all achievements tied to it.
|
||||
*/
|
||||
|
||||
class AchCategory extends AchList implements Tieable {
|
||||
protected $ties_cult;
|
||||
protected $ties_civ;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
$this->addChild($this->makeChild($res[$i]));
|
||||
}
|
||||
|
||||
#echo var_export($this->nodes->findNode(1),true);
|
||||
}
|
||||
|
||||
function getOpen() { // just returns the previously set ID of the currently open MenuNode
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
* Doubly Linked List
|
||||
*
|
||||
* This list is linked to an avl tree for searching purpose!
|
||||
*/
|
||||
class DLL {
|
||||
private $first;
|
||||
private $last;
|
||||
|
@ -34,7 +39,7 @@
|
|||
return $this->last;
|
||||
}
|
||||
|
||||
function addNode($data,$before = null) {
|
||||
function addNode($data,$before = null) { // add a node
|
||||
if($this->findNode($data->getID()) != null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -71,13 +76,13 @@
|
|||
$this->first = $n;
|
||||
}
|
||||
|
||||
$this->avl->insert($n);
|
||||
$this->avl->insert($n); // pass on to avl tree
|
||||
$this->size++;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function removeNode($id) {
|
||||
function removeNode($id) { // remove a node
|
||||
$this->avl->inorder();
|
||||
|
||||
$n = $this->findNode($id);
|
||||
|
@ -109,7 +114,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
$this->avl->remove($id);
|
||||
$this->avl->remove($id); // pass on to avl tree
|
||||
$this->size--;
|
||||
}
|
||||
|
||||
|
@ -120,6 +125,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* List nodes
|
||||
*/
|
||||
|
||||
class DLLnode {
|
||||
private $parent;
|
||||
private $child;
|
||||
|
@ -128,7 +137,7 @@
|
|||
function DLLNode($d) {
|
||||
$this->parent = null;
|
||||
$this->child = null;
|
||||
$this->data = $d;
|
||||
$this->data = $d; // actual data
|
||||
}
|
||||
|
||||
final function getParent() {
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
$this->nodes->removeNode($id);
|
||||
}
|
||||
|
||||
function getChildByID($id) {
|
||||
function getChildByID($id) { // returns a DLL node
|
||||
return $this->nodes->findNode($id);
|
||||
}
|
||||
|
||||
function getChildDataByID($id) {
|
||||
function getChildDataByID($id) { // returns the actual content of the found DLL node
|
||||
$tmp = $this->getChildByID($id);
|
||||
if($tmp != null) {
|
||||
return $tmp->data;
|
||||
|
|
|
@ -223,9 +223,7 @@
|
|||
$iter = $cat->getDone();
|
||||
while($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
#$sz = sizeof($tmp);
|
||||
#for($i=0;$i<$sz;$i++) {
|
||||
#echo "A";
|
||||
|
||||
if($curr->inDev() || !$curr->parentDone()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -239,9 +237,7 @@
|
|||
$iter = $cat->getOpen();
|
||||
while($iter->hasNext()) {
|
||||
$curr = $iter->getNext();
|
||||
#$sz = sizeof($tmp);
|
||||
#for($i=0;$i<$sz;$i++) {
|
||||
#echo "B";
|
||||
|
||||
if($curr->inDev() || !$curr->parentDone()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -367,7 +363,7 @@
|
|||
$skip = false;
|
||||
|
||||
while($obj->hasNext()) {
|
||||
#foreach($obj as $elem) {
|
||||
|
||||
$elem = $obj->getNext();
|
||||
if(($i%2) == 0) {
|
||||
$html .= "<tr>";
|
||||
|
|
|
@ -60,7 +60,6 @@ require_once("fb/facebook.php");
|
|||
// Update user acces on Db
|
||||
$DBc = ryDB::getInstance(APP_NAME."_test");
|
||||
#$DBc = ryDB::getInstance(APP_NAME);
|
||||
#$DBc = ryDB::getInstance("ahufler");
|
||||
|
||||
$c = "";
|
||||
if(!$_USER->isIG()) {
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
return new AdmAtom($d,$this);
|
||||
}
|
||||
|
||||
function getLang($lang) {
|
||||
function getLang($lang) { // load language
|
||||
global $DBc;
|
||||
|
||||
$res = $DBc->sqlQuery("SELECT * FROM ach_objective_lang WHERE aol_objective='".$this->getID()."' AND aol_lang='".$lang."'");
|
||||
|
@ -80,7 +80,7 @@
|
|||
return $res[0]['aol_name'];
|
||||
}
|
||||
|
||||
function setLang($lang,$txt) {
|
||||
function setLang($lang,$txt) { // write language
|
||||
global $DBc,$_USER;
|
||||
|
||||
$DBc->sqlQuery("INSERT INTO ach_objective_lang (aol_task,aol_lang,aol_name) VALUES ('".$this->getID()."','".$DBc->sqlEscape($lang)."','".$DBc->sqlEscape($txt)."') ON DUPLICATE KEY UPDATE aol_name='".$DBc->sqlEscape($txt)."'");
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
return new AdmObjective($d,$this);
|
||||
}
|
||||
|
||||
function getLang($lang) {
|
||||
function getLang($lang) { // load language
|
||||
global $DBc;
|
||||
|
||||
$res = $DBc->sqlQuery("SELECT * FROM ach_task_lang WHERE atl_task='".$this->getID()."' AND atl_lang='".$lang."'");
|
||||
|
@ -80,7 +80,7 @@
|
|||
return array(0=>$res[0]['atl_name'],1=>$res[0]['atl_template']);
|
||||
}
|
||||
|
||||
function setLang($lang,$txt,$tpl) {
|
||||
function setLang($lang,$txt,$tpl) { // write language
|
||||
global $DBc,$_USER;
|
||||
|
||||
$DBc->sqlQuery("INSERT INTO ach_task_lang (atl_task,atl_lang,atl_name,atl_template) VALUES ('".$this->getID()."','".$DBc->sqlEscape($lang)."','".$DBc->sqlEscape($txt)."',".mkn($tpl).") ON DUPLICATE KEY UPDATE apl_name='".$DBc->sqlEscape($txt)."',apl_template=".mkn($tpl)."");
|
||||
|
|
|
@ -35,8 +35,6 @@ if($_ADMIN->isIG()) {
|
|||
|
||||
require_once("class/mySQL_class.php");
|
||||
|
||||
#require_once("include/ach_render_admin.php");
|
||||
#require_once("include/ach_render_csr.php");
|
||||
require_once($_CONF['app_achievements_path']."include/ach_render_common.php");
|
||||
|
||||
require_once($_CONF['app_achievements_path']."class/DLL_class.php");
|
||||
|
@ -68,7 +66,6 @@ require_once("class/AdmAtom_class.php");
|
|||
|
||||
#require_once("class/CSRDispatcher_trait.php");
|
||||
require_once("class/CSR_inter.php");
|
||||
#require_once("class/CSRMenu_class.php");
|
||||
require_once("class/CSRCategory_class.php");
|
||||
require_once("class/CSRAchievement_class.php");
|
||||
require_once("class/CSRTask_class.php");
|
||||
|
@ -76,13 +73,10 @@ require_once("class/CSRObjective_class.php");
|
|||
require_once("class/CSRAtom_class.php");
|
||||
|
||||
$DBc = ryDB::getInstance("app_achievements_test");
|
||||
#$DBc = ryDB::getInstance("ahufler");
|
||||
|
||||
function mkn($x) {
|
||||
global $DBc;
|
||||
#echo "<br>".$x." =>";
|
||||
if($x == null || strtolower($x) == "null" || $x == "") {
|
||||
#echo "NULL";
|
||||
return "NULL";
|
||||
}
|
||||
else {
|
||||
|
@ -139,7 +133,6 @@ $c = "<script type='text/javascript'>
|
|||
}
|
||||
|
||||
|
||||
#$c .= ach_render_menu();
|
||||
|
||||
$c .= "</div></td>
|
||||
<td valign='top'>";
|
||||
|
@ -211,9 +204,6 @@ $c .= "</div></td>
|
|||
$c .= atom_render_category($cat);
|
||||
}
|
||||
|
||||
#a:p:o:a
|
||||
|
||||
|
||||
|
||||
$c .= "</td>
|
||||
</tr>
|
||||
|
@ -286,10 +276,6 @@ $c .= "</div></td>
|
|||
$c .= atom_render_category($cat);
|
||||
}
|
||||
|
||||
#a:p:o:a
|
||||
|
||||
|
||||
|
||||
$c .= "</td>
|
||||
</tr>
|
||||
</table></center>";
|
||||
|
@ -546,15 +532,10 @@ $c .= "</div></td>
|
|||
echo "<br>rendering: ".round($stop_time - $start_time,3);
|
||||
}
|
||||
|
||||
#a:p:o:a
|
||||
|
||||
|
||||
|
||||
$c .= "</td>
|
||||
</tr>
|
||||
</table></center>";
|
||||
|
||||
//category
|
||||
}
|
||||
|
||||
if($_REQUEST['mode'] == "player" && $_ADMIN->isCSR()) {
|
||||
|
@ -609,7 +590,6 @@ $c .= "</div></td>
|
|||
$c .= "</div></td>
|
||||
<td width='645px' valign='top'>";
|
||||
|
||||
#$open = $menu->getOpenCat();
|
||||
|
||||
if($open != 0) {
|
||||
$c .= csr_render_category($cat);
|
||||
|
@ -630,8 +610,6 @@ $c .= "</div></td>
|
|||
|
||||
}
|
||||
|
||||
#$c .= ach_render_content();
|
||||
|
||||
$c .= "</td>
|
||||
</tr>
|
||||
</table></center>";
|
||||
|
|
Loading…
Reference in a new issue