Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Mys 1.3.4 Pet Lineages? (http://www.mysidiaadoptables.com/forum/showthread.php?t=5014)

Abronsyth 02-09-2016 01:24 PM

Mys 1.3.4 Pet Lineages?
 
I understand, I think, the rough basics for how this would need to be done if I wanted to create lineages that could be displayed on a pets page...I know you'd need probably 2 new columns in the owned_adopts table, one for each parent. I know in the database the default could be set to "Unknown" so 1st gen pets simply have "unknown" parents...now my main issue that I don't know how to figure out is how to actually take the information, when two pets are bred, and record it in the database, and then display that information in a pedigree fashion on the pets page.

I imagine you'd need two new variables, such as $mother and $father...and then edit in class_breeding.php to insert the parental data into the database;
PHP Code:

$mysidia->db->insert("owned_adoptables", array("aid" => NULL"type" => $adopt->getType(), "name" => "Unnamed""owner" => $mysidia->user->username"currentlevel" => 0"totalclicks" => 0"code" => $code
                                                           
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'notfortrade'"isfrozen" => 'no'"gender" => $gender"offsprings" => 0"lastbred" => 0"originalowner" => $mysidia->user->username"birthday" => date("F jS, Y"), "mother" => $mother"father" => $father   )); 

Then of course you should be able to display the parents on the pet's page like so;
{$adopt->mother} or {$this->adopt->mother}, etc.

Now when defining the parent variables I want to include both the IDs of the parents, and the names. The ID is important because it can then be used to link to the parent's page (so then you can actually follow the family tree back to f0). So the database itself should store the parent's ID, not the name, and then we can just use the ID of the parent to find the name for the sake of displaying it.

So I think my main issue is actually recording the information of the parents. In the breeding files I see the variables $male and $female are used to determine the parents...which means that I can probably use this somehow, but I'm not sure how, because I don't see where the parent's data is summoned.

Now as for displaying an adoptable's offspring on it's profile...I have no idea. There's the getOffspring function, but does anyone know what that actually does?

I know this post is a big mess of my theories and rambling, but does anything think they could shed light on this a bit? In theory it really shouldn't be that difficult, I don't think.

Kyttias 02-09-2016 02:38 PM

Try storing $this->female->getAdoptID() for the mother and $this->male->getAdoptID() for the father.

Once that information exists in the database for a pet, you can also lookup grandparents. (Without calling getAdoptID() again, actually, because it's just pulling the information from a column in the database with the names of whatever you store the mother/father data as. If you store it in the database as 'mother' and 'father' you'll want to pull $this->female->mother, $this->female->father, for example, to get the grandparents on the mother's side.) And then you can store information about the grandparents, too.

PHP Code:

                "mother" => $this->female->getAdoptID(), 
                
"father" => $this->male->getAdoptID(),
                
"grandmotherA" => $this->female->mother
                
"grandmotherB" => $this->female->father,
                
"grandfatherA" => $this->male->mother
                
"grandfatherB" => $this->male->father 

Allow them to store as 'NULL' in the database if those values don't exist.

On your pet profiles, this will create links to the parents by the names (and if no parent, "---" and it will link to the same pet that it's currently on). I've actually got this sitting in a function in class_ownedadoptable.php, but it shouldn't be too bad to move around elsewhere? (The $this may need to change.)
PHP Code:

$p1name "---";
$p2name "---";
if (
$this->mother != NULL) { $mother = new OwnedAdoptable($this->mother); $p1name $mother->name$p1id $mother->aid; } else { $p1id $this->aid; }
if (
$this->father != NULL) { $father = new OwnedAdoptable($this->father); $p2name $father->name$p2id $father->aid; } else { $p2id $this->aid; } 

Code:

Parents: <a href='../../levelup/click/".$p1id."'>".$p1name."</a> and <a href='../../levelup/click/".$p2id."'>".$p2name."</a>
For displaying children...
PHP Code:

        $children "";
        
$babies = array();
        
$offsprings explode(","$this->offsprings);
        if (
$offsprings != ""){
            foreach(
$offsprings as $offspring){
                if (
$offspring != 0){
                    
$child = new OwnedAdoptable($offspring);
                    
$babies[] = "<a href='../../levelup/click/".$offspring."'>".$child->name."</a>";
                }
            }
            
$children implode(", ",$babies);
            if (empty(
$children)){ $children ""; } else {$children "<br/>Children: ".$children; }
        } 

Just add the $children variable wherever you want it, I suggest off the end of parents.

I haven't gotten around to displaying grandparents yet, but it's pretty much the same as for the parents.

(edit: I woke up a few hours later and changed a couple things. Btw, that last chunk of code is hilarious to read out loud when you're super tired.)

(edit later: If using this in myadoptsview.php instead of making a function to call in class_ownedadoptable.php, change every instance of $this-> to $adopt-> and that's the only difference.)

Abronsyth 02-11-2016 04:50 PM

I have the parents/etc working perfectly now, but I'm not super sure where I should be putting that bit of code for the children?

---

OK, so in my view/myadoptsview.php, where I am currently displaying this information, I have this so far for displaying parents and grandparents (please note my set-up for managing pets is modified):
PHP Code:

        $mother $mysidia->db->select("owned_adoptables", array("mother"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$mother == NULL) { $motherview "Unknown"; } else { $motherview "<a href='../../levelup/click/{$mother}'><img src='http://catisserie.net/levelup/siggy/{$mother}' width='25%'/></a>"; }
        
$father $mysidia->db->select("owned_adoptables", array("father"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$father == NULL) { $fatherview "Unknown"; } else { $fatherview "<a href='../../levelup/click/{$father}'><img src='http://catisserie.net/levelup/siggy/{$father}' width='25%'/></a>"; }
        
$grandmotherA $mysidia->db->select("owned_adoptables", array("grandmotherA"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$grandmotherA == NULL) { $grandmotherAview "Unknown"; } else { $grandmotherAview "<a href='../../levelup/click/{$grandmotherA}'><img src='http://catisserie.net/levelup/siggy/{$grandmotherA}' width='12%' /></a>"; }
        
$grandmotherB $mysidia->db->select("owned_adoptables", array("grandmotherB"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$grandmotherB == NULL) { $grandmotherBview "Unknown"; } else { $grandmotherBview "<a href='../../levelup/click/{$grandmotherB}'><img src='http://catisserie.net/levelup/siggy/{$grandmotherB}' width='12%' /></a>"; }
        
$grandfatherA $mysidia->db->select("owned_adoptables", array("grandfatherA"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$grandfatherA == NULL) { $grandfatherAview "Unknown"; } else { $grandfatherAview "<a href='../../levelup/click/{$grandfatherA}'><img src='http://catisserie.net/levelup/siggy/{$grandfatherA}' width='12%' /></a>"; }
        
$grandfatherB $mysidia->db->select("owned_adoptables", array("grandfatherB"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$grandfatherB == NULL) { $grandfatherBview "Unknown"; } else { $grandfatherBview "<a href='../../levelup/click/{$grandfatherB}'><img src='http://catisserie.net/levelup/siggy/{$grandfatherB}' width='12%'/></a>"; } 

And then I display this information like so;
PHP Code:

<center><strong>Family Tree</strong><br>
<
table border='0'>
    <
tr>
        <
td></td>
        <
td></td>
        <
td>{$grandmotherAview}</td>
    </
tr>
    <
tr>
        <
td></td>
        <
td>{$motherview}</td>
        <
td>{$grandfatherAview}</td>
    </
tr>
    <
tr>
        <
td>{$name}</td>
        <
td></td>
        <
td></td>
    </
tr>
    <
tr>
        <
td></td>
        <
td>{$fatherview}</td>
        <
td>{$grandmotherBview}</td>
    </
tr>
    <
tr>
        <
td></td>
        <
td></td>
        <
td>{$grandfatherBview}</td>
    </
tr>
</
table>
</
center><br

And as you can see it's working splendidly!
http://i.imgur.com/E38bAwT.png

Kyttias 02-11-2016 11:13 PM

Oh, um, put it wherever you like/need to? In my version, it also happens to contain 'Children:' beforehand but takes into account whether or not they have any before displaying the text at all. My code as it is currently just loops through a list of text names, whereas yours are images.

So let's start again, now that I see what you have. ^^;;;

You really shouldn't need to access the database over and over again as you are, the variables that hold the id# of the the parents and grandparents are now literally part of the current pet's object in the same way their species type, gender, and the personality/stat mod is. So, try just {$adopt->grandfatherB} for example, rather than making a database call?

Actually, here:
PHP Code:

if ($adopt->mother == NULL) { $motherview "Unknown"; } else { $motherview "<a href='../../levelup/click/{$adopt->mother}'><img src='../../levelup/siggy/{$adopt->mother}' width='25%' height='25%'/></a>"; }
if (
$adopt->father == NULL) { $fatherview "Unknown"; } else { $fatherview "<a href='../../levelup/click/{$adopt->father}'><img src='../../levelup/siggy/{$adopt->father}' width='25%' height='25%'/></a>"; }
if (
$adopt->grandmotherA == NULL) { $grandmotherAview "Unknown"; } else { $grandmotherAview "<a href='../../levelup/click/{$adopt->grandmotherA}'><img src='../../levelup/siggy/{$adopt->grandmotherA}' width='12%' height='12%'/></a>"; }
if (
$adopt->grandmotherB == NULL) { $grandmotherBview "Unknown"; } else { $grandmotherBview "<a href='../../levelup/click/{$adopt->grandmotherB}'><img src='../../levelup/siggy/{$adopt->grandmotherB}' width='12%' height='12%'/></a>"; }
if (
$adopt->grandfatherA == NULL) { $grandfatherAview "Unknown"; } else { $grandfatherAview "<a href='../../levelup/click/{$adopt->grandfatherA}'><img src='../../levelup/siggy/{$adopt->grandfatherA}' width='12%' height='12%'/></a>"; }
if (
$adopt->grandfatherB == NULL) { $grandfatherBview "Unknown"; } else { $grandfatherBview "<a href='../../levelup/click/{$adopt->grandfatherB}'><img src='../../levelup/siggy/{$adopt->grandfatherB}' width='12%' height='12%'/></a>"; } 

Also, try this for establishing children instead (so it works on the myadoptsview.php page and uses just images):
PHP Code:

$babies = array();
$offsprings explode(","$adopt->offsprings);
if (
$offsprings != ""){
    foreach(
$offsprings as $offspring){
        if (
$offspring != 0){
            
$babies[] = "<a href='../../levelup/click/{$offspring}'><img src='../../levelup/siggy/{$offspring}' width='12%' height='12%'/></a>";
        }
    }
    
$children implode(""$babies);
    if (empty(
$children)){ $children "None"; } 


Use {$children} just like you're using things like {$grandfatherBview} in your table.

Abronsyth 02-12-2016 12:36 PM

Oh man, that's so much less messy, haha, thank you.

Hmmm...my site is cheerfully throwing this at me;
Code:

Fatal error: Cannot access protected property OwnedAdoptable::$offsprings in /home/arieng/catisserie.net/view/myadoptsview.php on line 295

Kyttias 02-12-2016 02:25 PM

In classes/class_ownedadoptable.php make offsprings a public property instead of a protected one. If you ever have any variable that gives that error, find the class and change it to public. I didn't have this error because I must have changed mine a long time ago, I guess?

Abronsyth 02-12-2016 02:56 PM

OK, it seems pretty confused about what pets it should be displaying for offspring. I've got it showing the parents of 2nd, 3rd, etc generation then it shows the mother of the adoptable. If look at the 1st generation it shows one of the pets that cat has been bred with before.

Edit: Actually it just seems to be displaying a random pet that is somehow connected to that cat (for example displaying the mother of the cat that the one I am viewing has mated with).

Kyttias 02-12-2016 03:58 PM

Inside the database the field 'offsprings' contains an array of id numbers - this array has new babies added to it every time a pet is bred. All we're doing is looping through it.

Check in the database to see if the offspring being rendered are correct?

However, there really isn't a system in place that prevents children from breeding with their parents? That I know of? A pet's parent can also be their grandparent.

Abronsyth 02-12-2016 06:02 PM

Ok, this is odd. Apparently none of the data that should be added to the table adopts_breeding is actually being added to it. It's 100% empty. Breeding is fully functional on the site, though at one point one of my users mentioned that it seemed the breeding cooldown wasn't working.

Kyttias 02-12-2016 08:23 PM

The offsprings data I'm referring to is stored with the parents inside adopts_owned_adoptables, it should be the thirteen column or so!

If you've never made any adopts that only obtainable through breeding, then, yeah, adopts_breeding is going to be empty - it has contents in the STRUCTURE tab, no actual rows, because you have none made! Mine is also "empty" because I haven't made any of that type yet. It appears adopts_breeding holds species-specific information - for pets that can only be obtained BY breeding that are NEVER available in shops or for free.

Anyway, yeah, make a species available through "/admincp/breeding/add" to see data inside adopts_breeding. This would be good for 'chimera' pets like... if species was tigers and species was lions, you'd enter in that data and force the system to give ligers instead of either parent if they're bred together. You can have this result appear ALL the time, or, only sometimes. So, 'if parents are X,Y, babies will come out as Z' whatever the percent is set. (Actually to be honest I don't know if we're supposed to enter in species type numbers from the adopts_adoptables columns or their names.) You can also have things like 'anytime the mother is an X, there is a 90 percent chance the babies will also be an X' even though ordinarily, results are always 50-50 during breeding.

To be honest, I forgot Mysidia even offered such a thing, as it's been a while since I've been through the AdminCP.

Sorry to cause panic!

Abronsyth 02-12-2016 09:26 PM

Okay, I sort of figured as much but when you said in the database that I was concerned, haha.

So I'm looking in owned_adoptables, but it seems that the Offsprings column is recording the number of offspring each adopt has produced, but not the actual IDs of the offspring...I'm not sure if this is the normal behavior, or how to alter it. I assume I could change something in class_breeding.php (maybe) to update that column each time a cat is bred to include the new offspring IDs, but I'm not sure how to make it then so that the new IDs are added as a list, and not replacing the data already there.

Kyttias 02-12-2016 11:14 PM

Hmmm!!! I might have changed something significant for my own site, haha... hang on.

Alright, I don't know what the default $offsprings field is actually used for. I re-purposed it. Since I don't feel comfortable asking you to do the same in case it breaks an Mysidia feature you're using but I'm not, we're going to make some tweaks.

First, let's create a new column in adopts_owned_adoptables called descendants. We're going to have it be varchar 500, but even that may not be big enough if your site gets too large.

Second, let's first go back to the code we were working on before. Instead of looking for the column offsprings, we'll change it to look for descendants.

PHP Code:

$babies = array();
$descendants explode(","$adopt->descendants);
if (
$descendants != ""){
    foreach(
$descendants as $offspring){
        if (
$offspring != 0){
            
$babies[] = "<a href='../../levelup/click/{$offspring}'><img src='../../levelup/siggy/{$offspring}' width='12%' height='12%'/></a>";
        }
    }
    
$children implode(""$babies);
    if (empty(
$children)){ $children "None"; } 


So here's the bad news - Mysidia actually doesn't keep track of your kids. That's something I taught MINE to do. I had completely forgotten, but I'm not surprised, it was over six months ago... woops! So this will keep track of future kids, but anything prior to this won't be linked to it's kids.

In breeding.php find:

PHP Code:

            if($num 0){
                
$offsprings $breeding->getOffsprings();
                
$offspringID $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num 1;
                
$links = new LinkedList;
                foreach(
$offsprings as $offspring){
                    
$image $offspring->getEggImage("gui");
                    
$links->add(new Link("myadopts/manage/{$offspringID}"$image));
                    
$offspringID++;
                }
                
$this->setField("links"$links);
            } 

We need to add to this if statement. Immediately after, or before if you'd rather, $this->setField("links", $links); but definitely before the closing bracket, we'll be adding this:

PHP Code:

/* Kyt: Descendants Mod!! */
$newbabies = array();
foreach(
$offsprings as $offspring){ 
    
$newbabies[] = $offspringID;
    
$offspringID++;
}

if (
$female->descendants != 0){ $mothersOffspring $female->descendants; } else { $mothersOffspring ""; }
if (
$male->descendants != 0){ $fathersOffspring $male->descendants; } else { $fathersOffspring ""; }

for(
$i 0$i count($newbabies); $i++){
    
$mothersOffspring .= $newbabies[$i].",";
    
$fathersOffspring .= $newbabies[$i].",";
}

$updatedMotherOffspring preg_replace('/^(0,)+/'''$mothersOffspring);
$updatedFatherOffpsring preg_replace('/^(0,)+/'''$fathersOffspring);

$mysidia->db->update("owned_adoptables", array("descendants" => $updatedMotherOffspring), "aid = '{$female->aid}'");
$mysidia->db->update("owned_adoptables", array("descendants" => $updatedFatherOffpsring), "aid = '{$male->aid}'");
/* Descendants Mod End!! */ 

Again, make extra sure it's inside that if statement.

Get back to me with the results?

...the long and the short of it is, I made this exact feature for myself six months ago but kind of just built it in while I was working on my new breeding system and never finished actually making the whole family tree visual part. x'D I was more than happy to help because I knew I was mostly done with mine and it was the push I needed to finish.

Here's mine:
http://orig02.deviantart.net/3a71/f/...as-d9rj8nb.png

Abronsyth 02-13-2016 11:16 AM

OK, now the only issue I am encountering is for some reason it added +1 to the ID of the offspring (which causes it to not work). So the offspring ID should be 25422, but it's showing 25423 on the parent's page.

When I manually changed it in the database to the correct ID, it works perfectly, though! So that's a plus!

Kyttias 02-13-2016 02:55 PM

When your babies are born, you get to see them, right? It should be storing the IDs of the ones seen. Try combining for the foreach loops. (I have mine combined.)

Put $newbabies = array(); before the existing foreach loop above the mod.
Add $newbabies[] = $offspringID; to the inside of the old foreach loop.
Go ahead and delete the loop inside my mod (and $newbabies = array(); before it, of course).

Basically, this function was already build a list of image links to your babies from their ID numbers. All I'm doing is taking the same list of IDs and putting them in the database. They should not be different! The pets seen at birth should be the same ones seen in their family tree.

Abronsyth 02-17-2016 11:37 AM

OK, so I bred two pets and these are the offspring IDs;
25753, 25754, 25756

But this is what is in the descendants column;
25756,25757,25758,

breeding.php;
PHP Code:

<?php

use Resource\Native\Integer;
use 
Resource\Native\String;
use 
Resource\Native\Null;
use 
Resource\Collection\LinkedList;

class 
BreedingController extends AppController{

    public function 
__construct(){
        
parent::__construct("member");
        
$mysidia Registry::get("mysidia");        
        
$userStatus $mysidia->user->getstatus();
        if(
$userStatus->canbreed == "no") throw new NoPermissionException("permission");        
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$settings = new BreedingSetting($mysidia->db);
        if(
$settings->system != "enabled") throw new InvalidActionException("system");
        
        if(
$mysidia->input->post("submit")){
            if(
$mysidia->input->post("female") == "none" or $mysidia->input->post("male") == "none"){
                  throw new 
InvalidIDException("none_select");
            }
            
            try{
                
$female = new OwnedAdoptable($mysidia->input->post("female"), $mysidia->user->username);
                
$male = new OwnedAdoptable($mysidia->input->post("male"), $mysidia->user->username);
                
$breeding = new Breeding($female$male$settings); 
                
$validator $breeding->getValidator("all");
                
$validator->validate();
            }
            catch(
AdoptNotfoundException $ane){
                throw new 
InvalidIDException("none_exist");
            }
            catch(
BreedingException $bre){                
                
$status $bre->getmessage();
                
$validator->setStatus($status);
                throw new 
InvalidActionException($status);
            }
            
            if(
$settings->method == "advanced"$species $breeding->getBabySpecies();
            
$breeding->getBabyAdopts($species);
            
$breeding->breed($adopts);
            
$num $breeding->countOffsprings();
                        
            if(
$num 0){
                
$offsprings $breeding->getOffsprings();
                
$offspringID $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num 1
                
$links = new LinkedList;
                foreach(
$offsprings as $offspring){
                    
$image $offspring->getEggImage("gui");
                    
$links->add(new Link("myadopts/manage/{$offspringID}"$image));
                    
$offspringID++;
                }
                
$this->setField("links"$links);
/* Kyt: Descendants Mod!! */
$newbabies = array();
foreach(
$offsprings as $offspring){ 
    
$newbabies[] = $offspringID;
    
$offspringID++;
}

if (
$female->descendants != 0){ $mothersOffspring $female->descendants; } else { $mothersOffspring ""; }
if (
$male->descendants != 0){ $fathersOffspring $male->descendants; } else { $fathersOffspring ""; }

for(
$i 0$i count($newbabies); $i++){
    
$mothersOffspring .= $newbabies[$i].",";
    
$fathersOffspring .= $newbabies[$i].",";
}

$updatedMotherOffspring preg_replace('/^(0,)+/'''$mothersOffspring);
$updatedFatherOffpsring preg_replace('/^(0,)+/'''$fathersOffspring);

$mysidia->db->update("owned_adoptables", array("descendants" => $updatedMotherOffspring), "aid = '{$female->aid}'");
$mysidia->db->update("owned_adoptables", array("descendants" => $updatedFatherOffpsring), "aid = '{$male->aid}'");
/* Descendants Mod End!! */
            
}
            else 
$this->setField("links", new Null);
            
$this->setField("breeding"$breeding);        
            return;
        }

        
$this->setField("cost", new Integer($settings->cost));
        
$current = new DateTime;
        
$lasttime $current->getTimestamp() - (($settings->interval) * 24 60 60);
                
        
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND gender = 'f' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
        
$female = ($stmt->rowcount() == 0)?new Null:$mysidia->db->fetchMap($stmt);
        
$this->setField("femaleMap"$female);
  
        
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND gender = 'm' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
        
$male = ($stmt->rowcount() == 0)?new Null:$mysidia->db->fetchMap($stmt);
        
$this->setField("maleMap"$male);
    }
}
?>

Maybe I put something together wrong..?

Kyttias 02-17-2016 12:08 PM

Yes, that appears to be counting the next three exactly... yeah, just combine the foreach loops like I said in my last post. Here, I made the edit:

PHP Code:

<?php

use Resource\Native\Integer;
use 
Resource\Native\String;
use 
Resource\Native\Null;
use 
Resource\Collection\LinkedList;

class 
BreedingController extends AppController{

    public function 
__construct(){
        
parent::__construct("member");
        
$mysidia Registry::get("mysidia");        
        
$userStatus $mysidia->user->getstatus();
        if(
$userStatus->canbreed == "no") throw new NoPermissionException("permission");        
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$settings = new BreedingSetting($mysidia->db);
        if(
$settings->system != "enabled") throw new InvalidActionException("system");
        
        if(
$mysidia->input->post("submit")){
            if(
$mysidia->input->post("female") == "none" or $mysidia->input->post("male") == "none"){
                  throw new 
InvalidIDException("none_select");
            }
            
            try{
                
$female = new OwnedAdoptable($mysidia->input->post("female"), $mysidia->user->username);
                
$male = new OwnedAdoptable($mysidia->input->post("male"), $mysidia->user->username);
                
$breeding = new Breeding($female$male$settings); 
                
$validator $breeding->getValidator("all");
                
$validator->validate();
            }
            catch(
AdoptNotfoundException $ane){
                throw new 
InvalidIDException("none_exist");
            }
            catch(
BreedingException $bre){                
                
$status $bre->getmessage();
                
$validator->setStatus($status);
                throw new 
InvalidActionException($status);
            }
            
            if(
$settings->method == "advanced"$species $breeding->getBabySpecies();
            
$breeding->getBabyAdopts($species);
            
$breeding->breed($adopts);
            
$num $breeding->countOffsprings();
                        
            if(
$num 0){
                
$offsprings $breeding->getOffsprings();
                
$offspringID $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num 1
                
$links = new LinkedList;
                
$newbabies = array(); // Kyt: Added line for Descendants Mod!!
                
foreach($offsprings as $offspring){
                    
$newbabies[] = $offspringID// Kyt: Added line for Descendants Mod!!
                    
$image $offspring->getEggImage("gui");
                    
$links->add(new Link("myadopts/manage/{$offspringID}"$image));
                    
$offspringID++;
                }
                
$this->setField("links"$links);
/* Kyt: Descendants Mod!! */
if ($female->descendants != 0){ $mothersOffspring $female->descendants; } else { $mothersOffspring ""; }
if (
$male->descendants != 0){ $fathersOffspring $male->descendants; } else { $fathersOffspring ""; }

for(
$i 0$i count($newbabies); $i++){
    
$mothersOffspring .= $newbabies[$i].",";
    
$fathersOffspring .= $newbabies[$i].",";
}

$updatedMotherOffspring preg_replace('/^(0,)+/'''$mothersOffspring);
$updatedFatherOffpsring preg_replace('/^(0,)+/'''$fathersOffspring);

$mysidia->db->update("owned_adoptables", array("descendants" => $updatedMotherOffspring), "aid = '{$female->aid}'");
$mysidia->db->update("owned_adoptables", array("descendants" => $updatedFatherOffpsring), "aid = '{$male->aid}'");
/* Descendants Mod End!! */
            
}
            else 
$this->setField("links", new Null);
            
$this->setField("breeding"$breeding);        
            return;
        }

        
$this->setField("cost", new Integer($settings->cost));
        
$current = new DateTime;
        
$lasttime $current->getTimestamp() - (($settings->interval) * 24 60 60);
                
        
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND gender = 'f' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
        
$female = ($stmt->rowcount() == 0)?new Null:$mysidia->db->fetchMap($stmt);
        
$this->setField("femaleMap"$female);
  
        
$stmt $mysidia->db->select("owned_adoptables", array("name""aid"), "owner = '{$mysidia->user->username}' AND gender = 'm' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
        
$male = ($stmt->rowcount() == 0)?new Null:$mysidia->db->fetchMap($stmt);
        
$this->setField("maleMap"$male);
    }
}
?>


Abronsyth 02-17-2016 01:05 PM

Okay, excellent, it seems to be fully functioning now!

Aaand one of my users just presented to me an error that occurs with direct inbreeding. If the parents of a pet are siblings, then the grandparents only show for the mother, and for the father it says both grandparents are Unknown. I have no idea why this is..? (Maybe the script is opposed to inbreeding, haha)

Kyttias 02-17-2016 01:09 PM

Hmmm... make sure all the numbers line up in the database? Can I see the kitties involved?

Abronsyth 02-18-2016 02:46 PM

Here's one of the cats whose parents are siblings (from the same litter):
http://catisserie.net/levelup/click/25715


It would seem that it did not add the grandparent B information in the database, only A.

tahbikat 02-27-2016 07:06 PM

*o* I might try to cop this if you guys don't mind... lol

Kyttias 02-27-2016 08:48 PM

Sure, best of luck!

Abron, do you know if you managed to fix the grandparent issue? I assume it's some typo somewhere. ;3;

Abronsyth 02-28-2016 08:13 AM

Kyttias, no, haven't yet, as I got distracted (oops).

All I know is that when the parents are siblings, then the offspring only has the mother's parent's data stored, and not the father's (they have the same parents). But if you go to either the mother's or the father's pages it displays their parents just fine, so it's an error specifically in storing the data of the grandparents B for the baby.

SilverDragonTears 01-14-2017 08:47 AM

Is it possible to have this as a tutorial? I'd love to implement it.

parayna 06-20-2017 12:01 PM

I'd love to implement it too! The visual stuff I can usually work out how to display but this would be an awesome mod or turorial :usedusedused:

Abronsyth 06-21-2017 09:18 AM

I will contact Kyttias and ask for her permission to repost this as an organized tutorial :veeee:

parayna 06-21-2017 09:22 AM

Nice, thank you :jay:

Kyttias 06-21-2017 12:24 PM

Sure guys, that's fine! :wiii:

Abronsyth 06-21-2017 04:41 PM

Ooor you'll respond before then, haha! Cool, thank you!

parayna 06-22-2017 06:58 AM

Thanks Kyttias :D


All times are GMT -5. The time now is 01:30 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.