<commit_before>from __future__ import unicode_literals

from django.conf import settings

from django.db import models

from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class UserProfile(models.Model):
    """Define User Profile model"""
    user = models.OneToOneField(
        settings.AUTH_USER_MODEL,
        related_name="profile"
    )
    friends = models.ManyToManyField(
        "self",
        null=True,
        blank=True,
    )
    games = models.ManyTomanyField(
        "Game",
        related_name='player',
        null=True,
        Blank=True,
        db_index=True
    )
    date_created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        """Return string output of username."""
        return self.user.get_full_name() or self.username

    @property
    def is_active(self):
        """
        Return a boolean value indicating
        whether the profile's user is active.
        """
        return self._is_active


@python_2_unicode_compatible
class Game(models.Model):
    host = models.ForeignKey(
        user=settings.AUTH_USER_MODEL,
    )
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now=True)
    complete = models.BooleanField(default=False)
    winner = models.OneToOneField(
        settings.AUTH_USER_MODEL,
        null=True,
        default=None,
    )


@python_2_unicode_compatible
class Round(models.Model):
    game = models.ForeignKey(
        game=Game,
        default=0)
    mrx_loc = models.IntegerField(null=True)
    red_loc = models.IntegerField(null=True)
    yellow_loc = models.IntegerField(null=True)
    green_loc = models.IntegerField(null=True)
    blue_loc = models.IntegerField(null=True)
    purple_loc = models.IntegerField(null=True)

    def get_active_piece(self):
        """Return the piece (x, r, y, g, b, p) to move next"""
        pass

    def complete(self):
        """Return True if all rounds in field are truthy, else false."""
        pass<commit_msg>added turn_number() to Game, working on _piece_location().<commit_after>from __future__ import unicode_literals

from django.conf import settings

from django.db import models

from django.utils.encoding import python_2_unicode_compatible


@python_2_unicode_compatible
class UserProfile(models.Model):
    """Define User Profile model"""
    user = models.OneToOneField(
        settings.AUTH_USER_MODEL,
        related_name="profile"
    )
    friends = models.ManyToManyField(
        "self",
        null=True,
        blank=True,
    )
    games = models.ManyToManyField(
        "Game",
        related_name='player',
        null=True,
        blank=True,
        db_index=True
    )
    date_created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        """Return string output of username."""
        return self.user.get_full_name() or self.username

    @property
    def is_active(self):
        """
        Return a boolean value indicating
        whether the profile's user is active.
        """
        return self._is_active


@python_2_unicode_compatible
class Game(models.Model):
    host = models.ForeignKey(
        settings.AUTH_USER_MODEL,
    )
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now=True)
    complete = models.BooleanField(default=False)
    winner = models.OneToOneField(
        settings.AUTH_USER_MODEL,
        null=True,
        default=None,
        related_name="won"
    )

    def turn_number(self):
        return self.rounds.objects.count()

    def _piece_location(self, piece):
        """
        Accept a string with the name of the piece (color or mrx)xs
        and return the most recent location of a piece.
        """

        loc = "".join(piece, "_loc")
        qs = self.rounds.objects.only(loc)
        import pdb; pdb.set_trace()

    def __str__(self):
        """Return string output of username."""
        return self.id


@python_2_unicode_compatible
class Round(models.Model):
    game = models.ForeignKey(
        Game,
    )
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now=True)
    mrx_loc = models.IntegerField(null=True)
    red_loc = models.IntegerField(null=True)
    yellow_loc = models.IntegerField(null=True)
    green_loc = models.IntegerField(null=True)
    blue_loc = models.IntegerField(null=True)
    purple_loc = models.IntegerField(null=True)

    def __str__(self):
        """Return string output of username."""
        return "game: {}, turn: {}".format(self.game.id, self.id)

    def get_active_piece(self):
        """Return the piece (x, r, y, g, b, p) to move next"""
        pass

    def complete(self):
        """Return True if all rounds in field are truthy, else false."""
        pass
{'fraction_non_alphanumeric': 0.09807534807534808, 'fraction_numerical': 0.0018427518427518428, 'mean_word_length': 2.8343799058084773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1766567', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1441, 'n_words': 332}