espe Posted July 17, 2012 Share Posted July 17, 2012 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! 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. Quote Link to comment https://forums.phpfreaks.com/topic/265858-let-the-user-choose-between-three-random-quests/ Share on other sites More sharing options...
Mahngiel Posted July 17, 2012 Share Posted July 17, 2012 ...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. Quote Link to comment https://forums.phpfreaks.com/topic/265858-let-the-user-choose-between-three-random-quests/#findComment-1362285 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.