give names to levels

Forum
Last Post
Threads / Messages

kristhasirah

Member
Member
Joined
Jan 22, 2010
Messages
197
Points
16
Location
In middle of the nothingness
Mysidian Dollar
20,995
this code is just an edited version of the $gender_lookup code posted by kittyas.
and whats it does is to give a specific name to each level, so instead of displaying the numbers it will display a name:

PHP:
        $level_lookup = $mysidia->db->select("owned_adoptables", array("currentlevel"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if ($level_lookup == "10") {$levels = "Ancient"; } 
        if ($level_lookup == "9") {$levels = "Adult";} 
        if ($level_lookup == "8") {$levels = "Subadult";}  
        if ($level_lookup == "7") {$levels = "Juvenile";}
        if ($level_lookup == "6") {$levels = "Hatchling";} 
        if ($level_lookup == "5") {$levels = "New Born";} 
        if ($level_lookup <= "4") {$levels = "Egg";}

my site uses a max of 10 levels for the adopts, just need to remove those that you dont need and change the number to match the levels in your site.
to display the code in your adopt profile you just need to replace {$adopt->getCurrentLevel()} with {$levels}

but if you whant to "properly" display the needed levelup points, this is mostly to "hide" the other levels... the hatched adopt need 40 points divided in 4 levels so to hide the rest of the levels and make them look like is just one level you just need to add this:
PHP:
        $number = 40 - $adopt->getTotalClicks();
        $nextLev = "(Next Stage in ".$number." more Exp)";

replace the number with the needed clicks to make the adopt hatch.
now probably most of you are using also the {$toNext} posted here to display the needed clicks for the next stage, so now we need to add this code after the $nextLev:
PHP:
        if($adopt->getcurrentlevel() <= "4"){$stages = "{$levels}{$nextLev}";}  else {$stages = "{$levels}{$toNext}";}

and to display the info of the adopt just replace {$adopt->getCurrentLevel()} {$toNext} with {$levels}

if you are using KatFennec Public Profile Mod the needed points are displayed at top of the feed button so i did a few changes to the code and this is the edited code:
PHP:
public function publicprofile(){
            $mysidia = Registry::get("mysidia");
            $adopt = $this->getField("adopt");            
            $adoptcurrentlevel = $adopt->currentlevel;
            $document = $this->document;
            $document->setTitle("Viewing {$adopt->getName()}'s profile");
            if($adopt->hasNextLevel()){
            $nextLevel = $adopt->getNextLevel();
            #$requiredClicks = $nextLevel->getRequiredClicks();
$thisisauniqueid = new OwnedAdoptable($adopt->getAdoptID());
$gender_lookup = $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
if ($gender_lookup == "m") { $gender = "Male"; $pronoun = "him"; } else { $gender = "Female"; $pronoun = "her"; } 
$alternates_lookup = $mysidia->db->select("owned_adoptables", array("usealternates"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        $level_lookup = $mysidia->db->select("owned_adoptables", array("currentlevel"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if ($level_lookup == "10") {$levels = "Ancient"; }
        if ($level_lookup == "9") {$levels = "Adult";} 
        if ($level_lookup == "8") {$levels = "Subadult";}
        if ($level_lookup == "7") {$levels = "Juvenile";}
        if ($level_lookup == "6") {$levels = "Hatchling";}
        if ($level_lookup == "5") {$levels = "New Born";}
        if ($level_lookup <= "4") {$levels = "egg";}
if ($mysidia->user->username == $adopt->getOwner()){ $manage_btn = "<a class='btn btn-sm btn-info' href='../../myadopts/manage/{$adopt->getAdoptID()}'><i class='fa fa-gear'></i> Manage</a>"; } else { $manage_btn = ""; }

        if($adopt->hasNextLevel()){
        $level = $adopt->getNextLevel();
        $levelupClicks = $adopt->getLevelupClicks();
        $toNext = "(Next Stage in ".$levelupClicks." more EXP)"; } else { $toNext = "(MAX)"; }
        $number = 40 - $adopt->getTotalClicks();
        $nextLev = "(Next Stage in ".$number." more EXP)";  
        if($adopt->getcurrentlevel() <= "4"){$stages = "{$levels}{$nextLev}";}  else {$stages = "{$levels}{$toNext}";} 
        $document->add(new Comment("{$stages}");
if($adopt->getTradeStatus() == "fortrade") { $tradestatus = "<b>For Trade</b>"; } 
else { $tradestatus = "<b>Not For Trade</b>"; }



// If you've already seen the pet today:
if ($adopt->hasVoter($mysidia->user, $date)){
$document->add(new Comment("<a class='btn btn-sm btn-info disabled' href='../../levelup/click/{$adopt->getAdoptID()}'><i class='fa fa-paw'></i> Already Fed</a>"));
}
// If you haven't seen the pet today:
else {
$document->add(new Comment("<a class='btn btn-sm btn-info' href='../../levelup/click/{$adopt->getAdoptID()}'><i class='fa fa-paw'></i> Feed</a>"));
};
}
$document->add(new Comment("{$manage_btn}
<br> <br>
<img src='{$thisisauniqueid->getImage()}'><br>"));
$adoptabletype = $mysidia->db->select("adoptables", array(), "type='{$adopt->getType()}'")->fetchObject();
$diet = $adoptabletype->Diet;
$level = $adopt->getCurrentLevel();
$document->add(new Comment("<ul>
<li>Lives With: <a href='/profile/view/{$adopt->getOwner()}'>{$adopt->getOwner()}</a></li>
<li>Species: {$adopt->getType()}</li>
<li>Gender: {$gender}</li>
<li>LVL: {$levels}</li>
<li>Total EXP: {$adopt->getTotalClicks()}</li> 
<li>Trade Status: {$tradestatus}</li>

"));
        }


Hope this is useful to some one ^^ the $levels don't need to be names, they can be numbers too or whatever you want
 
Last edited:
You can also put them in the stats page, you just have to remove the database call and then replace "$level_lookup" with "$adopt>getCurrentLevel()".
 
thanks for posting changes needed to make it work in the stats page, i totally forgot about that XD as i completely removed that code form the manage adopts =p because with the profile i made for my adopts the stats page was no longer needed.

also for those that want to have the info of the needed point for the next stage, beside of the current stage just:
Delete:
PHP:
        $document->add(new Comment("{$stages}");
and replace:
PHP:
{$levels}
with:
PHP:
{$stages}
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,115
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top