change wholesome award to emoji award

pull/211/head
Aevann 2023-10-04 16:05:43 +03:00
parent b24be481d7
commit 7fced29fba
11 changed files with 122 additions and 87 deletions

View File

@ -9,8 +9,7 @@
position: absolute;
}
.stackable-container div,
.stackable-container img, .ricardo {
.stackable-container div, .stackable-container img, .ricardo {
animation-iteration-count: infinite !important;
animation-timing-function: linear !important;
}
@ -19,7 +18,7 @@
width: min(7vw, 50px) !important;
}
.wholesome img {
.emoji-award img {
width: min(8vw, 60px) !important;
}
@ -28,16 +27,14 @@
}
.emoji-award:nth-child(even), .emoji-award:nth-child(n+2):nth-child(n+3) img {
animation-direction: alternate-reverse;
}
.wholesome:nth-child(even),
.wholesome:nth-child(n+2):nth-child(n+3) img
{animation-direction: alternate-reverse}
@keyframes sealX {
@keyframes emojiX {
100% {transform: translateX(98vw)}
}
@keyframes sealY {
@keyframes emojiY {
100% {transform: translateY(80vh)}
}
@ -57,14 +54,27 @@
.scooter:nth-child(even) {animation-direction: reverse;}
.scooter:nth-child(even) img {transform: scaleX(-1);}
.wholesome {animation: sealX 8s alternate}
.wholesome img {animation: sealY 9s alternate}
.train, .scooter {animation: train 12s;}
.emoji-award {
animation: emojiX 8s alternate;
}
.emoji-award img {
animation: emojiY 9s alternate;
}
.train, .scooter {
animation: train 12s;
}
@media (max-width: 768px) {
.wholesome {animation: sealX 6s alternate}
.wholesome img {animation: sealY 7s alternate}
.train, .scooter {animation: train 6s;}
.emoji-award {
animation: emojiX 6s alternate;
}
.emoji-award img {
animation: emojiY 7s alternate;
}
.train, .scooter {
animation: train 6s;
}
}
/*confetti*/

View File

@ -137,6 +137,11 @@ function pick(kind, price, coins, marseybux) {
document.getElementById('note').placeholder = "Insert new username here, or leave empty to add 1 day to the duration of the current username.";
document.getElementById('note').maxLength = 25;
}
else if (kind == "emoji") {
document.getElementById('notelabel').innerHTML = "Emoji name:";
document.getElementById('note').placeholder = "Insert one site emoji here.";
document.getElementById('note').maxLength = 33;
}
else {
document.getElementById('notelabel').innerHTML = "Note (optional):";
document.getElementById('note').placeholder = "Note to include in award notification";

View File

@ -20,6 +20,7 @@ class AwardRelationship(Base):
awarded_utc = Column(Integer)
created_utc = Column(Integer)
price_paid = Column(Integer, default = 0, nullable=False)
note = Column(String)
user = relationship("User", primaryjoin="AwardRelationship.user_id==User.id", back_populates="awards")
post = relationship("Post", primaryjoin="AwardRelationship.post_id==Post.id", back_populates="awards")

View File

@ -314,6 +314,11 @@ class Comment(Base):
def award_count(self, kind, v):
return len([x for x in self.awards if x.kind == kind])
@property
@lazy
def emoji_award_emojis(self):
return [x.note for x in self.awards if x.kind == "emoji"]
@property
@lazy
def json(self):

View File

@ -262,6 +262,11 @@ class Post(Base):
return 4
return num
@property
@lazy
def emoji_award_emojis(self):
return [x.note for x in self.awards if x.kind == "emoji"]
@lazy
def realurl(self, v):
url = self.url

View File

@ -211,19 +211,6 @@ AWARDS = {
"enabled": IS_HOMOWEEN(),
"positive": True,
},
"pumpkin": {
"kind": "pumpkin",
"title": "Pumpkin",
"description": "",
"icon": "fas fa-jack-o-lantern",
"color": "text-orange",
"price": 200,
"deflectable": False,
"cosmetic": True,
"ghost": True,
"enabled": IS_HOMOWEEN(),
"positive": True,
},
"candy-corn": {
"kind": "candy-corn",
"title": "Candy Corn",
@ -476,10 +463,10 @@ AWARDS = {
"enabled": True,
"positive": True,
},
"wholesome": {
"kind": "wholesome",
"title": "Wholesome",
"description": "Summons a wholesome marsey on the post.",
"emoji": {
"kind": "emoji",
"title": "Emoji",
"description": "Summons a bouncing emoji on the post.",
"icon": "fas fa-smile-beam",
"color": "text-yellow",
"price": 300,

View File

@ -177,7 +177,8 @@ def award_thing(v, thing_type, id):
g.db.add(award)
note = request.values.get("note", "").strip()
note = request.values.get("note", "").strip()[:200]
award.note = note
safe_username = f"@{thing.author_name} is"
@ -554,50 +555,56 @@ def award_thing(v, thing_type, id):
if thing_type == 'comment' and (not thing.author.deflector or v == thing.author):
thing.rainbowed = True
g.db.add(thing)
elif kind == "spider":
if author.spider: author.spider += 86400
else: author.spider = int(time.time()) + 86400
badge_grant(user=author, badge_id=179, notify=False)
elif kind == "grinch":
badge_grant(badge_id=91, user=author)
elif kind == "hw-grinch":
badge_grant(badge_id=185, user=author)
elif kind == "bite":
if author.zombie < 0:
author = v
elif kind == "emoji":
award.note = award.note.strip(":").lower()
emoji = g.db.query(Emoji).filter_by(name=award.note).one_or_none()
if not emoji:
abort(404, f'an Emoji with the name "{award.note}" was not found!')
elif IS_HOMOWEEN():
if kind == "spider":
if author.spider: author.spider += 86400
else: author.spider = int(time.time()) + 86400
badge_grant(user=author, badge_id=179, notify=False)
elif kind == "grinch":
badge_grant(badge_id=91, user=author)
elif kind == "hw-grinch":
badge_grant(badge_id=185, user=author)
elif kind == "bite":
if author.zombie < 0:
author = v
if author.zombie == 0:
author.zombie = -1
badge_grant(user=author, badge_id=181)
award_object = AwardRelationship(user_id=author.id, kind='bite')
g.db.add(award_object)
send_repeatable_notification(author.id,
"As the zombie virus washes over your mind, you feel the urge "
"to… BITE YUMMY BRAINS :marseyzombie:<br>"
"You receive a free **Zombie Bite** award: pass it on!")
elif author.zombie > 0:
author.zombie -= 1
if author.zombie == 0:
send_repeatable_notification(author.id, "You are no longer **VAXXMAXXED**! Time for another booster!")
author.zombie = -1
badge_grant(user=author, badge_id=181)
badge = author.has_badge(182)
award_object = AwardRelationship(user_id=author.id, kind='bite')
g.db.add(award_object)
send_repeatable_notification(author.id,
"As the zombie virus washes over your mind, you feel the urge "
"to… BITE YUMMY BRAINS :marseyzombie:<br>"
"You receive a free **Zombie Bite** award: pass it on!")
elif author.zombie > 0:
author.zombie -= 1
if author.zombie == 0:
send_repeatable_notification(author.id, "You are no longer **VAXXMAXXED**! Time for another booster!")
badge = author.has_badge(182)
if badge: g.db.delete(badge)
elif kind == "vax":
if author.zombie < 0:
author.zombie = 0
send_repeatable_notification(author.id, "You are no longer **INFECTED**! Praise Fauci!")
badge = author.has_badge(181)
if badge: g.db.delete(badge)
elif kind == "vax":
if author.zombie < 0:
author.zombie = 0
send_repeatable_notification(author.id, "You are no longer **INFECTED**! Praise Fauci!")
elif author.zombie >= 0:
author.zombie += 2
author.zombie = min(author.zombie, 10)
badge = author.has_badge(181)
if badge: g.db.delete(badge)
elif author.zombie >= 0:
author.zombie += 2
author.zombie = min(author.zombie, 10)
badge_grant(user=author, badge_id=182)
elif kind == "jumpscare":
author.jumpscare += 1
badge_grant(user=author, badge_id=182)
elif kind == "jumpscare":
author.jumpscare += 1
if author.received_award_count: author.received_award_count += 1

View File

@ -1,21 +1,24 @@
<div id="awards-container" class="w-100 h-100">
{% macro stackable_award(award, src, alt) %}
<div class="stackable-container">
{% for i in range(p.award_count(award, v)) %}
<div class="{{award}}">
<img loading="lazy" alt="{{alt}}" src="{{src}}">
</div>
{% endfor %}
{% for i in range(p.award_count(award, v)) %}
<div class="{{award}}">
<img loading="lazy" alt="{{alt}}" src="{{src}}">
</div>
{% endfor %}
</div>
{% endmacro %}
{% if p.award_count("wholesome", v) %}
{% if IS_HOMOWEEN() %}
{% set wholesome = '/e/marseypumpkin.webp' %}
{% else %}
{% set wholesome = '/e/marseywholesome.webp' %}
{% endif %}
{{stackable_award('wholesome', wholesome, ':#marseywholesome:')}}
{% if p.award_count("emoji", v) %}
<div class="stackable-container">
{% for emoji in p.emoji_award_emojis %}
{% set src = '/e/' + emoji + '.webp' %}
{% set alt = ':#' + emoji + ':' %}
<div class="emoji-award">
<img loading="lazy" alt="{{alt}}" src="{{src}}">
</div>
{% endfor %}
</div>
{% endif %}
{% if p.award_count("train", v) %}

View File

@ -116,7 +116,11 @@
<span class="comment-collapse-icon" data-nonce="{{g.nonce}}" data-onclick="collapse_comment('{{c.id}}')"></span>
{% for a in c.awards %}
<i class="{{a.class_list}} px-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}"></i>
{% if a.kind == "emoji" %}
<img alt="{{a.title}} Award given by @{{a.user.username}}" data-bs-toggle="tooltip" loading="lazy" src="{{SITE_FULL_IMAGES}}/e/{{a.note}}.webp" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}" width="20px">
{% else %}
<i class="{{a.class_list}} px-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}"></i>
{% endif %}
{% endfor %}
{% if c.parent_post %}

View File

@ -30,7 +30,11 @@
{% endif %}
{% for a in p.awards %}
<i class="{{a.class_list}} px-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}"></i>
{% if a.kind == "emoji" %}
<img alt="{{a.title}} Award given by @{{a.user.username}}" data-bs-toggle="tooltip" loading="lazy" src="{{SITE_FULL_IMAGES}}/e/{{a.note}}.webp" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}" width="20px">
{% else %}
<i class="{{a.class_list}} px-1" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{a.title}} Award given by @{{a.user.username}}"></i>
{% endif %}
{% endfor %}
{% if v and v.admin_level >= PERMS['USER_SHADOWBAN'] and p.author.shadowbanned %}

View File

@ -0,0 +1,4 @@
alter table award_relationships add column note varchar(200);
update award_relationships set kind='emoji', note='marseywholesome' where kind='wholesome';
update award_relationships set kind='emoji', note='marseypumpkin' where kind='pumpkin';