Skip to content

Commit

Permalink
better random color things
Browse files Browse the repository at this point in the history
  • Loading branch information
catgirlinspace committed Nov 22, 2023
1 parent f9dd50b commit 95bed34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions splatnet_assets/templatetags/mask_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@ def mask_id(weapon_object: SubWeapon | SpecialWeapon):

random_color_options = [
Color.from_hex("cd43a6"),
Color.from_hex("e1820d"),
Color.from_hex("31c4a9"),
Color.from_hex("cdcd34"),
Color.from_hex("94c921"),
Color.from_hex("3a28c4"),
Color.from_hex("4e4edd"),
Color.from_hex("0d0ddc"),
Color.from_hex("b62ea7"),
Color.from_hex("5dab21"),
]


@register.simple_tag(takes_context=True)
def get_color(context, uploader: User, use_random_color: bool):
if context.get('color'):
return ''
user = context.get('user')
if uploader.sponsor_tiers[SponsorshipTiers.SPONSOR]:
context['color'] = uploader.favorite_color
Expand Down
2 changes: 2 additions & 0 deletions users/templates/users/includes/battle-card.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% load mask_id %}
{% load static %}
<a class="group hover:z-10 card-mask rounded-2xl {% if battle.vs_mode == "BANKARA" %}bg-splatoon-battle-ranked{% elif battle.vs_mode == "X_MATCH" %}bg-splatoon-battle-xmatch{% elif battle.vs_mode == "CHALLENGE" %}bg-splatoon-battle-league{% else %}bg-splatoon-battle-regular{% endif %} battle-card-background transition duration-200 hover:rotate-2 odd:hover:-rotate-2 drop-shadow-lg hover:drop-shadow-2xl {% if battle.judgement != "WIN" %}brightness-[0.80]{% endif %}"
href="{% url 'battles:view_battle' battle.id %}">
Expand Down Expand Up @@ -39,6 +40,7 @@
{% with player=battle.player %}
<img src="{{ player.weapon.flat_image.url }}?height=80&width=80" class="inline-block h-10 w-10" alt="">
{{ player.weapon.name.string }}
{% get_color uploader use_random_color %}
{% include "splatnet_assets/mask_image.html" with object=player.weapon.sub class="inline h-6 w-6" uploader=battle.uploader image_params="height=48&width=48" %}
{% include "splatnet_assets/mask_image.html" with object=player.weapon.special class="inline h-6 w-6" uploader=battle.uploader image_params="height=48&width=48" %}
{% endwith %}
Expand Down

0 comments on commit 95bed34

Please sign in to comment.