Skip to content

Commit

Permalink
[422] Properly display achievement date (Character feed feature). Tha…
Browse files Browse the repository at this point in the history
…nks to Vasago for a constant reminder about this issue :)
  • Loading branch information
Shadez committed Dec 19, 2010
1 parent 48607cd commit 9eec617
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 40 deletions.
47 changes: 34 additions & 13 deletions includes/classes/class.achievements.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @package World of Warcraft Armory
* @version Release Candidate 1
* @revision 410
* @revision 422
* @copyright (c) 2009-2010 Shadez
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
Expand Down Expand Up @@ -35,46 +35,54 @@
* @category Achievements class
* @access public
**/
public $guid;
public $guid = 0;

/**
* Character achievement points
* @category Achievements class
* @access public
**/
public $pts;
public $pts = 0;

/**
* Achievement ID
* @category Achievements class
* @access public
**/
public $achId;
public $achId = -1;

/**
* Character achievements count
* @category Achievements class
* @access private
**/
private $m_count;
private $m_count = 0;

private $b_isInitialized = false;

private $db = null;

/**
* Assign $armory variable
* Class constructor, assigns $armory instance.
* @category Achievements class
* @access public
* @param Armory $armory
* @return bool
**/
public function Achievements($armory) {
if(!is_object($armory)) {
die('<b>Fatal Error:</b> armory must be instance of Armory class!');
}
$this->armory = $armory;
return true;
}

/**
* Creates Achievement class instance
* @category Achievements class
* @access public
* @param int $player_guid
* @param ArmoryDatabaseHandler $db
* @param bool $check = true
* @return bool
**/
Expand All @@ -96,6 +104,7 @@ public function InitAchievements($player_guid, $db, $check = true) {
$this->guid = $player_guid;
self::CalculateAchievementPoints();
self::CountCharacterAchievements();
$this->b_isInitialized = true;
return true;
}

Expand All @@ -106,6 +115,10 @@ public function InitAchievements($player_guid, $db, $check = true) {
* @return int
**/
public function GetAchievementPoints() {
if(!$this->b_isInitialized) {
$this->armory->Log()->writeError('%s : unexpected method call: class was not initialized.', __METHOD__);
return false;
}
return $this->pts;
}

Expand All @@ -116,6 +129,10 @@ public function GetAchievementPoints() {
* @return int
**/
public function GetAchievementsCount() {
if(!$this->b_isInitialized) {
$this->armory->Log()->writeError('%s : unexpected method call: class was not initialized.', __METHOD__);
return false;
}
return $this->m_count;
}

Expand All @@ -132,7 +149,7 @@ public function CalculateAchievementPoints() {
}
$achievement_ids = $this->db->select("SELECT `achievement` FROM `character_achievement` WHERE `guid`=%d", $this->guid);
if(!$achievement_ids) {
$this->armory->Log()->writeError('%s : unable to find any completed achievement for player %d', __METHOD__, $this->guid);
$this->armory->Log()->writeError('%s : unable to find any completed achievements for player %d', __METHOD__, $this->guid);
return false;
}
$ids = array();
Expand Down Expand Up @@ -172,7 +189,7 @@ public function GetSummaryAchievementData($category) {
}
$achievement_data = array('categoryId' => $category);
$categories = 0;
// 3.3.5a
// 4.0.1
switch($category) {
case ACHIEVEMENTS_CATEGORY_GENERAL:
$categories = 92;
Expand Down Expand Up @@ -273,7 +290,7 @@ public function GetLastAchievements() {
}
$achievements = $this->db->select("SELECT `achievement`, `date` FROM `character_achievement` WHERE `guid`=%d ORDER BY `date` DESC LIMIT 5", $this->guid);
if(!$achievements) {
$this->armory->Log()->writeError('%s : unable to get data from character_achievement (player %d does not have achievements?)', __METHOD__, $this->guid);
$this->armory->Log()->writeError('%s : unable to get data from character_achievement (player %d does not have any completed achievement?)', __METHOD__, $this->guid);
return false;
}
$aCount = count($achievements);
Expand All @@ -288,9 +305,10 @@ public function GetLastAchievements() {
* @category Achievements class
* @access public
* @param int $achId = 0
* @param bool $returnStamp = false
* @return string
**/
public function GetAchievementDate($achId = 0) {
public function GetAchievementDate($achId = 0, $returnStamp = false) {
if($achId == 0) {
$achId = $this->achId;
}
Expand All @@ -303,6 +321,9 @@ public function GetAchievementDate($achId = 0) {
$this->armory->Log()->writeError('%s : unable to find completion date for achievement %d, player %d', __METHOD__, $achId, $this->guid);
return false;
}
if($returnStamp) {
return $achievement_date;
}
return date('d/m/Y', $achievement_date); // Hack (Can't find the reason why achievement date is not displaying. Working on it.)
}

Expand Down Expand Up @@ -414,7 +435,7 @@ public function IsAchievementCompleted($achId) {
* @return bool
**/
public function IsAchievementExists($achId) {
return $this->armory->aDB->selectCell("SELECT 1 FROM `ARMORYDBPREFIX_achievement` WHERE `id`=%d LIMIT 1", $achId);
return (bool) $this->armory->aDB->selectCell("SELECT 1 FROM `ARMORYDBPREFIX_achievement` WHERE `id`=%d LIMIT 1", $achId);
}

/**
Expand Down Expand Up @@ -453,14 +474,14 @@ public function LoadAchievementPage($page_id, $faction) {
unset($return_data['completed'][$this->achId]['data']['titleReward']);
}
if($page_id == ACHIEVEMENTS_CATEGORY_FEATS) {
// Feats of Strength have no achievement points
// Feats of Strength has no achievement points
unset($return_data['completed'][$this->achId]['data']['points']);
}
$return_data['completed'][$this->achId]['data']['dateCompleted'] = self::GetAchievementDate();
$return_data['completed'][$this->achId]['display'] = 1;
$parent_used = false;
if($parentId > 0 && self::IsAchievementCompleted($parentId)) {
$j=0;
$j = 0;
$fullPoints = 0;
$return_data['completed'][$this->achId]['achievement_tree'] = array();
while($parentId != 0) {
Expand Down
Loading

6 comments on commit 9eec617

@Vasago
Copy link

@Vasago Vasago commented on 9eec617 Dec 19, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much. BTW very last thing what troubles many people about nacked characters and missing model - you said something about extraction but i did not find an way how to do so - if you tell me the way I can extract it for you and this armory :-)

@Shadez
Copy link
Owner Author

@Shadez Shadez commented on 9eec617 Dec 19, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vasago
Copy link

@Vasago Vasago commented on 9eec617 Dec 20, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying now according to apache catch all and after send them to you but there are some missing like:
models/item/texturecomponents/torsouppertexture/robe_pvpwarlock_b_04_chest_tu_u.png
models/item/texturecomponents/torsouppertexture/robe_pvpwarlock_b_04_chest_tu_u.jpg
models/item/texturecomponents/torsolowertexture/robe_pvpwarlock_b_04_chest_tl_u.jpg
models/item/texturecomponents/torsolowertexture/robe_pvpwarlock_b_04_chest_tl_u.png
Where else can i find them?

@Vasago
Copy link

@Vasago Vasago commented on 9eec617 Dec 20, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also there are some warnings:
Warning: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0

Warning: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0

@Der-WU
Copy link

@Der-WU Der-WU commented on 9eec617 Dec 20, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anyone has the newest files for 3d viewer, he can upload them to my ftp server and i can share them with full speed.
Cause i´m not understand how to extract them from the DBC files. :)

Greatz WuChEn

@Shadez
Copy link
Owner Author

@Shadez Shadez commented on 9eec617 Jan 7, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying now according to apache catch all and after send them to you but there are some missing like:
models/item/texturecomponents/torsouppertexture/robe_pvpwarlock_b_04_chest_tu_u.png

Sorry for long response - Github wasn't noticied me about new comments. Well, that's what I was talking about - I do not know how to generate file suffixes (_u, _m, _f).
Files that listed in your comment should have _f suffix instead of _u.

Please sign in to comment.