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

View file

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

View file

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