View Single Post
  #32  
Old 02-15-2016, 12:01 PM
Corsair's Avatar
Corsair Corsair is offline
Member
 
Join Date: Jan 2012
Posts: 128
Gender: Female
Credits: 12,041
Corsair is on a distinguished road
Exclamation

Thanks for being so penitent. I am still trying to get a handle on this php thing.

http://monstari.mysidiahost.com/index
PHP Code:
<?php

use Resource\Collection\LinkedList;

class 
InventoryView extends View{
    
     public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
$document->setTitle($mysidia->lang->inventory);
        
$document->addLangvar("You may manage these items as you like, or go to the alchemy page to make your own items: <br>");    
        
$document->add(new Link("inventory/alchemy""Go to Alchemy Laboratory!"));    
        
$document->add(new Comment("<br><br>")); 
        
        
$inventory $this->getField("inventory");
        
        
        
$iids $inventory->getiids();
        for(
$i 0$i $iids->length(); $i++){
            
$item $inventory->getitem($iids[$i]);
                 
            
# Descriptions of the item functions
            
switch ($item->function) {
                case 
"Click1"$usage "<br/><b>use:</b> Feed a pet to give them {$item->value} EXP."; break;
                case 
"Click2"$usage "<br/><b>use:</b> Feed a pet to set their EXP to {$item->value}."; break;
                case 
"Click3"$usage "<br/><b>use:</b> Resets EXP earned today to 0."; break;
                case 
"Level1"$usage "<br/><b>use:</b> Raises the Level of your pet by {$item->value}."; break;
                case 
"Level2"$usage "<br/><b>use:</b> Sets the Level of your pet to {$item->value}."; break;
                case 
"Level3"$usage "<br/><b>use:</b> Makes your pet Level 0 again!"; break;
                case 
"Gender"$usage "<br/><b>use:</b> Swaps the gender of your pet to its opposite!"; break;            
                default;
                    
$usage ""; break;
            }  
# End item function descriptions        

            
            # Rendering items now
            
$document->add(new Comment("
            <div class=\"s_panel sc_item\">
            <img rel=\"tooltip\" title=\"
{$item->description} <em>{$usage}</em>\" src=\"{$item->imageurl}\"/><br/>
              <b>
{$item->itemname}</b><br> Own &times;{$item->quantity}<br/>"FALSE));

            
# If item is consumable, add use button
            
if($item->consumable == "yes") {
                
$useForm = new FormBuilder("useform""inventory/uses""post");
                
$useForm->setLineBreak(FALSE);
                
$useForm->buildPasswordField("hidden""action""uses")
                        ->
buildPasswordField("hidden""itemname"$item->itemname)
                        ->
buildButton("Use""use""use");
                
$document->add($useForm);
            }

           
# Add sellback button so long as the item is not a key item
            
$sellback $item->price 2;
            
$document->add(new Comment("<hr>{$sellback} {$mysidia->settings->cost} Each "FALSE));
            if(
$item->function != "Key") {
                
$sellForm = new FormBuilder("sellform""inventory/sell""post");
                
$sellForm->setLineBreak(FALSE);
                
$sellForm->buildPasswordField("hidden""action""sell")
                         ->
buildPasswordField("hidden""itemname"$item->itemname);
                
                
$quantity = new TextField("quantity");
                
$quantity->setSize(3);
                
$quantity->setMaxLength(3);
                
$quantity->setLineBreak(FALSE);

                
$sell = new Button("Sell""sell""sell");
                
$sell->setLineBreak(FALSE);

                
$sellForm->add($quantity);
                
$sellForm->add($sell);
            }    
            
$document->add($sellForm);
            
$document->add(new Comment("</div>"FALSE));   

        } 
# END item for loop

    
# END index function  
            
    
public function uses(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;    
        if(
$mysidia->input->post("aid")){
            
$message = (string)$this->getField("message");
            
$document->setTitle($mysidia->lang->global_action_complete);
            
$document->addLangvar($message);
            return;        
        }
        
        
$petMap $this->getField("petMap");
        
$document->setTitle($mysidia->lang->select_title);
        
$document->addLangvar($mysidia->lang->select);        
        
$chooseFrom = new Form("chooseform""uses""post");
        
        
$adoptable = new DropdownList("aid");
        
$adoptable->add(new Option("None Selected""none"));
        if(
$petMap->size() > 0){
            
$iterator $petMap->iterator();
            while(
$iterator->hasNext()){
                
$adopt $iterator->nextEntry();
                
$adoptable->add(new Option($adopt->getValue(), $adopt->getKey()));
            }
        }        
        
$chooseFrom->add($adoptable);
        
        
$chooseFrom->add(new PasswordField("hidden""itemname"$mysidia->input->post("itemname")));
        
$chooseFrom->add(new PasswordField("hidden""validation""valid"));
        
$chooseFrom->add(new Button("Choose this Adopt""submit""submit"));
        
$document->add($chooseFrom);
    }
    
    public function 
sell(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
$document->setTitle($this->lang->global_transaction_complete);
        
$document->addLangvar("{$this->lang->sell}{$mysidia->input->post("quantity")} {$mysidia->input->post("itemname")} {$this->lang->sell2}");
    }
    
    public function 
toss(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        if(
$mysidia->input->get("confirm")){
            
$document->setTitle($this->lang->global_action_complete);
            
$document->addLangvar("{$this->lang->toss}{$mysidia->input->post("itemname")}{$this->lang->toss2}");
            return;
        }
    
        
$document->setTitle($this->lang->toss_confirm);
        
$document->addLangvar($this->lang->toss_warning);    

        
$confirmForm = new FormBuilder("confirmform""toss/confirm""post");
        
$confirmForm->buildPasswordField("hidden""action""toss")
                    ->
buildPasswordField("hidden""itemname"$mysidia->input->post("itemname"))
                    ->
buildButton("Please Toss""confirm""confirm");
        
$document->add($confirmForm);            
    }
public function 
alchemy(){
        
$mysidia Registry::get("mysidia");
        
$document $this->document;
        
        if(
$mysidia->input->post("iid") and $mysidia->input->post("iid2")){
            
$alchemy $this->getField("alchemy");
            
$newitem $alchemy->getNewItem()->itemname;
            
$document->setTitle($this->lang->alchemy_success);
            
$document->addLangvar($this->lang->alchemy_newitem.$newitem.$this->lang->alchemy_newitem2);    
            return;        
        }

        
$document->setTitle($this->lang->alchemy_title);
        
$document->addLangvar($this->lang->alchemy);
        
$itemMap $this->getField("itemMap");
        
$settings $this->getField("settings");
        
$alchemyFrom = new Form("alchemyform""alchemy""post");
        
$alchemyFrom->add(new Comment("<b>Cost of performing Alchemy: {$settings->cost} {$mysidia->settings->cost}</b><br>"));
        
        
$alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose));        
        
$items = new DropdownList("iid");
        
$items->add(new Option("None Selected""none"));
        if(
$itemMap->size() > 0){
            
$iterator $itemMap->iterator();
            while(
$iterator->hasNext()){
                
$item $iterator->nextEntry();
                
$items->add(new Option($item->getValue(), $item->getKey()));
            }
        }        
        
$alchemyFrom->add($items);

        
$alchemyFrom->add(new Comment($mysidia->lang->alchemy_choose2));        
        
$items2 = new DropdownList("iid2");
        
$items2->add(new Option("None Selected""none"));
        if(
$itemMap->size() > 0){
            
$iterator $itemMap->iterator();
            while(
$iterator->hasNext()){
                
$item2 $iterator->nextEntry();
                
$items2->add(new Option($item2->getValue(), $item2->getKey()));
            }
        }        
        
$alchemyFrom->add($items2);        
        
$alchemyFrom->add(new Button("Let's mix the items now!""submit""submit"));
        
$document->add($alchemyFrom);        
    }
}
?>
Reply With Quote