Mysidia Adoptables Support Forum  

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

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 09-02-2013, 02:17 PM
RandomFrog RandomFrog is offline
Member
 
Join Date: Aug 2013
Posts: 13
Gender: Female
Credits: 1,886
RandomFrog is on a distinguished road
Default

Okay, here is the code:

PHP Code:
<?php

class BreedingController extends AppController{

    private 
$view;
    private 
$subController;

    public function 
__construct(){
        
parent::__construct("member");
        
$mysidia Registry::get("mysidia");        
        
$userStatus $mysidia->user->getstatus();
        if(
$userStatus->canbreed == "no") throw new NoPermissionException("It appears that you have been banned for breeding.");        
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $mysidia->frame->getDocument();
        
$settings = new BreedingSetting($mysidia->db);
        if(
$settings->system != "enabled") throw new InvalidActionException($mysidia->lang->system);
        
        if(
$mysidia->input->post("submit")){
            if(
$mysidia->input->post("female") == "none" or $mysidia->input->post("male") == "none"){
                  throw new 
InvalidIDException("You haven't selected a male or female adoptable.");
            }
            
            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("There is no adoptable that has that ID!");
            }
            catch(
BreedingException $bre){                
                
$status $bre->getmessage();
                
$validator->setStatus($status);
                throw new 
InvalidActionException($mysidia->lang->{$status});
            }
            
            if(
$settings->method == "advanced"$species $breeding->getBabySpecies();
            
$breeding->getBabyAdopts($species);
            
$breeding->breed($adopts);
            
$num $breeding->countOffsprings();

            if(
$num 0){
                
$document->setTitle("Breeding is Successful!");
                
$document->add(new Comment("Congratulations! Breeding is successful, you have acquired {$breeding->countOffsprings()} baby adoptables from the breeding center."));
                
$document->add(new Comment("Click on one of the links to see them!"));
                
$offsprings $breeding->getOffsprings();
                
$offspringID $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num 1;
                foreach(
$offsprings as $offspring){
                    
$image $offspring->getEggImage("gui");
                    
$link = new Link("myadopts/manage/{$offspringID}"$image);
                    
$document->add($link);
                    
$offspringID++;
                }
            }
            else{
                
$document->setTitle("Breeding has failed...");
                
$document->addLangvar(It did not workMaybe you can try again!");
            }            
            return;
        }
        
        
$document->setTitle($mysidia->lang->title);
        
$document->addLangvar($mysidia->lang->default.$mysidia->lang->money);
        
$document->addLangvar("{$settings->cost} {$mysidia->settings->cost}");
        
$document->addLangvar($mysidia->lang->warning.$mysidia->lang->select);
        
$breedingForm = new Form("breedingform", "breeding", "post");
        
$current = new DateTime;
        
$lasttime = $current->getTimestamp() - (($settings->interval) * 24 * 60 * 60);
        
        
$stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner '{$mysidia->user->username}' AND gender 'f' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
        if(
$stmt->rowcount() == 0) $document->addLangvar($mysidia->lang->female);
        else{ 
            
$female = new DropdownList("female");
            
$femaleIDs = $stmt->fetchAll(PDO::FETCH_COLUMN);    
            
$femaleNames = $mysidia->db->select("owned_adoptables", array("name"), "owner '{$mysidia->user->username}' AND gender 'f' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'")->fetchAll(PDO::FETCH_COLUMN);
            
$female->add(new Option("None Selected", "none"));
            
$female->fill($femaleNames$femaleIDs);
            
$breedingForm->add(new Comment("Female", FALSE));
            
$breedingForm->add($female);
        }    
  
        
$stmt = $mysidia->db->select("owned_adoptables", array(), "owner '{$mysidia->user->username}' AND gender 'm' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'");
        if(
$stmt->rowcount() == 0) $document->addLangvar($mysidia->lang->male);
        else{
            
$male = new DropdownList("male");
            
$maleIDs = $stmt->fetchAll(PDO::FETCH_COLUMN);    
            
$maleNames = $mysidia->db->select("owned_adoptables", array("name"), "owner '{$mysidia->user->username}' AND gender 'm' AND currentlevel >= {$settings->level} AND lastbred <= '{$lasttime}'")->fetchAll(PDO::FETCH_COLUMN);
            
$male->add(new Option("None Selected", "none"));
            
$male->fill($maleNames$maleIDs);
            
$breedingForm->add(new Comment("Male", FALSE));
            
$breedingForm->add($male);
        }
        
        
$breedingForm->add(new PasswordField("hidden", "breed", "yes"));
        
$breedingForm->add(new Button("Let's breed!", "submit", "submit"));
        $document->add($breedingForm);    
    }
}
?>
It also WAS working when I installed it.
Reply With Quote
 

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blank page with x10Hosting bisexuowl Questions and Supports 0 09-22-2015 09:42 PM
No errors, just a blank page? FounderSim Questions and Supports 5 10-04-2014 04:15 PM
Blank Inventory Page ilrak Questions and Supports 5 09-23-2014 09:03 PM
Blank Page Samuel hunter Questions and Supports 8 01-01-2013 04:08 PM
Blank page LilPixie Questions and Supports 2 02-20-2009 09:59 PM


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

Currently Active Users: 1450 (0 members and 1450 guests)
Threads: 4,082, Posts: 32,047, 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 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636