Skip to main content

Base models and API for Django-based simulations.

Project description

Base models and API for Django-based simulations.

Provides an API compatible with the Wharton Interactive marketplace.

Getting Started

Install simpl-cloud, with the API extras if required:

pip install simpl-cloud[api]

Add simpl to your project’s Django settings module, along with the following settings:

INSTALLED_APPS = {
    # ...
    'simpl',
}
SIMPL_GAME_EXPERIENCE = "simpl.GameExperience"
SIMPL_RUN = "simpl.Run"
SIMPL_INSTANCE = "simpl.Instance"
SIMPL_CHARACTER = "simpl.Character"
SIMPL_PLAYER = "simpl.Player"
SIMPL_LOGOUT_URL_NAME = "account_logout"

Add the following to your project’s URL conf:

urlpatterns = [
  # ...
  path("simpl/", include("simpl.urls")),
]

Architecture Overview

Run objects provide management and configuration of one or more game instances.

Launching game instances

When a player is added to a run, their details are stored in a Player object.

When they start playing your game, they will be attached to an Character object in a game Instance object that will track the progress of their game.

For multiplayer runs, these players will be initially grouped into Lobby object so they can be assigned to a game Instances. A lobby can be marked as ready once it is ready to start.

You can use Run.prepare to create new game Instance objects or manually create these.

Game play URL

The API uses a customizable url endpoint for players. You can specify this by using a custom Player model and overriding Player.get_play_url.

Alternatively, you can specify a SIMPL_GET_PLAY_URL in your settings as a dotted path to a function that receives a player instance and returns the correct url.

Run status

A run has the following statuses:

  • Set up (initial state, until any configuration options are provided)

  • Players prepare (optional step to if your game experience if players can interact with their Instance before gameplay starts)

  • Running (game Instances are running)

  • Debrief (optional step if your game experience provides a different interface after gameplay finishes)

Game Instance status

Each game Instance also has a status:

  • Preparing - waiting to start (Instance.date_start unset)

  • Playing - game in progress (Instance.date_start set but Instance.date_end unset)

  • Ended - game complete (Instance.date_end set)

Player status

Your app may mark a player as having completed the game (with a date).

Custom models

Extend the Simpl Django models by overriding the default classes in your project’s Django settings module:

  • Instance via SIMPL_INSTANCE = "your_app.YourInstance"

  • Character via SIMPL_CHARACTER = "your_app.YourCharacter"

  • GameExperience (only if your app provides multiple different game experiences) via SIMPL_GAME_EXPERIENCE = "your_app.YourGameExperience"

More rarely, you may also want to override the run and player:

  • Run via SIMPL_RUN = "your_app.YourRun"

  • Player via SIMPL_PLAYER = "your_app.YourPlayer"

Your overridden classes should subclass the related simpl.models.Base* abstract models.

The Character class will need two related abstract models, BaseCharacterData and BaseCharacterLinked. This is to make it possible to have character data as a template, not linked to a user or instance.

Auth0

If using Auth0 for social authentication, add the following Django settings to make sure users are correctly logged out of Auth0 and (optionally) redirected after logout:

ACCOUNT_ADAPTER = "simpl.auth0.Auth0LogoutAdapter"
AUTH0_LOGOUT_RETURN_TO = "some.url"

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpl-cloud-1.0.2.tar.gz (280.8 kB view details)

Uploaded Source

Built Distribution

simpl_cloud-1.0.2-py3-none-any.whl (302.3 kB view details)

Uploaded Python 3

File details

Details for the file simpl-cloud-1.0.2.tar.gz.

File metadata

  • Download URL: simpl-cloud-1.0.2.tar.gz
  • Upload date:
  • Size: 280.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.9

File hashes

Hashes for simpl-cloud-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7eb06055c8c98180a7901a0eb16d5d223669af021dc11d068d3c6d898c154194
MD5 f3be6f4bbf7fbe3088509e7d83721333
BLAKE2b-256 5c374938162d06e4e62acfd5f1a7e437d22adcb269a608aeca13cb1533cfc7a7

See more details on using hashes here.

File details

Details for the file simpl_cloud-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: simpl_cloud-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 302.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.9

File hashes

Hashes for simpl_cloud-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df4fb3563547adecece06263a39f7c4f9d585fa1ae2ceaffa5d7f6e77e742290
MD5 6d83a0a3459bc0f5627f327afc364408
BLAKE2b-256 e7b606a2a898592ecc92a3b6e974394bf1db9db5a26c0dd0b398acbe7ae24371

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page