Code Monkey home page Code Monkey logo

onb's Introduction

Build Status

ONB - One dice Battles

One dice Battles is a miniature wargame system that aims to suport elaborate rules, but to be very simple to play, through the usage of pre-computed actions tests. Don't worry: you still have to roll a dice yourself, but only one. Creatures and entities are created inside the program, and the user can generate a simple 'action' card for each action and each pair of attacking creature / attacked creature. On this card is writed the dice player should roll and the bonus to apply. Then, when a player want to perform an attack, he only have to roll the dice, apply bonuses/maluses, and look in the game table of dammages how many damage he dealt to his opponent.

One dice to rule them all

Every game cards and tables should be printable in order to allow playing without any screen. Users should be able to choose their armies in the program, and/or create their own creatures, before printing all informations useful for the game, or use them directly in the program

Installation

Requirements

Install dependencies

  • Install pipenv packages
  • Install PostgreSQL and create 'onb' user with 'onb' password, and databases 'onb_dev', 'onb_testing' and 'onb_production'

Environment variables:

(You can put them into '.env')

  • DATABASE_URL
  • JWT_SECRET_KEY
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Usage

You can run a script in the projet with:

./run.sh <script_name>

Scripts:

  • main.py (default entry point)
  • sqldb/generateDb.py

You can also run tests:

./runTests.sh

Or start the development server:

./startDevApi.sh

For local development with 'dev', you must:

  • Have a working postgresql server
  • Create tables with ./run.sh sqldb/generateDb.sh
  • Launch a local instance of dynamoDB on port 8000 (with java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb)

API

Development API can be accessed at http://127.0.0.1:5000

The API has a swagger specification on swaggerhub

Code specifications

| engine
	| models
		| [Game models files]
	| generator
		| [Game models geneators]
| sqldb
	| models
		| [Website models]
| api
	| common
		| [Common API code]
	| ressources
		| [API endpoints]
| tests
	| [Test files, following the same organization as the global one]

Sql models for game objects are automaticly created Game model name format: camelCase name, must end with 'model'. Ex: CreatureModel ; MyWeaponModel

Game model class definitions: (engine/models)

class MyModelTypeModel(BaseGameModel):
	"""
	model identifier will be 'my_model_type'
	Any game models must inherit 'GameEntityModel'
	"""
	def getFields():
		"""
		Return all fields present in the model
		Fields are automaticly inherited
		
		Optional fields attributes:
		- default [default :None] defines the default field value
		- min [default: None] defines the minimum accepted value / minimum string size
		- max [default: None] defines the maximum accepted value / maximum string size
		- values [default: [] ] defines a list of accepted values (ignored if empty)
		- generated [default: False] Tell the value is generated, the users will be dissuaded to change it's value
		"""
		return {
			'my_int_field_name': IntField(),
			'my_bool_field_name': BoolField(),
			'my_string_field_name': StringField(),
			'my_float_field_name': FloatField(),
			
			'my_submodel_field': ClassField('model_identifier'),
			'my_list_field': ListField('stored_model_type_identifier'), # List of models (shortcut for below)
			'my_list_field': ListField(<field object>), # List of fields <field object>
			'my_int_list': ListField(IntField(min=3)), # Example of a list of int values
			
			'my_foreign_key_field': ForeignKeyField('modle_id'), # Store an id to reference a model stored in db
			'my_2nd_foreign_key_field': ForeignKeyField('modle_id', default='modle_id'), # Fill with a model
		}
	
	storable = True # [default=False] If the property is set to True, a new table will be created in the database in order to store this models. Otherwise, this model can still be stored in an other model's field
	exposedFields = ['<field_name>',' <field_name>'] # Fields that will be copied in the databse entry, in order to easily retrieve the model
	

Models tables can store the model and any model that inherit it Model identifiers are created by taking the model class without the ending 'Model', and separating word with '_'. All letters are lowercase. For instance, **'MyVikingCharacterModel' **identifer will be 'my_viking_character'

Code

  • Tabulations are used instead of spaces
  • Names must be in camelCase format,
  • Game models properties and sql model fields use lowercase letters and underscores

onb's People

Contributors

webalorn avatar

Watchers

 avatar  avatar

onb's Issues

Sql models

  • Automatic load of linked game model
  • foreign key -> integration with linked models
  • ._modelObj -> .model
  • Automatic generation when models saved

Get game models schemas

  • GET /model/<model_name>/schemas must return the schema of the model, all submodels, and models that inherit from the main model or sub-models
  • Remove 'schema' from GET /model/<model_name>/

Create API endpoints

  • Game models (Units, universes)
  • Game play models (Army, Battle)
  • User (logged, anonymous, claim account, change password)
  • User settings
  • User profile
  • Friends
  • Search user
  • Search in models
  • News system

  • Dynamic i18n
  • Messaging system
  • Image upload

  • Generated models

REST API

  • Flask
  • Flask RESTful
  • Peewee integration

Create/Update models

  • Model description in 'model' field, optional
  • Allow update of 'is_public'
  • Allow update of 'is_official' for admins

Export model

  • Export fields types and restrictions
  • Export/Do not export generated fields
  • Store generated fields, but not foreign keys fields

i18n endpoints

  • POST /i18n
  • GET /i18n/{lang}
  • GET /i18n/{lang}/{id}
  • PUT /i18n/{lang}/{id}
  • PUT /i18n/key/{id}

Add more models filters

  • Filter by owner
  • Filter by public only (do not show user private models)
  • Filter by exposed property
  • Filter by creation date
  • Set max pagination value to 100, min to 1

Battles endpoints

  • POST /battle
  • GET /battle/{id}
  • DELETE /battle/{id}
  • PUT /battle/{id}
  • PUT /battle/{id}/user/{id}
  • DELETE /battle/{id}/user/{id}
  • GET /battle/{id}/armies
  • POST /battle/{id}/armies
  • GET /army/{id}
  • PUT /army/{id}
  • DELETE /army/{id}
  • PUT /army/{id}/unit/{unit_id}
  • DELETE /army/{id}/unit/{unit_id}

And add endpoints to get all battles of a player (owned and invited to)

User API endpoints

  • GET /user/auth
  • DELETE /user/auth
  • GET /user/{id}
  • GET /user
  • POST /user
  • PUT /user
  • POST /user/auth
  • GET /user/anonymous
  • POST /user/anonymous
  • GET /user/username_available
  • Add tests

API endpoints documentation

Create a swagger documentation file with the specification of the whole API

  • Game models (Units, universes)
  • Game play models (Army, Battle)
  • User (logged, anonymous, claim account, change password)
  • User settings
  • User profile
  • Friends
  • Search user
  • Search in models
  • Dynamic i12n
  • Messaging system
  • News system
  • Image upload

Add roles

  • Normal user
  • Anonymous user
  • Admin user

Create role-based access system

Create i12n system

  • Secify 'lang' in request body (for game models and news) to automaticly convert 'i12n:' texts into translated text (or text in english if the translation was not found)
  • Create i12n models and tables

Migrations

Add a peewee module to support migrations

i18n engine

i18n parameters:

  • id [a-zA-Z0-9_]
  • lang
  • user_id
    Stored values:
  • key = id:user_id:lang
  • translation

Functions

  • Get translations
  • Create a new translation
  • Delete a translation

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.