#1470 documentation update

--HG--
branch : gsoc2012-achievements
This commit is contained in:
SirCotare 2012-08-20 17:41:46 +02:00
parent c888a5249e
commit d3b7289e56
27 changed files with 122 additions and 343 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

View file

@ -1,4 +1,9 @@
<?php <?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 { class DataDispatcher {
private $value; private $value;
private $entity; private $entity;
@ -10,6 +15,8 @@
$this->event = array(); $this->event = array();
} }
//registering atoms
function registerValue($name,$callback) { function registerValue($name,$callback) {
if(!is_array($this->value[$name])) { if(!is_array($this->value[$name])) {
$this->value[$name] = array(); $this->value[$name] = array();
@ -31,6 +38,8 @@
$this->event[$name][] = $callback; $this->event[$name][] = $callback;
} }
//unregistering atoms
function unregisterValue($name,$callback) { function unregisterValue($name,$callback) {
$res = array_search($callback,$this->value[$name],true); $res = array_search($callback,$this->value[$name],true);
if($res !== false) { if($res !== false) {
@ -52,6 +61,8 @@
} }
} }
//dispatching data
function dispatchValue($key,$val) { function dispatchValue($key,$val) {
if(is_array($this->value[$key])) { if(is_array($this->value[$key])) {
foreach($this->value[$key] as $callback) { foreach($this->value[$key] as $callback) {

View file

@ -1,4 +1,7 @@
<?php <?php
/*
* This class is the wrapper for all loaded datasources. It will store them and pass the "drive" command on to them.
*/
class DataSourceHandler { class DataSourceHandler {
private $source; private $source;
@ -10,7 +13,7 @@
$this->source[] = $src; $this->source[] = $src;
} }
function drive($cid) { function drive($cid) { // tell the datasources to start reading data
foreach($this->source as $elem) { foreach($this->source as $elem) {
$elem->drive($cid); $elem->drive($cid);
} }

View file

@ -1,4 +1,7 @@
<?php <?php
/*
* Unlike normal values, entities may contain several values. This is their wrapper.
*/
abstract class Entity { abstract class Entity {
private $name; private $name;

View file

@ -1,4 +1,8 @@
<?php <?php
/*
* Logging, logging, logging....
*/
class Logfile { class Logfile {
private $logfile; private $logfile;

View file

@ -1,4 +1,8 @@
<?php <?php
/*
* Just to make sure every datasource has a drive() function...
*/
abstract class SourceDriver { abstract class SourceDriver {
abstract function drive($cid); abstract function drive($cid);
} }

View file

@ -1,4 +1,8 @@
<?php <?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 { class ValueCache {
private $char; private $char;
@ -6,17 +10,17 @@
$this->char = false; $this->char = false;
} }
function setChar($c) { function setChar($c) { // select the character
$this->char = $c; $this->char = $c;
} }
function writeData($key,$val) { function writeData($key,$val) { // write to cache
global $DBc; 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"); $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; 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"); $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");

View file

@ -1,10 +1,13 @@
<?php <?php
/*
* MySQL connection class
*/
class mySQL { class mySQL {
var $DBc; var $DBc;
var $DBstats; var $DBstats;
var $cached; var $cached;
function mre($in) { function mre($in) { // shorter than "mysql_real_escape_string"
if(is_array($in)) { if(is_array($in)) {
foreach($in as $key=>$elem) { foreach($in as $key=>$elem) {
$in[$key] = mysql_real_escape_string(stripslashes($elem)); $in[$key] = mysql_real_escape_string(stripslashes($elem));
@ -16,20 +19,21 @@
return $in; return $in;
} }
function mySQL($err=false) { function mySQL($err=false) { // constructor
$this->DBstats = array(); $this->DBstats = array();
$this->DBc = false; $this->DBc = false;
//set error handling
if($err === "DIE" || $err === "PRINT" || $err === "ALERT" || $err === "HIDE" || $err === "LOG") { if($err === "DIE" || $err === "PRINT" || $err === "ALERT" || $err === "HIDE" || $err === "LOG") {
$this->DBerror = $err; $this->DBerror = $err;
} }
else { else {
$this->DBerror = "HIDE"; $this->DBerror = "HIDE";
} }
$this->resetStats(); $this->resetStats(); // reset stats counter
$this->cached = false; $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()); $this->DBc = mysql_pconnect($ip,$user,$pass) or $this->error(mysql_error());
if($this->DBc && $db) { if($this->DBc && $db) {
$this->database($db); $this->database($db);
@ -37,7 +41,7 @@
$this->resetStats(); $this->resetStats();
} }
function database($db) { function database($db) { // set database
if(!$this->DBc) { if(!$this->DBc) {
return false; return false;
} }
@ -49,14 +53,11 @@
$this->DBstats['error'] = 0; $this->DBstats['error'] = 0;
} }
function getStats() { function getStats() { // return stats
return $this->DBstats; return $this->DBstats;
} }
function sendSQL($query,$handling="PLAIN",$buffer=false) { // can be INSERT, DELETE, UPDATE, ARRAY, NONE, PLAIN 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) { if(!$this->DBc) {
return false; return false;
} }
@ -68,8 +69,6 @@
$res = mysql_query($query,$this->DBc) or $this->error(mysql_error(),$query); $res = mysql_query($query,$this->DBc) or $this->error(mysql_error(),$query);
} }
#$this->cached = $res;
$this->DBstats['query']++; $this->DBstats['query']++;
if($res) { if($res) {
@ -95,7 +94,6 @@
else { else {
return $res; return $res;
} }
//mysql_free_result($res);
} }
else { else {
return false; return false;
@ -131,7 +129,7 @@
} }
} }
private function error($error,$query = false) { private function error($error,$query = false) { // error handler
global $log; global $log;
$this->DBstats['error']++; $this->DBstats['error']++;

View file

@ -1,22 +1,4 @@
<?php <?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) { function dateTime_to_timestamp($dt) {
#2012-05-12 00:26:40 #2012-05-12 00:26:40
$tmp = explode(" ",$dt); $tmp = explode(" ",$dt);
@ -31,7 +13,7 @@
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL); curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c); $contents = curl_exec($c);
$err = curl_getinfo($c,CURLINFO_HTTP_CODE); #$err = curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c); curl_close($c);
if ($contents) return $contents; if ($contents) return $contents;
else return FALSE; else return FALSE;

View file

@ -1,4 +1,8 @@
<?php <?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"); @include_once("script/include_InPoly_class.php");
function in_region($pos,$where) { function in_region($pos,$where) {

View file

@ -1,4 +1,8 @@
<?php <?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__); $BASE_PATH = dirname(__FILE__);
require_once($BASE_PATH."/entity/FactionPoints_entity.php"); 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/PhysCharacs_entity.php");
require_once($BASE_PATH."/entity/PhysScores_entity.php"); require_once($BASE_PATH."/entity/PhysScores_entity.php");
require_once($BASE_PATH."/entity/SkillPoints_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/SpentSkillPoints_entity.php");
require_once($BASE_PATH."/entity/Position_entity.php"); require_once($BASE_PATH."/entity/Position_entity.php");
require_once($BASE_PATH."/entity/Gear_entity.php"); require_once($BASE_PATH."/entity/Gear_entity.php");
@ -19,7 +23,6 @@
require_once($BASE_PATH."/entity/MissionList_entity.php"); require_once($BASE_PATH."/entity/MissionList_entity.php");
class PDRtoXMLdriver extends SourceDriver { class PDRtoXMLdriver extends SourceDriver {
private $conf;
private $ignore; private $ignore;
private $ignore_block; private $ignore_block;
private $lock; private $lock;
@ -31,11 +34,6 @@
private $skills; private $skills;
function PDRtoXMLdriver() { function PDRtoXMLdriver() {
require_once("conf.php");
$this->conf = $_CONF;
$this->lock = 0; $this->lock = 0;
$this->open = null; $this->open = null;
$this->entity = null; $this->entity = null;

View file

@ -1,6 +0,0 @@
<?php
$_CONF = array();
$_CONF['xml_dir'] = ".";
?>

View file

@ -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`
--

View file

@ -20,7 +20,7 @@
$this->AVLpreorder($this->root); $this->AVLpreorder($this->root);
} }
private function AVLpreorder($p) { private function AVLpreorder($p) { // recursive; output preorder representation
if($p != null) { if($p != null) {
echo $p->getID().", "; echo $p->getID().", ";
$this->AVLpreorder($p->getLeft()); $this->AVLpreorder($p->getLeft());
@ -32,7 +32,7 @@
$this->AVLinorder($this->root); $this->AVLinorder($this->root);
} }
private function AVLinorder($p) { private function AVLinorder($p) { // recursive; output postorder representation
if($p != null) { if($p != null) {
$this->AVLinorder($p->getLeft()); $this->AVLinorder($p->getLeft());
echo $p->getID().", "; echo $p->getID().", ";
@ -40,7 +40,7 @@
} }
} }
function insert($node) { function insert($node) { // insert a new node
if($this->root == null) { if($this->root == null) {
$this->root = new AVLTreeNode($node); $this->root = new AVLTreeNode($node);
} }
@ -49,7 +49,7 @@
} }
} }
function remove($id) { function remove($id) { // remove a node
$n = $this->AVLfind($id,$this->root); $n = $this->AVLfind($id,$this->root);
if($n != null) { if($n != null) {
@ -59,8 +59,7 @@
return null; return null;
} }
function find($id) { function find($id) { // find a node
#echo "<br>search!";
$res = $this->AVLfind($id,$this->root); $res = $this->AVLfind($id,$this->root);
if($res != null) { if($res != null) {
return $res->getNode(); return $res->getNode();
@ -68,10 +67,8 @@
return null; return null;
} }
private function AVLfind($id,$n) { private function AVLfind($id,$n) { // recursive; search for a node
#echo "<br>".$id;
if($n != null) { if($n != null) {
#echo "<br>searching for ".$id." compare to ".$n->getID();
if($n->getID() != $id) { if($n->getID() != $id) {
if($n->getID() > $id) { if($n->getID() > $id) {
$n = $this->AVLfind($id,$n->getLeft()); $n = $this->AVLfind($id,$n->getLeft());
@ -85,7 +82,7 @@
return $n; 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) { if($n->getLeft() == null || $n->getRight() == null) {
$s = $n; $s = $n;
} }
@ -121,7 +118,7 @@
return $r; return $r;
} }
private function AVLinsert($r,$n) { private function AVLinsert($r,$n) { // insert a node into the actual tree
if($r == null) { if($r == null) {
$r = $n; $r = $n;
} }
@ -129,12 +126,12 @@
if($n->getID() < $r->getID()) { if($n->getID() < $r->getID()) {
$r->setLeft($this->AVLinsert($r->getLeft(),$n)); $r->setLeft($this->AVLinsert($r->getLeft(),$n));
$r = $this->balance($r); $r = $this->balance($r); // rebalance
} }
elseif($n->getID() > $r->getID()) { elseif($n->getID() > $r->getID()) {
$r->setRight($this->AVLinsert($r->getRight(),$n)); $r->setRight($this->AVLinsert($r->getRight(),$n));
$r = $this->balance($r); $r = $this->balance($r); // rebalance
} }
$r->setHeight(max($r->getHeightLeft(),$r->getHeightRight())+1); $r->setHeight(max($r->getHeightLeft(),$r->getHeightRight())+1);
@ -143,8 +140,7 @@
return $r; return $r;
} }
private function balance($r) { private function balance($r) { // do a rebalancation of the tree
#return $r;
if($r->bal() == -2) { if($r->bal() == -2) {
$lc = $r->getLeft(); $lc = $r->getLeft();
if($lc->getHeightLeft() >= $lc->getHeightRight()) { if($lc->getHeightLeft() >= $lc->getHeightRight()) {
@ -168,8 +164,7 @@
return $r; return $r;
} }
private function Successor($r) { private function Successor($r) { // find the successor for a node
#echo "succ: ".$r->getID();
if($r->getRight() != null) { if($r->getRight() != null) {
return $this->Minimum($r->getRight()); 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) { if($r == null) {
return null; return null;
} }
@ -201,6 +196,8 @@
return $p; return $p;
} }
//rotations
private function RotateToRight($r) { private function RotateToRight($r) {
if($this->debug) { if($this->debug) {
echo "rotaRight<br>"; echo "rotaRight<br>";
@ -238,8 +235,14 @@
$r->setRight($this->RotateToRight($r->getRight())); $r->setRight($this->RotateToRight($r->getRight()));
return $this->RotateToLeft($r); return $this->RotateToLeft($r);
} }
//end rotations
} }
/*
* AVL tree nodes
*/
class AVLTreeNode { class AVLTreeNode {
private $height; private $height;
private $left; private $left;
@ -249,10 +252,10 @@
function AVLTreeNode($node) { function AVLTreeNode($node) {
$this->height = 0; $this->height = 0;
$this->left = null; $this->left = null; // left child
$this->right = null; $this->right = null; // right child
$this->node = $node; $this->node = $node; // actual data stored
$this->parent = null; $this->parent = null; // parent node
} }
function getParent() { function getParent() {
@ -289,7 +292,7 @@
return $this->right->getHeight(); return $this->right->getHeight();
} }
function bal() { function bal() { // calculate value to eval balancing
$r = -1; $r = -1;
$l = -1; $l = -1;

View file

@ -1,4 +1,9 @@
<?php <?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 { class AchAchievement extends AchList {
######################### #########################
# PHP 5.3 compatible # PHP 5.3 compatible
@ -44,9 +49,9 @@
parent::__construct(); parent::__construct();
$this->setParent($parent); $this->setParent($parent); // real parent node
$this->setID($data['aa_id']); $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->category = $data['aa_category'];
$this->tie_race = $data['aa_tie_race']; $this->tie_race = $data['aa_tie_race'];
$this->tie_civ = $data['aa_tie_civ']; $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) { if($this->parent_id == null) {
return true; return true;
} }
@ -83,19 +88,11 @@
} }
} }
#@override Parentum::makeChild()
protected function makeChild($a) { protected function makeChild($a) {
return new AchTask($a,$this); 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() { function getParentID() {
return $this->parent_id; return $this->parent_id;
} }
@ -120,7 +117,7 @@
return $this->name; return $this->name;
} }
function getValueDone() { function getValueDone() { // calculate the yubopoints that are already done
$val = 0; $val = 0;
$iter = $this->getDone(); $iter = $this->getDone();
while($iter->hasNext()) { while($iter->hasNext()) {
@ -130,7 +127,7 @@
return $val; return $val;
} }
function getValueOpen() { function getValueOpen() { // get the yubopoints of the next open task
$iter = $this->getOpen(); $iter = $this->getOpen();
if($iter->hasNext()) { if($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
@ -139,7 +136,7 @@
return 0; return 0;
} }
function fillTemplate($insert = array()) { function fillTemplate($insert = array()) { // fill the naming template with given value
if($this->template == null) { if($this->template == null) {
return implode(";",$insert); return implode(";",$insert);
} }
@ -170,7 +167,7 @@
return ($this->sticky == 1); return ($this->sticky == 1);
} }
function isHeroic() { function isHeroic() { // check parent category if it is heroic
return $this->parent->isHeroic(); return $this->parent->isHeroic();
} }

View file

@ -1,4 +1,8 @@
<?php <?php
/*
* Category class that is loading all achievements tied to it.
*/
class AchCategory extends AchList implements Tieable { class AchCategory extends AchList implements Tieable {
protected $ties_cult; protected $ties_cult;
protected $ties_civ; protected $ties_civ;

View file

@ -32,7 +32,6 @@
$this->addChild($this->makeChild($res[$i])); $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 function getOpen() { // just returns the previously set ID of the currently open MenuNode

View file

@ -1,4 +1,9 @@
<?php <?php
/*
* Doubly Linked List
*
* This list is linked to an avl tree for searching purpose!
*/
class DLL { class DLL {
private $first; private $first;
private $last; private $last;
@ -34,7 +39,7 @@
return $this->last; return $this->last;
} }
function addNode($data,$before = null) { function addNode($data,$before = null) { // add a node
if($this->findNode($data->getID()) != null) { if($this->findNode($data->getID()) != null) {
return false; return false;
} }
@ -71,13 +76,13 @@
$this->first = $n; $this->first = $n;
} }
$this->avl->insert($n); $this->avl->insert($n); // pass on to avl tree
$this->size++; $this->size++;
return null; return null;
} }
function removeNode($id) { function removeNode($id) { // remove a node
$this->avl->inorder(); $this->avl->inorder();
$n = $this->findNode($id); $n = $this->findNode($id);
@ -109,7 +114,7 @@
} }
} }
$this->avl->remove($id); $this->avl->remove($id); // pass on to avl tree
$this->size--; $this->size--;
} }
@ -120,6 +125,10 @@
} }
} }
/*
* List nodes
*/
class DLLnode { class DLLnode {
private $parent; private $parent;
private $child; private $child;
@ -128,7 +137,7 @@
function DLLNode($d) { function DLLNode($d) {
$this->parent = null; $this->parent = null;
$this->child = null; $this->child = null;
$this->data = $d; $this->data = $d; // actual data
} }
final function getParent() { final function getParent() {

View file

@ -30,11 +30,11 @@
$this->nodes->removeNode($id); $this->nodes->removeNode($id);
} }
function getChildByID($id) { function getChildByID($id) { // returns a DLL node
return $this->nodes->findNode($id); return $this->nodes->findNode($id);
} }
function getChildDataByID($id) { function getChildDataByID($id) { // returns the actual content of the found DLL node
$tmp = $this->getChildByID($id); $tmp = $this->getChildByID($id);
if($tmp != null) { if($tmp != null) {
return $tmp->data; return $tmp->data;

View file

@ -223,9 +223,7 @@
$iter = $cat->getDone(); $iter = $cat->getDone();
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "A";
if($curr->inDev() || !$curr->parentDone()) { if($curr->inDev() || !$curr->parentDone()) {
continue; continue;
} }
@ -239,9 +237,7 @@
$iter = $cat->getOpen(); $iter = $cat->getOpen();
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "B";
if($curr->inDev() || !$curr->parentDone()) { if($curr->inDev() || !$curr->parentDone()) {
continue; continue;
} }
@ -367,7 +363,7 @@
$skip = false; $skip = false;
while($obj->hasNext()) { while($obj->hasNext()) {
#foreach($obj as $elem) {
$elem = $obj->getNext(); $elem = $obj->getNext();
if(($i%2) == 0) { if(($i%2) == 0) {
$html .= "<tr>"; $html .= "<tr>";

View file

@ -60,7 +60,6 @@ require_once("fb/facebook.php");
// Update user acces on Db // Update user acces on Db
$DBc = ryDB::getInstance(APP_NAME."_test"); $DBc = ryDB::getInstance(APP_NAME."_test");
#$DBc = ryDB::getInstance(APP_NAME); #$DBc = ryDB::getInstance(APP_NAME);
#$DBc = ryDB::getInstance("ahufler");
$c = ""; $c = "";
if(!$_USER->isIG()) { if(!$_USER->isIG()) {

View file

@ -72,7 +72,7 @@
return new AdmAtom($d,$this); return new AdmAtom($d,$this);
} }
function getLang($lang) { function getLang($lang) { // load language
global $DBc; global $DBc;
$res = $DBc->sqlQuery("SELECT * FROM ach_objective_lang WHERE aol_objective='".$this->getID()."' AND aol_lang='".$lang."'"); $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']; return $res[0]['aol_name'];
} }
function setLang($lang,$txt) { function setLang($lang,$txt) { // write language
global $DBc,$_USER; 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)."'"); $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)."'");

View file

@ -72,7 +72,7 @@
return new AdmObjective($d,$this); return new AdmObjective($d,$this);
} }
function getLang($lang) { function getLang($lang) { // load language
global $DBc; global $DBc;
$res = $DBc->sqlQuery("SELECT * FROM ach_task_lang WHERE atl_task='".$this->getID()."' AND atl_lang='".$lang."'"); $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']); 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; 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).""); $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)."");

View file

@ -35,8 +35,6 @@ if($_ADMIN->isIG()) {
require_once("class/mySQL_class.php"); 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']."include/ach_render_common.php");
require_once($_CONF['app_achievements_path']."class/DLL_class.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/CSRDispatcher_trait.php");
require_once("class/CSR_inter.php"); require_once("class/CSR_inter.php");
#require_once("class/CSRMenu_class.php");
require_once("class/CSRCategory_class.php"); require_once("class/CSRCategory_class.php");
require_once("class/CSRAchievement_class.php"); require_once("class/CSRAchievement_class.php");
require_once("class/CSRTask_class.php"); require_once("class/CSRTask_class.php");
@ -76,13 +73,10 @@ require_once("class/CSRObjective_class.php");
require_once("class/CSRAtom_class.php"); require_once("class/CSRAtom_class.php");
$DBc = ryDB::getInstance("app_achievements_test"); $DBc = ryDB::getInstance("app_achievements_test");
#$DBc = ryDB::getInstance("ahufler");
function mkn($x) { function mkn($x) {
global $DBc; global $DBc;
#echo "<br>".$x." =>";
if($x == null || strtolower($x) == "null" || $x == "") { if($x == null || strtolower($x) == "null" || $x == "") {
#echo "NULL";
return "NULL"; return "NULL";
} }
else { else {
@ -138,8 +132,7 @@ $c = "<script type='text/javascript'>
</ul><p />"; </ul><p />";
} }
#$c .= ach_render_menu();
$c .= "</div></td> $c .= "</div></td>
<td valign='top'>"; <td valign='top'>";
@ -211,9 +204,6 @@ $c .= "</div></td>
$c .= atom_render_category($cat); $c .= atom_render_category($cat);
} }
#a:p:o:a
$c .= "</td> $c .= "</td>
</tr> </tr>
@ -286,10 +276,6 @@ $c .= "</div></td>
$c .= atom_render_category($cat); $c .= atom_render_category($cat);
} }
#a:p:o:a
$c .= "</td> $c .= "</td>
</tr> </tr>
</table></center>"; </table></center>";
@ -546,15 +532,10 @@ $c .= "</div></td>
echo "<br>rendering: ".round($stop_time - $start_time,3); echo "<br>rendering: ".round($stop_time - $start_time,3);
} }
#a:p:o:a
$c .= "</td> $c .= "</td>
</tr> </tr>
</table></center>"; </table></center>";
//category
} }
if($_REQUEST['mode'] == "player" && $_ADMIN->isCSR()) { if($_REQUEST['mode'] == "player" && $_ADMIN->isCSR()) {
@ -608,8 +589,7 @@ $c .= "</div></td>
$c .= "</div></td> $c .= "</div></td>
<td width='645px' valign='top'>"; <td width='645px' valign='top'>";
#$open = $menu->getOpenCat();
if($open != 0) { if($open != 0) {
$c .= csr_render_category($cat); $c .= csr_render_category($cat);
@ -630,8 +610,6 @@ $c .= "</div></td>
} }
#$c .= ach_render_content();
$c .= "</td> $c .= "</td>
</tr> </tr>
</table></center>"; </table></center>";