Skip to content

Multiplayer Battleship-like game with a social focus to help connect people.

Notifications You must be signed in to change notification settings

jamisoncozart/Treasure-Sweep-Game

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Treasure Sweep Game

C# .NET Team Week for Epicodus

By: Michelle Morin, Jamison Cozart, Dusty McCord, Patrick Kille April 6-9, 2020

Picture of UI

Description

This application allows users to play Treasure Sweep, a battleship-esque game for uncovering hidden treasure on an opponent's beach rather than sinking their ships. This application is available to play on Heroku!

Specifications:

  • When a user registers a new account, the application redirects to a log in view.
  • A registered user can log in to their Treasure Sweep account
  • When a user logs in to their Treasure Sweep account, the application redirects to a Profile view.
    • If the user does not have a profile, the user is instructed to create a profile. If the user has an existing profile, the profile is displayed.
  • A registered, logged in user is able to start a new game
  • Once a new game is initalized, both game players' profiles include a link to the game
  • The player who started the new game ("player one" hereafter) is initially the current player, and their opponent ("player two" hereafter) is not able to take a turn until player one's turn is complete.
  • Player one completes their turn by selecting an available (i.e., not previously selected) tile on the Treasure Sweep board labeled "opponent's board".
  • When player one selects an available tile, the tile changes appearance according to whether or not the tile hid a treasure chest, a bomb, or an empty space.
  • Player one is able to view their board for reference, to see how their opponent's moves are affecting their beach.
  • Once player one completes their turn, player two is able to view the result of player one's turn on their board (labeled "your board" from the perspective of player two). If player one struck a treasure chest, the tile will become an opened treasure chest; a mine becomes an explosion; an empty sandy space becomes a hole in the sand.
  • Turns alternate between player one and player two until a game ending condition is met. Game ending conditions include:
    • the first player to uncover all treasure chests on the other player's beach wins
    • a player who digs up a bomb loses
  • The Games Turn view automatically refreshes, in case the user does not refresh the page to recognize that it is their turn to play.
  • When a game is over, neither player is permitted to take another turn.
  • The application includes a leaderboard displaying, for all players who have completed at least one game, the players' win percentage (wins/completed games).
  • In a user's profile, all games associated with the user are sorted in descending order by the date/time of the most recent turn.

Project Concept:

We defined our minimum viable product (MVP) as an application that allows a user to:

  • Register for a Treasure Sweep account
  • Login to their Treasure Sweep account
  • Initialize a new game and invite a friend to join the game
  • During their turn, select a target on the other user's game board,
  • Display results of each players turn (i.e., open an uncovered treasure chest when they strike treasure, uncover an empty hole when they select an empty space, show an explosion when they select the opponent's burried bomb), and
  • Notify each user when the game was over and identify the winning player.

In addition to the MVP, we defined several stretch goals, including:

  • Randomly generating new game boards each turn
    • We incorporated this stretch goal in our Game model. Each new game object is instantiated with two game boards each having several treasure chests and a mine randomly placed.
  • Hosting the application
    • We deployed this application to Heroku by wrapping the TreasureSweep application in a docker container and releasing the docker container to Heroku. This process required us to switch from a MySQL database to a SQLite database, so that the database could be dockerized and sent to Heroku. Unfortunately using SQLite on Heroku means that the database is wiped every 24 hours.
  • Integrating a chat feature, so users in a game could send messages back and forth to one another
  • Setting up an email mailer, to notify each user when it was their turn to play.
  • Implementing private and public game options, so that a user could join any public game that does not have a second player

Setup/Installation Requirements

Install .NET Core

on macOS:

  • Click here to download a .NET Core SDK from Microsoft Corp.
  • Open the file (this will launch an installer which will walk you through installation steps. Use the default settings the installer suggests.)

on Windows:

  • Click here to download the 64-bit .NET Core SDK from Microsoft Corp.
  • Open the .exe file and follow the steps provided by the installer for your OS.

Install dotnet script

Enter the command dotnet tool install -g dotnet-script in Terminal (macOS) or PowerShell (Windows).

Install MySQL and MySQL Workbench

on macOS:

Download the MySQL Community Server DMG File here. Follow along with the installer until you reach the configuration page. Once you've reached Configuration, set the following options (or user default if not specified):

  • use legacy password encryption
  • set password (and change the password field in appsettings.json file of this repository to match your password)
  • click finish
  • open Terminal and enter the command echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile if using Git Bash.
  • Verify MySQL installation by opening Terminal and entering the command mysql -uroot -p{your password here, omitted brackets}. If you gain access to the MySQL command line, installation is complete. An error (e.g., -bash: mysql: command not found) indicates something went wrong.

Download MySQL Workbench DMG file here. Install MySQL Workbench to Applications folder. Open MySQL Workbench and select Local instance 3306 server, then enter the password you set. If it connects, you're all set.

on Windows:

Download the MySQL Web Installer here and follow along with the installer. Click "Yes" if prompted to update, and accept license terms.

  • Choose Custom setup type
  • When prompted to Select Products and Features, choose the following: MySQL Server (Will be under MySQL Servers) and MySQL Workbench (Will be under Applications)
  • Select Next, then Execute. Wait for download and installation (can take a few minutes)
  • Advance through Configuration as follows:
    • High Availability set to Standalone.
    • Defaults are OK under Type and Networking.
    • Authentication Method set to Use Legacy Authentication Method.
    • Set password to epicodus. You can use your own if you want but epicodus will be assumed in the lessons.
    • Unselect Configure MySQL Server as a Windows Service.
  • Complete installation process

Add the MySQL environment variable to the System PATH. Instructions for Windows 10:

  • Open the Control Panel and visit System > Advanced System Settings > Environment Variables...
  • Select PATH..., click Edit..., then Add.
  • Add the exact location of your MySQL installation and click OK. (This location is likely C:\Program Files\MySQL\MySQL Server 8.0\bin, but may differ depending on your specific installation.)
  • Verify installation by opening Windows PowerShell and entering the command mysql -uroot -p{your password here, omitted brackets}. It's working correctly if you gain access to the MySQL command line. Exit MySQL by entering the command exit.
  • Open MySQL Workbench and select Local instance 3306 server (may be named differently). Enter the password you set, and if it connects, you're all set.

Clone this repository

Enter the following commands in Terminal (macOS) or PowerShell (Windows):

cd desktop
git clone https://github.com/jamisoncozart/Treasure-Sweep-Game
cd Treasure-Sweep-Game/TreasureSweepGame

_Confirm that you have navigated to the TreasureSweepGame directory

pwd

Recreate the treasure_sweep database using the following commands (in Terminal on macOS or PowerShell on Windows) at the root of the TreasureSweepGame directory:

dotnet restore
dotnet build
dotnet ef database update

Run this application by entering the following command in Terminal (macOS) or PowerShell (Windows) at the root of the TreasureSweepGame directory:

dotnet run
dotnet watch run

To view/edit the source code of this application, open the contents of the TreasureSweepGame.Solution directory in a text editor or IDE of your choice (e.g., to open all contents of the directory in Visual Studio Code on macOS, enter the command code . in Terminal at the root of the TreasureSweepGame.Solution directory).

Known Bugs

Currently, the deployed version of this application allows a player to take multiple turns during one turn by clicking on multiple sand tiles in rapid succession. We think this has to do with the speed at which our application runs on Heroku, and need to add additional validation to prevent a user from taking multiple turns in one turn.

Technologies Used

  • Git
  • HTML
  • CSS
  • JavaScript
  • C#
  • dotnet script
  • ASP.NET Core MVC 2.2
  • Entity Framework Core 2.2
  • Identity
  • Newtonsoft.Json
  • Razor
  • SQLite
  • Docker
  • Deployed to Heroku!

License

Licensed under the MIT license.

© 2020 - Michelle Morin, Jamison Cozart, Dusty McCord, Patrick Kille

About

Multiplayer Battleship-like game with a social focus to help connect people.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 58.4%
  • HTML 31.6%
  • CSS 9.6%
  • JavaScript 0.4%