#1470 updated achievements app to latest live version

--HG--
branch : gsoc2012-achievements
This commit is contained in:
SirCotare 2013-02-15 14:51:41 +01:00
parent 598adb8489
commit 6017025058
9 changed files with 397 additions and 148 deletions

View file

@ -4,7 +4,7 @@
* open and done. * open and done.
*/ */
class AchAchievement extends AchList { class AchAchievement extends AchList implements Tieable {
######################### #########################
# PHP 5.3 compatible # PHP 5.3 compatible
# InDev_trait replaces this in PHP 5.4 # InDev_trait replaces this in PHP 5.4
@ -44,7 +44,7 @@
protected $template; protected $template;
protected $sticky; protected $sticky;
function AchAchievement($data,$parent) { function AchAchievement($data,&$parent) {
global $DBc,$_USER,$_CONF; global $DBc,$_USER,$_CONF;
parent::__construct(); parent::__construct();
@ -68,7 +68,7 @@
$this->template = $res[0]['aal_template']; $this->template = $res[0]['aal_template'];
} }
$res = $DBc->sqlQuery("SELECT * FROM ach_task LEFT JOIN (ach_task_lang) ON (atl_lang='".$_USER->getLang()."' AND atl_task=at_id) LEFT JOIN (ach_player_task) ON (apt_task=at_id AND apt_player='".$_USER->getID()."') WHERE at_achievement='".$this->id."' ORDER by at_torder ASC"); $res = $DBc->sqlQuery("SELECT * FROM ach_task LEFT JOIN (ach_task_lang) ON (atl_lang='".$_USER->getLang()."' AND atl_task=at_id) LEFT JOIN (ach_player_task) ON (apt_task=at_id AND apt_player='".$_USER->getID()."') WHERE at_achievement='".$this->id."' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$parent->getCurrentCult().'|'.$parent->getCurrentCiv()."')) ORDER by at_torder ASC");
$sz = sizeof($res); $sz = sizeof($res);
for($i=0;$i<$sz;$i++) { for($i=0;$i<$sz;$i++) {
@ -112,12 +112,64 @@
return $this->parent_id; return $this->parent_id;
} }
function getTieRace() { function hasTieRace_open() {
#return $this->tie_race;
$iter = $this->child_open->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieRace_open() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieAlign_open() {
#return $this->tie_civ;
$iter = $this->child_open->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlign_open() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieRace_done() {
#return $this->tie_race;
$iter = $this->child_done->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieRace_done() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieAlign_done() {
#return $this->tie_civ;
$iter = $this->child_done->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlign_done() && !$curr->inDev()) {
return true;
}
}
return false;
}
function hasTieRaceDev() {
#return $this->tie_race; #return $this->tie_race;
$iter = $this->nodes->getIterator(); $iter = $this->nodes->getIterator();
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->hasTieRace()) { if($curr->hasTieRaceDev()) {
return true; return true;
} }
} }
@ -125,12 +177,12 @@
return false; return false;
} }
function getTieCiv() { function hasTieAlignDev() {
#return $this->tie_civ; #return $this->tie_civ;
$iter = $this->nodes->getIterator(); $iter = $this->nodes->getIterator();
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->hasTieCiv()) { if($curr->hasTieAlignDev()) {
return true; return true;
} }
} }
@ -138,25 +190,14 @@
return false; return false;
} }
function getTieCult() {
#return $this->tie_cult;
$iter = $this->nodes->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieCult()) {
return true;
}
}
return false;
}
function isTiedRace($r) { function isTiedRace_open($r) {
#return $this->tie_race; #return $this->tie_race;
$iter = $this->nodes->getIterator(); $iter = $this->child_open->getIterator();
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->isTiedRace($r)) { if($curr->isTiedRace_open($r)) {
return true; return true;
} }
} }
@ -164,12 +205,12 @@
return false; return false;
} }
function isTiedCiv($c) { function isTiedAlign_open($cult,$civ) {
#return $this->tie_civ; #return $this->tie_civ;
$iter = $this->nodes->getIterator(); $iter = $this->child_open->getIterator();
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->isTiedCiv($c)) { if($curr->isTiedAlign_open($cult,$civ)) {
return true; return true;
} }
} }
@ -177,12 +218,12 @@
return false; return false;
} }
function isTiedCult($c) { function isTiedRace_done($r) {
#return $this->tie_cult; #return $this->tie_race;
$iter = $this->nodes->getIterator(); $iter = $this->child_done->getIterator();
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->isTiedCult($c)) { if($curr->isTiedRace_done($r)) {
return true; return true;
} }
} }
@ -190,6 +231,20 @@
return false; return false;
} }
function isTiedAlign_done($cult,$civ) {
#return $this->tie_civ;
$iter = $this->child_done->getIterator();
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->isTiedAlign_done($cult,$civ)) {
return true;
}
}
return false;
}
function getImage() { function getImage() {
return $this->image; return $this->image;
} }

View file

@ -4,28 +4,34 @@
*/ */
class AchCategory extends AchList implements Tieable { class AchCategory extends AchList implements Tieable {
protected $ties_cult; protected $ties_align_done;
protected $ties_civ; protected $ties_race_done;
protected $ties_race; protected $ties_align_open;
protected $ties_race_open;
protected $ties_race_dev; protected $ties_race_dev;
protected $ties_cult_dev; protected $ties_align_dev;
protected $ties_civ_dev;
protected $cult; protected $cult;
protected $civ; protected $civ;
protected $race; protected $race;
protected $heroic; protected $heroic;
protected $contest; protected $contest;
protected $allow_civ;
protected $allow_cult;
function AchCategory($id,$race = null,$cult = null,$civ = null) { function AchCategory($id,$race = null,$cult = "c_neutral",$civ = "c_neutral") {
global $DBc,$_USER; global $DBc,$_USER;
parent::__construct(); parent::__construct();
if($civ != "%") {
$civ = $DBc->sqlEscape($civ); $civ = $DBc->sqlEscape($civ);
}
if($cult != "%") {
$cult = $DBc->sqlEscape($cult); $cult = $DBc->sqlEscape($cult);
}
$race = $DBc->sqlEscape($race); $race = $DBc->sqlEscape($race);
if($race == null) { /*if($race == null) {
$race = $_USER->getRace(); $race = $_USER->getRace();
} }
@ -35,10 +41,11 @@
if($civ == null) { if($civ == null) {
$civ = $_USER->getCiv(); $civ = $_USER->getCiv();
} }*/
$this->cult = $cult; $this->cult = $cult;
$this->civ = $civ; $this->civ = $civ;
$this->rave = $race;
$this->id = $DBc->sqlEscape($id); $this->id = $DBc->sqlEscape($id);
@ -56,61 +63,78 @@
} }
} }
$res = $DBc->sqlQuery("SELECT ac_heroic,ac_contest FROM ach_category WHERE ac_id='".$this->id."'"); $res = $DBc->sqlQuery("SELECT ac_heroic,ac_contest,ac_allow_civ,ac_allow_cult FROM ach_category WHERE ac_id='".$this->id."'");
$this->heroic = $res[0]['ac_heroic']; $this->heroic = $res[0]['ac_heroic'];
$this->contest = $res[0]['ac_contest']; $this->contest = $res[0]['ac_contest'];
$this->allow_civ = $res[0]['ac_allow_civ'];
$this->allow_cult = $res[0]['ac_allow_cult'];
//load counts for tie determination
/*$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
$this->ties_cult = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_civ IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
$this->ties_civ = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_race IS NOT NULL AND aa_category='".$this->id."' AND aa_dev='0'");
$this->ties_race = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_race IS NOT NULL AND aa_category='".$this->id."'");
$this->ties_race_dev = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_cult IS NOT NULL AND aa_category='".$this->id."'");
$this->ties_cult_dev = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) as anz FROM ach_achievement WHERE aa_tie_civ IS NOT NULL AND aa_category='".$this->id."'");
$this->ties_civ_dev = $res[0]['anz'];*/
$iter = $this->nodes->getIterator(); $iter = $this->nodes->getIterator();
$tmp = false; $tmp = false;
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->getTieRace()) { if($curr->hasTieRace_open() && !$curr->inDev()) {
$tmp = true; $tmp = true;
break; break;
} }
} }
$this->ties_race = $tmp; $this->ties_race_open = $tmp;
$iter = $this->nodes->getIterator(); $iter = $this->nodes->getIterator();
$tmp = false; $tmp = false;
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->getTieCiv()) { if($curr->hasTieAlign_open() && !$curr->inDev()) {
$tmp = true; $tmp = true;
break; break;
} }
} }
$this->ties_civ = $tmp; $this->ties_align_open = $tmp;
$iter = $this->nodes->getIterator(); $iter = $this->nodes->getIterator();
$tmp = false; $tmp = false;
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->getTieCult()) { if($curr->hasTieRace_done() && !$curr->inDev()) {
$tmp = true; $tmp = true;
break; break;
} }
} }
$this->ties_cult = $tmp; $this->ties_race_done = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlign_done() && !$curr->inDev()) {
$tmp = true;
break;
}
}
$this->ties_align_done = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieRaceDev()) {
$tmp = true;
break;
}
}
$this->ties_race_dev = $tmp;
$iter = $this->nodes->getIterator();
$tmp = false;
while($iter->hasNext()) {
$curr = $iter->getNext();
if($curr->hasTieAlignDev()) {
$tmp = true;
break;
}
}
$this->ties_align_dev = $tmp;
} }
#@override Parentum::makeChild() #@override Parentum::makeChild()
@ -118,28 +142,36 @@
return new AchAchievement($a,$this); return new AchAchievement($a,$this);
} }
function isTiedRace() { function isAllowedCult() {
return ($this->ties_race > 0); return ($this->allow_cult == 1);
} }
function isTiedCult() { function isAllowedCiv() {
return ($this->ties_cult > 0); return ($this->allow_civ == 1);
} }
function isTiedCiv() { function hasTieRace_open() {
return ($this->ties_civ > 0); return $this->ties_race_open;
} }
function isTiedRaceDev() { function hasTieAlign_open() {
return ($this->ties_race_dev > 0); return $this->ties_align_open;
} }
function isTiedCultDev() { function hasTieRace_done() {
return ($this->ties_cult_dev > 0); return $this->ties_race_done;
} }
function isTiedCivDev() { function hasTieAlign_done() {
return ($this->ties_civ_dev > 0); return $this->ties_align_done;
}
function hasTieRaceDev() {
return $this->ties_race_dev;
}
function hasTieAlignDev() {
return $this->ties_align_dev;
} }
function getCurrentCiv() { function getCurrentCiv() {
@ -154,6 +186,22 @@
return $this->race; return $this->race;
} }
function isTiedRace_open($r) {
return null;
}
function isTiedAlign_open($cult,$civ) {
return null;
}
function isTiedRace_done($r) {
return null;
}
function isTiedAlign_done($cult,$civ) {
return null;
}
function isHeroic() { function isHeroic() {
return ($this->heroic == 1); return ($this->heroic == 1);
} }

View file

@ -15,7 +15,7 @@
//read all recent tasks of user //read all recent tasks of user
//make distinct achievement list //make distinct achievement list
$res = $DBc->sqlQuery("SELECT DISTINCT aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_name, (SELECT aal_template FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_template FROM ach_achievement as ach,ach_task,ach_player_task WHERE at_achievement=aa_id AND apt_player='".$_USER->getID()."' AND apt_task=at_id ORDER by apt_date DESC LIMIT 0,".$size); $res = $DBc->sqlQuery("SELECT DISTINCT apt_date,aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_name, (SELECT aal_template FROM ach_achievement_lang WHERE aal_lang='".$_USER->getLang()."' AND aal_achievement=ach.aa_id) as aal_template FROM ach_achievement as ach,ach_task,ach_player_task WHERE at_achievement=aa_id AND ach.aa_dev='0' AND apt_player='".$_USER->getID()."' AND apt_task=at_id ORDER by apt_date DESC LIMIT 0,".$size);
#echo var_export($res,true); #echo var_export($res,true);
@ -107,6 +107,10 @@
return "c_neutral"; return "c_neutral";
} }
function getCurrentRace() {
return "r_matis";
}
function isHeroic() { function isHeroic() {
return false; return false;
} }
@ -114,5 +118,55 @@
function isContest() { function isContest() {
return false; return false;
} }
function hasTieRace_open()
{
return false;
}
function hasTieAlign_open()
{
return false;
}
function hasTieRace_done()
{
return false;
}
function hasTieAlign_done()
{
return false;
}
function hasTieRaceDev()
{
return false;
}
function hasTieAlignDev()
{
return false;
}
function isTiedRace_open($r)
{
return true;
}
function isTiedAlign_open($cult, $civ)
{
return true;
}
function isTiedRace_done($r)
{
return true;
}
function isTiedAlign_done($cult, $civ)
{
return true;
}
} }
?> ?>

View file

@ -1,5 +1,5 @@
<?php <?php
class AchTask extends Parentum { class AchTask extends Parentum implements Tieable {
######################### #########################
# PHP 5.3 compatible # PHP 5.3 compatible
# InDev_trait replaces this in PHP 5.4 # InDev_trait replaces this in PHP 5.4
@ -38,8 +38,9 @@
protected $inherit_obj; protected $inherit_obj;
private $heritage_list; private $heritage_list;
protected $tie_race; protected $tie_race;
protected $tie_cult; #protected $tie_cult;
protected $tie_civ; #protected $tie_civ;
protected $tie_align;
function AchTask($data,$parent) { function AchTask($data,$parent) {
global $DBc,$_USER,$_CONF; global $DBc,$_USER,$_CONF;
@ -88,7 +89,7 @@
$this->tie_race[] = $res[$i]['attr_race']; $this->tie_race[] = $res[$i]['attr_race'];
} }
$res = $DBc->sqlQuery("SELECT attcult_cult FROM ach_task_tie_cult WHERE attcult_task='".$this->id."'"); /*$res = $DBc->sqlQuery("SELECT attcult_cult FROM ach_task_tie_cult WHERE attcult_task='".$this->id."'");
$sz = sizeof($res); $sz = sizeof($res);
$this->tie_cult = array(); $this->tie_cult = array();
@ -102,6 +103,14 @@
$this->tie_civ = array(); $this->tie_civ = array();
for($i=0;$i<$sz;$i++) { for($i=0;$i<$sz;$i++) {
$this->tie_civ[] = $res[$i]['attciv_civ']; $this->tie_civ[] = $res[$i]['attciv_civ'];
}*/
$res = $DBc->sqlQuery("SELECT atta_alignment FROM ach_task_tie_align WHERE atta_task='".$this->id."'");
$sz = sizeof($res);
$this->tie_align = array();
for($i=0;$i<$sz;$i++) {
$this->tie_align[] = $res[$i]['atta_alignment'];
} }
} }
@ -119,6 +128,7 @@
$this->addChild($curr); $this->addChild($curr);
$this->heritage_list->insert($curr); $this->heritage_list->insert($curr);
} }
return true;
} }
#@override Parentum::makeChild() #@override Parentum::makeChild()
@ -141,36 +151,74 @@
} }
function hasTieRace() { function hasTieRace() {
if($this->dev == 1) {
return false;
}
return (sizeof($this->tie_race) != 0); return (sizeof($this->tie_race) != 0);
} }
function hasTieCult() { function hasTieAlign() {
return (sizeof($this->tie_cult) != 0); if($this->dev == 1) {
return false;
}
return (sizeof($this->tie_align) != 0);
} }
function hasTieCiv() { function hasTieRace_open() {
return (sizeof($this->tie_civ) != 0); return $this->hasTieRace();
}
function hasTieRace_done() {
return $this->hasTieRace();
}
function hasTieAlign_open() {
return $this->hasTieAlign();
}
function hasTieAlign_done() {
return $this->hasTieAlign();
}
function hasTieRaceDev() {
return (sizeof($this->tie_race) != 0);
}
function hasTieAlignDev() {
return (sizeof($this->tie_align) != 0);
} }
function isTiedRace($r) { function isTiedRace($r) {
if(sizeof($this->tie_race) == 0) { if(sizeof($this->tie_race) == 0) {
return true; return true;
} }
return in_array($r,$this->race); return in_array($r,$this->tie_race);
} }
function isTiedCult($c) { function isTiedAlign($cult,$civ) {
if(sizeof($this->tie_cult) == 0) { if($cult == "%" || $civ == "%") {
return true; return true;
} }
return in_array($c,$this->tie_cult); if(sizeof($this->tie_align) == 0) {
return true;
}
return in_array(($cult.'|'.$civ),$this->tie_align);
} }
function isTiedCiv($c) { function isTiedRace_open($r) {
if(sizeof($this->tie_civ) == 0) { return $this->isTiedRace($r);
return true;
} }
return in_array($c,$this->tie_civ);
function isTiedRace_done($r) {
return $this->isTiedRace($r);
}
function isTiedAlign_done($cult,$civ) {
return $this->isTiedAlign($cult,$civ);
}
function isTiedAlign_open($cult,$civ) {
return $this->isTiedAlign($cult,$civ);
} }
function getAchievement() { function getAchievement() {

View file

@ -23,15 +23,15 @@
} }
function getRace() { function getRace() {
return $this->data['race']; return 'r_'.$this->data['race'];
} }
function getCiv() { function getCiv() {
return $this->data['civilization']; return 'c_'.$this->data['civ'];
} }
function getCult() { function getCult() {
return $this->data['cult']; return 'c_'.$this->data['cult'];
} }
function getName() { function getName() {

View file

@ -6,12 +6,28 @@
on a user's cult of civ allegiance. on a user's cult of civ allegiance.
---------------------------*/ ---------------------------*/
function isTiedCult(); function hasTieRace_open();
function isTiedCiv(); function hasTieAlign_open();
function getCurrentCiv(); function hasTieRace_done();
function getCurrentCult(); function hasTieAlign_done();
function hasTieRaceDev();
function hasTieAlignDev();
function isTiedRace_open($r);
function isTiedAlign_open($cult,$civ);
function isTiedRace_done($r);
function isTiedAlign_done($cult,$civ);
#function getCurrentCiv();
#function getCurrentCult();
} }
?> ?>

View file

@ -4,7 +4,7 @@
$c = "<table> $c = "<table>
<tr> <tr>
<td>".ach_render_yubopoints($_USER->getID())."</td> <td>".ach_render_yubopoints()."</td>
</tr> </tr>
</table> </table>
@ -22,7 +22,21 @@
$open = $menu->getOpenCat(); $open = $menu->getOpenCat();
if($open != 0) { if($open != 0) {
$cat = new AchCategory($open,$_REQUEST['cult'],$_REQUEST['civ']); if($_REQUEST['cult']) {
$cult = $_REQUEST['cult'];
}
else {
$cult = $_USER->getCult();
}
if($_REQUEST['civ']) {
$civ = $_REQUEST['civ'];
}
else {
$civ = $_USER->getCiv();
}
$cat = new AchCategory($open,$_USER->getRace(),$cult,$civ);
} }
else { else {
$cat = new AchSummary($menu,$_CONF['summary_size']); $cat = new AchSummary($menu,$_CONF['summary_size']);
@ -47,7 +61,7 @@
$html = "<form method='post' action='?cat=".$cat->getID()."'> $html = "<form method='post' action='?cat=".$cat->getID()."'>
<table> <table>
<tr>"; <tr>";
if($cat->isTiedCult()) { if($cat->isAllowedCult()) {
$html.= "<td> $html.= "<td>
<select name='cult'> <select name='cult'>
<option value='c_neutral'"; if($cult == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option> <option value='c_neutral'"; if($cult == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
@ -56,7 +70,7 @@
</select> </select>
</td>"; </td>";
} }
if($cat->isTiedCiv()) { if($cat->isAllowedCiv()) {
$html.= "<td> $html.= "<td>
<select name='civ'> <select name='civ'>
<option value='c_neutral'"; if($civ == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option> <option value='c_neutral'"; if($civ == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
@ -73,30 +87,30 @@
<font size='12px' color='#FFFFFF'>"; <font size='12px' color='#FFFFFF'>";
if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx /*if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx
#While being of neutral allegiance with the higher powers #While being of neutral allegiance with the higher powers
$html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("<font color='orange'>".get_translation('ach_c_neutral',$_USER->getLang())."</font>")); $html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("<font color='orange'>".get_translation('ach_c_neutral',$_USER->getLang())."</font>"));
} }
elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral
#While being of neutral allegiance with the homin civilizations #While being of neutral allegiance with the homin civilizations
$html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("<font color='orange'>".get_translation('ach_c_neutral',$_USER->getLang())."</font>")); $html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("<font color='orange'>".get_translation('ach_c_neutral',$_USER->getLang())."</font>"));
} }*/
elseif($cat->isTiedCiv() && $cat->isTiedCult() && $cult == "c_neutral" && $civ == "c_neutral") { // neutral / neutral if(($cult == "c_neutral" || !$cat->isAllowedCult()) && ($civ == "c_neutral" || !$cat->isAllowedCiv())) { // neutral / neutral
#While being of neutral allegiance #While being of neutral allegiance
$html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("<font color='orange'>".get_translation('ach_c_neutral',$_USER->getLang())."</font>")); $html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("<font color='orange'>".get_translation('ach_c_neutral',$_USER->getLang())."</font>"));
} }
else { //other else { //other
#While being aligned with the #While being aligned with the
$html .= get_translation('ach_allegiance_start',$_USER->getLang()); $html .= get_translation('ach_allegiance_start',$_USER->getLang());
if($cat->isTiedCult() && $cult != "c_neutral") { if($cat->isAllowedCult() && $cult != "c_neutral") {
#CULT #CULT
$html .= "<font color='orange'>".ach_translate_cc($cult)."</font>"; $html .= "<font color='orange'>".ach_translate_cc($cult)."</font>";
if($cat->isTiedCiv() && $civ != "c_neutral") { if($cat->isAllowedCiv() && $civ != "c_neutral") {
#and the CIV #and the CIV
$html .= get_translation('ach_allegiance_and',$_USER->getLang())." <font color='orange'>".ach_translate_cc($civ)."</font>"; $html .= get_translation('ach_allegiance_and',$_USER->getLang())." <font color='orange'>".ach_translate_cc($civ)."</font>";
} }
} }
elseif($cat->isTiedCiv() && $civ != "c_neutral") { elseif($cat->isAllowedCiv() && $civ != "c_neutral") {
#CIV #CIV
$html .= "<font color='orange'>".ach_translate_cc($civ)."</font>"; $html .= "<font color='orange'>".ach_translate_cc($civ)."</font>";
} }
@ -153,7 +167,7 @@
else { else {
$html .= "<img src='".$_CONF['image_url']."pic/menu_space.png?cacheid=".$_CONF['image_cdate']."' />"; $html .= "<img src='".$_CONF['image_url']."pic/menu_space.png?cacheid=".$_CONF['image_cdate']."' />";
} }
$html .= "</td><td><a href='?lang=en&cat=".$curr->getID()."'><font size='".(16-$sub)."px'"; $html .= "</td><td><a href='?cat=".$curr->getID()."'><font size='".(16-$sub)."px'";
if($curr->isOpen()) { if($curr->isOpen()) {
$html .= " color='orange'"; $html .= " color='orange'";
} }
@ -181,7 +195,7 @@
return "<center style='font-size:24px;'>".get_translation('ach_no_heroic_deeds',$_USER->getLang())."</center>"; return "<center style='font-size:24px;'>".get_translation('ach_no_heroic_deeds',$_USER->getLang())."</center>";
} }
if($cat->isTiedCult() || $cat->isTiedCiv()) { if($cat->hasTieAlign_done() || $cat->hasTieAlign_open()) {
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat); $html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
} }
@ -189,10 +203,10 @@
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->inDev() || !$curr->parentDone()) { if($curr->inDev() || !$curr->parentDone() || !$curr->isTiedRace_done($cat->getCurrentRace()) || !$curr->isTiedAlign_done($cat->getCurrentCult(),$cat->getCurrentCiv())) {
continue; continue;
} }
$html .= ach_render_achievement_done($curr); $html .= ach_render_achievement_done($curr,$cat);
} }
if($cat->isHeroic()) { if($cat->isHeroic()) {
@ -203,16 +217,16 @@
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->inDev() || !$curr->parentDone()) { if($curr->inDev() || !$curr->parentDone() || !$curr->isTiedRace_open($cat->getCurrentRace()) || !$curr->isTiedAlign_open($cat->getCurrentCult(),$cat->getCurrentCiv())) {
continue; continue;
} }
$html .= ach_render_achievement_open($curr); $html .= ach_render_achievement_open($curr,$cat);
} }
return $html; return $html;
} }
function ach_render_achievement_done(&$ach) { function ach_render_achievement_done(&$ach,&$cat) {
global $_CONF; global $_CONF;
$html = " $html = "
@ -223,7 +237,7 @@
<tr> <tr>
<td width='70px'><img src='".$_CONF['image_url']."pic/icon/".$ach->getImage()."?cacheid=".$_CONF['image_cdate']."'></td> <td width='70px'><img src='".$_CONF['image_url']."pic/icon/".$ach->getImage()."?cacheid=".$_CONF['image_cdate']."'></td>
<td><center><font size='22px'><b>".$ach->getName()."</b></font></center> <td><center><font size='22px'><b>".$ach->getName()."</b></font></center>
<table>".ach_render_task_done($ach)."</table> <table>".ach_render_task_done($ach,$cat)."</table>
</td> </td>
<td width='35px'>"; <td width='35px'>";
if((!$ach->isHeroic() && !$ach->isContest()) && $ach->getValueDone() > 0) { if((!$ach->isHeroic() && !$ach->isContest()) && $ach->getValueDone() > 0) {
@ -243,7 +257,7 @@
return $html; return $html;
} }
function ach_render_achievement_open(&$ach) { function ach_render_achievement_open(&$ach,&$cat) {
global $_CONF; global $_CONF;
$html = " $html = "
@ -291,7 +305,7 @@
return $html; return $html;
} }
function ach_render_task_done(&$ach) { function ach_render_task_done(&$ach,&$cat) {
global $_CONF; global $_CONF;
$html = ""; $html = "";
@ -299,7 +313,7 @@
while($task_list->hasNext()) { while($task_list->hasNext()) {
$task = $task_list->getNext(); $task = $task_list->getNext();
if($task->inDev()) { if($task->inDev() || !$task->isTiedRace_open($cat->getCurrentRace()) || !$task->isTiedAlign_open($cat->getCurrentCult(),$cat->getCurrentCiv())) {
continue; continue;
} }
$html .= "<tr><td><font color='#66CC00'><b>".$task->getDisplayName()."</b></font><br>( ".date('d.m.Y',$task->getDone())." )"; $html .= "<tr><td><font color='#66CC00'><b>".$task->getDisplayName()."</b></font><br>( ".date('d.m.Y',$task->getDone())." )";
@ -370,13 +384,13 @@
$html = ""; $html = "";
if($obj->isdone()) { if($obj->isdone()) {
$html .= "<img src='".$_CONF['image_url']."pic/check.png?cacheid=".$_CONF['image_cdate']."' height='10px' />&nbsp;<font color='#71BE02;'>"; $html .= "<table><tr><td><img src='".$_CONF['image_url']."pic/check.png?cacheid=".$_CONF['image_cdate']."' height='10px' /></td><td>&nbsp;<font color='#71BE02;'>";
} }
else { else {
$html .= "<img src='".$_CONF['image_url']."pic/pending.png?cacheid=".$_CONF['image_cdate']."' height='10px' />&nbsp;<font color='#999999;'>"; $html .= "<table><tr><td><img src='".$_CONF['image_url']."pic/pending.png?cacheid=".$_CONF['image_cdate']."' height='10px' />&nbsp;<font color='#999999;'></td><td>";
} }
$html .= $obj->getDisplayName()."</font>"; $html .= $obj->getDisplayName()."</font></td></tr></table>";
return $html; return $html;
} }

View file

@ -1,12 +1,12 @@
<?php <?php
function ach_render() { function ach_render() {
global $user,$_CONF; global $_USER,$_CONF;
$c = "<center><table> $c = "<center><table>
<tr> <tr>
<td colspan='2' align='left'> <td colspan='2' align='left'>
<div style='display:block;border-bottom:1px solid #000000;'> <div style='display:block;border-bottom:1px solid #000000;'>
<div style='float:left;width:420px;'>".ach_render_yubopoints($user['id'])."</div> <div style='float:left;width:420px;'>".ach_render_yubopoints()."</div>
<div style='float:right;width:420px;text-align:right;'>".ach_render_facebook()."</div> <div style='float:right;width:420px;text-align:right;'>".ach_render_facebook()."</div>
<div style='clear:both;'></div> <div style='clear:both;'></div>
</div> </div>
@ -31,7 +31,21 @@
$open = $menu->getOpenCat(); $open = $menu->getOpenCat();
if($open != 0) { if($open != 0) {
$cat = new AchCategory($open,null,$_REQUEST['cult'],$_REQUEST['civ']); if($_REQUEST['cult']) {
$cult = $_REQUEST['cult'];
}
else {
$cult = $_USER->getCult();
}
if($_REQUEST['civ']) {
$civ = $_REQUEST['civ'];
}
else {
$civ = $_USER->getCiv();
}
$cat = new AchCategory($open,$_USER->getRace(),$cult,$civ);
} }
else { else {
#die($_CONF['summary_size']); #die($_CONF['summary_size']);
@ -63,7 +77,7 @@
<div style='display:block;text-align:center;'><form method='post' action='?cat=".$cat->getID()."' id='cc_form'> <div style='display:block;text-align:center;'><form method='post' action='?cat=".$cat->getID()."' id='cc_form'>
<table> <table>
<tr>"; <tr>";
if($cat->isTiedCult()) { if($cat->isAllowedCult()) {
$html.= "<td> $html.= "<td>
<select name='cult' onchange='document.getElementById(\"cc_form\").submit();'> <select name='cult' onchange='document.getElementById(\"cc_form\").submit();'>
<option value='c_neutral'"; if($cult == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option> <option value='c_neutral'"; if($cult == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
@ -72,7 +86,7 @@
</select> </select>
</td>"; </td>";
} }
if($cat->isTiedCiv()) { if($cat->isAllowedCiv()) {
$html.= "<td> $html.= "<td>
<select name='civ' onchange='document.getElementById(\"cc_form\").submit();'> <select name='civ' onchange='document.getElementById(\"cc_form\").submit();'>
<option value='c_neutral'"; if($civ == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option> <option value='c_neutral'"; if($civ == "c_neutral") { $html.= " selected='selected'"; } $html .= ">".get_translation('ach_c_neutral',$_USER->getLang())."</option>
@ -89,30 +103,30 @@
<div style='display:block;font-weight:bold;font-size:20px;color:#FFFFFF;text-align:center;margin-bottom:5px;'>"; <div style='display:block;font-weight:bold;font-size:20px;color:#FFFFFF;text-align:center;margin-bottom:5px;'>";
if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx /*if($cat->isTiedCult() && !$cat->isTiedCiv() && $cult == "c_neutral") { // neutral / xx
#While being of neutral allegiance with the higher powers #While being of neutral allegiance with the higher powers
$html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>")); $html .= get_translation('ach_allegiance_neutral_cult',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
} }
elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral elseif($cat->isTiedCiv() && !$cat->isTiedCult() && $civ == "c_neutral") { // xx / neutral
#While being of neutral allegiance with the homin civilizations #While being of neutral allegiance with the homin civilizations
$html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>")); $html .= get_translation('ach_allegiance_neutral_civ',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
} }*/
elseif($cat->isTiedCiv() && $cat->isTiedCult() && $cult == "c_neutral" && $civ == "c_neutral") { // neutral / neutral if(($cult == "c_neutral" || !$cat->isAllowedCult()) && ($civ == "c_neutral" || !$cat->isAllowedCiv())) { // neutral / neutral
#While being of neutral allegiance #While being of neutral allegiance
$html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>")); $html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
} }
else { //other else { //other
#While being aligned with the #While being aligned with the
$html .= get_translation('ach_allegiance_start',$_USER->getLang()); $html .= get_translation('ach_allegiance_start',$_USER->getLang());
if($cat->isTiedCult() && $cult != "c_neutral") { if($cat->isAllowedCult() && $cult != "c_neutral") {
#CULT #CULT
$html .= "<span class='o'>".ach_translate_cc($cult)."</span>"; $html .= "<span class='o'>".ach_translate_cc($cult)."</span>";
if($cat->isTiedCiv() && $civ != "c_neutral") { if($cat->isAllowedCiv() && $civ != "c_neutral") {
#and the CIV #and the CIV
$html .= get_translation('ach_allegiance_and',$_USER->getLang())." <span class='o'>".ach_translate_cc($civ)."</span>"; $html .= get_translation('ach_allegiance_and',$_USER->getLang())." <span class='o'>".ach_translate_cc($civ)."</span>";
} }
} }
elseif($cat->isTiedCiv() && $civ != "c_neutral") { elseif($cat->isAllowedCiv() && $civ != "c_neutral") {
#CIV #CIV
$html .= "<span class='o'>".ach_translate_cc($civ)."</span>"; $html .= "<span class='o'>".ach_translate_cc($civ)."</span>";
} }
@ -193,7 +207,7 @@
if($curr->inDev()) { if($curr->inDev()) {
continue; continue;
} }
$html .= "<span class='ach_mspan'><a href='?lang=en&cat=".$curr->getID()."'><table class='ach_menu'> $html .= "<span class='ach_mspan'><a href='?cat=".$curr->getID()."'><table class='ach_menu'>
<tr>"; <tr>";
if($sub == 0) { if($sub == 0) {
$html .= "<td style='width:32px;'><img src='".$_CONF['image_url']."pic/menu/".$curr->getImage()."' /></td>"; $html .= "<td style='width:32px;'><img src='".$_CONF['image_url']."pic/menu/".$curr->getImage()."' /></td>";
@ -221,7 +235,7 @@
return "<center style='font-size:24px;'>".get_translation('ach_no_heroic_deeds',$_USER->getLang())."</center>"; return "<center style='font-size:24px;'>".get_translation('ach_no_heroic_deeds',$_USER->getLang())."</center>";
} }
if($cat->isTiedCult() || $cat->isTiedCiv()) { if($cat->hasTieAlign_done() || $cat->hasTieAlign_open()) {
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat); $html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat);
} }
@ -229,10 +243,10 @@
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->inDev() || !$curr->parentDone()) { if($curr->inDev() || !$curr->parentDone() || !$curr->isTiedRace_done($cat->getCurrentRace()) || !$curr->isTiedAlign_done($cat->getCurrentCult(),$cat->getCurrentCiv())) {
continue; continue;
} }
$html .= ach_render_achievement_done($curr); $html .= ach_render_achievement_done($curr,$cat);
} }
if($cat->isHeroic()) { if($cat->isHeroic()) {
@ -243,16 +257,16 @@
while($iter->hasNext()) { while($iter->hasNext()) {
$curr = $iter->getNext(); $curr = $iter->getNext();
if($curr->inDev() || !$curr->parentDone()) { if($curr->inDev() || !$curr->parentDone() || !$curr->isTiedRace_open($cat->getCurrentRace()) || !$curr->isTiedAlign_open($cat->getCurrentCult(),$cat->getCurrentCiv())) {
continue; continue;
} }
$html .= ach_render_achievement_open($curr); $html .= ach_render_achievement_open($curr,$cat);
} }
return $html; return $html;
} }
function ach_render_achievement_done(&$ach) { function ach_render_achievement_done(&$ach,&$cat) {
global $_CONF; global $_CONF;
$html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%"> $html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%">
@ -277,7 +291,7 @@
} }
$html .= '</td> $html .= '</td>
</tr><tr><td align="center" valign="top"><table>'; </tr><tr><td align="center" valign="top"><table>';
$html .= ach_render_task_done($ach); $html .= ach_render_task_done($ach,$cat);
$html .= '</table></td></tr></tbody></table></center> $html .= '</table></td></tr></tbody></table></center>
</td> </td>
<td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_r.png);"></td> <td style="background-image: url('.$_CONF['image_url'].'pic/bar_done_r.png);"></td>
@ -292,7 +306,7 @@
return $html; return $html;
} }
function ach_render_achievement_open(&$ach) { function ach_render_achievement_open(&$ach,&$cat) {
global $_CONF; global $_CONF;
$html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%"> $html = '<div style="display: block; margin-bottom: 5px;"><table cellpadding="0" cellspacing="0" width="100%">
@ -352,7 +366,7 @@
return $html; return $html;
} }
function ach_render_task_done(&$ach) { function ach_render_task_done(&$ach,&$cat) {
global $_CONF; global $_CONF;
$html = ""; $html = "";
@ -360,7 +374,7 @@
while($task_list->hasNext()) { while($task_list->hasNext()) {
$task = $task_list->getNext(); $task = $task_list->getNext();
if($task->inDev()) { if($task->inDev() || !$task->isTiedRace_open($cat->getCurrentRace()) || !$task->isTiedAlign_open($cat->getCurrentCult(),$cat->getCurrentCiv())) {
continue; continue;
} }
$html .= "<tr><td><span style='color:#66CC00;font-weight:bold;'>".$task->getDisplayName()."</span></td><td>( ".date('d.m.Y',$task->getDone())." )</td>"; $html .= "<tr><td><span style='color:#66CC00;font-weight:bold;'>".$task->getDisplayName()."</span></td><td>( ".date('d.m.Y',$task->getDone())." )</td>";

View file

@ -105,6 +105,6 @@ else {
} }
echo ryzom_app_render("achievements", $c, $_USER->isIG()); echo ryzom_app_render(strtoupper(get_translation('ach_app_name',$_USER->getLang())), $c, $_USER->isIG());
?> ?>