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)
-   -   Public breeding - need some help (http://www.mysidiaadoptables.com/forum/showthread.php?t=5477)

Dinocanid 06-27-2017 12:42 PM

Public breeding - need some help
 
I think I've gotten really close to some sort of public breeding system that I'm looking forward to share, but I've run into a problem. Currently, you can reach the page through "site.com/levelup/breed/insertaid", which runs well and good, until you actually press the breed button; then you get this error:
Quote:

Adoptable ID breeding does not exist or does not belong to the owner specified...
After clicking the button, the url becomes "site.com/levelup/breed/breeding", and of course "breeding" is not a valid adopt id. Is there any way to make it "site.com/levelup/breed/insertaid/breeding" or "site.com/levelup/breeding"?

This is what it looks like:
PHP Code:

public function breed(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
        if(
$mysidia->input->post("submit")){
            
$links $this->getField("links"); 
            if(
$links instanceof LinkedList){
                
$breeding $this->getField("breeding");
                
$document->setTitle("Breeding is Successful!");
                
$document->add(new Comment("Congratulations! Breeding is successful, you have acquired {$breeding->countOffsprings()} baby adoptables from breeding center."));
                
$document->add(new Comment("Click on one of the links below to manage your adoptables now!"));
                
$iterator $links->iterator();
                while(
$iterator->hasNext()) $document->add($iterator->next());            
            }
            else{
                
$document->setTitle("Fail!");
                
$document->addLangvar("Why it failed goes here");
            }            
            return;
        }
        
        
$adopt $this->getField("adopt");
        
$gender_lookup $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$gender_lookup == "m") { $gender "Male"$pronoun "him"; } else { $gender "Female"$pronoun "her"; }
        
        
$cost $this->getField("cost")->getValue();
        
$femaleMap $this->getField("femaleMap");
        
$maleMap $this->getField("maleMap");
        
$document->setTitle("Breeding Center");
        
$document->add(new Comment("<font color=red><h2>This is currently being tested! It doesn't work yet! </h2></font>"));
        
$document->add(new Comment("<img src='{$adopt->getImage()}'>"));
        
        
$document->add(new Comment("You currently have $ {$mysidia->user->getcash()}, the cost of breeding is: "));
        
$document->addLangvar(" $ {$settings->cost}");
        
        
$breedingForm = new Form("breedingform""breeding""post");
        
//If the requested pet is male!
        
        
if($gender == "Male"){
        
// $breedingForm->add(new Comment("<div class='besideright'>"));
        
if($femaleMap instanceof LinkedHashMap){
               
$female = new DropdownList("female");
            
$female->add(new Option("None Selected""none"FALSE));            
            
$female->fill($femaleMap);
            
        }
        else 
$female = new Comment(" None of your female adoptables can breed at the time.");
        
$breedingForm->add($female);
    
        }
        
        
//If the requested pet is female!    
        
if($gender == "Female"){
            
          if(
$maleMap instanceof LinkedHashMap){
            
$male = new DropdownList("male");
            
$male->add(new Option("None Selected""none"FALSE));
            
$male->fill($maleMap);
        }
        else 
$male = new Comment(" None of your male adoptables can breed at the time."FALSE);
        
$breedingForm->add($male);
            
        }
        
            
$breedingForm->add(new Comment("<br></br>"));
        
$breedingForm->add(new PasswordField("hidden""breed""yes"));
        
$breedingForm->add(new Button("Breed""submit""submit"));
        
$document->add($breedingForm);    
    } 

(levelupview)

PHP Code:

public function breed(){
        
$mysidia Registry::get("mysidia");
        
$this->setField("adopt"$this->adopt);
        
$gender_lookup $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if (
$gender_lookup == "m") { $gender "Male";} else { $gender "Female";}
        
$settings = new BreedingSetting($mysidia->db);
        
$userStatus $mysidia->user->getstatus();
        if(
$settings->system != "enabled") throw new InvalidActionException("system");
        if(
$userStatus->canbreed == "no") throw new NoPermissionException("permission");
        
        
//If the requested pet is male!
        
if($gender "Male"){
        if(
$mysidia->input->post("submit")){
            if(
$mysidia->input->post("female") == "none"){
                  throw new 
InvalidIDException("none_select");
            }
            
            try{
                
$female = new OwnedAdoptable($mysidia->input->post("female"), $mysidia->user->username);
                
$male = new OwnedAdoptable($this->adopt->getAdoptID());
                
$breeding = new Breeding($female$male$settings); 
                
$validator $breeding->getValidator("fcase");
                
$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);
            }
            else 
$this->setField("links", new Null);
            
$this->setField("breeding"$breeding);        
            return;
        }
    }
        
        
//If the requested pet is female!
        
if($gender "Female"){
        if(
$mysidia->input->post("submit")){
            if(
$mysidia->input->post("female") == "none"){
                  throw new 
InvalidIDException("none_select");
            }
            
            try{
                
$male = new OwnedAdoptable($mysidia->input->post("male"), $mysidia->user->username);
                
$female = new OwnedAdoptable($this->adopt->getAdoptID());
                
$breeding = new Breeding($female$male$settings); 
                
$validator $breeding->getValidator("mcase");
                
$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);
            }
            else 
$this->setField("links", new Null);
            
$this->setField("breeding"$breeding);        
            return;
        }
        
//Stop here!!
            
        
}

        
$this->setField("cost", new Integer($breedcost));
        
$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);
    } 

(levelup)

draugluin 10-19-2018 03:23 AM

Quote:

After clicking the button, the url becomes "site.com/levelup/breed/breeding", and of course "breeding" is not a valid adopt id. Is there any way to make it "site.com/levelup/breed/insertaid/breeding" or "site.com/levelup/breeding"?
hmmmm ....

maybe ... try this

PHP Code:


$breedingForm 
= new Form("breedingform""/{$adopt->getAdoptID()}/breeding""post"); 


draugluin 08-27-2019 08:27 AM

This mod looks so good ! Have you gotten anywhere with it?

Missy Master 07-15-2020 12:25 PM

This is exactly what I am desperate for, myself, a way to have public breeding.

Few people will want to breed exclusively with their own, they'll want a way to breed with popular etc pets, special ones.

Missy Master 07-15-2020 05:50 PM

I think the error may lie in:

"owner = '{$mysidia->user->username}'


Somewhere, it's calling up who owns the pet and saying nope. I've fiddled with several places and pages (view, class, etc) and can't get rid of the invalid ID, even when I can get the males to show from other members in the list. Beats me, I am stumped.

Jeremydepp50 10-02-2020 09:26 AM

Quote:

Originally Posted by Dinocanid (Post 36547)
I think I've gotten really close to some sort of public breeding system that I'm looking forward to share, but I've run into a problem. Currently, you can reach the page through "site.com/levelup/breed/insertaid", which runs well and good, until you actually press the breed button; then you get this error:


After clicking the button, the url becomes "site.com/levelup/breed/breeding", and of course "breeding" is not a valid adopt id. Is there any way to make it "site.com/levelup/breed/insertaid/breeding" or "site.com/levelup/breeding"?

This is what it looks like:
PHP Code:

public function breed(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
        if(
$mysidia->input->post("submit")){
            
$links $this->getField("links"); 
            if(
$links instanceof LinkedList){
                
$breeding $this->getField("breeding");
                
$document->setTitle("Breeding is Successful!");
                
$document->add(new Comment("Congratulations! Breeding is successful, you have acquired {$breeding->countOffsprings()} baby adoptables from breeding center."));
                
$document->add(new Comment("Click on one of the links below to manage your adoptables now!"));
                
$iterator $links->iterator();
                while(
$iterator->hasNext()) $document->add($iterator->next());            
            }
            else{
                
$document->setTitle("Fail!");
                
$document->addLangvar("Why it failed goes here");
            }            
            return;
        }
        
        
$adopt $this->getField("adopt");
        
$gender_lookup $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();
        if (
$gender_lookup == "m") { $gender "Male"$pronoun "him"; } else { $gender "Female"$pronoun "her"; }
        
        
$cost $this->getField("cost")->getValue();
        
$femaleMap $this->getField("femaleMap");
        
$maleMap $this->getField("maleMap");
        
$document->setTitle("Breeding Center");
        
$document->add(new Comment("<font color=red><h2>This is currently being tested! It doesn't work yet! </h2></font>"));
        
$document->add(new Comment("<img src='{$adopt->getImage()}'>"));
        
        
$document->add(new Comment("You currently have $ {$mysidia->user->getcash()}, the cost of breeding is: "));
        
$document->addLangvar(" $ {$settings->cost}");
        
        
$breedingForm = new Form("breedingform""breeding""post");
        
//If the requested pet is male!
        
        
if($gender == "Male"){
        
// $breedingForm->add(new Comment("<div class='besideright'>"));
        
if($femaleMap instanceof LinkedHashMap){
               
$female = new DropdownList("female");
            
$female->add(new Option("None Selected""none"FALSE));            
            
$female->fill($femaleMap);
            
        }
        else 
$female = new Comment(" None of your female adoptables can breed at the time.");
        
$breedingForm->add($female);
    
        }
        
        
//If the requested pet is female!    
        
if($gender == "Female"){
            
          if(
$maleMap instanceof LinkedHashMap){
            
$male = new DropdownList("male");
            
$male->add(new Option("None Selected""none"FALSE));
            
$male->fill($maleMap);
        }
        else 
$male = new Comment(" None of your male adoptables can breed at the time."FALSE);
        
$breedingForm->add($male);
            
        }
        
            
$breedingForm->add(new Comment("<br></br>"));
        
$breedingForm->add(new PasswordField("hidden""breed""yes"));
        
$breedingForm->add(new Button("Breed""submit""submit"));
        
$document->add($breedingForm);    
    } 

(levelupview)
https://boathousegear.com/www-stapleseasyrebates-com-rebatecard-staples-easy-rebate-center/
PHP Code:

public function breed(){
        
$mysidia Registry::get("mysidia");
        
$this->setField("adopt"$this->adopt);
        
$gender_lookup $mysidia->db->select("owned_adoptables", array("gender"), "aid = '{$this->adopt->getAdoptID()}'")->fetchColumn();
        if (
$gender_lookup == "m") { $gender "Male";} else { $gender "Female";}
        
$settings = new BreedingSetting($mysidia->db);
        
$userStatus $mysidia->user->getstatus();
        if(
$settings->system != "enabled") throw new InvalidActionException("system");
        if(
$userStatus->canbreed == "no") throw new NoPermissionException("permission");
        
        
//If the requested pet is male!
        
if($gender "Male"){
        if(
$mysidia->input->post("submit")){
            if(
$mysidia->input->post("female") == "none"){
                  throw new 
InvalidIDException("none_select");
            }
            
            try{
                
$female = new OwnedAdoptable($mysidia->input->post("female"), $mysidia->user->username);
                
$male = new OwnedAdoptable($this->adopt->getAdoptID());
                
$breeding = new Breeding($female$male$settings); 
                
$validator $breeding->getValidator("fcase");
                
$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);
            }
            else 
$this->setField("links", new Null);
            
$this->setField("breeding"$breeding);        
            return;
        }
    }
        
        
//If the requested pet is female!
        
if($gender "Female"){
        if(
$mysidia->input->post("submit")){
            if(
$mysidia->input->post("female") == "none"){
                  throw new 
InvalidIDException("none_select");
            }
            
            try{
                
$male = new OwnedAdoptable($mysidia->input->post("male"), $mysidia->user->username);
                
$female = new OwnedAdoptable($this->adopt->getAdoptID());
                
$breeding = new Breeding($female$male$settings); 
                
$validator $breeding->getValidator("mcase");
                
$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);
            }
            else 
$this->setField("links", new Null);
            
$this->setField("breeding"$breeding);        
            return;
        }
        
//Stop here!!
            
        
}

        
$this->setField("cost", new Integer($breedcost));
        
$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);
    } 

(levelup)

Your way of telling everything in this article is truly pleasant, every one be capable of easily be aware of it, Thanks a lot.


All times are GMT -5. The time now is 06:02 AM.

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