📜 ⬆️ ⬇️

Own browser - mouse path: WHY?

Start: habrahabr.ru/post/249625

Frankly, I planned to confine myself to one short article in which I was going to briefly list the difficulties in the way of anyone who wants to start their own server on the farm with a browser game on the OpenSource engine. However, it suddenly turned out that everything I wanted to say simply does not interfere with one article of a reasonable size. Well, then this will be a few articles. Now you can not try to shove everything into one post and disassemble all the rakes in detail on the path of the future browser administrator.

The first article of the cycle, unexpectedly even for me, turned into general recommendations about the behavior of the Server Administrator. But already now it is obvious that this is running ahead of the locomotive. Before someone decides to install a browser and become an admin, he must answer the main Question for himself. And this question sounds like this: “WHY FOR ?!”
')


But before giving possible answers to this question, I would like to clarify for whom this series of articles is intended.

As you know, it is better to be rich and healthy than poor and sick. In our case, it is better to have money for development and promotion and / or have your own experience in this field. If you recognize yourself in this description, then these articles are not for you. Really - if you have the money to develop, then why should you mess with free engines? It is easier to hire professional professionals who will do this job better, faster and in total - with less hemorrhoids. How to act in such cases is described in tens and hundreds of great articles on here, on Habré. Search and read them.

If you have experience developing browsers, then again, you have no reason to read this article. You yourself can quickly and beautifully write your own engine, and then sell it to the publisher or cooperate with a specialist in promotion.

If you have experience in promoting network projects, you don’t need to get involved with the development, installation and support of your engine. It is easier for you to find a more or less working server and offer your services to the administrator for a share of the income. If you are a really good specialist, then any administrator will happily grab at the chance to increase the attendance of his server and his income.

Now that we have cut off the “rich and healthy”, only the “poor and sick” have remained. Those who have neither money nor skills, but there is only a burning desire to become the administrator of their server. And now you can try to answer the question asked above: “Well, why do you need all this?”

I really do not want to dispel dreams and hopes of future administrators who are already mentally managing servers with thousands of registrations and hundreds online. But the reality is sad and cruel. The first few months (or even years) you will not be able to offer players ANYTHING-
- You use one of the ready-made engines - which means that numerous variations of such servers are already scattered across the network by the hundreds;
- You still do not have any skills to somehow select your server from hundreds of similar ones;
- You have no money for hiring at least some specialists - everything, i.e. ABSOLUTELY EVERYTHING you have to do yourself! Starting from setting up the operating system and ending with the administration of the forum (which, by the way, you will also have to deploy) and in-game chat;
- You do not even have money for promotion and advertising - so even you have to do it yourself. You will have to learn about CEOs so that they stand out from a host of identical clones with at least meta tags. You will have to register yourself in dozens of directories to get at least some number of registrations and at least some online. You will have to search for thematic forums yourself and advertise your game - where it is not prohibited by the rules.

Still have a desire to run your browser? Then answer yourself the question "Why?". Just be honest with yourself! Variants of the answer to this question - a huge set. I will try to consider just a few of them - and explain why they are badly suited as a reason for launching my own browser. So…

The answer is zero - MONEY
As already mentioned in the previous article - there is no fish here. At least some exhaust can be expected only with serious investments of forces and / or funds. And often - both. But even with this, at least “to zero”, the browser will come out very soon.

The first answer is to COME YOUR CHSV
There is absolutely nothing wrong with that. As a motivator, the combing of ChSV will probably be stronger than even the desire for profit. But I say right away - it's not worth it. You can scratch the CSW in easier ways. For example - to find an already open server with the same “poor and sick” admin and ask for moderators. Costs and responsibilities - the minimum, profit and the size of ČSV - on the achievable maximum, taking into account the complete lack of skills and money.

The second answer is to LEARN
Do you want to learn a new language - say, PHP, in which most browsers are written - and could not think of anything better than learning it from the free engine code? Really! There are much better and painless ways to learn PHP! The network has a huge number of training courses with examples on any level of complexity - starting with “Hello World!” And ending with examples of creating a simple game from scratch. With detailed explanations of each step, commented code, the community, ready to answer your questions. In general, virtually any other way to learn a new language is BETTER than digging into a regular free browser.
And I know what I'm talking about - the code of literally every ogame-like engine clone that I scanned for in quality varies from "monstrous" to "very bad." Even including my SuperNova code. There are objective reasons for this. Very rarely, the entire lifetime of an engine, its code is written by the same command. As a rule, the free engine code is a hodgepodge of fragments written by different people with different levels of experience and different approaches to writing software. All these mixed pieces are somehow joined together. The structure of the database is usually terrible. There are no foreign keys and even important indexes in the tables, the records are not normalized, the data often duplicate each other, and for the same data several different tables are used simply because different pieces of code were written by different people at different times. Trying to learn from this code is to break your coding style from the start and learn the bad practice, so to speak, “from the cradle”.
But even if the engine was developed by one person / one team, then here you are not immune from the mismatch code. The fact is that it is human nature to learn. New techniques are being developed, new practices are being added, and an arsenal of tools is being expanded. And as the engine continues to grow, it grows and develops and provides more and more tools for performing standard actions. And the fact that a year ago it seemed to the programmer to be the pinnacle of skill (and it was him, judging objectively) in a year would only cause a nervous grin and feeling of awkwardness. Yes, of course - if you initially planned the architecture of the game, painted the structure of the database and clearly followed your plans, then all this would have been avoided. Only, alas, people who can do this have long been working either for themselves or for their uncle. And free engines are written by enthusiasts. Therefore - the monstrous quality of the code of such engines is not an exception, but the rule.

The third answer is to MAKE YOUR OWN
I have to disappoint here too - at first, most of the time you will understand the terrible code of others just so that you can go to the smaller part - fix the errors of others. Virtually any free engine contains: an almost complete lack of validation of the input parameters for type conformity and correctness; direct insertion of data from the user into the table without screening - the path to SQL-injection; direct data output from users both in HTML code (the path to the appearance of virus scams and malicious scripts in your browser) and in JS code (at best, make your scripts inoperable, and at worst - allow you to execute hostile code on the page); direct recording of data in the database tables with complete disregard for competition - and this is a direct path to deadlocks, race condition situations, unit losses, resources and other game nishtyakov. And this is just the tip of the iceberg! Few engines do full-fledged “system-data-type” checks, and they too trust the data from the browser - which in the long term gives malicious players the opportunity to appropriate resources or even manipulate other people's accounts. And I have not yet mentioned the wrong choice of data types in the database, when after a couple of years of work for top players, there is an overflow of fields in the tables with all the accompanying hard-to-catch glitches, or a wrong internal data storage format — when line 070 suddenly converts to a number number 56.
And even when you close the main holes and fix the most egregious glitches, the curse of the Inherited Code will always be above you. Any of your attempts to make something of your own, new and interesting, will come up against the fact that with the current code and the current structure of the database, this will simply be IMPOSSIBLE without rewriting a noticeable piece of the game. Or when fixing a glitch in one place leads to a completely different glitch in a seemingly unrelated part of the code - simply because the old glitch was already taken into account and corrected by someone else in its fragment.
Well, if you just want to participate in the development and make something of your own, join some existing project. Even if you are not included in the team (and who needs you without skills and money?), Then at least you can try to write some mod and get advice and help on the project forum.

Still want to set your browser? Well, the mouse! Welcome to the country of tough and thorny cacti! Here are just a few plants that you have to completely chew on your way.

Cactus First - LONELINESS
I wrote it above, but I will emphasize once again - get ready for the fact that you have to do everything yourself. Starting from setting up the server for the game and ending with page layout and even drawing pictures for the game. Or at least to the remaking of free images from an Internet. If you have a familiar admin who will help you set up a server, a familiar typesetter who will help you to create pages, or a familiar artist who will draw pictures for you - you are very, very lucky!
However, immediately tune in to the fact that this assistance is temporary and / or episodic. You can only answer for your desire to make the Perfect Browser and only you have an incentive to continue working on it. If someone from those with whom you started the project along with the time has cooled down - you should not blame him. Say “thank you” to him for the work done and continue the journey without him. If someone helped you out of friendship, you should not consider him your debtor and rely on the fact that you can use his skills always and without restrictions. If there is an opportunity, carefully observe what and how your friend did, so that next time you can repeat these actions yourself, and ask for help only in extreme cases. If you do everything right, then you will have to turn for help less and less, and you will also get related skills in addition to learning the main programming language.

Cactus II - NO SKILLS
At first, any action will cause a bunch of questions. At first it will be unclear even where to begin and what to grab. This is normal. It is worth waiting for and it is worth preparing in advance. At the very beginning, you will have not only skills, but you will not even know where to find the answers to your questions and sometimes you will not even understand how to formulate a question. As they say - read the docks, they rule. Sometimes free engines contain the simplest instructions for installing a game in a standard / basic configuration.
Often in the forums you can find answers to the most frequently asked questions. But remember that the question on the forum is the expense of a “loan of help”. Just because you downloaded the engine and wanted to install it does not make the author of the engine something to you! Therefore, avoid spending your credit on general questions like “How to install MySQL?” Or “How to set up PHP?”. Such answers are easier to find in Google - with a great degree of probability there already is the necessary answer, which was given for a case similar to yours or very close.
It also does not make sense to ask questions on languages ​​in the forum - there are answers to all your questions in Google - usually much more, better and more detailed than you will be answered in the forum. Even to questions on the engine, the best answers are to look for yourself. In the end, your engine will be OpenSource and the ideal code documentation is the code itself.
And some IDE will help you understand the intricacies of govnokod. Personally, for example, I use phpStorm. In addition to the free trial version, JetBrains provide free licenses for authors of OpenSource projects. The most useful functions when learning a new code are Alt-F7 - “Found Usages” (find all the places where this variable / constant / function / etc is used), Ctrl-B - “Declarations” (go to the place of variable / constant / functions / etc) and Ctrl-Alt-F - “Found in path” (global search for a string in the entire project).
In general, IDE (not necessarily phpStorm) helps a lot in initial language acquisition. Syntax highlighting, indication of syntax errors and possible logical errors in the code, automatic formatting - all this makes it very easy to get familiar with the code. A jumbled file with broken formatting can be easily brought to a neat, readable form using the Ctrl-Alt-L built-in function - “Reformat code ...”
And here it can help if you already have some related skills.
Can you draw pictures? SUMPTUOUSLY! You can make a unique game "right out of the box"! It is enough just to put a standard engine, to replace a part of the pictures with the pictures you painted - and this will already give an influx of players. Because let it be a “normal ogame-clone”, but the appearance will attract attention and for the time being, to mask the full standardization of the game. Meet - on clothes. True, they are escorted by the mind, so sooner or later they will have to go to work with the code. But it will not be so painful, because you have already done some work, replacing the pictures in the game (which, by the way, can be very nontrivial in some projects!)
Know how to impose? It's almost as cool as drawing! You can make your game look just by manipulating building blocks in templates. Moreover, you can take the standard game template and remake it for mobile users, which will give you +100 to new players right away! All the engines I have seen sin by the fact that playing games based on them from mobile phones is either very inconvenient or impossible (for example, due to too much use of mouseover, mouseenter and mouseleave events, or right-click) .
Know how to CEO? Well, then it is not clear why you even read this text. You yourself know how to cut money on clones of other sites.

Third Cactus - NO FREE TIME
Be prepared for the fact that the first time you just do not have free time. Work-food-sleep-browser - this will be your cycle for the first few months, until you get at least basic knowledge and skills. Moreover, time will be spent not only and not so much on the modification and mastering of the code itself, but on the accompanying actions: tuning and optimizing the OS; setting and getting used to the work environment; expanding, setting up and moderating the forum; game moderation; promotion of the game - all this, I remind you, you will probably have to do it alone.
If you are doing your browser and you have free time, then either you are not working / not learning anywhere, or you are doing something wrong and do not put the right amount of effort into the game.

Cactus Four - MIDDLE STATISTIC “VALUABILITY” OF PLAYERS
I note - "ingratitude" is not in vain put in quotes. Practice shows that most players are normal and adequate. And usually you will not even notice their presence, except by the change in the number of online. However, sometimes there are inadequate. And this is the spoon of tar that will spoil the barrel of honey. It is very difficult to remember that the bulk of your players like everything when there is inadequate chatting in the chat room and starts to throw feces left and right.
For your own moral health, I recommend that you do not enter into correspondence with such inadequacies and block them immediately. You will be healthier. However, in more detail on communicating with users, I plan to tell in one of the following articles. In the meantime, it should be remembered: the most important value of a novice admin browser is his mental health and self-reliance. You will have enough reasons and reasons for disappointment and frustration to add communication with inadequate to this list.

And again, almost 17 kb of text was quietly typed. Therefore, on this major note, we end this article.

Continued: habrahabr.ru/post/257165

Source: https://habr.com/ru/post/249705/


All Articles