1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Improvements to /mm

This commit is contained in:
Steffo 2019-02-10 16:55:47 +01:00
parent df1c30eca8
commit ccc1870915
6 changed files with 54 additions and 40 deletions

27
db.py
View file

@ -6,7 +6,7 @@ from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy import Column, BigInteger, Integer, String, DateTime, ForeignKey, Float, Enum, create_engine, \
UniqueConstraint, PrimaryKeyConstraint, Boolean, LargeBinary, Text, Date, func
UniqueConstraint, PrimaryKeyConstraint, Boolean, LargeBinary, Text, Date
from sqlalchemy.inspection import inspect
import requests
import errors
@ -14,11 +14,13 @@ from errors import NotFoundError, AlreadyExistingError, PrivateError
import re
import enum
import loldata
from dirty import Dirty, DirtyDelta
from utils.dirty import Dirty, DirtyDelta
import sql_queries
from flask import escape
import configparser
import typing
from utils import MatchmakingStatus
import strings
if typing.TYPE_CHECKING:
# noinspection PyPackageRequirements
from discord import User as DiscordUser
@ -1250,19 +1252,10 @@ class Match(Base):
plist = f"Giocatori{minimum}:\n"
ignore_count = 0
for player in player_list:
if player.status == MatchmakingStatus.READY:
icon = "🔵"
elif player.status == MatchmakingStatus.WAIT_FOR_ME:
icon = "🕒"
elif player.status == MatchmakingStatus.MAYBE:
icon = ""
elif player.status == MatchmakingStatus.SOMEONE_ELSE:
icon = "💬"
elif player.status == MatchmakingStatus.IGNORED:
icon = strings.MATCHMAKING.ENUM_TO_EMOJIS[player.status]
if player.status == MatchmakingStatus.IGNORED:
ignore_count += 1
continue
else:
continue
plist += f"{icon} {player.user.royal.username}\n"
if ignore_count:
ignored = f"❌ <i>{ignore_count} persone non sono interessate.</i>\n"
@ -1298,14 +1291,6 @@ class Match(Base):
}
class MatchmakingStatus(enum.IntEnum):
WAIT_FOR_ME = 1
READY = 2
MAYBE = 3
SOMEONE_ELSE = 4
IGNORED = -1
class MatchPartecipation(Base):
__tablename__ = "matchpartecipations"
__table_args__ = (PrimaryKeyConstraint("user_id", "match_id"),)

View file

@ -11,7 +11,7 @@ import telegram
import sys
import coloredlogs
import requests
from dirty import Dirty, DirtyDelta
from utils import Dirty, DirtyDelta
from sentry_sdk import configure_scope
logging.getLogger().disabled = True

View file

@ -1,4 +1,4 @@
from db import MatchmakingStatus
import utils
import dice
import typing
@ -118,28 +118,44 @@ class MARKOV:
# Matchmaking service strings
class MATCHMAKING:
TICKER_TEXT = {
"match_ready": "🔵 Hai detto che sei pronto per giocare!",
"match_wait_for_me": "🕒 Hai chiesto agli altri di aspettarti.",
"match_maybe": " Hai detto che forse ci sarai.",
"match_ignore": " Non hai intenzione di partecipare.",
"match_close": "🚩 Hai notificato tutti che la partita sta iniziando.",
"match_cancel": "🗑 Hai annullato la partita."
EMOJIS = {
"ready": "🔵",
"wait_for_me": "🕒",
"maybe": "",
"ignore": "",
"close": "🚩",
"cancel": "🗑"
}
GAME_START = {
MatchmakingStatus.READY: "🔵 Che <b>{match_title}</b> abbia inizio!",
MatchmakingStatus.WAIT_FOR_ME: "🕒 Sbrigati! <b>{match_title}</b> sta per iniziare!",
MatchmakingStatus.MAYBE: "❓ <b>{match_title}</b> sta iniziando. Se vuoi partecipare, fai in fretta!",
ENUM_TO_EMOJIS = {
utils.MatchmakingStatus.READY: EMOJIS["ready"],
utils.MatchmakingStatus.WAIT_FOR_ME: EMOJIS["wait_for_me"],
utils.MatchmakingStatus.MAYBE: EMOJIS["maybe"],
utils.MatchmakingStatus.IGNORED: EMOJIS["ignore"],
}
BUTTONS = {
"match_ready": "🔵 Sono pronto per iniziare!",
"match_wait_for_me": "🕒 Ci sarò, aspettatemi!",
"match_maybe": "❓ Forse vengo, se non ci sono fate senza di me.",
"match_ignore": "❌ Non ci sarò.",
"match_close": "🚩 ADMIN: Avvia la partita",
"match_cancel": "🗑 ADMIN: Annulla la partita"
"match_ready": f"{EMOJIS['ready']} Sono pronto per iniziare!",
"match_wait_for_me": f"{EMOJIS['wait_for_me']} Ci sarò, aspettatemi!",
"match_maybe": f"{EMOJIS['maybe']} Forse vengo, se non ci sono fate senza di me.",
"match_ignore": f"{EMOJIS['ignore']} Non ci sarò.",
"match_close": f"{EMOJIS['close']} ADMIN: Avvia la partita",
"match_cancel": f"{EMOJIS['cancel']} ADMIN: Annulla la partita"
}
TICKER_TEXT = {
"match_ready": f"{EMOJIS['ready']} Hai detto che sei pronto per giocare!",
"match_wait_for_me": f"{EMOJIS['wait_for_me']} Hai chiesto agli altri di aspettarti.",
"match_maybe": f"{EMOJIS['maybe']} Hai detto che forse ci sarai.",
"match_ignore": f"{EMOJIS['ignore']} Non hai intenzione di partecipare.",
"match_close": f"{EMOJIS['close']} Hai notificato tutti che la partita sta iniziando.",
"match_cancel": f"{EMOJIS['cancel']} Hai annullato la partita."
}
GAME_START = {
utils.MatchmakingStatus.READY: "🔵 Che <b>{match_title}</b> abbia inizio!",
utils.MatchmakingStatus.WAIT_FOR_ME: "🕒 Sbrigati! <b>{match_title}</b> sta per iniziare!",
utils.MatchmakingStatus.MAYBE: "❓ <b>{match_title}</b> sta iniziando. Se vuoi partecipare, fai in fretta!",
}
class ERRORS:

4
utils/__init__.py Normal file
View file

@ -0,0 +1,4 @@
from .dirty import Dirty, DirtyDelta
from .mmstatus import MatchmakingStatus
__all__ = ["Dirty", "DirtyDelta", "MatchmakingStatus"]

9
utils/mmstatus.py Normal file
View file

@ -0,0 +1,9 @@
import enum
class MatchmakingStatus(enum.IntEnum):
WAIT_FOR_ME = 1
READY = 2
MAYBE = 3
SOMEONE_ELSE = 4
IGNORED = -1