from django.db import models
from players.choices import POSITION_CHOICES, TEAM_CHOICES

class Player(models.Model):
    player_id = models.CharField(max_length=10, primary_key=True)
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    position = models.CharField(max_length=3, choices=POSITION_CHOICES, blank=True, null=True)
    team = models.CharField(max_length=3, choices=TEAM_CHOICES, blank=True, null=True)
    hashtag = models.CharField(max_length=100, blank=True, null=True)
    depth_chart_position = models.CharField(blank=True, null=True)
    status = models.CharField(max_length=50, blank=True, null=True)
    sport = models.CharField(max_length=50, blank=True, null=True)
    fantasy_positions = models.JSONField(blank=True, null=True)
    number = models.CharField(blank=True, null=True)
    search_last_name = models.CharField(max_length=50, blank=True, null=True)
    injury_start_date = models.DateField(blank=True, null=True)
    weight = models.CharField(max_length=10, blank=True, null=True)
    practice_participation = models.CharField(max_length=50, blank=True, null=True)
    sportradar_id = models.CharField(max_length=50, blank=True, null=True)
    college = models.CharField(max_length=100, blank=True, null=True)
    fantasy_data_id = models.CharField(blank=True, null=True)
    injury_status = models.CharField(max_length=50, blank=True, null=True)
    height = models.CharField(max_length=10, blank=True, null=True)
    search_full_name = models.CharField(max_length=100, blank=True, null=True)
    age = models.CharField(blank=True, null=True)
    stats_id = models.CharField(max_length=50, blank=True, null=True)
    birth_country = models.CharField(max_length=50, blank=True, null=True)
    espn_id = models.CharField(max_length=50, blank=True, null=True)
    search_rank = models.CharField(blank=True, null=True)
    depth_chart_order = models.CharField(blank=True, null=True)
    years_exp = models.CharField(blank=True, null=True)
    rotowire_id = models.CharField(max_length=50, blank=True, null=True)
    rotoworld_id = models.CharField(blank=True, null=True)
    search_first_name = models.CharField(max_length=50, blank=True, null=True)
    yahoo_id = models.CharField(max_length=50, blank=True, null=True)

    def __str__(self):
        return f'{self.first_name} {self.last_name}'


class PlayerStats(models.Model):
    player = models.ForeignKey(Player, on_delete=models.CASCADE)
    season_year = models.IntegerField()
    week = models.IntegerField()
    pass_yards = models.IntegerField()
    pass_tds = models.IntegerField()
    rush_yards = models.IntegerField()
    rush_tds = models.IntegerField()
    receiving_yards = models.IntegerField()
    receiving_tds = models.IntegerField()
    receptions = models.IntegerField()
    fumbles = models.IntegerField()
    total_points = models.FloatField()