Giter Site home page Giter Site logo

py-game-models's Introduction

Game models

Read the guideline before starting.

Imagine you want to create a game using Django. You should create models for it first.

First task:

In db/models.py create the following models:

1. Race

Each player should choose a race to play, such as Elf, Dwarf, Human, or Ork. Race has the following fields:

  • name - a unique char field with the maximum length of 255 characters.
  • description - a text field, can be blank.

2. Skill

Each race has unique skills. Create a model Skill for them. Each skill has:

  • name - a unique char field with a maximum length of 255 characters.
  • bonus - a char field with a maximum length of 255 characters. This field describes what kind of bonus players can get from it.
  • race - a foreign key that points to the Race model. It shows which race has the corresponding skill.

3. Guild

The player has an opportunity to become a member of a guild. It has:

  • name - a unique char field with the maximum length of 255 characters.
  • description - a text field, can be blank.

4. Player model

And finally, a Player model. It should have the following fields:

  • nickname - a unique char field with a maximum length of 255 characters.
  • email - an email field with a maximum length of 255 characters.
  • bio - a char field with a maximum length of 255 characters. It stores a short description provided by a user about himself/herself.
  • race - a foreign key that points to the Race model and shows the race of the player.
  • guild - a foreign key that points to the Guild model and stores an id of the guild the player is a member of. Please note: player should not be deleted when the guild is deleted.
  • created_at - a DateTime field, that is set with the current time by default.

Second Task:

Implement function main() in main.py:

Read data about players from players.json and add the corresponding entries to the database. Note, that some guilds, races and skills are used for different players. Create only one instance for each guild, race and skill, do not copy them.

Note: You can check, if some record already exists using Model.objects.filter(some_field="data").exists() (returns True or False)

Note: Check your code using this checklist before pushing your solution.

py-game-models's People

Contributors

ivanramyk avatar danylott avatar abnormaltype avatar nattalli avatar y-havryliv 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.