Why am I so bad at this???!?!?!?
All was working fine until I changed one thing and now I don't know what that thing was. I tried commenting out several lines of code to no avail. It's somewhere in the index section. I've commented out everything else, so I'mma just post that section.
Here's trainview.php
PHP:
<?php
namespace View\Main;
use Controller\Main;
use Model\DomainModel\Item;
use Model\DomainModel\Member;
use Model\DomainModel\OwnedItem;
use Model\DomainModel\UserProfile;
use Model\DomainModel\User;
use Model\DomainModel\OwnedAdoptable;
use Resource\Core\Registry;
use Resource\Core\View;
use Resource\GUI\Document\Comment;
use Resource\GUI\Component\Image;
use Resource\GUI\Component\Link;
class TrainView extends View {
public function index() {
$mysidia = Registry::get("mysidia");
$document = $this->document;
$required = new OwnedItem(17, $mysidia->user->getID());
$profile = $mysidia->user->getProfile();
$document->setTitle("<img src='https://i.postimg.cc/HnfxQxcw/H200.png'> Training Area <img src='https://i.postimg.cc/HnfxQxcw/H200.png'>");
$document->add(new Comment("Work In Progress. I will post a news update when I get this working.<hr>"));
$document->add(new Comment("<center>Welcome to the Training Grounds. Here, you can train your assigned companion's stats. It costs 30 Gold Pieces to train once.<br>Better stats means better performance in battle, so let's get to work!</center><hr>"));
if($required->inInventory()){
if ($profile->getFavpetID() == 0){
$document->add(new Comment("<center>You don't have an assigned companion. Assign one <a href='https://ashenblade.click/account/profile'>here</a>.</center>"));
} else{
$favpet = new OwnedAdoptable($profile->getFavpetID());
$favorite = new OwnedAdoptable($profile->getFavpet());
$document->add(new Comment("<center>
Your assigned companion is your {$favorite}.<br>
To change it, click <a href='../account/profile'>here</a>.
</center>"));
$document->add(new Comment("To train, select the stat that you would like to work on.<br><br>
<b>{$favpet}'s Stats</b><br>
<table>
<tr><th>Strength</th>
<th>Speed</th>
<th>Stamina</th></tr>
<tr><td>{$favpet->strength}</td>
<td>{$favpet->speed}</td>
<td>{$favpet->stamina}</td>
</table><br><br>
", FALSE));
$document->add(new Link("train/strength", "Train Strength"));
$document->add(new Comment("<br>"));
$document->add(new Link("train/speed", "Train Speed"));
$document->add(new Comment("<br> "));
$document->add(new Link("train/stamina","Train Stamina"));
}
} else{
$document->add(new Comment("You need a training bag to train your critters. Get one in the <a href='https://ashenblade.click/shop/browse/2'>general store</a>."));
}
}
Even ChatGPT can't figure out what's wrong DX
After a LOT of troubleshooting, it turns out it doesn't like defining $favpet or $favorite............ It doesn't seem to mind
$profile->getFavpetID but when I try to define
$favpet or
$favorite with that same function, it goofs up.
Try this:
PHP:
<?php
namespace View\Main;
use Controller\Main;
use Model\DomainModel\Item;
use Model\DomainModel\Member;
use Model\DomainModel\OwnedItem;
use Model\DomainModel\UserProfile;
use Model\DomainModel\User;
use Model\DomainModel\OwnedAdoptable;
use Resource\Core\Registry;
use Resource\Core\View;
use Resource\GUI\Document\Comment;
use Resource\GUI\Component\Image;
use Resource\GUI\Component\Link;
class TrainView extends View{
public function index() {
$mysidia = Registry::get("mysidia");
$document = $this->document;
$required = new OwnedItem(17, $mysidia->user->getID());
$profile = $mysidia->user->getProfile();
$document->setTitle("<img src='https://i.postimg.cc/HnfxQxcw/H200.png'> Training Area <img src='https://i.postimg.cc/HnfxQxcw/H200.png'>");
$document->add(new Comment("Work In Progress. I will post a news update when I get this working.<hr>"));
$document->add(new Comment("<center>Welcome to the Training Grounds. Here, you can train your assigned companion's stats. It costs 30 Gold Pieces to train once.<br>Better stats means better performance in battle, so let's get to work!</center><hr>"));
if($required->inInventory()){
if ($profile->getFavpetID() == 0){
$document->add(new Comment("<center>You don't have an assigned companion. Assign one <a href='https://ashenblade.click/account/profile'>here</a>.</center>"));
}
else{
$favpet = new OwnedAdoptable($profile->getFavpetID());
$document->add(new Comment("<center>
Your assigned companion is your {$favpet->getName()}.<br>
To change it, click <a href='../account/profile'>here</a>.
</center>"));
$document->add(new Comment("To train, select the stat that you would like to work on.<br><br>
<b>{$favpet->getName()}'s Stats</b><br>
<table>
<tr><th>Strength</th>
<th>Speed</th>
<th>Stamina</th></tr>
<tr><td>{$favpet->getStrength()}</td>
<td>{$favpet->getSpeed()}</td>
<td>{$favpet->getStamina()}</td>
</table><br><br>
", FALSE));
$document->add(new Link("train/strength", "Train Strength"));
$document->add(new Comment("<br>"));
$document->add(new Link("train/speed", "Train Speed"));
$document->add(new Comment("<br> "));
$document->add(new Link("train/stamina","Train Stamina"));
}
} else{
$document->add(new Comment("You need a training bag to train your critters. Get one in the <a href='https://ashenblade.click/shop/browse/2'>general store</a>."));
}
}
}
You don't need to assign {$favourite} on this page, before I did it because that was how I displayed the image. Now you only need {$favpet} as you're just calling the information you need.
To call information you use the same functions that are defined in ownedadoptable.php.
So here's a list you could use.
{$favpet} by itself calls the type/species name.
{$favpet->getAdoptID()} gets the ID.
{$favpet->getName()} calls the adopt's name. You cannot just use $favpet->name because name is a protected function in ownedadoptable.php (you can see what's protected, public, or private, at the top of ownedadoptable.php)
{$favpet->getStrength()} calls the strength. We assigned in ownedadoptable.php last time.
I recommend setting speed and stamina the same way in the model, it gets you used to the process and means you can use getSpeed and getStamina whenever you need to.
Technically you can use {$favpet->strength}, etc, and it DOES work because we set strength, speed, etc, as public in ownedadoptable.php. However I still recommend getting used to getStrength() instead because most things tend to be set to protected and it helps you to get used to it lol.
So the process tends to be set something in the model, then you can use it whenever you call that model. In this case
$favpet = new OwnedAdoptable($profile->getFavpetID()); is calling from the ownedadoptable.php file.
Hopefully that helps you!