PHP web game learning-Xnova (ogame) source code explanation (12 ). 15. Research Page (ResearchBuildingPage. php) research is relatively simple because there is no queue, but there are some special things. Let's take a look at a previous article 15. Research Page (ResearchBuildingPage. php)
The study is relatively simple because there is no queue, but there are some special things. Let's first look at a previous processing function handlejavasiebuild ().
This function is used to deal with current scientific and technological research. the B _tech_planet field is the planet ID of the study, the B _tech field is the time point for completing the study, and the B _tech_id field is the specific technology field name of the study. The function logic is not difficult. I will not explain it carefully. let's take a look at it. now we will go to the research page:
First, check whether there are any research institutes on the current planet.
Then, check whether there is any research in the building queue of the current planet and use the CheckLabSettingsInQueue () function to check; this function is skipped.
Next we will look at the previous structure. let's first look at the following construction code, loop:
1. determine whether it is scientific research
2. determine whether this study can be performed, mainly by checking the preconditions in the vars. php file.
3. resources required for research
4. time required to obtain the study
5. then determine whether the study can be conducted.
6. The following is a branch: if there is no research in progress, the next level of html is constructed; if there is research in progress, the remaining time of the study is constructed.
7. final output page
Now let's go back to the previous step and explain the logic of the gamer click research. It is divided into two logical segments: one is research, and the other is to cancel research.
1. Research: perform some security checks first, then obtain the required resources and time, and construct statements for deducting resources.
2. cancel the study: obtain the required resources and construct statements for returning resources.
3. finally, submit it to the database to update resources and other information.
The logic of the research page is much simpler than that of the previous building page. the next chapter will be the shipbuilding page.
The ResearchBuildingPage. php study is relatively simple because there is no queue, but there are some special things. Let's take a look at a previous study...