A
A
Alixx2021-08-26 20:41:03
Software design
Alixx, 2021-08-26 20:41:03

How to launch and track the progress of quests in laravel browser?

Hello.
The laravel browser game has a variety of quests. They are issued at different moments of the game - when performing any actions (come to the location, start work, complete work, collect resources, etc.), when performing any actions for the first time, when reaching any values ​​on the counters (kill N other players to build N buildings, reach level N for a character/city/building, etc.). Although in essence it is all the performance of any action.
As you can see, actions can be completely different, processed in different modules. What's the best way to start quests? The most seemingly obvious option is simply to call a certain method in the right place, in which there are a lot of if and if all checks are performed, then we launch the corresponding quest.
For example, (I describe conditionally) quest 1 is launched at the third start of work in building A. So in the code where the work start method for building A is called, before that we call the method of checking for the fulfillment of conditions for starting quest 1? There, if this launch is the third in a row and the player has such and such a level, then we launch quest 1, and note in the database that the player has launched quest 1 at its first stage. It's the same with quest tracking for now...
Tell me, is there a more concise option for doing such things?
You can do something like events in laravel, but it also turns out that you need to call these “events” throughout the code of game modules ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-08-26
@delphinpro

I do not know how about conciseness, but the coherence is excessive. The job start method doesn't need to know anything about quests at all. It is enough for him to simply publish an event: Work is started in building A.
And there further, whoever needs it, will subscribe to this event and do what he needs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question