Home >Backend Development >PHP Tutorial >Xnova (ogame) source code interpretation for PHP web game learning (12)_PHP tutorial
15. Research Page (ResearchBuildingPage.php)
The research is relatively simple because there is no queue; but there are also some special things. Let's first look at HandleTechnologieBuild(), a processing function we studied before.
This function handles current technology research, where the b_tech_planet field is the planet ID of the research, the b_tech field is the time point when the research was completed, and the b_tech_id field is the specific technology field name of the research. Functional logic is not difficult, so I won’t explain it in detail. Let’s take a look for yourself. Let’s officially enter the research page:
First check whether there is a research institute on the current planet.
Then check whether there is a research institute in the current planet's construction queue, use the function CheckLabSettingsInQueue() to check; this function is skipped.
The next step is the previous structure. Let’s first look at the following construction code, loop:
1. Determine whether it is scientific and technological research
2. Determine whether this research can be conducted, mainly the precondition check in the vars.php file
3. Obtain the necessary resources for research
4. Time required to obtain research
5. Then determine whether such research can be carried out
6. The following is a branch: if there is no research in progress, then construct the next level of html; if there is research in progress, construct the remaining time of the research
7. Final output page
Now go back to the front and explain the logic of player click research. It is divided into two sections of logic, one is research and the other is canceling research.
1. Research: First perform some security checks, then obtain the required resources and time, and construct statements such as deducting resources
2. Cancel research: obtain required resources, construct statements such as returning resources
3. Finally submit it to the database, update resources and other information
The logic of the research page is much simpler than the previous building page. The next chapter will be the shipyard page.