S
S
Sanya Hihi Haha2020-05-08 15:42:52
Django
Sanya Hihi Haha, 2020-05-08 15:42:52

How to organize such a system?

Good day, citizens
Give me a kick so that I understand which way to dig

Actually the question
There is a text rpg on django

There is a hero in the game he has items of equipment, indicators, etc.

I want to make an "arena" - the arena is available for a certain amount of time Let's say 2 hours. There the player fought with others for 2 hours and the arena was closed to everyone.

My thoughts, create a table with fields
1. arena_exp_time (end time)
2. arena_user_id (link to the user (OneToOne) who entered it)
3. user_win_count (number of wins in this arena in 2 hours)

But that's not the problem, say, if there are 5 such arenas per day? to create on 5 tables for everyone? No, I think it's complete nonsense.

What to read to implement this?
Thanks to

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2020-05-08
@ValarMayar

What's the problem with organizing something like this?

class Arena(models.Model):
    exp_time = models.DateTimeField(...
    win_count = models.PositiveIntegerField(default=0, ...
    ...

class ArenaUser(models.Model):
    arena = models.ForeignKey(Arena,...
    user = models.ForeignKey(User,...
    ...

or
class Arena(models.Model):
    exp_time = models.DateTimeField(...
    win_count = models.PositiveIntegerField(default=0, ...
    users = models.ManyToManyField(User,...
    ...

D
Dimonchik, 2020-05-08
@dimonchik2013

read about models and relationships many-to-many or one-to-many, depending on how you organize

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question