Git Product home page Git Product logo

lovecraft's Introduction

A simple frontend for the Don't Mess with Cthulhu business logic that Dave Otaguro wrote.

Overview

This is an Angular TypeScript frontend that uses AngularFire to connect to a FireStore database. There currently is no server, nor are there server-less functions - all of the state is read from and written to by the client. This is not the most robust way to do this, as there should be some sort of API that the client hits, but it was the easiest.

Architecture

The original intention of the game logic was for it to be a NodeJS backend that stored all the games in memory was accessed by the frontend via an API. However, when I was writing this, I had so much trouble figuring out how to do a streaming API with FireBase (and I didn't want to do polling) that I just decided to make it completely serverless and power it with a FireStore database.

That being said, the application is designed in such a way that if we want to back to the other way, we can easily do so. This was done with the following architecture:

  • Facade - this class is the one written by Dave and contains all of the business logic for the game itself.
  • GameStore - this is Data Access Object interface that is used as the middle-man between the Facade and wherever the game data is stored. Dave's original implementation stored everything in memory, so I factored that out into an in-memory GameStore. I also created a Firestore GameStore that stores all of the data in a Firestore DataBase.
  • GameService is the class that the client uses to communicate with the Facade. As the Facade was originally intended (to live on the backend), the GameService could be a series of RPC calls to the server. However, in the current implementation, GameService simply proxies calls through to the Facade, which is also located on the client.

For Developers

To download the application, clone the repository and then run npm install from the root directory.

To run the application locally, simply cd into the client directory and run ng serve. To deploy it to Firebase hosting, run ng build --prod and then cd to the base directory and run firebase deploy. You may need to download the Angular and Firebase CLIs.

To run the business logic tests, run karma start my.conf.js from the root directory. This will run all the tests in the game/ directory. To run the client tests, run ng test from the client directory. There is currently no mechanism to ensure that these tests are passing when committing, so they may fail at any time. The game/ tests are generally stable, but client/ ones have been flaky in the past (and maybe the present).

Open bugs

lovecraft's People

Contributors

dependabot[bot] avatar dotaguro avatar kevinvillela avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.