Quest Page Help

Forum
Last Post
Threads / Messages

dlithehil

Member
Member
Joined
Jun 10, 2022
Messages
83
Points
18
Mysidian Dollar
699
Heyo... again.
I'm making a quest page, and I figured out most of the code to begin with which I'm super proud of.
I have this code that works:
PHP:
if($questsdone == 0){
            //------------ Fetch Quest ------------------------
            $document->add(new Comment("Heya! I was wondering if you could find me 3 berries. Not the strawberries. Those are gross... I just don't like going foraging. I have some gold to spare."));
            //------------- Selects Item ------------------------
            $item = new OwnedItem(2, $profile);
            //----------Counts the number of item on a given profile ----------------
            $berries = $item->getQuantity($profile);
            //------Now we need to make sure they have the correct number of berries.
            if($berries >= 3){
               $document->add(new Comment("Thank you so much! Here's your reward!"));
               $item->remove(3, $profile);
               $mysidia->user->changeMoney(50);
            } else {
                $document->add(new Comment("You don't have enough berries yet..."));
            }
        }
But I was wondering if there was any way to make a confirmation button before it just takes the items. Preferably this would be without having to direct to a subpage. Basically, i want from "if($berries>=3){" to the end (the part that says there's not enough berries) to pop up only if they have stated that they want to hand over their berries. I can do this with a subpage, but I don't want to have to make a new subpage for each fetch quest I end up making...
 
I added
PHP:
$document->add(new Button("test", "Testing"));
but I don't really understand how buttons work on Mysidia.
I tried this???
PHP:
if(isset($_POST["Testing"])==true){
            //------Now we need to make sure they have the correct number of berries.
            if($berries >= 3){
               $document->add(new Comment("Thank you so much! Here's your reward!"));
               //$item->remove(3, $profile);
               //$mysidia->user->changeMoney(50);
               //$mysidia->user->setQuestsDone(1, "update");
            } else {
                $document->add(new Comment("You don't have enough berries yet..."));
            }
}

It doesn't break my site, but the button also does nothing.
 
Figured out how to make the button do something, but it sends me to myurl/berries instead of running the $mysidia->input->post function. I'm still looking though!
PHP:
<?php

namespace View\Main;
use Resource\Core\Registry;
use Resource\Core\View;
use Resource\Core\Model;
use Resource\GUI\Document\Comment;
use Resource\GUI\Component\Link;
use Resource\GUI\Component\Image;
use Resource\GUI\Container\Form;
use Resource\GUI\Component\Button;
use Model\DomainModel\User;
use Model\DomainModel\UserProfile;
use Model\DomainModel\Adoptable;
use Model\DomainModel\OwnedAdoptable;
use Model\DomainModel\Item;
use Model\DomainModel\OwnedItem;
use Model\DomainModel\Member;

class QuestsView extends View{
   
    public function index(){
        $mysidia = Registry::get("mysidia");
        $document = $this->document;
        $document->setTitle("Quest Board");
        $document->add(new Comment("Welcome to the quest board. When there's someone who needs someone to help them with something, they come here. They usually offer compensation, too.<br><b>Broken at the moment</b><br>"));
       
        $profile = $mysidia->user->getID();
        $mysidia->user->getID();
        $questsdone = $mysidia->user->getQuestsDone();
        $mysidia->user->getQuestsDone();
        $day = date('z');
        $lastday = $mysidia->user->questday;
        $next = $day - $lastday;
       
       
        if($questsdone == 0){
            //------------ Fetch Quest ------------------------
            $document->add(new Comment("Heya! I was wondering if you could find me 3 berries. Not the strawberries. Those are gross... I just don't like going foraging. I have some gold to spare."));
            //------------- Selects Item ------------------------
            $item = new OwnedItem(2, $profile);
            //----------Counts the number of item on a given profile ----------------
            $berries = $item->getQuantity($profile);
           
            //-----------Confirmation Button Function-----------------------
            if($mysidia->input->post("berries")){
            //------Now we need to make sure they have the correct number of berries.
                if($berries >= 3){
                    $document->add(new Comment("Thank you so much! Here's your reward!"));
                    //$item->remove(3, $profile);
                    //$mysidia->user->changeMoney(50);
                    //$mysidia->user->setQuestsDone(1, "update");
                } else {
                    $document->add(new Comment("You don't have enough berries yet..."));
                }
            }
            //----------The Confirmation Button Itself----------
            $berryForm = new Form ("berries", "berries", "post");
            $berryForm->add(new Button("Give Berries", "berries", "sumbmit"));
            $document->add($berryForm);
           
        }  /* Add your elseif($questsdone == 1 && $next > 1) or whatever number of quests done below here. You need to keep $next greater than however many days you want them to wait minus 1*/
        //------If all quests are completed (aka quests done = the number of quests) ---------------------
        else { $document->add(new Comment("<center>You've completed all the quests we have right now! Check back later. </center><br>
            <span style='font-size:10px;'>(If you haven't completed all the quests we have to offer, you can do a new quest 2 days after your last <em>completed</em> quest.If you wait exactly one year after completing a quest, it will show as the same day of the year, and show this message. Just wait a couple days)"));
           
        }
    }
}

Edit: set it to direct to a page with a pretty random string for a url so people cant skip around on quests. also made it so that people cant keep getting rewarded for a quest by going back to the same page.
 
Last edited:

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,295
Messages
33,186
Members
1,606
Latest member
kandriamage
BETA

Latest Threads

Latest Posts

Top