1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00
This commit is contained in:
Steffo 2018-10-09 00:51:57 +02:00
parent 6065395e27
commit d99219a076
8 changed files with 55 additions and 13 deletions

11
cast.py
View file

@ -1,8 +1,9 @@
import random
import math
import db
def cast(spell_name: str, target_name: str, platform: str) -> str:
def cast(spell_name: str, target_name: str, platform: str, halloween_callback=None) -> str:
spell = spell_name.capitalize()
# Seed the rng with the spell name
# so that spells always deal the same damage
@ -38,6 +39,14 @@ def cast(spell_name: str, target_name: str, platform: str) -> str:
total *= crit
else:
crit_msg = ""
# HALLOWEEN
if total >= 800:
halloween_callback()
return "❇️ Ho lanciato <b>{spell}</b> su " \
f"<i>{target_name}</i>.\n" \
f"{crit_msg}" \
f"...ma non succede nulla."
# END
if platform == "telegram":
if dmg_dice == 10 and dmg_max == 100 and dmg_mod == 20:
return f"❇️‼️ Ho lanciato <b>{spell}</b> su " \

9
db.py
View file

@ -993,6 +993,15 @@ class Halloween(Base):
logging.debug(f"{self.royal.username} has obtained Moon A via LoL.")
else:
logging.debug(f"{self.royal.username} hasn't passed the LoL challenge yet.")
if self[3] is None:
# osu! sss
osu = session.query(Osu).join(Royal).filter_by(id=self.royal.id).one_or_none()
r = requests.get(f"https://osu.ppy.sh/api/get_scores"
f"?k={config['Osu!']['ppy_api_key']}&b=2038&u={osu.osu_id}")
j = r.json()
if len(j) > 0:
self[3] = datetime.datetime.now()
# If run as script, create all the tables in the db
if __name__ == "__main__":

View file

@ -1,16 +1,9 @@
import secrets
from flask import Flask, render_template, request, abort, redirect, url_for, Markup, escape, jsonify
from flask import session as fl_session
from flask import Flask, render_template, request, abort, redirect, url_for
from flask import g as fl_g
import db
import bcrypt
import configparser
import markdown2
import datetime
import telegram
import query_discord_music
import random
import re
from raven.contrib.flask import Sentry
app = Flask(__name__)

BIN
static/endgame.ogg Normal file

Binary file not shown.

View file

@ -4,6 +4,12 @@ body {
box-sizing: border-box;
}
#time-left {
font-family: monospace;
font-size: 110px;
color: grey;
}
.container {
max-width: 900px;
margin-left: auto;

View file

@ -68,8 +68,8 @@ def new_lol_rank(item: db.LeagueOfLegends):
def process():
while True:
logger.info("Pausing for 30 minutes.")
time.sleep(1800)
#logger.info("Pausing for 30 minutes.")
#time.sleep(1800)
session = db.Session()
logger.info("Now updating Halloween data.")
update_block(session, session.query(db.Halloween).all())

View file

@ -124,14 +124,30 @@ def cmd_cast(bot: Bot, update: Update):
session = db.Session()
# Find a target for the spell
target = random.sample(session.query(db.Telegram).all(), 1)[0]
# HALLOWEEN
caster = session.query(db.Telegram).filter_by(telegram_id=update.message.from_user.id).join(db.Royal).one_or_none()
def callback():
if caster is None:
return
nsession = db.Session()
halloween = nsession.query(db.Halloween).filter_by(royal=caster.royal).one_or_none()
if halloween is not None:
halloween[7] = datetime.datetime.now()
nsession.commit()
nsession.close()
# Close the session
session.close()
bot.send_message(update.message.chat.id, cast.cast(spell_name=spell,
# END
bot.send_message(update.message.chat.id, cast.cast(spell_name=spell, halloween_callback=callback,
target_name=target.username if target.username is not None
else target.first_name, platform="telegram"),
parse_mode="HTML")
@catch_and_report
def cmd_color(bot: Bot, update: Update):
bot.send_message(update.message.chat.id, "I am sorry, unknown error occured during working with your request,"

View file

@ -11,6 +11,7 @@
<script>
var username;
var user_id;
var sound = new Audio("{{ url_for('static', filename='endgame.ogg') }}");
function timer() {
let now = new Date().getTime();
@ -38,6 +39,8 @@
document.getElementsByName("user_id").forEach((item) => {
item.setAttribute("value", user_id);
})
sound.loop = true;
sound.play();
});
})
}
@ -107,6 +110,7 @@
it is rather dashing, isn't it?
</div>
{% elif loop.index == 4 %}
{# 1 #}
<h2>
uproot the evil
</h2>
@ -121,6 +125,7 @@
<input type="submit" value="this is my answer!">
</form>
{% elif loop.index == 5 %}
{# ghostbusters #}
<h2>
remove the ghosts
</h2>
@ -147,10 +152,14 @@
</form>
{% elif loop.index == 7 %}
<h2>
fire the magic
</h2>
<div class="description">
the ritual requires very strong magic.<br>
gather all your power, and hit someone with all of it.<br>
this magic talisman will absorb it if it's strong enough.<br>
<i>the talisman is made of white marble, and has "800+" engraved on it.</i>
</div>
{% endif %}
</div>