Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Mys v1.3.x Mods (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=42)
-   -   Mys v1.3.x Stat/SKill System (http://www.mysidiaadoptables.com/forum/showthread.php?t=4563)

Hwona 06-29-2014 04:13 PM

Try this:
PHP Code:

<?php

use Resource\Native\Integer;
use 
Resource\Collection\ArrayList;
use 
Resource\Utility\Curl;

class 
LevelupController extends AppController{

    const 
PARAM "aid";
    private 
$adopt;
    private 
$settings;

    public function 
__construct(){
        
parent::__construct();
        
$this->settings = new LevelSetting;
        
$mysidia Registry::get("mysidia");

        if(
$mysidia->input->action() == "click" or $mysidia->input->action() == "siggy"$this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
        if(
$mysidia->user instanceof Member){
            
$status $mysidia->user->getstatus();   
            if(
$status->canlevel == "no") throw new InvalidActionException("banned");
        }    
    }
    
    public function 
index(){
        throw new 
InvalidActionException("global_action");
    }
    
    public function 
click(){
        
$mysidia Registry::get("mysidia");
        
$date = new DateTime;
        
$ip secure($_SERVER['REMOTE_ADDR']);
        
$statname rand(0,100) ;

        if(
$this->settings->system != "enabled") throw new NoPermissionException("disabled");
        elseif(
$this->adopt->hasVoter($mysidia->user$date)){





            
$message "<div id='stats'>Statname: {$adoptablestatname}</div>";
$message $message .= (($mysidia->user instanceof Member)?$mysidia->lang->already_leveled_member:$mysidia->lang->already_leveled_guest);  


            throw new 
LevelupException($message);        
        }
        




        
          
$message $message .= "
<div id='stats'>
Statname: 
{$adoptablestatname}
</div><br>
We're sorry, but you cannot add clicks to this adoptable at this time because its owner has chosen to freeze it.  Frozen adoptables do not accept new clicks and do not level up.  Thanks anyway for the click though, but the owner of this adoptable wants to keep this adoptable young so it will not be counted."
;
        elseif(
$this->adopt->isFrozen() == "yes") throw new LevelupException($message);
        elseif(
$mysidia->user->getVotes() > $this->settings->number) throw new LevelupException("number");
        elseif(
$this->settings->owner == "disabled" and $this->adopt->getOwner() == $mysidia->user->username){
             throw new 
LevelupException("owner");               
        }
        else{
          
$message $message .= "<br><text align ='center'><div id='clickpagelink'><a href='{$mysidia->path->getAbsolute()}levelup/click/{$this->adopt->getAdoptID()}'>Click here to visit {$adoptablename}</a><br></div>";  
            
$newClicks $this->adopt->getTotalClicks() + 1;
            
$this->adopt->setTotalClicks($newClicks"update");
            
$mysidia->db->insert("vote_voters", array("void" => NULL"date" => $date->format('Y-m-d'), "username" => $mysidia->user->username"ip" => $ip"adoptableid" => $mysidia->input->get("aid")));         
            
            if(
$this->adopt->hasNextLevel()){
                
$nextLevel $this->adopt->getNextLevel();
                
$requiredClicks $nextLevel->getRequiredClicks();
                if(
$requiredClicks and $newClicks >= $requiredClicks$this->adopt->setCurrentLevel($nextLevel->getLevel(), "update");
            }
            
            
$reward $mysidia->user->clickreward($this->settings->reward);
            
$mysidia->user->changecash($reward);            
            
$this->setField("adopt"$this->adopt);
            
$this->setField("reward", new Integer($reward));
            throw new 
LevelupException($message);
        }
    }

    public function 
siggy(){
        
$mysidia Registry::get("mysidia");
        
// The adoptable is available, let's collect its info
        
$usingimage "no";
        
$image $this->adopt->getImage(); 
      
        
$usegd $mysidia->settings->gdimages;
        
$imageinfo = @getimagesize($image);
        
$imagemime $imageinfo["mime"]; // Mime type of the image file, should be a .gif file...

        
if(function_exists('imagegif') and $usegd == "yes" and $imagemime == "image/gif"){
            
$usingimage "yes"//Turn the template system off
            
$type $this->adopt->getType();
            list(
$width$height$type$attr) = getimagesize($image); // The size of the original adoptable image

            // Lets create the new target image, with a size big enough for the text for the adoptable
            
$newheight $height 72;
            
$newwidth = ($newwidth 250)?250:$width;
            
$img_temp imagecreatetruecolor($newwidth$newheight); 
            
$alphablending true;  
         
            
// Lets create the image and save its transparency  
            
$img_old = @imagecreatefromgif($image);  
            
imagealphablending($img_oldtrue);  
            
imagesavealpha($img_oldtrue);
   
            
// Lets copy the old image into the new image with  
            
ImageCopyResampled($img_temp$img_old0000$width$height$width$height);    
            
$textheight $width 2;
            
$image $img_temp;
            
$bgi imagecreatetruecolor($newwidth$newheight);
            
$color imagecolorallocate($bgi515151);
         
            
// Build text for siggy
            
$str1 "Name: ".$this->adopt->getName();
            
$str2 "Owner: ".$this->adopt->getOwner();
            
$str3 "Click Here to Boost Me!";
            
$str4 "More Pets at:";
            
$str5 "www.".constant("DOMAIN");

            
// Renger Image
            
imagestring ($image120$textheight,  $str1$color);
            
imagestring ($image120$textheight 13,  $str2$color);
            
imagestring ($image120$textheight 26,  $str3$color);
            
imagestring ($image120$textheight 42,  $str4$color);
            
imagestring ($image120$textheight 55,  $str5$color);
            
$background imagecolorallocate($image000);  
            
ImageColorTransparent($image$background);  
 
            
// At the very last, let's clean up temporary files
            
header("Content-Type: image/GIF");
            
ImageGif ($image);
            
imagedestroy($image);
            
imagedestroy($img_temp);
            
imagedestroy($img_old);
            
imagedestroy($bgi);

        }
        else{      
                
// We are going to try and get this image the old fashioned way...
            
$extList = array();
            
$extList['gif'] = 'image/gif';
            
$extList['jpg'] = 'image/jpeg';
            
$extList['jpeg'] = 'image/jpeg';
            
$extList['png'] = 'image/png';

            
//Define the output file type
            
$contentType 'Content-type: '.$extList$imageinfo['extension'] ];

            if(
$imageinfo['extension'] =! "image/gif" and $imageinfo['extension'] =! "image/jpeg" and $imageinfo['extension'] =! "image/png"){             
                throw new 
InvalidIDException("The file Extension is not allowed!");
            }
            else{
                
// File type is allowed, so proceed
                
$status "";
                
header($contentType);
                
$curl = new Curl($image);
                
$curl->setHeader();
                
$curl->exec();
                
$curl->close();
            } 
        }
    }
    
    public function 
daycare(){        
        
$daycare = new Daycare;
        
$adopts $daycare->getAdopts();
        
$this->setField("daycare"$daycare);
    }
}
?>


Missy Master 06-29-2014 04:17 PM

Not working for me still ... anyone else want to try this on a 1.3.4 site?

I really can't imagine what's wrong!

Hwona 06-29-2014 04:29 PM

Does v.1.3.4 have the comment() function?

Missy Master 06-29-2014 04:45 PM

1 Attachment(s)
I'm not sure .. ah, and shop is giving the same error as adopt and breeding were.



I have uploaded the 1.3.4 shop file, if you have time you can alter that when you are able.

We're getting there, I'm anxious to get this all working because it's fantastic!!


I'm already working on a mod for the mod, to have the mother and father stats combine to be inherited!

Hwona 06-29-2014 06:32 PM

Try this code:
PHP Code:

<?php

use Resource\Native\Integer;

class 
ShopController extends AppController{

    const 
PARAM "shop";

    public function 
__construct(){
        
parent::__construct("member");    
        
$mysidia Registry::get("mysidia");        
        
$mysidia->user->getstatus();
        if(
$mysidia->user->status->canshop == "no"){
            throw new 
NoPermissionException($mysidia->lang->denied);
        }
        if(
$mysidia->input->action() != "index" and !$mysidia->input->get("shop")){
            throw new 
InvalidIDException($mysidia->lang->global_id);
        }
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$shopList = new Shoplist($mysidia->input->post("shoptype"));
        if(
$shopList->gettotal() == 0) throw new InvalidIDException("none");
        
$this->setField("shopList"$shopList);
    }
    
    public function 
browse(){
        
$mysidia Registry::get("mysidia");        
        
$shoptype $mysidia->db->select("shops", array("shoptype"), "shopname = '{$mysidia->input->get("shop")}'")->fetchColumn();
        
$shoplist = new Shoplist($shoptype);
        
$shop $shoplist->createshop($mysidia->input->get("shop"));
        
$this->setField("shop"$shop);
    }
    
    public function 
purchase(){
        
$mysidia Registry::get("mysidia");
        if(!
$mysidia->input->post("buy")) throw new InvalidIDException($mysidia->lang->global_id);
        
        if(
$mysidia->input->post("shoptype") == "itemshop"$this->purchaseItem();
        
        elseif(
$mysidia->input->post("shoptype") == "adoptshop"$this->purchaseAdopt();
        
        
        
        
        
        
        
        else throw new 
InvalidActionException($mysidia->lang->global_action);
    }
    
    private function 
purchaseItem(){
        
$mysidia Registry::get("mysidia");        
        
$shop = new Itemshop($mysidia->input->get("shop"));
        
$item $shop->getitem($mysidia->input->post("itemname"));
        
$item->assign($mysidia->user->username);
        
$oldquantity $item->getoldquantity();
        
$newquantity $oldquantity $mysidia->input->post("quantity");
            
        if(!
is_numeric($mysidia->input->post("quantity"))){
            throw new 
InvalidActionException($mysidia->lang->invalid_quantity);
        }
        elseif(
$newquantity $item->cap){
            throw new 
InvalidActionException($mysidia->lang->full_quantity); 
        }
        else{
            
$shop->purchase($item);
            
$this->setField("cost", new Integer($item->getcost($shop->salestax)));
        }        
    }
    
    private function 
purchaseAdopt(){
        
$mysidia Registry::get("mysidia");
        
$shop = new Adoptshop($mysidia->input->get("shop"));
        
$adopt $shop->getadopt($mysidia->input->post("adopttype"));
        
$statname rand(minimum value,maximum value) ;
        
$adopt->assign($mysidia->user->username);            
        
$shop->purchase($adopt);
        
$mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $offspringID");  
        
$this->setField("cost", new Integer($adopt->getcost($shop->salestax)));        
    }
}
?>

Also, the breeding sounds great, but if you're going to implement the training and award system I have on my site, you'll also have to limit the number of training items that can be used on an adopt.

Missy Master 06-29-2014 07:14 PM

Aww this one didn't work ... and yeah very true, I'll have to change some of the item amounts allowed.

Hwona 06-29-2014 08:01 PM

Sorry about that - my mistake!
PHP Code:

<?php

use Resource\Native\Integer;

class 
ShopController extends AppController{

    const 
PARAM "shop";

    public function 
__construct(){
        
parent::__construct("member");    
        
$mysidia Registry::get("mysidia");        
        
$mysidia->user->getstatus();
        if(
$mysidia->user->status->canshop == "no"){
            throw new 
NoPermissionException($mysidia->lang->denied);
        }
        if(
$mysidia->input->action() != "index" and !$mysidia->input->get("shop")){
            throw new 
InvalidIDException($mysidia->lang->global_id);
        }
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$shopList = new Shoplist($mysidia->input->post("shoptype"));
        if(
$shopList->gettotal() == 0) throw new InvalidIDException("none");
        
$this->setField("shopList"$shopList);
    }
    
    public function 
browse(){
        
$mysidia Registry::get("mysidia");        
        
$shoptype $mysidia->db->select("shops", array("shoptype"), "shopname = '{$mysidia->input->get("shop")}'")->fetchColumn();
        
$shoplist = new Shoplist($shoptype);
        
$shop $shoplist->createshop($mysidia->input->get("shop"));
        
$this->setField("shop"$shop);
    }
    
    public function 
purchase(){
        
$mysidia Registry::get("mysidia");
        if(!
$mysidia->input->post("buy")) throw new InvalidIDException($mysidia->lang->global_id);
        
        if(
$mysidia->input->post("shoptype") == "itemshop"$this->purchaseItem();
        
        elseif(
$mysidia->input->post("shoptype") == "adoptshop"$this->purchaseAdopt();
        
        
        
        
        
        
        
        else throw new 
InvalidActionException($mysidia->lang->global_action);
    }
    
    private function 
purchaseItem(){
        
$mysidia Registry::get("mysidia");        
        
$shop = new Itemshop($mysidia->input->get("shop"));
        
$item $shop->getitem($mysidia->input->post("itemname"));
        
$item->assign($mysidia->user->username);
        
$oldquantity $item->getoldquantity();
        
$newquantity $oldquantity $mysidia->input->post("quantity");
            
        if(!
is_numeric($mysidia->input->post("quantity"))){
            throw new 
InvalidActionException($mysidia->lang->invalid_quantity);
        }
        elseif(
$newquantity $item->cap){
            throw new 
InvalidActionException($mysidia->lang->full_quantity); 
        }
        else{
            
$shop->purchase($item);
            
$this->setField("cost", new Integer($item->getcost($shop->salestax)));
        }        
    }
    
    private function 
purchaseAdopt(){
        
$mysidia Registry::get("mysidia");
        
$shop = new Adoptshop($mysidia->input->get("shop"));
        
$adopt $shop->getadopt($mysidia->input->post("adopttype"));
        
$statname rand(0,100) ;
        
$adoptid $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY aid DESC LIMIT 1")->fetchColumn() - $num 1;
        
$adopt->assign($mysidia->user->username);            
        
$shop->purchase($adopt);
        
$mysidia->db->update("owned_adoptables",array("statname" => $statname),"aid = $adoptid");  
        
$this->setField("cost", new Integer($adopt->getcost($shop->salestax)));        
    }
}
?>

Try this. :3

Missy Master 06-29-2014 08:24 PM

Heeeeey ! Looks like you got it!! YAY!! Thank you!!

If you're able to get Levelup going, I'll test that out ...just let me know. And thank you for all your work on this!

Hwona 06-29-2014 08:54 PM

Hmm, all I need to know is whether or not the comment function would work... either that or, I need to check some v.1.3.4 files.

Missy Master 06-29-2014 08:59 PM

HOF ? You know this PHP far better than I ...what say you ? :)


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

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