sqlQuery("SELECT count(*) as anz FROM players WHERE id='".$DBc_char->sqlEscape($id)."'");
if($res[0]['anz'] > 0) {
return true;
}
return false;
}
function user_get_name($id) {
global $DBc_char;
$res = $DBc_char->sqlQuery("SELECT name FROM players WHERE id='".$DBc_char->sqlEscape($id)."'");
return $res[0]['name'];
}
function user_get_data($id) {
global $_CONF,$DBc_char;
$DBc_align = new mySQL($_CONF['mysql_error']);
$DBc_align->connect($_CONF['char_mysql_server'],$_CONF['char_mysql_user'],$_CONF['char_mysql_pass'],$_CONF['char_mysql_database']);
$res = $DBc_char->sqlQuery("SELECT cid FROM players WHERE id='".$DBc_char->sqlEscape($id)."'");
$res = $DBc_align->sendSQL("SELECT race,civilisation,cult FROM characters WHERE char_id='".$res[0]['cid']."'","ARRAY");
return $res[0];
}
function csr_render_yubopoints() {
global $DBc,$_USER,$_CONF;
$res = $DBc->sqlQuery("SELECT sum(at_value) as anz FROM ach_task,ach_player_task WHERE at_id=apt_task AND apt_player='".$_USER->getID()."'");
$html = "
".$_USER->getName()." ".max(0,$res[0]['anz'])." ";
return $html;
}
function csr_render_find_player() {
global $DBc_char;
$html = "";
if($_REQUEST['pname'] != "") {
$html .= "";
$res = $DBc_char->sqlQuery("SELECT * FROM players WHERE (name LIKE '".$DBc_char->sqlEscape(strtolower($_REQUEST['pname']))."%' OR id='".$DBc_char->sqlEscape(strtolower($_REQUEST['pname']))."') AND deleted='0' LIMIT 0,100");
$sz = sizeof($res);
if($sz == 0) {
$html .= "
no characters found";
}
$cols = 1;
if($sz > 8) {
$cols = 3;
}
$html .= "
";
for($i=0;$i<$sz;$i++) {
if($cols != 1 && ($i%$cols) == 0) {
$html .= "
";
}
$html .= "".$res[$i]['name']." | ";
}
$html .= "
";
$html .= "
";
}
return $html;
}
function csr_render_menu(&$menu,$sub = 0) {
$html = "";
return $html.adm_render_mnode($menu,$sub);
}
function adm_render_mnode(&$menu,$sub) {
global $_CONF;
$html = "";
$iter = $menu->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
#$sz = $menu->getSize();
#for($i=0;$i<$sz;$i++) {
# $curr = $menu->getChild($i);
if($curr->inDev()) {
#continue;
}
$html .= "getID()."'>";
if($curr->hasOpenCat() != 0) {
$html .= "".adm_render_mnode($curr,($sub+4))."
";
}
}
return $html;
}
function csr_render_category(&$cat) {
$html = "";
if($cat->hasTieAlign_done() || $cat->hasTieAlign_open()) {
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
}
$iter = $cat->getDone();
while($iter->hasNext()) {
$curr = $iter->getNext();
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "A";
if($curr->inDev()) {
continue;
}
$html .= ach_render_achievement_done($curr);
}
$iter = $cat->getOpen();
while($iter->hasNext()) {
$curr = $iter->getNext();
#$sz = sizeof($tmp);
#for($i=0;$i<$sz;$i++) {
#echo "B";
if($curr->inDev()) {
continue;
}
$html .= ach_render_achievement_open($curr);
}
return $html;
}
function ach_render_achievement_done(&$ach) {
global $_CONF;
$html = '
|
|
|
|
|
'.$ach->getName().' |
'.$ach->getValueDone().'
|
';
$html .= ach_render_task_done($ach);
$html .= ' |
|
|
|
|
|
';
return $html;
}
function ach_render_achievement_open(&$ach) {
global $_CONF;
$html = '
|
|
|
|
|
'.$ach->getName().' |
'.$ach->getValueOpen().'
|
';
$html .= ach_render_task_open($ach);
$html .= ' |
|
|
|
|
|
';
return $html;
}
function ach_render_task_open(&$ach) {
$html = "";
$task_list = $ach->getOpen();
$task = $task_list->getNext();
if($task->inDev()) {
return $html;
}
$html .= "";
if($task->getName() != null) {
$html .= $task->getDisplayName();
}
else {
$html .= "[untitled]";
}
$html .= " getPath()."'>Task: grant";
if($task->objDrawable()) {
$html .= ach_render_obj_list($task->getIterator());
}
return $html;
}
function ach_render_task_done(&$ach) {
global $_CONF;
$html = "";
$task_list = $ach->getDone();
while($task_list->hasNext()) {
$task = $task_list->getNext();
if($task->inDev()) {
continue;
}
$html .= "";
}
return $html;
}
function ach_render_obj_list($obj) {
$html = "";
$i = 0;
$skip = false;
while($obj->hasNext()) {
#foreach($obj as $elem) {
$elem = $obj->getNext();
if(($i%2) == 0) {
$html .= "";
}
switch($elem->getDisplay()) {
case "meta":
$html .= "".ach_render_obj_meta($elem)." | ";
break;
case "value":
if(($i%2) == 1) {
$html .= "
";
}
$html .= "".ach_render_obj_value($elem)." | ";
$i++;
break;
case "simple":
$html .= "".ach_render_obj_simple($elem)." | ";
break;
case "hidden":
default:
//do nothing
$skip = true;
break;
}
if(($i%2) == 1) {
$html .= "
";
}
if(!$skip) {
$i++;
}
$skip = false;
}
if(($i%2) == 1) {
$html .= "";
}
$html .= "
";
return $html;
}
function ach_render_obj_simple(&$obj) {
global $_CONF;
$html = "";
if($obj->isdone()) {
$html .= " ";
}
else {
$html .= " ";
}
$html .= $obj->getDisplayName();
if($obj->isdone()) {
$html .= " getPath()."'>Obj: deny";
}
else {
$html .= " getPath()."'>Obj: grant";
}
$html .= "";
return $html;
}
function ach_render_obj_meta(&$obj) {
global $_CONF;
$html = "";
if($obj->isdone()) {
$col = "#71BE02";
$grey = "";
}
else {
$col = "#999999";
$grey = "grey/";
}
$html .= "";
return $html;
}
function ach_render_obj_value(&$obj) {
$html = "";
if($obj->getName() != null) {
if($obj->isdone()) {
$col = "#71BE02";
}
else {
$col = "#999999";
}
$html .= "".$obj->getDisplayName()."
";
}
$html .= "";
return $html;
}
function ach_render_progressbar($prog,$val,$width) {
$val = max(1,$val);
$left = floor($width*(100*($prog/$val))/100);
$html = "
";
if(($prog/$val) > 0.85) {
$html .= " ".nf($prog)." / ".nf($val)." ";
}
$html .= " |
";
if(($prog/$val) <= 0.85) {
$html .= " ".nf($prog)." / ".nf($val)." ";
}
$html .= " |
";
return $html;
}
function ach_render_summary_header() {
global $_USER;
return "".get_translation('ach_summary_header',$_USER->getLang())."
";
}
function ach_render_summary_footer(&$summary) {
global $_USER;
$nodes = $summary->getSummary();
$html = "";
$sum_done = 0;
$sum_total = 0;
$i = 0;
foreach($nodes as $elem) {
if(($i%3) == 0) {
$html .= "";
}
$html .= "".$elem[0]." ".ach_render_progressbar($elem[1],$elem[2],200)." | ";
$sum_done += $elem[1];
$sum_total += $elem[2];
if(($i%3) == 2) {
$html .= "
";
}
$i++;
}
if(($i%3) == 2) {
$html .= "";
}
$html = "
".get_translation('ach_summary_stats',$_USER->getLang())."
".get_translation('ach_summary_stats_total',$_USER->getLang())." ".ach_render_progressbar($sum_done,$sum_total,450)."
|
".$html."
";
return $html;
}
function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",&$cat) {
global $_USER;
$html = "
";
/*if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx
#While being of neutral allegiance with the higher powers
$html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang()).""));
}
elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral
#While being of neutral allegiance with the homin civilizations
$html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang()).""));
}*/
if(($cult == "c_neutral" || !$cat->isAllowedCult()) && ($civ == "c_neutral" || !$cat->isAllowedCiv())) { // neutral / neutral
#While being of neutral allegiance
$html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("".get_translation('ach_c_neutral',$_USER->getLang()).""));
}
else { //other
#While being aligned with the
$html .= get_translation('ach_allegiance_start',$_USER->getLang());
if($cat->isAllowedCult() && $cult != "c_neutral") {
#CULT
$html .= "".ach_translate_cc($cult)."";
if($cat->isAllowedCiv() && $civ != "c_neutral") {
#and the CIV
$html .= get_translation('ach_allegiance_and',$_USER->getLang())." ".ach_translate_cc($civ)."";
}
}
elseif($cat->isAllowedCiv() && $civ != "c_neutral") {
#CIV
$html .= "".ach_translate_cc($civ)."";
}
}
#, accomplish the following achievements:
$html .= get_translation('ach_allegiance_end',$_USER->getLang())."
";
return $html;
}
?>