#1470 tied achievements added

--HG--
branch : gsoc2012-achievements
This commit is contained in:
SirCotare 2012-06-03 15:04:04 +02:00
parent 29d1d9372f
commit f18e2a7a76
5 changed files with 165 additions and 23 deletions

View file

@ -3,14 +3,27 @@
private $id = false;
private $ties_cult;
private $ties_civ;
private $cult;
private $civ;
function AchCategory($id,$cult,$civ) {
function AchCategory($id,$cult = null,$civ = null) {
global $DBc,$_USER;
$this->id = $id;
if($cult == null) {
$cult = $_USER->getCult();
}
if($civ == null) {
$civ = $_USER->getCiv();
}
$this->cult = $cult;
$this->civ = $civ;
$this->id = mysql_real_escape_string($id);
$res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND (aa_parent IS NULL OR NOT EXISTS (SELECT * FROM ach_perk WHERE ap_achievement=aa_id AND NOT EXISTS (SELECT * FROM ach_player_perk WHERE app_player='".$_USER->getID()."' AND app_perk=ap_id))) AND (aa_tie_race IS NULL OR aa_tie_race='".$_USER->getRace()."') AND (aa_tie_cult IS NULL OR aa_tie_cult='".mysql_real_escape_string($cult)."') AND (aa_tie_civ IS NULL OR aa_tie_civ='".mysql_real_escape_string($civ)."') ORDER by aal_name ASC");
$res = $DBc->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$_USER->getLang()."' AND aal_achievement=aa_id) WHERE aa_category='".$this->id."' AND aa_parent IS NULL AND (aa_tie_race IS NULL OR aa_tie_race='".$_USER->getParam('race')."') AND (aa_tie_cult IS NULL OR aa_tie_cult='".$cult."') AND (aa_tie_civ IS NULL OR aa_tie_civ='".$civ."') ORDER by aal_name ASC");
#MISSING: or parent is done
$sz = sizeof($res);
for($i=0;$i<$sz;$i++) {
#echo "Y";
@ -26,10 +39,10 @@
$this->nodes[] = $tmp;
}
$res = $DBc->sqlQuery("SELECT count(*) FROM ach_achievement WHERE aa_tie_cult IS NOT NULL");
$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 = $res[0]['anz'];
$res = $DBc->sqlQuery("SELECT count(*) FROM ach_achievement WHERE aa_tie_civ IS NOT NULL");
$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 = $res[0]['anz'];
}
@ -44,5 +57,13 @@
function isTiedCiv() {
return ($this->ties_civ > 0);
}
function getCurrentCiv() {
return $this->civ;
}
function getCurrentCult() {
return $this->cult;
}
}
?>

View file

@ -21,5 +21,21 @@
function getParam($p) {
return $this->data[$p];
}
function getRace() {
return $this->data['race'];
}
function getCiv() {
return $this->data['civilization'];
}
function getCult() {
return $this->data['cult'];
}
function getName() {
return $this->data['name'];
}
}
?>

View file

@ -4,8 +4,79 @@
return number_format($n, 0, '.', ',');
}
function ach_render_tiebar($cult = "neutral", $civ = "neutral") {
function ach_translate_cc($cc = 'c_neutral') {
global $_USER;
$t = array();
$t['c_matis'] = 'Matis';
$t['c_tryker'] = 'Tryker';
$t['c_fyros'] = 'Fyros';
$t['c_zorai'] = 'Zorai';
$t['c_kami'] = 'Kami';
$t['c_karavan'] = 'Karavan';
$t['c_neutral'] = get_translation('ach_c_neutral',$_USER->getLang());
return $t[$cc];
}
function ach_render_tiebar($cult = "c_neutral", $civ = "c_neutral",$cat) {
global $_USER;
$html = "<style>
.o {
color:orange;
}
</style>
<div style='display:block;text-align:center;'><form method='post' action='?cat=".$cat."' id='cc_form'>
<table>
<tr>
<td>
<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_kami'"; if($cult == "c_kami") { $html.= " selected='selected'"; } $html .= ">Kami</option>
<option value='c_karavan'"; if($cult == "c_karavan") { $html.= " selected='selected'"; } $html .= ">Karavan</option>
</select>
</td>
<td>
<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_fyros'"; if($civ == "c_fyros") { $html.= " selected='selected'"; } $html .= ">Fyros</option>
<option value='c_matis'"; if($civ == "c_matis") { $html.= " selected='selected'"; } $html .= ">Matis</option>
<option value='c_tryker'"; if($civ == "c_tryker") { $html.= " selected='selected'"; } $html .= ">Tryker</option>
<option value='c_zorai'"; if($civ == "c_zorai") { $html.= " selected='selected'"; } $html .= ">Zorai</option>
</select>
</td>
</tr>
</table>
</form></div>
<div style='display:block;font-weight:bold;font-size:20px;color:#FFFFFF;text-align:center;margin-bottom:5px;'>";
if($cult == "c_neutral" && $civ == "c_neutral") {
#$html .= "While being of <span class='o'>neutral</span> allegiance";
$html .= get_translation('ach_allegiance_neutral',$_USER->getLang(),array("<span class='o'>".get_translation('ach_c_neutral',$_USER->getLang())."</span>"));
}
else {
#$html .= "While being aligned with the <span class='o'>";
$html .= get_translation('ach_allegiance_start',$_USER->getLang());
if($cult != "c_neutral") {
#$html .= $cult;
$html .= "<span class='o'>".ach_translate_cc($cult)."</span>";
if($civ != "c_neutral") {
#$html .= "</span> and the <span class='o'>".$civ;
$html .= get_translation('ach_allegiance_and',$_USER->getLang())." <span class='o'>".ach_translate_cc($civ)."</span>";
}
}
else {
#$html .= $civ;
$html .= " <span class='o'>".ach_translate_cc($cult)."</span>";
}
}
#$html .= "</span>, accomplish the following achievements:</div>";
$html .= get_translation('ach_allegiance_end',$_USER->getLang())."</div>";
return $html;
}
function ach_render_yubopoints() {
@ -13,7 +84,7 @@
$res = $DBc->sqlQuery("SELECT sum(ap_value) as anz FROM ach_perk,ach_player_perk WHERE ap_id=app_perk AND app_player='".$_USER->getID()."'");
$html = "<div style='display:block;border-bottom:1px solid #000000;'><img src='pic/yubo_done.png'>&nbsp;<span style='font-size:32px;'>".$res[0]['anz']."</span></div>";
$html = "<div style='display:block;border-bottom:1px solid #000000;'><span style='font-size:32px;'>".$_USER->getName()."&nbsp;<img src='pic/yubo_done.png'>&nbsp;".$res[0]['anz']."</span></div>";
return $html;
}
@ -62,6 +133,10 @@
function ach_render_category(&$cat) {
$html = "";
if($cat->isTiedCult() || $cat->isTiedCiv()) {
$html .= ach_render_tiebar($cat->getCurrentCult(),$cat->getCurrentCiv(),$cat->getID());
}
$tmp = $cat->getDone();
$sz = sizeof($tmp);
for($i=0;$i<$sz;$i++) {

View file

@ -13,6 +13,14 @@ require_once('conf.php');
// Ask to authenticate user (using ingame or session method) and fill $user with all information
ryzom_app_authenticate($user, false);
$user = array();
$user['id'] = 1;
$user['lang'] = 'en';
$user['name'] = 'Talvela';
$user['race'] = "r_matis";
$user['civilization'] = "c_neutral";
$user['cult'] = "c_neutral";
require_once("class/RyzomUser_class.php");
$_USER = new RyzomUser($user);
@ -74,20 +82,7 @@ $c .= "</div></td>
$open = $menu->getOpenCat();
if($open != 0) {
if($_REQUEST['cult']) {
$cult = mysql_real_escape_string($_REQUEST['cult']);
}
else {
$cult = $_USER->getParam('cult');
}
if($_REQUEST['civ']) {
$civ = mysql_real_escape_string($_REQUEST['civ']);
}
else {
$civ = $_USER->getParam('civ');
}
$cat = new AchCategory($open,$cult,$civ);
$cat = new AchCategory($open,$_REQUEST['cult'],$_REQUEST['civ']);
}
else {
$cat = new AchSummary($menu,8);

View file

@ -1,4 +1,4 @@
<?php // %2011-09-28T08:12:16+02:00
<?php
$__texts = array (
'ach_summary' =>
@ -29,6 +29,41 @@ $__texts = array (
'de' => '',
'ru' => '',
),
'ach_c_neutral' =>
array (
'en' => 'neutral',
'fr' => '',
'de' => '',
'ru' => '',
),
'ach_allegiance_neutral' =>
array (
'en' => 'While being of %s allegiance',
'fr' => '',
'de' => '',
'ru' => '',
),
'ach_allegiance_start' =>
array (
'en' => 'While being aligned with the ',
'fr' => '',
'de' => '',
'ru' => '',
),
'ach_allegiance_and' =>
array (
'en' => ' and the ',
'fr' => '',
'de' => '',
'ru' => '',
),
'ach_allegiance_end' =>
array (
'en' => ', accomplish the following achievements:',
'fr' => '',
'de' => '',
'ru' => '',
),
);