# Path: srs/models.py
# class Allyteam(models.Model):
#     numallies = models.IntegerField()
#     startrectbottom = models.FloatField(blank=True, null=True)
#     startrectleft = models.FloatField(blank=True, null=True)
#     startrectright = models.FloatField(blank=True, null=True)
#     startrecttop = models.FloatField(blank=True, null=True)
#     winner = models.BooleanField(default=False)
#     replay = models.ForeignKey(Replay, on_delete=CASCADE)
#     num = models.SmallIntegerField()
# 
#     def __unicode__(self):
#         return "Allyteam({}) win:{}".format(self.id, self.winner)
# 
# class Player(models.Model):
#     account = models.ForeignKey(PlayerAccount, blank=True, null=True, on_delete=CASCADE)
#     name = models.CharField(max_length=128, db_index=True)
#     rank = models.SmallIntegerField()
#     skill = models.CharField(max_length=16, blank=True)
#     skilluncertainty = models.SmallIntegerField(default=-1, blank=True)
#     spectator = models.BooleanField(default=False)
#     team = models.ForeignKey("Team", blank=True, null=True, on_delete=CASCADE)
#     replay = models.ForeignKey(Replay, on_delete=CASCADE)
#     startposx = models.FloatField(blank=True, null=True)
#     startposy = models.FloatField(blank=True, null=True)
#     startposz = models.FloatField(blank=True, null=True)
# 
#     def __unicode__(self):
#         return "Player({}, {})".format(self.id, self.name)
# 
#     def get_absolute_url(self):
#         return reverse("srs/player", args=[self.account.accountid])
# 
#     class Meta:
#         ordering = ["name"]


import json
import logging
import pprint
import random
import sys
import urllib.parse
import urllib.request
import requests
from os.path import exists as path_exists, join as path_join
from shutil import copyfile
from django.conf import settings
from PIL import Image, ImageColor, ImageDraw, ImageFont
from .models import Allyteam, Player
                    (
                        int(at.startrectright * full_img_x) - int(at.startrectleft * full_img_x),
                        int(at.startrectbottom * full_img_y) - int(at.startrecttop * full_img_y),
                    ),
                    (256, 256, 256, 96),
                )
                # draw border of box (no transparency)
                draw = ImageDraw.Draw(team_layer)
                tl_x, tl_y = team_layer.size
                for i in range(4):  # 4px border
                    draw.rectangle(
                        [(0 + i, 0 + i), (tl_x - i, tl_y - i)],
                        fill=None,
                        outline=(256, 256, 256, 256),
                    )
                del draw
                # overlay map with partly transparent box
                img.paste(
                    colors[c_count],
                    box=(
                        int(at.startrectleft * full_img_x),
                        int(at.startrecttop * full_img_y),
                        int(at.startrectright * full_img_x),
                        int(at.startrectbottom * full_img_y),
                    ),
                    mask=team_layer,
                )
                c_count += 1

        draw = ImageDraw.Draw(img)

# Path: srs/models.py
# class Allyteam(models.Model):
#     numallies = models.IntegerField()
#     startrectbottom = models.FloatField(blank=True, null=True)
#     startrectleft = models.FloatField(blank=True, null=True)
#     startrectright = models.FloatField(blank=True, null=True)
#     startrecttop = models.FloatField(blank=True, null=True)
#     winner = models.BooleanField(default=False)
#     replay = models.ForeignKey(Replay, on_delete=CASCADE)
#     num = models.SmallIntegerField()
# 
#     def __unicode__(self):
#         return "Allyteam({}) win:{}".format(self.id, self.winner)
# 
# class Player(models.Model):
#     account = models.ForeignKey(PlayerAccount, blank=True, null=True, on_delete=CASCADE)
#     name = models.CharField(max_length=128, db_index=True)
#     rank = models.SmallIntegerField()
#     skill = models.CharField(max_length=16, blank=True)
#     skilluncertainty = models.SmallIntegerField(default=-1, blank=True)
#     spectator = models.BooleanField(default=False)
#     team = models.ForeignKey("Team", blank=True, null=True, on_delete=CASCADE)
#     replay = models.ForeignKey(Replay, on_delete=CASCADE)
#     startposx = models.FloatField(blank=True, null=True)
#     startposy = models.FloatField(blank=True, null=True)
#     startposz = models.FloatField(blank=True, null=True)
# 
#     def __unicode__(self):
#         return "Player({}, {})".format(self.id, self.name)
# 
#     def get_absolute_url(self):
#         return reverse("srs/player", args=[self.account.accountid])
# 
#     class Meta:
#         ordering = ["name"]


# Path: srs/springmaps.py
import json
import logging
import pprint
import random
import sys
import urllib.parse
import urllib.request
import requests
from os.path import exists as path_exists, join as path_join
from shutil import copyfile
from django.conf import settings
from PIL import Image, ImageColor, ImageDraw, ImageFont
from .models import Allyteam, Player

                    (
                        int(at.startrectright * full_img_x) - int(at.startrectleft * full_img_x),
                        int(at.startrectbottom * full_img_y) - int(at.startrecttop * full_img_y),
                    ),
                    (256, 256, 256, 96),
                )
                # draw border of box (no transparency)
                draw = ImageDraw.Draw(team_layer)
                tl_x, tl_y = team_layer.size
                for i in range(4):  # 4px border
                    draw.rectangle(
                        [(0 + i, 0 + i), (tl_x - i, tl_y - i)],
                        fill=None,
                        outline=(256, 256, 256, 256),
                    )
                del draw
                # overlay map with partly transparent box
                img.paste(
                    colors[c_count],
                    box=(
                        int(at.startrectleft * full_img_x),
                        int(at.startrecttop * full_img_y),
                        int(at.startrectright * full_img_x),
                        int(at.startrectbottom * full_img_y),
                    ),
                    mask=team_layer,
                )
                c_count += 1

        draw = ImageDraw.Draw(img)

        players = Player.objects.filter(