Can you make this program
What You’re Building Your goal is to build a simple betting game. To start with, you enter your Name and the number of coins you’re starting with. To start, you choose how many coins to bet, then 12 tiles are shuffled face down. Each round you either choose a tile or take the coins you’ve won so far. If you choose a tile and it shows 0, you bust and lose your bet. If it has a number, your bet is multiplied by that number and the remaining tile values are doubled. Once you choose to take the coins, the amount is added to your total coins, and you can start a new game or cash out and stop playing. In addition to this, you’ll also create audit records to keep track of winnings and losings. Highlights The following highlights some of the techniques you will be employing in this assignment. Detailed instructions are included below. · The current player name and their total number of current coins will be stored in a cookie so that it can persist across sessions · The current game state (for the current player) will be stored in a Session · Essentially a game consists of a List of (randomly generated) Tile objects. You will use the NewtonSoft.Json package to serialize/deserialize the current game to/from the session as Json strings (as done in chapter 9). · You will implement some static helper methods along the way to make it easier to interact with the required Session & Cookie data · Once that is all working you will build on the solution to store an audit trail in a SQL server database Tour the Code To start, download the code called “Assignment 3 – Starting Code”, load it and make sure it compiles for you. Run the project and you’ll see a link on the default page that will take you to a list of tiles. These should all be face up, (they will also be huge because we haven’t used bootstrap to make the page look pretty yet) You’ll see red “X” tiles for any that are 0, and green “$” for any that have an amount. Currently, tiles will always display the amount, but we’ll be changing that. This assignment makes use of static helper classes and two have been created for you. Classes like this can be used to create code that you may call many times in your application. This makes the code easier to maintain as well as easier to write. Alternatively, if you prefer, you could encapsulate session access inside a class, much like the authors do in chapter 9. Go to the class, Helpers/GameHelper and you’ll see there is a single method called “GenerateNewGame”. This method generates a list of 12 tiles, with values randomly assigned to it. Change the line that says “Visible = true;” to “Visible = false;” and re-run the code. You should now notice that the tiles are all face down. From this point on, you should not need to make any changes to the GenerateNewGame helper method. I’ve also created a CoinHelper and have added hints via comments, as well as some starting code, in each class about the various types of helper methods you may find useful to create. This is optional, but it will make your life a lot easier. Controllers My expectation is that, by the end of this assignment you’ll have four controllers. Empty controllers have been created for you. a) HomeController – The default landing page as well as the page that lets you enter your bet b) PlayerController – The controller that create and cashes out player data. c) GameController – The main controller of the project that communicates game state to and from the client d) AuditController – This controller will display a list of audit records. Work Breakdown In order to build more complicated web sites, it’s often helpful to break the work into manageable steps. I’ve broken down the work for you into 8 parts, and I strongly recommend getting each part working before moving on to the next. In each section, you’ll find screen shots that you can use to work from. 1. Create a new player and let them cash out. 2. Have the player enter a bet, then start a new game. 3. Display the initial state of the game to the player 4. Implement the game rules when a player chooses a tile 5. Display helpful messages to the player. 6. Create your audit database. 7. Add in audit records and create an audit list. 8. Create a filter for the audit list that persists in session. Part 1) Create a new player and let them cash out. We’ll be keeping track of two pieces of data for the player; their name (player-name), and the total amount of coins they have (total-coins). Because we want this data to persist across sessions, we’ll be using cookies to store and retrieve this information 1) Install any Nuget packages and make any coding changes needed to enable Sessions and Serialization. (See Chapter 9 if you’ve forgotten) 2) Whenever we try to get to the default landing (i.e., Home) page, if the player-name cookie is empty, force the use to go the player controller in order to enter in new information 3) From the player controller: a. Create a Player object that keeps track of the player’s name and the starting number of coins. Name is a required fields and the total number of coins should be between 1.00 and 10,000.00 b. Create a view that collects this information, and, if it passes validation, stores it into cookies, then passes controller back to the Home/Index page 4) Modify the common navigation bar to display the total number of coins the player has along with a button to cash out. a. If they click on “Cash Out”, clear the cookies you’ve created and send the user back to the screen to enter a new player Part 2) Welcome the player, collect their bet, then start the game 5) Remove the direct link to the tile list from the homepage. It’s no longer needed. 6) On the home page, assuming that the player and total coins is stored in a cookie, welcome the player by name then collect their bet and send them off to the Game controller to start a new game. a. The amount of the bet must be greater than 0 i. Note: Creating custom validation won’t be covered until later in the course, so we won’t check to make sure that the player has enough coins to bet with. b. We’ll be saving all information about a single game into session, so once the user has entered a bet, we’ll need to deduct the betting amount from their total coins, then save the amount they bet into a session variable. i. HINT: Since the amount they can bet and win is a double, you’ll need to store the value as a string and convert it back to a double when needed. Also, this may be a good time to consider creating helper functions to keep track of coins. Part 3) Display the initial state of the game to the user. 7) We’ll be using serialization to store the list of tiles create into session. a. If the list of tiles isn’t in session, generate a new game and store it in session, otherwise, deserialize the information that’s there into a List of Tile. 8) Create a View Model for the page that contains the list of tiles along with the current betting amount 9) Make a number of UX changes to the page a. First, use the bootstrap grid system to organize the tiles, so that 6 tiles appear on each row b. Above the tiles, display the users bet along with a link either says “TAKE THE COINS!” if the current bet is above 0, and “Try Again” if the bet is 0 (We’ll add functionality later) i. To make things look nice, feel free to use bootstrap to make this look like a button c. Where the value is displaying, if the tile is not yet visible, instead create a link that says “CHOOSE” beneath the image. Keep the value if the tile is visible. Part 4) Implement the game rules when a user chooses a tile. 10) When a user chooses a tile we call out to the Game controller Reveal action. (Hint: each title has a TileIndex to keep track of each tile, which you should pass in) There, set the tile to visible, and then one of two things should happen: a. If the value is 0, the player has lost. Set the current bet to 0, then reveal all tiles so that player can see what they could have won i. If the user still has total coins, clicking on Try Again should take them to enter a new bet. ii. If the user now has 0 total coins, force the user to cash out and prompt for a new user. b. If the value is not zero, multiple the current bet by that amount, double any remaining amounts that have not yet been chosen, then let the user pick another tile (or TAKE THE COINS) 11) If a user selects takes the coins: a. Add the amount of the current bet to their total coins, then take the user back to make another wager. Part 5) Display helpful messages to the player Now that we have the game working, let’s add a few helpful messages to the program. 12) Using TempData, display messages to the user when the following event happen: a. If the user picks a 0 tile: “On no! You busted out. Better luck next time!” b. If the user pick a non-0 tile: “Congrats you’ve found a XXX multipler! All remaining values have doubled. Will you Press Your Luck?” c. If the user takes the coins: “BIG WINNER! You chased out for XXX coins! Care to press your luck again?” (Hint: This message will be displayed on the page where the player can enter their next bet) d. If the user cashes out completely: “You cashed out for XXX coins” e. If the user’s total coins ever drops to 0: “You’ve lost all your coins and must enter more to keep playing” Part 6) Create your audit database Now we’ll want to keep track of audit records when various events happen. Note that this project has not been set up to create a database. 13) Make changes to the project so that you can create a Entity Framework Code First database.