Good day! I am going to write an online game (HTML + CSS + PHP + SQL, WITHOUT JS), I carefully think over everything, collect graphics, etc. There was a question where to store quests? In a php file or database? After all, the quest may be different, from collecting items to talking to a person, etc. How to do? Store as an array with various elements and checks, or something else? Tell me please.
- And how does the storage of quests data differ from the storage of any other data? And yet, WITHOUT JS to create something worthy, you are unlikely to succeed, but this is IMHO. - Deonis
- The question is not to use JS, it differs in that it has unpredictable conditions. - angers777 pm
- will nosql save you? without js you turned down - zb '
2 answers
Well, for starters, I propose to sit down and think about what options for quests can be. As I understand it, quests can appear after the game is started - which means it’s better to store this in the database so that you don’t go to the game code every time. each change must be carefully checked ...
After you determine which quests can be, what input and output data, I suggest to make a model that can store this business, and according to this model you can create a database structure .
Each action is entered under its identifier, which is already tied to the logic in php. For example:
- Talk to the man = 1
- Collect Potion = 2
- Accumulate gold = 3
- Add person = 4
and additional parameter Value
- To talk with a person, for example, id the person / creature
- For example, an array of potions: Array ([id potion] = [qty], [item id] = [qty])
- The amount of gold, for example 500
- As in paragraph 1
Well, in order not to get magical id, you write name constants in php:
define("ACTION_TALK", 1); define("ACTION_COLLECT", 2); // и т.д.
ID | ACTION | Value
- For example like this: It is necessary to kill an animal; Need to talk to a man; Need to collect two potions; Need to accumulate 500 coins; Need to add a friend, etc., I have to create a column for each condition? Or how. ID | TEXT | FRIENDS | POISON | WAPEN | COIN - So what? - angers777
- for example, for each action you define your id, and then the value, in the answer right now, add an example. - IVsevolod
- thank! I will keep in mind! - angers777
An interesting idea, but no less interesting tools you offer for the development of online games. Why not look in the direction of flash and, for example, Player.IO service for multiplayer games. For the question: perhaps it is better to create a separate table in the database:
(id, the one who gave the task, the one who needs to pass the task, deadlines, condition of fulfillment, condition of failure).
And the tasks to take by the identifier as suggested by IVsevolod, pre-declaring them as constants
- thank! I will keep in mind! - angers777