Adding how many times a adopt is bred, to its page

Forum
Last Post
Threads / Messages

Kandria

Member
Member
Joined
Jul 4, 2020
Messages
43
Points
8
Age
38
Mysidian Dollar
371
One more, just because it came to mind, I might even try this one myself if I find time this week.

Right now I have it set so adopts can only be bred 5 times, but a user doesn't have a way to see how many times they've bred, so they're just sort of blindly hitting the limit. They know it is 5, but unless they keep track of each pet in their head or on a spreadsheet it's still a guess.

I think it would add QOL to just add in a line that says "Has been bred: X times" or something like that and have it pull from the database to display the number
 
I'm digging, trying to figure out how to use the breeding functions to get to the views

It looks like the game only tracks how many offspring your adoptables can have. I don't think it tracks how many times they are bred. That's what I'm seeing at the moment.
 
Last edited:
I'm thinking maybe the offspring is the number of times bred. Let me test and see quickly here...

Yup regardless of 1 or 2 offspring, each time I breed it's going up only by 1 in the database, so I'm pretty sure it's just labeled offspring but that is how many times bred
 
This should be easy then, you already have a function in model/domainmodel/ownedadoptables which is this:
public function getOffsprings()

You can add that to the viewmodel/ownedadoptableviewmodel

public function getOffsprings(){
return $this->model->getOffsprings();
}

and then in the getStats function add in

$stats->add(new Comment("Total Breedings: {$this->model->getOffsprings()}"));

You can use the getOffsprings() function in myadoptsview, and it will already be displayed when you manage your adopts because the manage function uses the getStats function
 
Last edited:
Like this? I only ask because after doing this I'm not seeing the number display anywhere, but also not getting an error
 

Attachments

  • ownedadoptableviewmodel.php
    2.1 KB · Views: 2
Check the offsprings field in the ownedadoptables table in the DB and change the default to 0 and set the null field to No.
 
Hurm, the default was already 0, I did change null to No, but it's still not showing on the pets page

1706468105084.png
 
Did you also add that function to model/domainmodel/ownedadoptable?

Add what to it? the line you quoted was already there

Code:
public function getOffsprings(){
        return $this->offsprings;
    }

Do I need to add the same functions I added to

ownedadoptableviewmodel?

Attaching what it look like now.
 

Attachments

  • ownedadoptable.php
    9.5 KB · Views: 2
Oh wait, no, it's already in the ownedadoptable model. Shoot, I don't know what's up then. I'll have to make these changes on my site and test it. I didn't plan to show the offspring count on my site because I'm going to add a field to put in the IDs of actual offspring so I can link to parents and children. I'm also not planning to limit how many times my pets can breed.

Edit: It is showing up on my adoptable manage page

Screenshot 2024-01-28 at 17-12-49 Mysidia1.3.6.png
Screenshot 2024-01-28 at 17-13-17 Mysidia1.3.6.png
 
Last edited:
That is fair, I want to lift the limit I have higher myself too but it's just hard for users to keep track of as-is
 
Here's my complete stats function in the ownedadoptableviewmodel

Code:
    public function getStats(){
        $mysidia = Registry::get("mysidia");
        $stats = new Division("adoptstats");
        $stats->add(new Comment("<br>{$this->model->getName()}'s Information:"));
        $stats->add(new Comment("<br>Adopt ID: {$this->model->getAdoptID()}"));
        $stats->add(new Comment ("Energy: <progress max='100' value='{$this->model->getEnergy()}'></progress><br>"));
        $stats->add(new Comment ("Mood: <progress max='100' value='{$this->model->getMood()}'></progress><br>"));
        $stats->add(new Comment("Total Clicks: {$this->model->getTotalClicks()}"));
        $stats->add(new Comment("Total Breedings: {$this->model->getOffsprings()}"));
        $stats->add(new Comment("Gender: ", FALSE));
        $stats->add($this->getGenderImage());
        
        if($this->model->hasNextLevel()){
            $level = $this->model->getNextLevel();
            $levelupClicks = $this->model->getLevelupClicks();
            $nextLevel = $level->getLevel() . $mysidia->lang->clicks . $levelupClicks;
        }
        else $nextLevel = $mysidia->lang->maximum;
        
        $adoptStats = "<br>Trade Status: {$this->model->getTradeStatus()}<br>
                       Current Level: {$this->model->getCurrentLevel()}<br>Next Level: {$nextLevel}";
        $stats->add(new Comment($adoptStats));
        return $stats;       
    }
 
Outside Mood and Energy (I don't have those mods installed) I have the same, I tried moving up Breeding to where you have it though under gender still nothing.

Also not sure if this helps, but I also don't have any stats like that on the pets page?
1706480860211.png

Never have, even if I flip back to the original/included CSS files rather then the bootstrap 5, so now I'm curious if that's a mod I don't have or if something my site as a whole has never displayed right..


EDIT:
OH I'm an idiot, it just dawned on me to check "get stats" rather than keep staring at the manage pet page because that's where I expected it to appear rather than on the stat page that I've never clicked... I'm so sorry for the run around, it DOES work xD
I'm dying inside a little now, it works and shows there ...
 
Last edited:
Oh please don't feel that way, I've done my own fair share of fumbling like a lost puppy trying to find my way around this beast :D I'm just glad my own struggles have put me in a position where I can help someone else struggle a little less.

To be fair, I forgot that I added the stats to the manage page and that was not the default in vanilla.
 
Last edited:
One last little update/ask on this

This is what I have so far
Code:
public function getStats(){
        $mysidia = Registry::get("mysidia");
        $stats = new Division("adoptstats");
        $stats->add(new Comment("<br>{$this->model->getName()}'s Information:"));
        $stats->add(new Comment("<br>Adopt ID: {$this->model->getAdoptID()}<br>"));
        $stats->add(new Comment("Total Clicks: {$this->model->getTotalClicks()}<br>"));
        $stats->add(new Comment("Total Breedings: {$this->model->getOffsprings()}<br>"));
        $stats->add(new Comment("Gender: ", FALSE));
        $stats->add($this->getGenderImage());

        if($this->model->hasNextLevel()){
            $level = $this->model->getNextLevel();
            $levelupClicks = $this->model->getLevelupClicks();
            $nextLevel = $level->getLevel() . $mysidia->lang->clicks . $levelupClicks;
        }
        else $nextLevel = $mysidia->lang->maximum;

        $adoptStats = "<br>Trade Status: {$this->model->getTradeStatus()}<br>
                       Current Level: {$this->model->getCurrentLevel()}<br>Next Level: {$nextLevel}";
        $stats->add(new Comment($adoptStats));
        return $stats;
    }

I know some of those things aren't vanilla but I did check the controller and they all have functions in ownedadoptable model

However, my page looks like this

1706502295248.png

It's smooshing Total Breedings with Gender, and no matter where i place <br> it's staying like this

It's not a huge deal, and I can live with it, but just curious why... and if there is an easy fix I'm missing

(I also tried adding more text after so it was

Code:
$stats->add(new Comment("Total Breedings: {$this->model->getOffsprings()} of 5<br>"));

but it still doesn't show the "of 5" after (how many the limit is set on my site, I know I could probably get it to fetch that number from the database too but this seemed easier)

Also not a huge deal just.. boggling my why it's not working
 
Oh, that's weird, it's like the code is not reading the line break or anything after the variable.

You can try putting the break in front of the gender info like this to at least get the line break
$stats->add(new Comment("<br>Gender: ", FALSE));

Edit: Wait, this info is being pulled somewhere else, notice your pet's page is saying Testing Alt's Statistics, but this line should make it say Testing Alt's Information
$stats->add(new Comment("<br>{$this->model->getName()}'s Information:"));
 
Last edited:
Huh that is, even stranger you right but nowhere in the file do I see "Statistics" used in ownedadoptableviewmodel
 
The statistics comes from line 14 lang\main\lang_myadopts.php, which is being added in view\main\myadoptsview.php line 73 (vanilla, it's under public function stats()), where the view is assembled.
Code:
        $document->setTitle($ownedAdopt->getName() . $this->lang->stats);
I'm not sure what's going on with the formatting though.
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,119
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top