Getting adopt's stats to display at certain level?

Forum
Last Post
Threads / Messages

tahbikat

Member
Member
Joined
Feb 11, 2014
Messages
408
Points
16
Age
30
Location
Louisiana
Mysidian Dollar
32,360
I wish I wasn't so helpless, but alas, I am. ;-;

I was wondering if there's an easy way to get an adopt's public stats on its levelup.php page to display only if it's a certain level?

So for example:
IF adopt is level 2 or below, then display certain stats (basically everything excluding gender, magic skill, and personality)
ELSE IF adopt is level 3 or 4, display all stats

- - - The reason I want this is because I want users to hatch their eggs first being being able to see its magic skill, personality, gender, etc. I'll still need to figure out a way to code out genders from elsewhere (my adopts page, etc) but yea.

Here's my levelup page function click:

PHP:
public function click(){
    $mysidia = Registry::get("mysidia");
    $date = new DateTime;
    $ip = secure($_SERVER['REMOTE_ADDR']);

    /*... First check if the system to levelup pets is enabled ...*/
    if($this->settings->system != "enabled") { throw new NoPermissionException("disabled"); }

    /*... Then check if the user has already visited the pet today ...*/
    elseif($this->adopt->hasVoter($mysidia->user, $date)){
        if($this->adopt->hasNextLevel()){
            $nextLevel = $this->adopt->getNextLevel();
            $requiredClicks = $nextLevel->getRequiredClicks();
        }

        $gender_lookup = $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$this->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 = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if ($alternates_lookup == "yes") { $usealternates = "Variant"; } else { $usealternates = "Normal"; }

        if ($mysidia->user->username == $this->adopt->getOwner()){ $manage_btn = "<i><a href='../../myadopts/manage/{$this->adopt->getAdoptID()}'> Manage {$this->adopt->getName()}</a></i><br /><br />"; } else { $manage_btn = ""; }

        if($this->adopt->hasNextLevel()){
            $level = $this->adopt->getNextLevel();
            $levelupClicks = $this->adopt->getLevelupClicks();
            $toNext = "(LVL ".$level->getLevel()." in ".$levelupClicks." more EXP)"; 
        } 
        else { $toNext = "(MAX)"; }

        if($this->adopt->getTradeStatus() == "fortrade") { $tradestatus = "For Trade"; } 
        else { $tradestatus = "Not For Trade"; }

        $message = "<div class='adopt_profile'>    <h2>{$this->adopt->getName()}</h2>    ";
        
        // If you've already seen the pet today:
        if ($this->adopt->hasVoter($mysidia->user, $date)){
            $message .= "<div class='already-seen-msg'><b>Thanks!</b>  You already visited this creature today!</div>";
        }
        // If you haven't seen the pet today:
        if (!$this->adopt->hasVoter($mysidia->user, $date)){
            $message .= "<div style='display: inline;'><span class='button'>Click</span></div>";
        }
            $message .= "<div class='pet-img'>{$manage_btn}
            <img src='{$this->adopt->getImage()}'/><br /><br />
            <img src='/picuploads/{$this->adopt->getRarity()}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' style='margin-right: -3px;' /> <img src='/picuploads/{$usealternates}.png' title='{$this->adopt->getRarity()} Species, {$usealternates}' />
            </div>
            <div class='pet-stats'>
                        <ul class='profile-list'>
                        <li class='statsFloat'><b>Owner</b>: <a href='/profile/view/{$this->adopt->getOwner()}'>{$this->adopt->getOwner()}</a></li>
                        <li class='statsFloat'><b>Personality</b>: {$this->adopt->getAdoptPersonality()}</li>
                        <li class='statsFloat'><b>Species</b>: {$this->adopt->getType()}</li>
                        <li class='statsFloat'><b>Magic Skill</b>: {$this->adopt->getMagic()}/100</li>
                        <li class='statsFloat'><b>Gender</b>: {$gender}</li>
                        <li class='statsFloat'><b>Obtained From</b>: {$this->adopt->getObtainedFrom()}</li>
                        <li class='statsFloat'><b>Total Points</b>: {$this->adopt->getTotalClicks()}</li>
                        <li class='statsFloat'><b>Obtained On</b>: {$this->adopt->getObtainedOn()}</li>
                        <li class='statsFloat'><b>Level</b>: {$this->adopt->getCurrentLevel()}</li>
                        <li class='statsFloat'><b>Trade Status</b>: {$tradestatus}</li> 

                        </ul>
                        <b>Description</b>: {$this->adopt->getAdultDescription()}<br /><br />
                        </div>";

        throw new LevelupException($message);
    } 

    /*... But do this if the pet is frozen! ...*/
    elseif($this->adopt->isFrozen() == "yes") { throw new LevelupException("frozen"); }

    /*... This one, if enabled, would prevent users from visiting a pet too much a day ...*/
    # elseif($mysidia->user->getVotes() > $this->settings->number) { throw new LevelupException("number"); }

    /*... If this setting were on in the backend, it would prevent the users from visiting their own pets ...*/
    # elseif($this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){ throw new LevelupException("owner");}
    
    /*... If the visitor has not seen the pet today, this will be displayed and the pet will level up! ...*/
    else{
        $newClicks = $this->adopt->getTotalClicks() + 1;
        $this->adopt->setTotalClicks($newClicks, "update");
        $mysidia->db->insert("vote_voters", array("void" => NULL, "date" => $date->format('Y-m-d'), "username" => $mysidia->user->username, "ip" => $ip, "adoptableid" => $mysidia->input->get("aid")));         
        
        $ago = date('Y-m-d', strtotime('-40 days'));
        $mysidia->db->delete("vote_voters", "date < '{$ago}'");    

        if($this->adopt->hasNextLevel()){
            $nextLevel = $this->adopt->getNextLevel();
            $requiredClicks = $nextLevel->getRequiredClicks();
            if($requiredClicks and $newClicks >= $requiredClicks) { $this->adopt->setCurrentLevel($nextLevel->getLevel(), "update"); }
        }
        
        $reward = $mysidia->user->clickreward($this->settings->reward);
        $mysidia->user->changecash($reward);            
        $this->setField("adopt", $this->adopt);
        $this->setField("reward", new Integer($reward));            
    }
}
 
PHP:
if ($this->adopt->getCurrentLevel() < 3){
/*if current level is less than three do this*/
} else {
/*well else it must be three or greater, so do this*/
}
Is this enough to help?

The property for finding the current level is already in the code you had, it just requires a basic if/else statement so I'm not sure what else you're looking for?
 
That's perfect, thank you! Ugh, so simple. I still don't have a solid understanding of PHP yet. ;-;
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,267
Messages
33,049
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top