Mys 1.3.4 Simple NPC Battle

Forum
Last Post
Threads / Messages
Okay- I got it to mostly work XD Im still havign issues though- For example I did the calling codes etc- but It still wont show me the amount-

Instead for my pet it says "Spooka has Trophies"

No number..I must be missing something...

Heres my adoptsview.php file-

PHP:
<?php

use Resource\Native\String;
use Resource\Collection\LinkedList;
use Resource\Collection\LinkedHashMap;

class MyadoptsView extends View{

    /**
     * @throws Exception
     */
    public function index(){
    	$document = $this->document;
    	$document->setTitle($this->lang->title);

    	$groups = $this->getField('groups');


    	$document->add($this->getField('pet_storage_info'));

    	$pagination = $this->getField("pagination");
    	$stmt = $this->getField("stmt")->get();
    	if($stmt->rowCount() == 0){
    		$document->addLangvar($this->lang->empty);
    		return;
    	}

    	$adopts = $stmt->fetchAll(PDO::FETCH_CLASS,'OwnedAdoptable');

    	foreach ($adopts as $a)
    	{
            if ($a->class == 'Colorful') {
              $categoryArray[] = $a->type;
            }
            else{
              $categoryArray[] = $a->class;
            }
    	}

    	$categories = array_unique($categoryArray);

    	$document->add(new Comment('<div id="tabs" class="c-tabs no-js">',false));

    	foreach ($categories as $tab) {
    		$document->add(new Comment("<a href='#' class='c-tabs-nav__link'>$tab</a>", FALSE));
    	}

    	$i = 0;
        // Style for inventory like display.
    	$document->add(new Comment('<style>
    		.sc_pet {
    			display: inline-table;
    			padding: 5px;
    			text-align: center;
    			font-family: "Trebuchet MS", Helvetica, sans-serif;
    			font-size: 14px;
    			margin-bottom: 3px;
    			height: 300px;
    		}
    		.s_pet_panel {
    			border-radius: 2px;
    			border: 1px solid #CCC;
    		}
    	</style>', FALSE));


    	$document->add(new Comment("<div class='c-tab is-active'>
    		<div class='c-tab__content'>", FALSE));

		/*
        $adoptTable = new TableBuilder("adopttable", 650);
        $adoptTable->setAlign(new Align("center", "middle"));
        $adoptTable->buildHeaders("Gender", "Name/Type", "Image", "Clicks", "Level");
		*/
        foreach ($adopts as $adopt) {
            if ($adopts[$i]->class == 'Colorful') {
                $adopts[$i]->class = $adopts[$i]->type;
                $adopts[$i]->type = 'Colorful';
            }
        	if ($i != 0 AND ($adopts[$i]->class != $adopts[$i-1]->class))
        	{
                //$document->add($adoptTable);
        		$document->add(new Comment('</div></div>',false));
        		$document->add(new Comment('<div class="c-tab"><div class="c-tab__content">',false));

				/*
                $adoptTable = new TableBuilder("adopttable", 650);
                $adoptTable->setAlign(new Align("center", "middle"));
                $adoptTable->buildHeaders("Gender", "Name/Type", "Image", "Clicks", "Level");
				*/
            }

            // Display Like Inventory System
            $document->add(new Comment("<div class='s_pet_panel sc_pet'>"));
            $document->add(new Comment("<em>{$adopt->getName()}</em>",false));
            $document->add($adopt->getGender("gui"));
            $document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "<br><img src='{$adopt->getImageFromWithin()}'>"));
            
               
                                     
                                $document->add(new Comment("<br>Total Clicks: {$adopt->getTotalClicks()} for Current Level: {$adopt->getCurrentLevel()}",false));
            $document->add(new Comment("</div>", FALSE));

            /* Table Display
            $cells = new LinkedList;
			$cells->add(new TCell($adopt->getGender("gui")));
			$cells->add(new TCell("<em>{$adopt->getName()}</em> the {$adopt->getType()}"));
			$cells->add(new TCell(new Link("myadopts/manage/{$adopt->getAdoptID()}", "<img src='{$adopt->getImageFromWithin()}'>")));
			$cells->add(new TCell($adopt->getTotalClicks()));
			$cells->add(new TCell($adopt->getCurrentLevel()));
			$adoptTable->buildRow($cells);
			*/

			$i++;
		}
        //$document->add($adoptTable);

		$document->add(new Comment(
			"</div></div><script src='/js/otherTabs.js'></script>
			<script>
				var myTabs = tabs({
					el: '#tabs',
					tabNavigationLinks: '.c-tabs-nav__link',
					tabContentContainers: '.c-tab'
				});

				myTabs.init();
			</script>", FALSE));

        /* Old original display code
        $adoptTable = new TableBuilder("adopttable", 650);
        $adoptTable->setAlign(new Align("center", "middle"));
        $adoptTable->buildHeaders("Gender", "Name/Type", "Image", "Clicks", "Level");
		while($aid = $stmt->fetchColumn()){
		    $adopt = new OwnedAdoptable($aid);
			$cells = new LinkedList;
		    $cells->add(new TCell($adopt->getGender("gui")));
			$cells->add(new TCell("<em>{$adopt->getName()}</em> the {$adopt->getType()}"));
			$cells->add(new TCell(new Link("myadopts/manage/{$aid}", $adopt->getImage("gui"))));
			$cells->add(new TCell($adopt->getTotalClicks()));
			$cells->add(new TCell($adopt->getCurrentLevel()));
			$adoptTable->buildRow($cells);
		}
        $document->add($adoptTable);
        */

        $document->addLangvar($pagination->showPage());

    }

    public function manage(){
           
    	$mysidia = Registry::get("mysidia");
    	$aid = $this->getField("aid")->getValue();
    	$name = $this->getField("name")->getValue();
    	$image = $this->getField("image");

    	$document = $this->document;		
    	$document->setTitle("Managing {$name}");
    	    
    	$document->add($image);
    	$document->add(new Comment("<br><br>This page allows you to manage {$name}.  Click on an option below to change settings.<br>
 <center>{$name} has {$trophies} trophies!</center><br>"));
        $document->add(new Link("pet/profile/$aid", ' View Public Profile', TRUE));
    	$document->add(new Image("templates/icons/add.gif"));
    	$document->add(new Link("levelup/click/{$aid}", " Level Up {$name}", TRUE));
    	$document->add(new Image("templates/icons/stats.gif"));
    	$document->add(new Link("myadopts/stats/{$aid}", " Get Stats for {$name}", TRUE));
    	$document->add(new Image("templates/icons/bbcodes.gif"));
    	$document->add(new Link("myadopts/bbcode/{$aid}", " Get BBCodes / HTML Codes for {$name}", TRUE));
    	$document->add(new Image("templates/icons/title.gif"));
    	$document->add(new Link("myadopts/rename/{$aid}", " Rename {$name}", TRUE)); 
    	$document->add(new Image("templates/icons/trade.gif"));
    	$document->add(new Link("myadopts/trade/{$aid}", " Change Trade status for {$name}", TRUE)); 
    	$document->add(new Image("templates/icons/freeze.gif"));
    	$document->add(new Link("myadopts/freeze/{$aid}", " Freeze or Unfreeze {$name}", TRUE)); 
    	$document->add(new Image("templates/icons/delete.gif"));
    	$document->add(new Link("pound/pound/{$aid}", " Pound {$name}", TRUE)); 
    	
    }

    public function stats(){
    	$mysidia = Registry::get("mysidia");
    	$adopt = $this->getField("adopt");		
    	$image = $this->getField("image");
    	$stmt = $this->getField("stmt")->get();

    	$document = $this->document;			
    	$document->setTitle($adopt->getName().$this->lang->stats);
    	$document->add($image);	
    	$document->add($adopt->getStats());					   				       
    	$document->addLangvar("<h2>{$adopt->getName()}'s Voters:</h2><br>{$this->lang->voters}<br><br>");	

    	$fields = new LinkedHashMap;
    	$fields->put(new String("username"), new String("getUsername"));
    	$fields->put(new String("date"), NULL);
    	$fields->put(new String("username::profile"), new String("getProfileImage"));
    	$fields->put(new String("username::message"), new String("getPMImage"));

    	$voterTable = new TableBuilder("voters", 500);
    	$voterTable->setAlign(new Align("center"));
    	$voterTable->buildHeaders("User", "Date Voted", "Profile", "PM");
    	$voterTable->setHelper(new UserTableHelper);
    	$voterTable->buildTable($stmt, $fields);
    	$document->add($voterTable);
    }

    public function bbcode(){
    	$mysidia = Registry::get("mysidia");
    	$adopt = $this->getField("adopt");			
    	$document = $this->document;
    	$document->setTitle($this->lang->bbcode.$adopt->getName()); 
    	$document->addLangvar($this->lang->bbcode_info);
    	$document->add(new Comment("<br>"));

    	$forumComment = new Comment("Forum BBCode: ");		
    	$forumComment->setUnderlined();
    	$forumcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}[/img][/url]";		
    	$forumArea = new TextArea("forumcode", $forumcode, 4, 50);
    	$forumArea->setReadOnly(TRUE);

    	$altComment = new Comment("Alternative BBCode: ");		
    	$altComment->setUnderlined();
    	$altcode = "[url={$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}][img]{$mysidia->path->getAbsolute()}get/{$adopt->getAdoptID()}"[/img][/url]";
    	$altArea = new TextArea("altcode", $altcode, 4, 50);
    	$altArea->setReadOnly(TRUE);

    	$htmlComment = new Comment("HTML BBCode: ");		
    	$htmlComment->setUnderlined();
    	$htmlcode = "<a href='{$mysidia->path->getAbsolute()}levelup/click/{$adopt->getAdoptID()}' target='_blank'>
<img src='{$mysidia->path->getAbsolute()}levelup/siggy/{$adopt->getAdoptID()}' border=0></a>";
    	$htmlArea = new TextArea("htmlcode", $htmlcode, 4, 50);
    	$htmlArea->setReadOnly(TRUE);

    	$document->add($forumComment);
    	$document->add($forumArea);
    	$document->add($altComment);
    	$document->add(($mysidia->settings->usealtbbcode == "yes")?$altArea:new Comment("The Admin has disabled Alt BBCode for this site."));
    	$document->add($htmlComment);
    	$document->add($htmlArea);
    }

    public function rename(){
    	$mysidia = Registry::get("mysidia");
    	$adopt = $this->getField("adopt");		
    	$image = $this->getField("image");		
    	$document = $this->document;

    	if($mysidia->input->post("submit")){
    		$document->setTitle($this->lang->rename_success_title);
    		$document->add($image);
    		$message = "<br>{$this->lang->rename_success}{$mysidia->input->post("adoptname")}. 
    		You can now manage {$mysidia->input->post("adoptname")} on the";
    		$document->addLangvar($message);
    		$document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "My Adopts Page"));
    		return;
    	}

    	$document->setTitle($this->lang->rename.$adopt->getName());
    	$document->add($image);
    	$document->addLangvar("<br />{$this->lang->rename_default}{$adopt->getName()}{$this->lang->rename_details}<br />");

    	$renameForm = new FormBuilder("renameform", "", "post");
    	$renameForm->buildTextField("adoptname")->buildButton("Rename Adopt", "submit", "submit");
    	$document->add($renameForm);		   
    }

    public function updatebio(){
 
        $mysidia = Registry::get('mysidia');
        $adopt = $this->getField('adopt');
        $d = $this->document;
        $d->setTitle($this->lang->updatebio . $adopt->getName());
        $d->addLangvar('<form method="post"><textarea name="bio" rows="10" cols="50">'.$adopt->getBio().'</textarea><br><input type="submit" name="submit" value="Update Bio"></form>');
      
    }

    public function trade(){
    	$mysidia = Registry::get("mysidia");
    	$aid = $this->getField("aid")->getValue();		
    	$image = $this->getField("image");	
    	$message = $this->getField("message")->getValue();		
    	$document = $this->document;
    	$document->setTitle($this->lang->trade);
    	$document->add($image);
    	$document->addLangvar($message);
    }

    public function freeze(){
    	$mysidia = Registry::get("mysidia");
    	$adopt = $this->getField("adopt");		
    	$image = $this->getField("image");	
    	$message = $this->getField("message")->getValue();			
    	$document = $this->document;		
    	$document->setTitle($this->lang->freeze);	

    	if($mysidia->input->get("confirm") == "confirm"){
    		$document->addLangvar($message);
    		$document->add(new Link("myadopts/manage/{$adopt->getAdoptID()}", "My Adopts Page"));        
    	}	 
    	else{
    		$document->add($image);
    		$document->add(new Comment("<br /><b>{$adopt->getName()}'s Current Status: "));

    		if($adopt->isfrozen() == "yes"){			    
    			$document->add(new Image("templates/icons/freeze.gif", "Frozen"));
    			$document->add(new Comment("Frozen<br<br>"));
    			$document->add(new Comment($this->lang->freeze));
    			$document->add(new Image("templates/icons/unfreeze.gif", "Unfreeze"));
                $document->addLangvar("<form method='post''><input type='submit' name='confirm' value='Unfreeze {$adopt->getName()}' class='button'></form>");
    			//$document->add(new Link("myadopts/freeze/{$adopt->getAdoptID()}/confirm", "Unfreeze this Adoptable", TRUE));
    		}
    		else{
    			$document->add(new Image("templates/icons/unfreeze.gif", "Not Frozen"));
    			$document->add(new Comment("Not Frozen<br><br>"));
    			$document->add(new Comment($this->lang->freeze));
    			$document->add(new Image("templates/icons/freeze.gif", "Greeze"));
                $document->addLangvar("<form method='post'><input type='submit' name='confirm' value='Freeze {$adopt->getName()}' class='button'></form>");
    			//$document->add(new Link("myadopts/freeze/{$adopt->getAdoptID()}/confirm", "Freeze this Adoptable", TRUE));
    		}
    		$document->add(new Comment("<br><br>"));
    		$document->add(new Image("templates/icons/warning.gif"));
    		$document->addLangvar($this->lang->freeze_warning);
    	}
    }

    public function release(){
        $document = $this->document;        
        $document->setTitle($this->lang->released);
        $document->addLangvar($this->lang->pet_released);  
    }
}

The other issue Is im trying to Add the trophies also to the Petview.php

But my coder added stuff and Im not sure how to do that.. I want it in the "Skills" Tab...

Here's my Petviewphp..

PHP:
<?php
class PetView extends View{

	public function profile(){
		$mysidia = Registry::get('mysidia');
		$d = $this->document;
		$adopt = $this->getField('adopt');
		$isdead = $adopt->isdead;
		$name = $adopt->getName();
		$title = 'Viewing ';
		if ($isdead) {
			$title = '<img src="/picuploads/dead.png"> Here Lies ';
			$name .= ' <img src="/picuploads/dead.png">';
		}
		else{
			if ($adopt->getOwner() == 'SYSTEM') {
				$title = '<img src="/picuploads/shackle.png"> ' . $title;
				$name .= '<img src="/picuploads/shackle.png">';
			}
		}
		if ($adopt->getOwner() == $mysidia->user->username) $title = 'Managing ';
		$d->setTitle(' ');
		$d->addLangVar('<table border=1px><tr><td valign="top">');
		$d->addLangvar("<b>{$title}{$name}</b><hr>");
		if ($isdead == false) {
			if ($adopt->getOwner() == 'SYSTEM') {
				$d->addLangVar("Owned by <a href='/profile/view/POUND'>The Pound</a><br><br>");
			}else{
				$d->addLangVar("Owned by <a href='/profile/view/{$adopt->getOwner()}'>{$adopt->getOwner()}</a><br><br>");
			}
		}
		if ($isdead) {
			$d->addLangvar("<div style='background:url({$mysidia->path->getAbsolute()}picuploads/paw.png); position:relative; height:248px; width:268px;'><div style='background:url({$mysidia->path->getAbsolute()}picuploads/wreath.png);height:248px; width:268px;position:absolute;z-index:30;'></div><div style='position:absolute;z-index:2;left:50px;bottom:10px'>".$adopt->getImage("gui") .'</div></div>');
		}else{
			if ($adopt->class == 'Colorful'){
			$d->addLangvar($adopt->getImage('gui'));
			}else{
				$d->add($adopt->getImage('gui'));
					
			}
		}
	
		if ($isdead){
			$d->addLangvar('</div>');
		}
		
		if ($adopt->isdead == false){
			if($adopt->isfrozen() == 'no'){
				$d->addLangvar("<br><a href='/levelup/click/{$adopt->aid}'>Play</a>");
			}else{
				$d->addLangvar('<br>Frozen');
			}
		}
		
		$freeze = 'Freeze';
		if ($adopt->isFrozen() == 'yes') $freeze = 'Unfreeze';
		if ($mysidia->user->username == $adopt->getOwner()){
		
			$d->addLangVar(" | <a href='/myadopts/manage/{$adopt->aid}'>Manage</a> | <a href='/myadopts/bbcode/{$adopt->aid}'>Codes</a> | <a href='/myadopts/freeze/{$adopt->aid}'>$freeze</a><br><a href='/pound/pound/{$adopt->aid}'>Pound $name</a><br> <a href='/pet/release/{$adopt->aid}'>Release $name</a>");
		}
		$d->addLangVar('</td><td valign="top">');

		$d->add(new Comment('<div id="tabs" class="c-tabs no-js"><div class="c-tabs-nav">',false));

		if ($adopt->class != 'Colorful') {
			$d->addLangVar("<a href='#' class='c-tabs-nav__link'>Bio</a><a href='#' class='c-tabs-nav__link'>About</a>");
			$d->addLangVar("</div><div class='c-tab is-active'><div class='c-tab__content'>{$adopt->getBio()}</div></div><div class='c-tab'>
				<div class='c-tab__content'>{$adopt->getDescription()}</div></div>");
			
		}else{
			$d->addLangVar("<a href='#' class='c-tabs-nav__link'>Bio</a><a href='#' class='c-tabs-nav__link'>Skills</a><a href='#' class='c-tabs-nav__link'>Lineage</a><a href='#' class='c-tabs-nav__link'>Offspring</a><a href='#' class='c-tabs-nav__link'>Stats</a>");
			$d->addLangVar("</div><div class='c-tab is-active'>
				<div class='c-tab__content'>");
			if ($mysidia->user->username == $adopt->getOwner()){
				$d->addLangvar('<a href="/myadopts/updatebio/'.$adopt->aid.'">Click Here to Update Bio</a><br><br>');
			}
			$d->addLangvar("{$adopt->getBio()}</div></div>
				<div class='c-tab'><div class='c-tab__content'><b>Sense:</b> {$adopt->sense}<br>
                    <b>Speed:</b> {$adopt->speed}<br>
                    <b>Strength:</b> {$adopt->strength}<br>
                    <b>Stamina:</b> {$adopt->stamina}<br></div></div>");

			// Lineage
			include('pedigree.php');

			$offspring = []; $parent = 'sire_id';
			if ($adopt->getGender() == 'f') $parent = 'dam_id';
			$offspring = $mysidia->db->select('owned_adoptables', [], "$parent = {$adopt->aid}")->fetchAll(PDO::FETCH_CLASS,'OwnedAdoptable');

			$d->addLangVar("<div class='c-tab'><div class='c-tab__content'><b>Offspring</b>");
			if (count($offspring) == 0) $d->addLangVar('<hr>None.');
			foreach ($offspring as $baby) {
				$d->addLangVar("<hr><a href='/pet/profile/{$baby->aid}'>{$baby->name}<br><img src='{$baby->getImage()}'></a>");
			}
			
			$d->addLangVar('</div></div>');

			$d->addLangVar("<div class='c-tab'><div class='c-tab__content'>");
			$d->addLangvar("<b>Personality:</b> {$adopt->personality()}<br>
				<b>Happiness:</b> {$adopt->happiness}/50<br>
				<b>Hunger:</b> {$adopt->hunger}/50<br>
				<b>Thirst:</b> {$adopt->thirst}/50<br>
				<b>Closeness:</b> {$adopt->closeness}/50<br>
				");
				
			$d->add($adopt->getStats());
			if ($adopt->breeder != null) {
				$d->addLangvar("<br><br><b>Breeder:</b> <a href='/profile/view/{$adopt->breeder}'>{$adopt->breeder}</a>");
				
			}
			

			$d->addLangvar("</div></div>");
		}
		$d->addLangVar('</td></tr></table>');

		$d->add(new Comment(
			"<script src='/js/otherTabs.js'></script>
			<script>
				var myTabs = tabs({
					el: '#tabs',
					tabNavigationLinks: '.c-tabs-nav__link',
					tabContentContainers: '.c-tab'
				});

				myTabs.init();
			</script>", FALSE));
	}

	public function release(){
		$d = $this->document;
		$adopt = $this->getField('adopt');
		$d->setTitle($this->lang->release);
		$d->addLangvar($adopt->getName().'<br>'.$adopt->getImage('gui').'<br><br>');
		$d->addLangvar($this->lang->release_warning);
		$d->addLangvar('<br><br><form method="post" action="/myadopts/release/'.$adopt->aid.'"><label for="password">Type your password below to confirm:</label><br><input type="password" name="password"><br><input type="submit" value="Release Pet?"></form>');
	}

	public function bio(){
	
		$d = $this->document;
		$adopt = $this->getField('adopt');
		
		$d->setTitle('Update Bio');
		$d->addLangvar($adopt->getName().'<br>'.$adopt->getImage('gui').'<br><br>');
		$d->addLangvar('<form method="post"><textarea name="bio">'.$adopt->bio.'</textarea><br><input type="submit" value="Update Bio" name="submit"></form>');
		  
	}
	

}

Thanks in advance.. Sorry im such a noob
 
In the myadopts.view I see that you place {$trophies} but I do not see anywhere that you actually designated what $trophies means, so that script basically doesn't know what you're asking it to show. Here's a version I modified of your manage function, try using it and let me know if it works:
PHP:
    public function manage(){ 
            
        $mysidia = Registry::get("mysidia"); 
        $aid = $this->getField("aid")->getValue(); 
        $name = $this->getField("name")->getValue(); 
        $image = $this->getField("image"); 
        $trophies = $mysidia->db->select("owned_adoptables", array("trophies"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn();

        $document = $this->document;         
        $document->setTitle("Managing {$name}"); 
             
        $document->add($image); 
        $document->add(new Comment("<br><br>This page allows you to manage {$name}.  Click on an option below to change settings.<br> 
 <center>{$name} has {$trophies} trophies!</center><br>")); 
        $document->add(new Link("pet/profile/$aid", ' View Public Profile', TRUE)); 
        $document->add(new Image("templates/icons/add.gif")); 
        $document->add(new Link("levelup/click/{$aid}", " Level Up {$name}", TRUE)); 
        $document->add(new Image("templates/icons/stats.gif")); 
        $document->add(new Link("myadopts/stats/{$aid}", " Get Stats for {$name}", TRUE)); 
        $document->add(new Image("templates/icons/bbcodes.gif")); 
        $document->add(new Link("myadopts/bbcode/{$aid}", " Get BBCodes / HTML Codes for {$name}", TRUE)); 
        $document->add(new Image("templates/icons/title.gif")); 
        $document->add(new Link("myadopts/rename/{$aid}", " Rename {$name}", TRUE));  
        $document->add(new Image("templates/icons/trade.gif")); 
        $document->add(new Link("myadopts/trade/{$aid}", " Change Trade status for {$name}", TRUE));  
        $document->add(new Image("templates/icons/freeze.gif")); 
        $document->add(new Link("myadopts/freeze/{$aid}", " Freeze or Unfreeze {$name}", TRUE));  
        $document->add(new Image("templates/icons/delete.gif")); 
        $document->add(new Link("pound/pound/{$aid}", " Pound {$name}", TRUE));  
         
    }

OK, so I think this should work for petview.php (cool system, btw), just replace the file with this;
PHP:
<?php 
class PetView extends View{ 

    public function profile(){ 
        $mysidia = Registry::get('mysidia'); 
        $d = $this->document; 
        $adopt = $this->getField('adopt'); 
        $isdead = $adopt->isdead; 
        $name = $adopt->getName(); 
        $title = 'Viewing '; 
        if ($isdead) { 
            $title = '<img src="/picuploads/dead.png"> Here Lies '; 
            $name .= ' <img src="/picuploads/dead.png">'; 
        } 
        else{ 
            if ($adopt->getOwner() == 'SYSTEM') { 
                $title = '<img src="/picuploads/shackle.png"> ' . $title; 
                $name .= '<img src="/picuploads/shackle.png">'; 
            } 
        } 
        if ($adopt->getOwner() == $mysidia->user->username) $title = 'Managing '; 
        $d->setTitle(' '); 
        $d->addLangVar('<table border=1px><tr><td valign="top">'); 
        $d->addLangvar("<b>{$title}{$name}</b><hr>"); 
        if ($isdead == false) { 
            if ($adopt->getOwner() == 'SYSTEM') { 
                $d->addLangVar("Owned by <a href='/profile/view/POUND'>The Pound</a><br><br>"); 
            }else{ 
                $d->addLangVar("Owned by <a href='/profile/view/{$adopt->getOwner()}'>{$adopt->getOwner()}</a><br><br>"); 
            } 
        } 
        if ($isdead) { 
            $d->addLangvar("<div style='background:url({$mysidia->path->getAbsolute()}picuploads/paw.png); position:relative; height:248px; width:268px;'><div style='background:url({$mysidia->path->getAbsolute()}picuploads/wreath.png);height:248px; width:268px;position:absolute;z-index:30;'></div><div style='position:absolute;z-index:2;left:50px;bottom:10px'>".$adopt->getImage("gui") .'</div></div>'); 
        }else{ 
            if ($adopt->class == 'Colorful'){ 
            $d->addLangvar($adopt->getImage('gui')); 
            }else{ 
                $d->add($adopt->getImage('gui')); 
                     
            } 
        } 
     
        if ($isdead){ 
            $d->addLangvar('</div>'); 
        } 
         
        if ($adopt->isdead == false){ 
            if($adopt->isfrozen() == 'no'){ 
                $d->addLangvar("<br><a href='/levelup/click/{$adopt->aid}'>Play</a>"); 
            }else{ 
                $d->addLangvar('<br>Frozen'); 
            } 
        } 
         
        $freeze = 'Freeze'; 
        if ($adopt->isFrozen() == 'yes') $freeze = 'Unfreeze'; 
        if ($mysidia->user->username == $adopt->getOwner()){ 
         
            $d->addLangVar(" | <a href='/myadopts/manage/{$adopt->aid}'>Manage</a> | <a href='/myadopts/bbcode/{$adopt->aid}'>Codes</a> | <a href='/myadopts/freeze/{$adopt->aid}'>$freeze</a><br><a href='/pound/pound/{$adopt->aid}'>Pound $name</a><br> <a href='/pet/release/{$adopt->aid}'>Release $name</a>"); 
        } 
        $d->addLangVar('</td><td valign="top">'); 

        $d->add(new Comment('<div id="tabs" class="c-tabs no-js"><div class="c-tabs-nav">',false)); 

        if ($adopt->class != 'Colorful') { 
            $d->addLangVar("<a href='#' class='c-tabs-nav__link'>Bio</a><a href='#' class='c-tabs-nav__link'>About</a>"); 
            $d->addLangVar("</div><div class='c-tab is-active'><div class='c-tab__content'>{$adopt->getBio()}</div></div><div class='c-tab'> 
                <div class='c-tab__content'>{$adopt->getDescription()}</div></div>"); 
             
        }else{ 
            $d->addLangVar("<a href='#' class='c-tabs-nav__link'>Bio</a><a href='#' class='c-tabs-nav__link'>Skills</a><a href='#' class='c-tabs-nav__link'>Lineage</a><a href='#' class='c-tabs-nav__link'>Offspring</a><a href='#' class='c-tabs-nav__link'>Stats</a>"); 
            $d->addLangVar("</div><div class='c-tab is-active'> 
                <div class='c-tab__content'>"); 
            if ($mysidia->user->username == $adopt->getOwner()){ 
                $d->addLangvar('<a href="/myadopts/updatebio/'.$adopt->aid.'">Click Here to Update Bio</a><br><br>'); 
            } 
            $d->addLangvar("{$adopt->getBio()}</div></div> 
                <div class='c-tab'><div class='c-tab__content'><b>Trohpies:</b> {$adopt->trophies}<br><br>
					<b>Sense:</b> {$adopt->sense}<br> 
                    <b>Speed:</b> {$adopt->speed}<br> 
                    <b>Strength:</b> {$adopt->strength}<br> 
                    <b>Stamina:</b> {$adopt->stamina}<br></div></div>"); 

            // Lineage 
            include('pedigree.php'); 

            $offspring = []; $parent = 'sire_id'; 
            if ($adopt->getGender() == 'f') $parent = 'dam_id'; 
            $offspring = $mysidia->db->select('owned_adoptables', [], "$parent = {$adopt->aid}")->fetchAll(PDO::FETCH_CLASS,'OwnedAdoptable'); 

            $d->addLangVar("<div class='c-tab'><div class='c-tab__content'><b>Offspring</b>"); 
            if (count($offspring) == 0) $d->addLangVar('<hr>None.'); 
            foreach ($offspring as $baby) { 
                $d->addLangVar("<hr><a href='/pet/profile/{$baby->aid}'>{$baby->name}<br><img src='{$baby->getImage()}'></a>"); 
            } 
             
            $d->addLangVar('</div></div>'); 

            $d->addLangVar("<div class='c-tab'><div class='c-tab__content'>"); 
            $d->addLangvar("<b>Personality:</b> {$adopt->personality()}<br> 
                <b>Happiness:</b> {$adopt->happiness}/50<br> 
                <b>Hunger:</b> {$adopt->hunger}/50<br> 
                <b>Thirst:</b> {$adopt->thirst}/50<br> 
                <b>Closeness:</b> {$adopt->closeness}/50<br> 
                "); 
                 
            $d->add($adopt->getStats()); 
            if ($adopt->breeder != null) { 
                $d->addLangvar("<br><br><b>Breeder:</b> <a href='/profile/view/{$adopt->breeder}'>{$adopt->breeder}</a>"); 
                 
            } 
             

            $d->addLangvar("</div></div>"); 
        } 
        $d->addLangVar('</td></tr></table>'); 

        $d->add(new Comment( 
            "<script src='/js/otherTabs.js'></script> 
            <script> 
                var myTabs = tabs({ 
                    el: '#tabs', 
                    tabNavigationLinks: '.c-tabs-nav__link', 
                    tabContentContainers: '.c-tab' 
                }); 

                myTabs.init(); 
            </script>", FALSE)); 
    } 

    public function release(){ 
        $d = $this->document; 
        $adopt = $this->getField('adopt'); 
        $d->setTitle($this->lang->release); 
        $d->addLangvar($adopt->getName().'<br>'.$adopt->getImage('gui').'<br><br>'); 
        $d->addLangvar($this->lang->release_warning); 
        $d->addLangvar('<br><br><form method="post" action="/myadopts/release/'.$adopt->aid.'"><label for="password">Type your password below to confirm:</label><br><input type="password" name="password"><br><input type="submit" value="Release Pet?"></form>'); 
    } 

    public function bio(){ 
     
        $d = $this->document; 
        $adopt = $this->getField('adopt'); 
         
        $d->setTitle('Update Bio'); 
        $d->addLangvar($adopt->getName().'<br>'.$adopt->getImage('gui').'<br><br>'); 
        $d->addLangvar('<form method="post"><textarea name="bio">'.$adopt->bio.'</textarea><br><input type="submit" value="Update Bio" name="submit"></form>'); 
           
    } 
     

}

Let me know if this works!
 
Okay the one for myadopts.php gives me this error

Fatal error: Call to a member function getAdoptID() on null in /home/atrocity/public_html/view/myadoptsview.php on line 157

second one works like a charm ^^
 
Alright, try changing the manage function in myadoptsview.php to this:
PHP:
   public function manage(){ 
            
        $mysidia = Registry::get("mysidia"); 
        $aid = $this->getField("aid")->getValue(); 
        $name = $this->getField("name")->getValue(); 
        $image = $this->getField("image"); 
        $trophies = $mysidia->db->select("owned_adoptables", array("trophies"), "aid = '{$aid}'")->fetchColumn();

        $document = $this->document;         
        $document->setTitle("Managing {$name}"); 
             
        $document->add($image); 
        $document->add(new Comment("<br><br>This page allows you to manage {$name}.  Click on an option below to change settings.<br> 
 <center>{$name} has {$trophies} trophies!</center><br>")); 
        $document->add(new Link("pet/profile/$aid", ' View Public Profile', TRUE)); 
        $document->add(new Image("templates/icons/add.gif")); 
        $document->add(new Link("levelup/click/{$aid}", " Level Up {$name}", TRUE)); 
        $document->add(new Image("templates/icons/stats.gif")); 
        $document->add(new Link("myadopts/stats/{$aid}", " Get Stats for {$name}", TRUE)); 
        $document->add(new Image("templates/icons/bbcodes.gif")); 
        $document->add(new Link("myadopts/bbcode/{$aid}", " Get BBCodes / HTML Codes for {$name}", TRUE)); 
        $document->add(new Image("templates/icons/title.gif")); 
        $document->add(new Link("myadopts/rename/{$aid}", " Rename {$name}", TRUE));  
        $document->add(new Image("templates/icons/trade.gif")); 
        $document->add(new Link("myadopts/trade/{$aid}", " Change Trade status for {$name}", TRUE));  
        $document->add(new Image("templates/icons/freeze.gif")); 
        $document->add(new Link("myadopts/freeze/{$aid}", " Freeze or Unfreeze {$name}", TRUE));  
        $document->add(new Image("templates/icons/delete.gif")); 
        $document->add(new Link("pound/pound/{$aid}", " Pound {$name}", TRUE));  
         
    }
 
I'm not sure if I did something wrong when I changed the price of training but I absentmindedly pressed the button for training while I testing and noticed my money was in the negative.
 
@Corsair
Try adding this to see if it'll help (make sure to define $traincost):
PHP:
if($mysidia->user->money < $traincost) {
   $document->add(new Comment(" You don't have enough money to train your companion!"));
  return;
}


Came up with a code to automatically change an adopt's stats emulating $mysidia->user->changecash(). This should be helpful updating the db with less code. Add it to /classes/class_ownedadoptable.php
PHP:
public function changestat($stat, $gainstat){
	$mysidia = Registry::get("mysidia");
        if(!is_numeric($gainstat)) throw new Exception('Cannot change crocuta stats by a non-numeric value!'); 
       
# Define $newstat...
       if($stat == "sense"){
          $newstat = $this->sense;
          } elseif($stat == "strength"){
          $newstat = $this->strength;
          }
                 
      $newstat += $gainstat;     
      
      $profile = $mysidia->user->getprofile();
         $mysidia->db->update("owned_adoptables", array("{$stat}" => $newstat), "aid = '{$profile->getFavPetID()}'"); 
         return TRUE;               
      
      }

To use:
PHP:
$randgain = rand(1,20);
$favpet->changestat(strength, $randgain);
 
Last edited:
I'm not sure if I did something wrong when I changed the price of training but I absentmindedly pressed the button for training while I testing and noticed my money was in the negative.

need help with this
 
I'm not sure if I did something wrong when I changed the price of training but I absentmindedly pressed the button for training while I testing and noticed my money was in the negative.

@Corsair
Try adding this to see if it'll help (make sure to define $traincost):
PHP:
if($mysidia->user->money < $traincost) {
   $document->add(new Comment(" You don't have enough money to train your companion!"));
  return;
}

This issue came up and lotus shared the solution :)
 
What would you suggest to limit the amount of training?
Say, you can only train any pet up to 5 times (regardless of stat) so you don't end up with a billion highly trained pets? It forces you to breed and train for better stats?
 
I would add a new column to the owned_adoptables table in phpMyAdmin and call it something like "timestrained," with the default set to 0. Then each time that pet is trained add +1 to that column...then just include an if/else statement to exclude any pets that have been trained 5 times. So...something like...
blarg_by_perocore-dbd0s8e.jpg


Add this under the list of defined variables for training:
PHP:
$trained = $favpet->timestrained; 
$total = $trained + 1;

And then at the end of each training type (before the break;):
PHP:
$mysidia->db->update("owned_adoptables", array("timestrained" => $total), "aid='{$profile->getFavpetID()}'");

Before the if($favpet->currentlevel = 3) add this;
PHP:
if($favpet->timestrained = 5){ 
$document->add(new Comment("This pet has maxed out its allowed training sessions! It can no longer be trained.", FALSE));
}
else{...}

With the {...} containing all of the training stuff.

Let me know if that makes sense/works out!
 
For what its worth, going back in all this time later, this brilliant Mod just needs all the attributes (sense, etc) changed to public instead of private.

I am much more php savvy a few years in -- and found it easy to get it working just fine!

Highly recommend this awesome and fun Mod!


Thanks again for it!
 
Kitt or anyone really but it's probably gonna be Kitt.....
What did class_breeding.php turn into? I've checked every file that has the word breed in it and that code is nowhere to be found. I just want genetics and breeding cause right now theres no reason to use the breeding function.
 
Kitt or anyone really but it's probably gonna be Kitt.....
What did class_breeding.php turn into? I've checked every file that has the word breed in it and that code is nowhere to be found. I just want genetics and breeding cause right now theres no reason to use the breeding function.
lol

Breeding adoptables has changed a lot so a lot of the code has moved or straight up been changed... for example, there is a function in model/domainmodel/adoptable.php for giving an adopt to a user.

PHP:
public function makeOwnedAdopt($owner, $name = NULL){
        $mysidia = Registry::get("mysidia");
        if(!$name) $name = $this->type;
        $code = $this->generateCode();
        $gender = $this->getGender();
        $mysidia->db->insert("owned_adoptables", ["aid" => NULL, "adopt" => $this->id, "name" => $name, "owner" => $owner, "currentlevel" => 0,
                                                  "totalclicks" => 0, "code" => $code, "imageurl" => "", "alternate" => 0, "tradestatus" => "fortrade",
                                                  "isfrozen" => "no", "gender" => $gender, "offsprings" => 0, "lastbred" => 0]);    
        $aid = $mysidia->db->lastInsertId();
        if(!$aid) return NULL;
        return new OwnedAdoptable($aid);
    }

Then in breedingservice.php there's this:

PHP:
public function breed(){
        $mysidia = Registry::get("mysidia");
        foreach($this->offsprings as $adopt){
            $adopt->makeOwnedAdopt($mysidia->user->getID());
        }
        $this->validator->setStatus("complete");  
    }

That essentially uses $adopt->makeOwnedAdopt($mysidia->user->getID()); to give the adopt to a user, and there's no direct insert like there used to be. So unfortunately adding stats while breeding will be a bit more complicated.

That being said, I have given it a shot and managed to get it working. :cool:

1) Open service/applicationservice/breedingservice.php. Add this:

PHP:
public function getBabyStrength(){
        $femaleStrength = $this->female->getStrength();
        $maleStrength = $this->male->getStrength();
        $parentStrength = $femaleStrength + $maleStrength;
        $strength = $parentStrength / 2;
        return $strength;
    }

2) Scroll to the bottom breed function and replace it with this:

PHP:
public function breed(){
        $mysidia = Registry::get("mysidia");
        foreach($this->offsprings as $adopt){
            $adopt->makeOwnedAdopt($mysidia->user->getID(), $this->getBabyStrength());
        }
        $this->validator->setStatus("complete");    
    }

3) Open model/domainmodel/adoptable.php. Find the makeOwnedAdopt function and replace it with this:

PHP:
public function makeOwnedAdopt($owner, $strength, $name = NULL){
        $mysidia = Registry::get("mysidia");
        if(!$name) $name = $this->type;
        $code = $this->generateCode();
        $gender = $this->getGender();
        $mysidia->db->insert("owned_adoptables", ["aid" => NULL, "adopt" => $this->id, "name" => $name, "owner" => $owner, "currentlevel" => 0, "totalclicks" => 0, "code" => $code, "imageurl" => "", "alternate" => 0, "tradestatus" => "fortrade", "isfrozen" => "no", "gender" => $gender, "offsprings" => 0,"strength" => $strength, "lastbred" => 0]);     
        $aid = $mysidia->db->lastInsertId();
        if(!$aid) return NULL;
        return new OwnedAdoptable($aid);
    }

If you want the strength to be randomised between the two parents instead, use this in breedingservice:

PHP:
public function getBabyStrength(){
        $femaleStrength = $this->female->getStrength();
        $maleStrength = $this->male->getStrength();
        $strength = rand($femaleStrength, $maleStrength);
        return $strength;
    }

Top 2 are parents, others are children (from 2 breedings):

2023-11-15 11_12_15-localhost _ MySQL _ mysidia _ adopts_owned_adoptables _ phpMyAdmin 5.2.0 a...png


If you want the strength to have a random chance to get a small boost you can use something like:

PHP:
public function getBabyStrength(){
        $femaleStrength = $this->female->getStrength();
        $maleStrength = $this->male->getStrength();
        $boostChance = rand(1,100);
        $boostAmount = rand(1,10);
        if($boostChance <= 10){
            $strength = rand($femaleStrength, $maleStrength) + $boostAmount;
        }
        else{
            $strength = rand($femaleStrength, $maleStrength);
        }
        
        return $strength;
    }

That essentially randomises the baby's strength between the two parents and then there is a 10% chance the baby gets a 1-10 boost. To change the values just change if($boostChance <= 10) to whatever chance you want. It basically means if the random value out of 100 lands on 1-10, they get the boost. And then $boostAmount is the two values the boost can be between.

With the above random + boost, this is what I got:

2023-11-15 11_22_58-localhost _ MySQL _ mysidia _ adopts_owned_adoptables _ phpMyAdmin 5.2.0 a...png

Then if you want to add MORE stats you basically need to repeat the steps and in public function breed you need to make this line have all the other stats:

PHP:
$adopt->makeOwnedAdopt($mysidia->user->getID(), $this->getBabyStrength());

So something like:

PHP:
$adopt->makeOwnedAdopt($mysidia->user->getID(), $this->getBabyStrength(), $this->getBabySpeed(), $this->getBabyStamina());

And also make sure to change:

PHP:
public function makeOwnedAdopt($owner, $strength, $name = NULL)

To also have the new values, like:

PHP:
public function makeOwnedAdopt($owner, $strength, $speed, $stamina, $name = NULL)

And don't forget the insert needs to include the new stats too.

Hopefully that was clear enough haha!
 
The one thing I couldn't figure out was how to make there be a default value per species and still work with breeding. So adding strength to the adopts_adoptables table so you could have a different default strength depending on the adopt... no matter what I tried it would either come out as 0 when the pet was adopted (ignoring the fact that I had 10 set as the default in the DB) OR the adopt default value would work but then the breeding value would always be one of the parents and not a mix.

Someone else might have an idea for how to fix that but for now you'll just have to stick to having a basic default strength for all adopts and have your stats be attained through breeding, and things like items/training...
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,119
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top