from django.db import models

class Blueprint(models.Model):
    name = models.CharField(max_length=30)

class MineBlueprint(models.Model):
    name = models.CharField(max_length=30, unique=True)
    max_output_rate = models.FloatField()
    output = models.IntegerField()
    max_capacity = models.FloatField()

    def __str__(self):
        return self.name

class FactoryBlueprint(models.Model):
    name = models.CharField(max_length=30, unique=True)
    max_output_rate = models.FloatField()
    output = models.IntegerField()
    max_capacity = models.FloatField()

    def __str__(self):
        return self.name

class ResourceType(models.Model):
    name = models.CharField(max_length=30, unique=True)
    requirements = models.ForeignKey('Resources', blank=True, null=True)

    def __str__(self):
        return self.name

class Mine(models.Model):
    name = models.CharField(max_length=30, unique=True)
    all_resources = models.ForeignKey('Resources')
    coordinates = models.ForeignKey('Coordinates')
    blueprint = models.IntegerField()
    production_level = models.FloatField()

    def __str__(self):
        return self.name

class Coordinates(models.Model):
    x = models.FloatField()
    y = models.FloatField()

class Resource(models.Model):
    amount = models.FloatField()
    resource_type = models.ForeignKey('ResourceType')

class Resources(models.Model):
    all_resources = models.ManyToManyField('Resource')
