";
if ($viewer) echo "
Viewing ";
$badgeURL = linkEmblem($wallEmblem, $wallOrientation);
echo "
";
function unlockItemAsTD($uType, $item) {
$aLevel = $item['aLevel'];
$aCompleted = $item['dateUnlocked'];
$aTypeNames[ACHIEVEMENT_MOVES_CAREER] = "Path Career Level $aLevel";
$aTypeNames[ACHIEVEMENT_MAZE_CAREER] = "Mazes Career Level $aLevel";
$aTypeNames[ACHIEVEMENT_MAZE_MASTERY] = "Maze Mastery Level $aLevel";
$aTypeNames[ACHIEVEMENT_CHAMPION_POINTS] = "Champion Level $aLevel";
$aTypeNames[ACHIEVEMENT_PERFECT_DAY] = "Perfect Days $aLevel";
$aTypeNames[ACHIEVEMENT_TUTORIAL] = 'Completing Tutorial';
$by = $aTypeNames[$item['aType']];
$on = relative_date(strtotime($aCompleted));
$unlockTitle = "$item[name]. From $by $on";
if ($item['aType'] == -1) {
$unlockTitle = "$item[name]";
}
$border = 'border: 1px solid #000; border-width: 2px 0px 2px 0px;';
$border = 'border: 1px solid #000;';
$class = 'grid_td_walls';
//$r .= displayUnlock($uType, $item[value], $unlockTitle);
//return $r;
switch ($uType) {
case UNLOCK_WALL_COLOR:
if ($GLOBALS['wallColor'] == $item[value]) {
$class = 'grid_td_active';
$border = 'border: 1px solid #26b;';
}
$r .= "
";
break;
case UNLOCK_WALL_EMBLEM:
if ($GLOBALS['wallEmblem'] == $item[value]) {
$class = 'grid_td_active';
$border = 'border: 1px solid #26b;';
}
$r .= "
";
break;
case UNLOCK_DISPLAY_COLOR:
if ($GLOBALS['nameColor'] == $item[value])
$border = 'border: 1px solid #26b;';
$r .= "
";
$r .= " $item[name] ";
$r .= " ";
break;
case UNLOCK_WALL_ORIENTATION:
$checked = '';
if (intval($GLOBALS['wallOrientation']) == intval($item[value])) $checked = 'checked';
//$r .= "
";
$r .= " ";
$r .= " $item[name] ";
$r .= " ";
break;
case UNLOCK_EXTRAS:
$r .= "
$item[name] ";
break;
}
return $r;
}
if (isset($unlocks)) {
echo "
Unlocks ";
//Define some names
$uTypeNames[UNLOCK_WALL_COLOR] = "Wall Colors";
$uTypeNames[UNLOCK_WALL_EMBLEM] = "Emblems";
$uTypeNames[UNLOCK_DISPLAY_COLOR] = "Username Colors";
$uTypeNames[UNLOCK_WALL_ORIENTATION] = "Emblem Rotations";
$uTypeNames[UNLOCK_EXTRAS] = "Extras";
$uSubtypeNames[UNLOCK_WALL_COLOR][0] = "Darker";
$uSubtypeNames[UNLOCK_WALL_COLOR][1] = "Brighter";
$uSubtypeNames[UNLOCK_WALL_EMBLEM][0] = "Simple";
$uSubtypeNames[UNLOCK_WALL_EMBLEM][1] = "Complicated";
//For every unlock type that the user has.
foreach ($unlocks as $uType => $unlock) {
$subtype = array();
echo "
$uTypeNames[$uType] unlocked: ";
foreach ($unlock as $item) {
$subtype[$item['subtype']][] = unlockItemAsTD($uType, $item);
if ((sizeof($subtype[$item['subtype']]) + 1) % 14 == 0)
$subtype[$item['subtype']][] = '
';
}
echo "";
foreach($subtype as $key => $content) {
$content = implode($content);
$tmpName = $uSubtypeNames[$uType][$key];
if (count($subtype) > 1)
echo "
$tmpName ";
echo "$content ";
}
echo "
";
}
}
echo " ";
if (!$viewer) {
//TODO add wall orientation
echo "
";
}
echo " ";
echo "Achievements ";
foreach($achievements as $aType => $a) {
$CPD = getAchievementsArray($aType);
$aLevel = $a['level'];
$aCompleted = $a['dateCompleted'];
$aCompleted = relative_date(strtotime($aCompleted));
if (!isset($uStats[$aType])) $uStats[$aType] = getAchievementCurrency($userID, $aType);
$uStats[$aType] = str_replace(",", "", $uStats[$aType]);
$uCurrent = $uStats[$aType];
$nUCurrent = number_format((double)$uCurrent);
$aTypeNames[1] = " Path Career Level $aLevel!";
$aTypeNames[2] = " Mazes Career Level $aLevel!";
$aTypeNames[3] = " Maze Mastery Level $aLevel!";
$aTypeNames[ACHIEVEMENT_CHAMPION_POINTS] = " Champion Level $aLevel!";
$aTypeNames[ACHIEVEMENT_PERFECT_DAY] = "Perfect Day level $aLevel!";
$aTypeNames[32] = 'Tutorial Complete!';
$aTypeCurrency[1] = "total moves mazed";
$aTypeCurrency[2] = "mazes played";
$aTypeCurrency[3] = "mazes with (tied) top score";
$aTypeCurrency[ACHIEVEMENT_CHAMPION_POINTS] = "champion points";
$name = $aTypeNames[$aType];
$currency = $aTypeCurrency[$aType];
echo "$name ";
if ($aType >= 32) {
echo "Completed $aCompleted";
continue;
}
$lastlevel = true;
foreach ($CPD as $item) {
list($required, $unlockType, $unlockValue, $unlockName) = $item;
if ($debug)
echo "At $required: ".displayUnlock($unlockType, $unlockValue, $unlockName)."
";
$nRequired = number_format($required);
if ($required > $uCurrent) {
$lastlevel = false;
if (!$debug)
break;
}
}
if ($lastlevel) {
echo "Completed all levels $aCompleted";
echo " $nUCurrent $currency";
continue;
}
$percent = round($uCurrent / $required * 100, 1);
//$percentLeft = 100 - $percent;
$pronoun = "you have";
if ($viewer)
$pronoun = "$UDisplay has";
echo "Last level earned $aCompleted";
echo " Currently $pronoun $nUCurrent $currency";
echo "
";
echo "Next level at $nRequired will unlock: ";
echo displayUnlock($unlockType, $unlockValue, $unlockName);
}
?>
";
echo " ";
echo " ";
htmlFooter();
// ----- Functions
//Thank you:
//http://snippets.dzone.com/posts/show/196
function relative_date($time) {
$today = strtotime(date('M j, Y'));
$reldays = ($time - $today)/86400;
if ($reldays >= 0 && $reldays < 1) {
return 'Today';
} else if ($reldays >= 1 && $reldays < 2) {
return 'Tomorrow';
} else if ($reldays >= -1 && $reldays < 0) {
return 'Yesterday';
}
if (abs($reldays) < 7) {
if ($reldays > 0) {
$reldays = floor($reldays);
return 'in ' . $reldays . ' day' . ($reldays != 1 ? 's' : '');
} else {
$reldays = abs(floor($reldays));
return $reldays . ' day' . ($reldays != 1 ? 's' : '') . ' ago';
}
}
if (abs($reldays) < 182) {
return date('l, F j',$time ? $time : time());
} else {
return date('l, F j, Y',$time ? $time : time());
}
}
?>