Giter Club home page Giter Club 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

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.