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.

 

...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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.