Jump to content

Let the user choose between three random quests


espe

Recommended Posts

Hello,

 

im new here, searching for good informations and hits about browsergame.

In PHP and MySQL i am a very beginner and having problems ofc! :D

 

I like to use different types of quests in this browsergames.

The most important are main quests with some history and daily quests to get money and xp.

 

Now I have some quest names and description for the daylies in a database table named `quests`.

In another table named `quest_types` I make clear what type of a quest it is.

 

My problem now is to display just three of the quests to a user. I can say...

function listRandomQuests() {
    global $db;
    
    $sql    =   "
                SELECT
                    questName,
                    questDescription
                FROM
                    quests
                WHERE
                    questTypeID = 2
                ORDER BY
                    rand()
                LIMIT
                    3
                ";
    $result = $db->query($sql);
    $rows   = array();
    
    while($row = $result->fetch_object()) {
        $rows[] = $row;
    }
    
    foreach($rows as $row) {
        echo "<div>";
        echo "<input id='$row->questName' type='radio' name='randomQuest' value='$row->questName' />";
        echo "<label for='$row->questName'>";
        echo "<span class='yellow'>$row->questName</span>";
        echo "<br />";
        echo "$row->questDescription";
        echo "</label>";
        echo "</div>";
    }
}

...but then every time the user reloads the page he get new quests. That is not good.

After showing the three availble quests they should be showed up the user finishes one of them.

Additionally there must be a reward, level based of the characters level.

 

I dont know how to write just three of the quests in an table like `character_quests` and WHEN and WHERE to calculate the money and experience reward.

 

Please give me some hints.

 

Link to comment
Share on other sites

...but then every time the user reloads the page he get new quests. That is not good.

 

You're going to need to add some redundancy checks to ensure that a) only one quest of a certain type can be used or b)only one path may be chosen.  This is factored primarily on how the quests are designed and their interactions with each other.  Dependent on your answer to the former question, you'll need to group these items by a shared table column and store said value against the user.  This likely  will not be simple as game progresses, but will be paramount to your development logic.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.