View Single Post
  #12  
Old 02-12-2016, 11:14 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 91,273
Kyttias is on a distinguished road
Default

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:
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 02-12-2016 at 11:53 PM.
Reply With Quote