Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #11  
Old 02-12-2016, 09:26 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,748
Abronsyth is on a distinguished road
Default

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.
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #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: 87,028
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
  #13  
Old 02-13-2016, 11:16 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,748
Abronsyth is on a distinguished road
Default

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!
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #14  
Old 02-13-2016, 02:55 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,028
Kyttias is on a distinguished road
Default

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.
__________________
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-13-2016 at 02:57 PM.
Reply With Quote
  #15  
Old 02-17-2016, 11:37 AM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,748
Abronsyth is on a distinguished road
Default

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..?
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #16  
Old 02-17-2016, 12:08 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,028
Kyttias is on a distinguished road
Default

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);
    }
}
?>
__________________
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.
Reply With Quote
  #17  
Old 02-17-2016, 01:05 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,748
Abronsyth is on a distinguished road
Default

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)
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #18  
Old 02-17-2016, 01:09 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 87,028
Kyttias is on a distinguished road
Default

Hmmm... make sure all the numbers line up in the database? Can I see the kitties involved?
__________________
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.
Reply With Quote
  #19  
Old 02-18-2016, 02:46 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 111,748
Abronsyth is on a distinguished road
Default

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.
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #20  
Old 02-27-2016, 07:06 PM
tahbikat's Avatar
tahbikat tahbikat is offline
Member
 
Join Date: Feb 2014
Location: Louisiana
Posts: 408
Gender: Female
Credits: 48,938
tahbikat is on a distinguished road
Default

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

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:27 AM.

Currently Active Users: 706 (0 members and 706 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636