Kyttias |
04-17-2015 10:39 AM |
Alright, let's just not display any pets here at all if the user has too many eggs, then? It'd just be teasing them, anyway.
Here's the whole document now:
PHP Code:
<?php
class AdoptView extends View{
public function index(){
$mysidia = Registry::get("mysidia");
$document = $this->document;
$number = 5; /* You want users to have no more than THIS ($number) many pets with...*/
$level = 6; /* ...a level less than or equal to THIS ($level) number! */
$petsAtLevel = $mysidia->db->select("owned_adoptables", array(), "owner = '{$mysidia->user->username}' AND currentlevel <= $level")->rowCount();
if ($petsAtLevel > $number){ /* If the number of pets at this level is greater than number... */
$document->setTitle("Too Many Eggs!");
$document->add(new Comment("You've got too many eggs and should wait until you've hatched one.", FALSE));
}
else { /* Else show existing things... */
if($mysidia->input->post("submit")){
$aid = $this->getField("aid")->getValue();
$name = $this->getField("name")->getValue();
$eggImage = $this->getField("eggImage")->getValue();
$image = new Image($eggImage);
$image->setLineBreak(TRUE);
$document->setTitle("{$name} adopted successfully");
$document->add($image);
$document->addLangvar("Congratulations! You just adopted {$name}. You can now manage {$name} on the ");
$document->add(new Link("myadopts", "Myadopts Page."));
$document->add(new Comment(""));
$document->add(new Link("myadopts/manage/{$aid}", "Click Here to Manage {$name}"));
$document->add(new Comment(""));
$document->add(new Link("myadopts/bbcode/{$aid}", "Click Here to get BBCodes/HTML Codes for {$name}"));
$document->add(new Comment(""));
$document->addLangvar("Be sure and");
$document->add(new Link("levelup/{$aid}", "feed "));
$document->addLangvar("{$name} with clicks so that they grow!");
return;
}
$document->setTitle($mysidia->lang->title);
$document->addLangvar((!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member);
$adoptForm = new Form("form", "adopt", "post");
$adoptTitle = new Comment("Available Adoptables");
$adoptTitle->setHeading(3);
$adoptForm->add($adoptTitle);
$adoptTable = new Table("table", "", FALSE);
$adopts = $this->getField("adopts");
for($i = 0; $i < $adopts->length(); $i++){
$row = new TRow;
$idCell = new TCell(new RadioButton("", "id", $adopts[$i]->getID()));
$imageCell = new TCell(new Image($adopts[$i]->getEggImage(), $adopts[$i]->getType()));
$imageCell->setAlign(new Align("center"));
$type = new Comment($adopts[$i]->getType());
$type->setBold();
$description = new Comment($adopts[$i]->getDescription(), FALSE);
$typeCell = new TCell;
$typeCell->add($type);
$typeCell->add($description);
$row->add($idCell);
$row->add($imageCell);
$row->add($typeCell);
$adoptTable->add($row);
}
$adoptForm->add($adoptTable);
$adoptSubtitle = new Comment("Adopt");
$adoptSubtitle->setHeading(3);
$adoptForm->add($adoptSubtitle);
$adoptForm->add(new Comment("Adoptable Name: ", FALSE));
$adoptForm->add(new TextField("name"));
$adoptForm->add(new Comment(""));
$adoptForm->add(new Button("Adopt Me", "submit", "submit"));
$document->add($adoptForm);
}
}
}
?>
@draugluin - As for the adopt shop, it's not a feature I'm making use of on my site so I wouldn't know how to make modifications there without creating one... If this is a feature to prevent new players from hoarding pets without patience, it's unlikely these new players will have enough funds to even purchase more eggs from a shop. And if they have money, why not let them, anyway? If you still really want this, classes/class_adoptshop.php, the display() function can be changed:
PHP Code:
public function display(){
$mysidia = Registry::get("mysidia");
$document = $mysidia->frame->getDocument();
$document->addLangvar($mysidia->lang->select_adopt);
if($this->gettotal() == 0){
$document->addLangvar($mysidia->lang->empty);
return;
}
$number = 5; /* You want users to have no more than THIS ($number) many pets with...*/
$level = 6; /* ...a level less than or equal to THIS ($level) number! */
$petsAtLevel = $mysidia->db->select("owned_adoptables", array(), "owner = '{$mysidia->user->username}' AND currentlevel <= $level")->rowCount();
if ($petsAtLevel > $number){ /* If the number of pets at this level is greater than number... */
$document->setTitle("Too Many Eggs!");
$document->add(new Comment("You've got too many eggs and should wait until you've hatched one.", FALSE));
}
else { /* Else show existing things... */
$adoptList = new TableBuilder("shop");
$adoptList->setAlign(new Align("center", "middle"));
$adoptList->buildHeaders("Image", "Class", "Type", "Description", "Price", "Buy");
$adoptList->setHelper(new ShopTableHelper);
$this->adopts = $this->getadopttypes();
foreach($this->adopts as $stockadopt){
$adopt = $this->getadopt($stockadopt->type);
$cells = new LinkedList;
$cells->add(new TCell($this->getadoptimage($adopt->eggimage)));
$cells->add(new TCell($adopt->class));
$cells->add(new TCell($adopt->type));
$cells->add(new TCell($adopt->description));
$cells->add(new TCell($adopt->cost));
$cells->add(new TCell($adoptList->getHelper()->getAdoptPurchaseForm($this, $adopt)));
$adoptList->buildRow($cells);
}
$document->add($adoptList);
}
}
Try that and let me know how it's working? :ooo:
|