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.4 Simple NPC Battle (http://www.mysidiaadoptables.com/forum/showthread.php?t=5143)

Abronsyth 07-01-2016 11:38 AM

Simple NPC Battle
 
Simple NPC Battle V.1.0

Hello!

This mod will cover several topics:
-assigning stats to adoptables (and making them inheritable through breeding)
-training adoptables to increase stats
-competing against randomly generated NPCs
-earning trophies from competing

This mod was specifically coded for and tested with Mysidia 1.3.4. While it may be adaptable to other versions of Mysidia it would take quite a bit of tweaking.

Note: the battleview.php code is based on Kyttias's explore code, I have permission from her to use and share it with you all :)

Demo:
http://i.imgur.com/FyN6mnF.gif

P.1: Stats
The code I will provide uses four stats: Sense, Speed, Strength, and Stamina. In this section I will show you how to add these four, but with some tweaking you can honestly use/add any sort of stats you'd like.

The first step is adding these stats to the database. In phpMyAdmin go to the table prefix_owned_adoptables, then go to the structure tab and scroll down to add four columns, naming them sense, speed, strength, and stamina. Type should be varchar and you shouldn't need more than 5. I set the default value as 10. (screenshot)

Once that is done, it's time to make it so that when a user adopts a new pet that pet has random stats. Go into the file adopt.php and find this line:
PHP Code:

$mysidia->db->insert("owned_adoptables"... 

Right above that insert this chunk of code:
PHP Code:

$sense rand(10,100);     
$speed rand(10,100); 
$strength rand(10,100); 
$stamina rand(10,100); 

Now add this to the end of the insert string, make sure it is BEFORE the ending ));, and that there is a comma between the last thing in there and the new stuff. So right after "lastbred" => 0 add a comma, and then add this before the ));
PHP Code:

"sense" => $sense"speed" => $speed"strength" => $strength"stamina" => $stamina 

Now we need to do the same thing in the files class_promocode.php and class_stockadopt.php, just follow the above steps for these two files.

Now breeding is a little bit more tricky since we want bred adoptables to inherit their parent's stats. So go into class_breeding.php and find the insert statement ($mysidia->db->insert("owned_adoptables"...). Right above it add this lovely chunk of code:
PHP Code:

$mother_se =  $this->female->sense;
$father_se =  $this->male->sense;
$mother_sp =  $this->female->speed;
$father_sp =  $this->male->speed;
$mother_str =  $this->female->strength;
$father_str =  $this->male->strength;
$mother_st =  $this->female->stamina;
$father_st =  $this->male->stamina;

$parent_se $mother_se $father_se;
$parent_sp $mother_sp $father_sp;
$parent_str $mother_str $father_str;
$parent_st $mother_st $father_st;

$sense $parent_se 2;     
$speed $parent_sp 2
$strength $parent_str 2
$stamina $parent_st 2

What this does is retrieve all of the parent stats, add each stat together (mother's sense + father's sense, etc), and then finds the average between them. So if the mother has 32 sense and the father has 64, the babies will have 48.
After you add that, add this in just like we did for the other files:
PHP Code:

"sense" => $sense"speed" => $speed"strength" => $strength"stamina" => $stamina 

Cool, now that's it for stats! Our battle page will display the pet's stats anyways, but if you want to display it on the level up pages and such check these threads out:
Restyling the Manage Page
Public Pet Profiles

P.2: Training
This section will cover how to train pets in order to increase stats!

So, we are going to need two files. First create a file called train.php and paste this in it:
PHP Code:

<?php

class TrainController extends AppController{
    
    public function 
__construct(){
        
parent::__construct("member");
    }

    public function 
index(){
        
$mysidia Registry::get("mysidia");        
    }

}
?>

That goes in your root folder and it is good to go. Close it and make a new file, this one called trainview.php. Now copy and paste this code into it:
PHP Code:

<?php
class TrainView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document
        
$document->setTitle("Stat Training");
                    
$document->add(new Comment("Welcome to the Gym. People from all across the land come here to train their pets and prep them for battle.<br>
                    <center><b>Each training session costs 30 CURRENCY.</b></center><br><br>
                    To train your pet it must be an adult, and it must be set as your assigned companion."
FALSE)); 
        
$profile $mysidia->user->getprofile();
        
$mysidia->user->getprofile(); 
        if ((int)
$profile->getFavpetID() == 0) { 
            
$document->addLangVar('<br><br>It seems you do not yet have not assigned a companion! Assign one and then come back.'); 
        return; 
        } 
        
$favpet = new OwnedAdoptable($profile->getFavpetID());    
        
        if (
$favpet->currentlevel 3){ 
            
$document->add(new Comment("<br><br>Woah, sorry there! Your pet isn't old enough to train, yet! Come back with an adult if you want to train!"FALSE)); 
      return; 
        } 
        if(
$favpet->currentlevel 3){
            
$document->add(new Comment("To train, select the stat that you would like to work on.<br><br>
                    <center><b>
{$favpet->name}'s Stats</b><br>
                    <u>Se | Sp | Str | Stm</u><br>
                    
{$favpet->sense} | {$favpet->speed} | {$favpet->strength} | {$favpet->stamina}<br>"FALSE));
            
$this->exploreButton("Train_Sense"FALSE"Train Sense");
            
$this->exploreButton("Train_Speed"FALSE"Train Speed");
            
$this->exploreButton("Train_Strength"FALSE"Train Strength");
            
$this->exploreButton("Train_Stamina"FALSE"Train Stamina");
        } 
# END no area selected

        /* If an area is selected: */
        
if($mysidia->input->post("area")){
            
            
$area $mysidia->input->post("area"); // This has apostrophes as *s instead, just like the exploreButtons above!
            
$str str_replace("_"" "$area);
            
$areaname str_replace("*""'"$str); // This one has apostrophes instead of asterisks.

            
$document->setTitle("{$areaname}");
                
$increase rand(1,5);
                
$sense $favpet->sense;
                
$newsense $sense $increase;
                
$speed $favpet->speed;
                
$newspeed $speed $increase;
                
$strength $favpet->strength;
                
$newstrength $strength $increase;
                
$stamina $favpet->stamina;
                
$newstamina $stamina $increase;
        
            switch (
$area){
                
# First one is the default response that will happen unless something specific is specified:
                
case $areaname$document->add(new Comment("<br><br>Oops, something has gone wrong."FALSE));
                break;

                
                case 
"Train_Sense"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the Sense training.<br><br>
                        
{$favpet->name} gained {$increase} Sense from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("sense" => $newsense), "aid='{$profile->getFavpetID()}'");
                break;
                case 
"Train_Speed"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the Speed training.<br><br>
                        
{$favpet->name} gained {$increase} Speed from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("speed" => $newspeed), "aid='{$profile->getFavpetID()}'");
                break;
                case 
"Train_Strength"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the Strength training.<br><br>
                        
{$favpet->name} gained {$increase} Strength from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("strength" => $newstrength), "aid='{$profile->getFavpetID()}'");
                break;
                case 
"Train_Stamina"
                    
$currentcash $mysidia->user->money;
                    
$newmoney $currentcash 30;
                        
$document->add(new Comment("<br><b>The Session:</b><br> Write something here about the training.<br><br>
                        
{$favpet->name} gained {$increase} Stamina from this session!"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("stamina" => $newstamina), "aid='{$profile->getFavpetID()}'");
                break;

            }

            return;
        }
    }

    public function 
exploreButton($areaname$image_link ""$customtext ""$customimg ""){
        
$document $this->document;
        
        if (
$image_link){ /* Image Links */
            
             
if (!$customimg){ /* Area Logo Image */
                 
$imgname str_replace("*""'"$areaname);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='train' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}_logo.png\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
             
             else { 
/* Custom Link Image */
                 
$imgname str_replace("*""'"$customimg);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='train' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
        } 
        
        else { 
/* Text-Only Links */
            
            
if (!$customtext){ /* Area Name Button */
                
$str str_replace("_"" "$areaname); $btn_name str_replace("*""'"$str);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' value='train' name='{$areaname}' type='submit'>
                    
{$btn_name}
                    </button>
                    </form>
                "
FALSE));
            } 
            
            else { 
/* Custom Link Text */
                
$customtext str_replace("*""'"$customtext);
                
$document->add(new Comment("
                    <form id='exploreform' action='train' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' style='display: inline;' value='train' name='{$areaname}' type='submit'>
                    
{$customtext}
                    </button>
                    </form>
                "
FALSE));
            }
        }
        return;
    }
}    
?>

First, customize the currency name around line 9 where it just says CURRENCY. Also change the price so that it reflects whatever you want to charge for each training session.

Then, to change the charge, scroll to where you see the line
PHP Code:

$newmoney $currentcash 30

and just change 30 to whatever the cost should be.

Each type of training has a section for you to write about the training session or add images, etc. Just fill it in to your pleasing!

P.3: Battle
This is the major focus of this mod! Creating a page that allows the user's fave pet to battle!

This requires two new files:
battle.php
This goes in the root folder where the files like adopt.php and account.php are.
PHP Code:

<?php

class BattleController extends AppController{
    
    public function 
__construct(){
        
parent::__construct("member");
    }

    public function 
index(){
        
$mysidia Registry::get("mysidia");        
    }

}
?>

battleview.php
This goes in the view folder.
PHP Code:

<?php
/* This is the Battle Mod view page. This page is created based on the explore script created by Kyttias, so credit for the base of that goes to her. The ability to select and use the favepet was from RestlessThoughts, as posted on this thread; http://mysidiaadoptables.com/forum/showthread.php?t=4827&page=3
*This mod is entirely a collection of what Abronsyth has learned from messing around with mods created by wonderful users such as the two mentioned above.
 */
class BattleView extends View{
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document
        
$document->setTitle("Battle");
                    
$document->add(new Comment("<br>"FALSE)); 
        
$profile $mysidia->user->getprofile();
        
$mysidia->user->getprofile(); 
        if ((int)
$profile->getFavpetID() == 0) { 
            
$document->addLangVar('<br><br>It seems you do not yet have not assigned a companion! Assign one and then come back.'); 
        return; 
        } 
        
$favpet = new OwnedAdoptable($profile->getFavpetID());    
        
        if (
$favpet->currentlevel 3){ 
            
$document->add(new Comment("<br><br>Woah, sorry there! Your companion isn't old enough to battle, yet! Come back with an adult companion if you want to compete!"FALSE)); 
      return; 
        } 
        if(
$favpet->currentlevel 3){
 
/*Random Opponent Stats*/
        
$opsense rand(1,100);
        
$opstamina rand(1,100);
        
$opstrength rand(1,100);
        
$opspeed rand(1,100);
    
/*Below determines how many trophies the pet earns by winning a batttle.*/
        
$trophies $favpet->trophies;
        
$newtrophy $trophies 1;
            
$document->add(new Comment("You enter the battle arena with {$favpet->name} at your side. Waiting at the opposite end of the arena is your opponent!<br>
            To engage in battle, select an attack from below. If you would not like to battle, you may simply leave this page.<br>"
FALSE));
            
$this->exploreButton("Use_Bite"FALSE"Bite");
            
$this->exploreButton("Use_Tackle"FALSE"Tackle");
            
$this->exploreButton("Use_Trick"FALSE"Trick");
        } 
        if(
$mysidia->input->post("area")){
            
            
$area $mysidia->input->post("area");

            
$document->setTitle("Battle");
        
            switch (
$area){
                case 
"Use_Bite"
                    
$opbite $opspeed $opstrength;
                    
$bite $favpet->speed $favpet->strength;
                    
$prize rand(25,50);
                    
$currentcash $mysidia->user->money;
                    
$newmoney $prize $currentcash;
                    if(
$bite $opbite){
                        
$document->add(new Comment("<br><br><table align='center' border='0px'>
                <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet dives in and attacks your opponent with a bite dealing 
{$bite} damage.
                        <br>The opponent counters the attack with 
{$opbite} damage, but it isn't enough!<br>
                        Your pet has won, and brought you 
{$prize} currency! Furthermore, {$favpet->name} has won a trophy!</center><br><br>"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("trophies" => $newtrophy), "aid='{$profile->getFavpetID()}'");
                    }
                    else{
                        
$document->add(new Comment("<br><br><table align='center' border='0px'>
                <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet dives in and attacks your opponent with a bite dealing 
{$bite} damage.
                        <br>The opponent counters the attack with 
{$opbite} damage, and manages to over power {$favpet->name}!<br>
                        Unfortunately your pet lost...better luck next time!</center><br><br>"
FALSE));
                    }
                break;
                case 
"Use_Tackle"
                    
$optackle $opstrength $opstamina;
                    
$tackle $favpet->strength $favpet->stamina;
                    
$prize rand(25,50);
                    
$currentcash $mysidia->user->money;
                    
$newmoney $prize $currentcash;
                    if(
$tackle $optackle){
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet launches forward and slams into the opponent, dealing 
{$tackle} damage!
                        <br>The opponent counters the attack with 
{$optackle} damage, but it isn't enough!<br>
                        Your pet has won, and brought you 
{$prize} currency! Furthermore, {$favpet->name} has won a trophy!</center><br><br>"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("trophies" => $newtrophy), "aid='{$profile->getFavpetID()}'");
                    }
                    else{
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet launches forward and slams into the opponent, dealing 
{$tackle} damage!
                        <br>The opponent counters the attack with 
{$opbite} damage, and manages to over power {$favpet->name}!<br>
                        Unfortunately your pet lost...better luck next time!</center><br><br>"
FALSE));
                    }
                break;
                case 
"Use_Trick"
                    
$optrick $opsense $opspeed;
                    
$trick $favpet->sense $favpet->speed;
                    
$prize rand(25,50);
                    
$currentcash $mysidia->user->money;
                    
$newmoney $prize $currentcash;
                    if(
$trick $optrick){
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet taunts the opponent and dashes out of the way at the last minute, tricking the opponent into running at the wall, dealing 
{$trick} damage!
                        <br>The opponent counters the attack with 
{$optrick} damage, but it isn't enough!<br>
                        Your pet has won, and brought you 
{$prize} currency! Furthermore, {$favpet->name} has won a trophy!</center><br><br>"FALSE));
                        
$mysidia->db->update("users", array("money" => $newmoney), "username='{$mysidia->user->username}'");
                        
$mysidia->db->update("owned_adoptables", array("trophies" => $newtrophy), "aid='{$profile->getFavpetID()}'");
                    }
                    else{
                        
$document->add(new Comment("<br><br>
                        <table align='center' border='0px'>
                    <tr>
                    <td width='40%' style='text-align:left;vertical-align:bottom;'>
                    <i>
{$favpet->name}</i><br>
                    <b>Sense:</b> 
{$favpet->sense}<br>
                    <b>Speed:</b> 
{$favpet->speed}<br>
                    <b>Strength:</b> 
{$favpet->strength}<br>
                    <b>Stamina:</b> 
{$favpet->stamina}<br>
                    </td>
                    <td width='20%'>
                    <center><b>VS</b></center>
                    </td>
                    <td width='40%' style='text-align:right;vertical-align:bottom'>
                    <i>Opponent</i><br>
                    <b>Sense:</b> 
{$opsense}<br>
                    <b>Speed:</b> 
{$opspeed}<br>
                    <b>Strength:</b> 
{$opstrength}<br>
                    <b>Stamina:</b> 
{$opstamina}<br>
                    </td>
                </tr>
            </table><br><center>Your pet taunts the opponent and dashes out of the way at the last minute, tricking the opponent into running at the wall, dealing 
{$trick} damage!
                        <br>The opponent counters the attack with 
{$optrick} damage, and manages to over power {$favpet->name}!<br>
                        Unfortunately your pet lost...better luck next time!</center><br><br>"
FALSE));
                    }
                break;
            }

            return;
        }
    }

    public function 
exploreButton($areaname$image_link ""$customtext ""$customimg ""){
        
$document $this->document;
        
        if (
$image_link){ /* Image Links */
            
             
if (!$customimg){ /* Area Logo Image */
                 
$imgname str_replace("*""'"$areaname);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='battle' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}_logo.png\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
             
             else { 
/* Custom Link Image */
                 
$imgname str_replace("*""'"$customimg);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-text btn-sm' value='battle' name='{$areaname}' type='submit'>
                    <img src=\"./images/
{$imgname}\"/>
                    </button>
                    </form>
                "
FALSE)); 
             }
        } 
        
        else { 
/* Text-Only Links */
            
            
if (!$customtext){ /* Area Name Button */
                
$str str_replace("_"" "$areaname); $btn_name str_replace("*""'"$str);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' value='battle' name='{$areaname}' type='submit'>
                    
{$btn_name}
                    </button>
                    </form>
                "
FALSE));
            } 
            
            else { 
/* Custom Link Text */
                
$customtext str_replace("*""'"$customtext);
                
$document->add(new Comment("
                    <form id='exploreform' action='battle' name='exploreform' method='post' role='form'>
                    <input id='area' name='area' type='hidden' value='
{$areaname}'>
                    <button id='
{$areaname}' class='btn-violet btn-sm' style='display: inline;' value='battle' name='{$areaname}' type='submit'>
                    
{$customtext}
                    </button>
                    </form>
                "
FALSE));
            }
        }
        return;
    }
}    
?>

Note lines 20 and 24:
PHP Code:

if ($favpet->currentlevel 3

PHP Code:

if($favpet->currentlevel 3

These make it so that if the user's assigned fave pet must be level 3 in order to battle. Change this number to whichever suits your needs (and remember the levels start at 0 for the egg).

Also note lines 49, 108, and 169:
PHP Code:

    $prize rand(25,50); 

This determines how much the user will be awarded each time their pet wins. The first number (25) is the minimum amount, and the second number (50) is the maximum amount.

There are many places in the code where you can alter and customize the text to your liking. For example, each attack uses two different stats, combines them to get a total, and uses that total against a similar total for the opponent.

Ask about it if you have questions!

Continue reading below for a guide on adding a simply trophy system!

Abronsyth 07-01-2016 11:39 AM

P.4: Trophies
Alright, finally ready for this!
Trophies are just another little extra thing that gives users more reason to engage in the battle system. I add extra incentive by rearranging my stats page to display based on number of trophies instead of clicks.

The battle code up above is already set up to add trophies, so no need to worry about that. We do have to set up the database, though.

Database
Go into phpMyAdmin, prefix_ownedadoptables, and add one new row with the following data:
Name Type Collation Null Default
trophies varchar(10) latin1_swedish_ci No 0

Displaying
Good job! Now in a file where you want to display the number of trophies (such as on the myadopts page, etc), you just need to include this to call it:
PHP Code:

$trophies $mysidia->db->select("owned_adoptables", array("trophies"), "aid = '{$adopt->getAdoptID()}'")->fetchColumn(); 

and this to display it:
PHP Code:

{$trophies

Stats Page
If you want to use the stats page to show adopts based on trophies instead of clicks there is just a minor adjustment to make.

Go to stats.php and change the FIRST line starting with "$stmt = " and replace that line with this:
PHP Code:

$stmt $mysidia->db->select("owned_adoptables", array("aid"), "1 ORDER BY trophies DESC LIMIT 10"); 

Now go into view/statsview.php...we have some things here to change so it actually displays the trophies.

Where you see the line $table->buildHeaders...replace it with this:
PHP Code:

$table->buildHeaders("Image""Name""Owner""Total Clicks""Trophies"); 

Now, scroll down to find this line:
PHP Code:

$cells->add(new String($adopt->getTotalClicks())); 

And add this right under it:
PHP Code:

$cells->add(new TCell($adopt->getTrophies())); 

That's it! You might also want to change the lang_stats.php file so that it reflects the changes.

P.5: Extras
You can add extra depth to this by creating other stats, such as health, battle skill, etc! Check out Dinocanid's health and mood mod, which could pair with this very nicely!
http://mysidiaadoptables.com/forum/s...ead.php?t=5263

Missy Master 07-18-2016 03:08 PM

Surprised no one commented to this!

Thank you for making this, I'm going to try it on one or more of my sites!! This looks pretty fantastic!!

Missy Master 07-29-2016 03:28 PM

Before I had a favpet selected, it came up ok and asked me to go choose a Companion -- I manually input the number of one of my pets in the appropriate section in the database (for the life of me I cannot remember how to just go choose one!) -- and got a white page!

This seems to be my time to get white pages haha. Got one on this and for every try at a public pet profile page so far ...



edit: Did find where to choose him in my account page, but still white page now for battle

Missy Master 07-30-2016 10:54 PM

Is anyone else using this or getting a white page from it ?

I'm two days from launching and I am considering not trying to use this, though it looks so fun ...

Hwona 08-01-2016 02:29 AM

This looks amazing! :D

NobodysHero 08-01-2016 08:03 PM

I'm stoked for this! Can't wait to use it! Thanks, Abronsyth!

Abronsyth 08-03-2016 12:14 PM

Missy Master, try doing it through the user CP instead? Go to /account/profile, and then select your pet from the drop down there. Then get back to me and let me know if it persists!

Missy Master 08-03-2016 09:10 PM

Still not working :(

If I remove the fav pet from the database, the page loads .. but once that id is in there, nope!



'It seems you do not yet have not assigned a companion! Assign one and then come back. ' With no fav pet assigned. With one, white page!

NobodysHero 09-01-2016 10:26 PM

Thought I would add in something here, maybe shed a little more light on the issue.

I'm seeing the same problem Missy did.

My error log is showing:
PHP Code:

[01-Sep-2016 22:15:11 America/ChicagoPHP Fatal error:  Uncaught exception 'Exception' with message 'Fatal Error: Class Owned_Adoptable either does not exist, or has its include path misconfigured!' in /home/mystfell/public_html/classes/class_loader.php:83
Stack trace
:
#0 [internal function]: Loader->load('Owned_Adoptable')
#1 /home/mystfell/public_html/view/battleview.php(18): spl_autoload_call('Owned_Adoptable')
#2 /home/mystfell/public_html/classes/class_frontcontroller.php(100): battleView->index()
#3 /home/mystfell/public_html/index.php(74): FrontController->render()
#4 /home/mystfell/public_html/index.php(78): IndexController::main()
#5 {main}
  
thrown in /home/mystfell/public_html/classes/class_loader.php on line 83
[01-Sep-2016 22:16:22 America/ChicagoPHP Notice:  Undefined variablecontroller in /home/mystfell/public_html/classes/class_language.php on line 111
[01-Sep-2016 22:16:22 America/ChicagoPHP Fatal error:  Cannot access protected property OwnedAdoptable::$currentlevel in /home/mystfell/public_html/view/battleview.php on line 20 


NobodysHero 09-13-2016 11:21 AM

Good news is, I partly found the answer to my question. For whatever reason, it can't pull from "currentlevel". Changing it to "AdoptLevel", "Level", and "CurrentLevel" allows the page to load, but doesn't allow me to battle, nor does it show my "favpet", insisting that my pet isn't level 1 or higher.

Looking at the error log after each save, seems like it keeps bumping on how to call the level of the pet. x.x So, now what?

Dinocanid 09-17-2016 09:38 AM

I can't get this to work either. I can get to the page just fine, but it keeps insisting that my favpet isn't level 3.

Abronsyth 09-20-2016 07:58 PM

Quote:

Originally Posted by NobodysHero (Post 34918)
Good news is, I partly found the answer to my question. For whatever reason, it can't pull from "currentlevel". Changing it to "AdoptLevel", "Level", and "CurrentLevel" allows the page to load, but doesn't allow me to battle, nor does it show my "favpet", insisting that my pet isn't level 1 or higher.

Looking at the error log after each save, seems like it keeps bumping on how to call the level of the pet. x.x So, now what?


I responded via PM but I'll paste this here for other's sakes:
Try going into class_ownedadoptable.php and changing the line here:
PHP Code:

    protected $currentlevel

to this:
PHP Code:

    public $currentlevel

Save, upload, and let me know if that fixes your issue :)

Everyone having the issue please make sure this has been done and then, once done, get back to me on it.

NobodysHero 09-21-2016 12:15 AM

THANK YOU! <3 Okay, so it didn't like that both the "currentlevel" and "name" were protected, instead of public. Changing that made it work for me!

NobodysHero 09-23-2016 05:53 PM

Now that I have this working, I'd like to add some graphics and such to make it more fun to look at and give their opponent a "face". So, my question here is, how would I go about perhaps using random images above the "random opponent side? I know how to post the image of the pet, but a random image code would be awesome. 8D Would be neat to also use this to make it seem like the "battleground" as changed. Just a thought!

Abronsyth 09-25-2016 12:32 PM

Oh yeah, that is totally doable! I actually originally had it set up that way but was having issues with aligning it in a way that looked really good...but the random opponent image isn't too difficult. You just need the images...so, where you add opponent stats add in this:
PHP Code:

$images rand(1,3); 

Change the 3 to suit whatever number of images you want possible. Then, below the stats add this:
PHP Code:

if($images 1) {
$opimage "<img src='IMAGE URL'/>";
}
elseif(
$images 2) {
$opimage "<img src='IMAGE URL'/>";
}
elseif(
$images 3) {
$opimage "<img src='IMAGE URL'/>";


Where it says IMAGE URL just change it to the image's url for the different opponent images. Then where you display the opponent's stats just add in {$opimage}. So, for example:
PHP Code:

<td width='40%' style='text-align:right;vertical-align:bottom'
{
$opimage}<br>                    
<
i>Opponent</i><br
                    <
b>Sense:</b> {$opsense}<br
                    <
b>Speed:</b> {$opspeed}<br
                    <
b>Strength:</b> {$opstrength}<br
                    <
b>Stamina:</b> {$opstamina}<br
                    </
td


Now I will note that I just wrote this without testing it at all, so I don't guarantee it'll work as is, but it should give you the general idea!

Abronsyth 10-13-2016 02:17 PM

Hey all! I updated the main post so that it now includes the training section! My method of training is very lazy at the moment, just spend some money, click a button, raise the stats.

I hope you all enjoy it <3

Abronsyth 11-26-2016 08:29 AM

Finally updated!

Now includes a Trophies section, and a little extras section :)

Ittermat 12-09-2016 09:33 PM

couple questions- I tried adding in the OP image coding but it keeps giving me errors... WHERE exactly do I put those? CAn you explain a little better please?

Also the trophies- where exactly and on which file do I put the calling code?

As well as How would I get my fave pets image for battling as well? {$Favepet} does not seem to work lol (And how would I flip the images so they're actually facing each other?)

EDIT: one more question- how would I make it so that they actually recieve items for winning? whether random or not so random lol...

(Apologies as I am a super noob at this)

Abronsyth 12-10-2016 08:10 AM

1. In the battleview.php file find this:
PHP Code:

 /*Random Opponent Stats*/ 
        
$opsense rand(1,100); 
        
$opstamina rand(1,100); 
        
$opstrength rand(1,100); 
        
$opspeed rand(1,100); 

Insert the image code right below that, so it looks like this:
PHP Code:

 /*Random Opponent Stats*/ 
$opsense rand(1,100); 
$opstamina rand(1,100); 
$opstrength rand(1,100); 
$opspeed rand(1,100); 
$images rand(1,3);  
if(
$images 1) {
$opimage "<img src='IMAGE URL'/>";
}
elseif(
$images 2) {
$opimage "<img src='IMAGE URL'/>";
}
elseif(
$images 3) {
$opimage "<img src='IMAGE URL'/>";


The image url needs to start with http:// and end in .jpg, .jpeg, .png, or .gif

2. You put the calling code wherever you want to display the trophies. So if you want to display it for the owner of a pet when they go to manage it, you can go to myadoptsview.php and add it within the manage function. This works best if you already have "profiles" set up. But for a quick example, here is the manage function with it added in:
PHP Code:

    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 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)); 
    } 

3. The base code for displaying it is this:
PHP Code:

<img src='{$favpet->getImage()}'/> 

But you also need to include this information to make it callable:
PHP Code:

$profile $mysidia->user->getprofile();
$favpet = new OwnedAdoptable($profile->getFavpetID()); 

As for flipping, not sure, I googled it and apparently this works (I have not tested it):
PHP Code:

$opimage "<img src='IMAGE URL' style='-moz-transform: scale(-1, 1);-webkit-transform: scale(-1, 1);-o-transform: scale(-1, 1);transform: scale(-1, 1);filter: FlipH;' />"

4. To directly insert an item into a user's inventory you use this string:
PHP Code:

$item "ItemName"

PHP Code:

$newitem = new StockItem($item);  
$newitem->append(1$mysidia->user->username); 


Ittermat 12-14-2016 01:45 AM

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 Code:

<?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 != 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"$forumcode450);
        
$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 Code:

<?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

Abronsyth 12-14-2016 09:35 AM

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 Code:

    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 Code:

<?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!

Ittermat 12-14-2016 10:24 AM

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 ^^

Abronsyth 12-14-2016 03:29 PM

Did you put it into myadoptsview.php or myadopts.php?

Ittermat 12-14-2016 03:33 PM

in myadoptsview

Abronsyth 12-14-2016 07:16 PM

Alright, try changing the manage function in myadoptsview.php to this:
PHP Code:

   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));  
         
    } 


Ittermat 12-14-2016 07:34 PM

That worked thanks!

Abronsyth 12-15-2016 08:08 AM

Great! Let me know if you have other problems.

Corsair 12-15-2016 07:10 PM

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.

lotus 12-16-2016 03:20 PM

@Corsair
Try adding this to see if it'll help (make sure to define $traincost):
PHP Code:

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 Code:

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 Code:

$randgain rand(1,20);
$favpet->changestat(strength$randgain); 


Silver_Brick 02-04-2017 09:28 AM

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

Abronsyth 02-04-2017 12:20 PM

Quote:

Originally Posted by Corsair (Post 35432)
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.

Quote:

Originally Posted by lotus (Post 35433)
@Corsair
Try adding this to see if it'll help (make sure to define $traincost):
PHP Code:

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 :)

Silver_Brick 02-13-2017 09:54 AM

ok :smile: and would you like to work with me an make a battling system where two user can battle online ??

Abronsyth 02-13-2017 02:20 PM

Sorry, that is quite beyond my capabilities!

Fox 05-24-2017 07:21 PM

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?

Abronsyth 06-17-2017 10:24 AM

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...
http://orig01.deviantart.net/862c/f/...re-dbd0s8e.jpg

Add this under the list of defined variables for training:
PHP Code:

$trained $favpet->timestrained
$total $trained 1

And then at the end of each training type (before the break;):
PHP Code:

$mysidia->db->update("owned_adoptables", array("timestrained" => $total), "aid='{$profile->getFavpetID()}'"); 

Before the if($favpet->currentlevel = 3) add this;
PHP Code:

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!

Missy Master 07-19-2020 08:26 PM

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!


All times are GMT -5. The time now is 01:35 AM.

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