Giter Club home page Giter Club logo

game-settings's Introduction

Game Setting Configuration Tool

๐Ÿš€ Getting Started

First, clone the repo to your local machine.

Then, install dependencies

npm install

In this demo, I used json-server as a mock server which supports some basic CRUD operations, so in order to get mock data, there is a prerequisit condition, you need to install the json-server

npm install -g json-server

Then you can simply run npm run server then npm start to run the project in your local environment

๐Ÿ“š Dependencies and ecosystem

This project was started with Create React App and uses a standard tech stack:

Some small but powerful third party libs used in the project:

I also used some utilities to standardize the code format and formalize the commit messages

prettier and commitlint respectively for code and commit message formatting, along with husky for automation based on git hooks.

๐Ÿ“” Implementation

1. Project Description/Potential Development

1.1. feature breakdown

This service is currently focusing on creating templates for a given parameter(configuration) in a game.

As a complete version of this service, this application will evolve into 2 main features.

  1. Parameter Panel (the currnet feature implemented of the project)

    this feature will allow in house designers/admins to config different parameters(json schema based) of the game by creating/editing/deleting different sets of templates.

    Why creating templates not directly creating settings:

    The reason way I go with this way of implementation is that based on my knowledge, game settings could be a dynamic range of particular fields and as for how to combine those fields, it is better for the game client (game programmers, other BE services) to decide, not by the live opertors/designers who may potentially use this tool, a single souce of truth will be better and easier to manage

    So when i read the requirement, the first thing came to my mind is that those parameters would be generated by the game client as json schema then store in the BE and send to the FE to consume.

    Then the FE receives different parameters and will manipulate the values of an instance of a given parameter

    So that is why I didn't choose to create a form by applying a bunch of predefined fields and save it.

    Also, when it comes to things like A/B testing, the way I propsed here will also prevent us from doing a lot of repetitive work.

    Imagine when we want to apply to two different segmentation with different parameter values.

    If we go with creating settings on the fly, that means we need to create multiple same forms. it is more error prone.

    But if we directly got this schema from the BE then the user only need to enter the different values for the same parameter. It is quick and easy.

  2. Editor Panel

    this feature will include an editor where it will consume templates greated from the parameter panel and will allow operators to directly apply those predefined template into the game.


Break the service down into two parts will allow us to comply with future requirements such as
  1. permission

    e.g. a live ops operator could only use existing template but cannot arbitrarily create any random templates, all the template creation has to be validated by an admin.

  2. A/B test

    can define different groups with different segmentation then apply different parameter template (config with different values)

Extra Here is a simple design mock I also created to illustrate the future extension of this service. Figma Link

1.2 Trade-Offs

  1. Currently form limitations: formik + yup

    Using formik + yup is an simple and easy way for a fixed form validation. However, when it comes to the dynamic range of potential game settings, that means we then need to create/predefine different kinds of yup schema. That means the service right now is not yet flexible enough to generate and validation automatically.

    The change I would do is to enrich the json schema with all the conditions then use/create a JSON schema form could do both dynamic rendering as well as validation at once. e.g. react-jsonschema-form

    Right now, I worte a set of utils functions to iterate through the parameter schema and render the form according, but YUP is validation is still hardcoded.

  2. formik vs react-hook-form

    formik is good and have a big community base, but in terms of performance, react-hook-form may be a better option, comparison, react-hook-form

  3. limited implementation Since this is a quick assignment, due to time constraint, I didn't start the project based on the vision, more on the actual requirements. so there are some UI elments that are currently not implemented or could be improved, such as the editor, json schema utils(to support more complex use cases).

2. Structure

/api

the api modules could ease the work when adding a new endpoint with minimum duplicated code

/pages

it defines different routes. Currently only has the main feature which is the parameter. More could be added to support consuming the parameter templates, such as in a game config editor

/sagas

it contains all the redux/sagas where it handles all the async logic, ask all the CRUD operations

/reducers

it uses the redux/toolkit and the duck pattern, reduced a lot of boilerplate from the old way

/selectors

it is used to compute derived data

/components

it contains all the components used in this app

Component Structure

__styled __: contains all the related styled component for a given component

__test __: test cases for a given component

About container and presentational components, in general, the rule of thumb is that i use index.js file to serve as the container for a given component, and all the remaining files under the same folder are presentational components

3. Form

The parameter form is rendered based on the parameter schema. Currently due to the time constraint, only support basic schema (one level object based) with limited fields.

Supported Schema format:

{
      "id": "XXX",
      "title": "XXX",
      "description": "XXX",
      "type": "object",
      "properties": {
        "XXX": {
          "type": "string",
          "enum": [
            "easy",
            "hard"
          ]
        },
        "XX": {
          "type": "number"
        }
      }
    }

Supported form fields:

  • Text,Number ===> input
  • Text/Number with enum ===> dropdown
  • boolean ===> checkbox

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.