Catalog
One . The experiment purpose 1
Two . The experimental requirements 1
3、 ... and . Code execution sequence and usage 3
Four . Experimental process 3
1. Database design 3
1.1 treasures 4
1.2 players 5
1.3 markets 6
1.4 picurl 6
2. Implementation of basic functions ( Sign in ,cwur etc. ) 8
2.1 Sign in / register 8
2.2 View user box 9
2.3 Browse the market 9
2.4 Wear treasure 10
2.5 Purchase treasure 11
2.6 Withdraw the treasure 13
2.7 Sell treasures 14
3. Timing task ( Treasure hunt + To make money ) Function implementation 17
4. Additional function function implementation 18
5. pytest test 23
6. Front end display 25
5、 ... and . matters needing attention 27
One . The experiment purpose
1. practice Mongodb operation , Learn how to design a database 2. practice Python Of Flask frame
3. Learn to use pytest test
4. Learn to use timed tasks to execute functions
Two . The experimental requirements
Consider the following game scenarios :
1. Each player has a certain amount of gold coins 、 treasure . There is a market for players to buy and sell treasures . Players can put treasures in the market Listing on the market , Set your own price . Other players pay enough gold , You can buy treasures .
2. Treasures fall into two categories : One is tools , It decides to hold the player's working ability ; One is accessories , It decides to hold the player's luck .
3. Each player can get one treasure every day through treasure hunt , The value of the treasure is determined by the player's luck . Every player can pass Labor earns gold coins , How much you earn depends on your ability to work .( A day in the game can be a real day 1 minute 、5 branch
The clock 、10 minute . Self setting .)
4. Each treasure has its own name ( Try not to repeat ). Each player can wear a limited number of treasures ( For example, a player Only one tool and two accessories can be worn ). The extra treasure is put in the storage box , It doesn't work , But it can be sold on the market .
5. Treasures listed on the market must be in the storage box and still in the storage box , Until the treasure is sold . Listed treasures can be collected return , And re listed at a new price . When the storage box cannot be filled , The treasure with the lowest luck or working ability will be automatically returned by the system closed .
6. Suppose the game never stops and the ultimate goal of the player is to get the best treasure .
Please build a hypothetical Web game , Available for many people to play online . The interface should be as simple as possible ( Simple text and links are can , Unwanted style). The background database uses mongodb. The following operations are provided for game players : Treasure hunt ( Can automatically every Once a day )、 To make money ( Automatically once a day )、 Wear treasure 、 Browse the market 、 Buy treasures 、 Listing treasures 、 Take back the treasure .
Submit : Program + Document requirements :
1. Documentation is mainly used to explain your database design , That is, what needs to be built collection, Every collection What is the document structure of Well , What indexes need to be built , How applications access databases ( Concrete CRUD command );
2. Design for player's operation JSON HTTP Interface to protocol , Custom interface format (request and response Of JSON); Write test cases and test code for each interface ;
3. Unlimited programming languages and web frame .