mirror of
https://github.com/RYGhub/royal-mifia.git
synced 2025-02-16 13:24:06 +00:00
tante cose
This commit is contained in:
parent
6baee3005e
commit
2d1eb8b27e
2 changed files with 75 additions and 53 deletions
68
main.py
68
main.py
|
@ -67,8 +67,6 @@ class Game:
|
|||
self.configstep = 0 # Passo attuale di configurazione
|
||||
self.roleconfig = dict() # Dizionario con le quantità di ruoli da aggiungere
|
||||
self.votingmifia = False # Seguire le regole originali della mifia che vota?
|
||||
self.missingmifia = False # La mifia può fallire un'uccisione
|
||||
self.misschance = 5 # Percentuale di fallimento di un'uccisione
|
||||
|
||||
# Liste di ruoli in gioco, per velocizzare gli endday
|
||||
self.playersinrole = dict()
|
||||
|
@ -250,15 +248,10 @@ class Game:
|
|||
killed = killlist.pop()
|
||||
if killed.alive:
|
||||
if killed.protectedby is None:
|
||||
if self.missingmifia and random.randrange(0, 100) < self.misschance:
|
||||
# Colpo mancato
|
||||
self.message(bot, s.mifia_target_missed.format(target=killed.tusername))
|
||||
else:
|
||||
# Uccisione riuscita
|
||||
killed.kill(bot, self)
|
||||
self.message(bot, s.mifia_target_killed.format(target=killed.tusername,
|
||||
icon=killed.role.icon,
|
||||
role=killed.role.name))
|
||||
killed.kill(bot, self)
|
||||
self.message(bot, s.mifia_target_killed.format(target=killed.tusername,
|
||||
icon=killed.role.icon,
|
||||
role=killed.role.name))
|
||||
else:
|
||||
self.message(bot, s.mifia_target_protected.format(target=killed.tusername,
|
||||
icon=killed.protectedby.role.icon,
|
||||
|
@ -287,11 +280,11 @@ class Game:
|
|||
kbmarkup = InlineKeyboardMarkup([
|
||||
[
|
||||
InlineKeyboardButton(s.preset_simple, callback_data="simple"),
|
||||
InlineKeyboardButton(s.preset_classic, callback_data="classic"),
|
||||
InlineKeyboardButton(s.preset_advanced, callback_data="advanced")
|
||||
InlineKeyboardButton(s.preset_classic, callback_data="classic")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(s.preset_oneofall, callback_data="oneofall")
|
||||
InlineKeyboardButton(s.preset_oneofall, callback_data="oneofall"),
|
||||
InlineKeyboardButton(s.preset_advanced, callback_data="advanced")
|
||||
]
|
||||
])
|
||||
# Manda la tastiera
|
||||
|
@ -315,7 +308,6 @@ class Game:
|
|||
"Servitore": 0
|
||||
}
|
||||
self.votingmifia = True
|
||||
self.missingmifia = False
|
||||
self.message(bot, s.preset_simple_selected.format(mifioso=self.roleconfig["Mifioso"],
|
||||
investigatore=self.roleconfig["Investigatore"],
|
||||
royal=len(self.players) - self.roleconfig["Mifioso"] - self.roleconfig["Investigatore"]))
|
||||
|
@ -336,7 +328,6 @@ class Game:
|
|||
"Servitore": 0
|
||||
}
|
||||
self.votingmifia = True
|
||||
self.missingmifia = False
|
||||
self.message(bot, s.preset_classic_selected.format(mifioso=self.roleconfig["Mifioso"], investigatore=self.roleconfig["Investigatore"], angelo=self.roleconfig["Angelo"], royal=len(self.players) - self.roleconfig["Mifioso"] - self.roleconfig["Investigatore"] - self.roleconfig["Angelo"], royalmenouno=len(self.players) - self.roleconfig["Mifioso"] - self.roleconfig["Investigatore"] - self.roleconfig["Angelo"] - 1))
|
||||
self.endconfig(bot)
|
||||
elif preset == "advanced":
|
||||
|
@ -388,8 +379,16 @@ class Game:
|
|||
self.roleconfig["Servitore"] = 0
|
||||
# Altri parametri
|
||||
self.votingmifia = False
|
||||
self.missingmifia = False
|
||||
self.message(bot, s.preset_advanced_selected.format(balancescore=balance))
|
||||
if balance < -30:
|
||||
self.message(bot, s.preset_advanced_selected + s.balance_mifia_big)
|
||||
elif balance < -5:
|
||||
self.message(bot, s.preset_advanced_selected + s.balance_mifia_small)
|
||||
elif balance < 5:
|
||||
self.message(bot, s.preset_advanced_selected + s.balance_perfect)
|
||||
elif balance < 30:
|
||||
self.message(bot, s.preset_advanced_selected + s.balance_royal_small)
|
||||
else:
|
||||
self.message(bot, s.preset_advanced_selected + s.balance_royal_big)
|
||||
self.endconfig(bot)
|
||||
elif preset == "oneofall":
|
||||
self.roleconfig = {
|
||||
|
@ -416,7 +415,6 @@ class Game:
|
|||
self.roleconfig[availableroles.pop().__name__] += 1
|
||||
unassignedplayers -= 1
|
||||
self.votingmifia = False
|
||||
self.missingmifia = False
|
||||
self.message(bot, s.preset_oneofall_selected)
|
||||
self.endconfig(bot)
|
||||
|
||||
|
@ -436,6 +434,7 @@ class Game:
|
|||
self.phase = 'Voting'
|
||||
# self.updategroupname(bot)
|
||||
self.day += 1
|
||||
self.players.sort(key=lambda p: p.tusername)
|
||||
self.assignroles(bot)
|
||||
self.message(bot, s.roles_assigned_successfully)
|
||||
for player in self.players:
|
||||
|
@ -481,7 +480,7 @@ class Game:
|
|||
# Scrivi sul file.
|
||||
file = open("{group}-{yy}-{mm}-{dd}-{hh}-{mi}.p".format(group=str(self.groupid), yy=t.year, mm=t.month, dd=t.day, hh=t.hour, mi=t.minute), 'wb')
|
||||
pickle.dump(self, file)
|
||||
self.message(bot, s.game_saved)
|
||||
self.adminmessage(bot, s.game_saved.format(name=self.name))
|
||||
file.close()
|
||||
|
||||
def victoryconditions(self, bot):
|
||||
|
@ -505,7 +504,7 @@ class Game:
|
|||
self.endgame(bot)
|
||||
# I mifiosi sono più del 50% dei vivi se la mifia è infallibile
|
||||
# o non ci sono più personaggi buoni se la mifia può mancare i colpi
|
||||
elif (not self.missingmifia and evil >= (alive-evil)) or good == 0:
|
||||
elif evil >= (alive - evil) or good == 0:
|
||||
self.message(bot, s.end_mifia_outnumber + s.victory_mifia)
|
||||
for player in self.players:
|
||||
if player.role.team == 'Good':
|
||||
|
@ -540,18 +539,21 @@ class Game:
|
|||
player.message(bot, s.role_assigned.format(icon=player.role.icon, name=player.role.name))
|
||||
if player.role.powerdesc is not None:
|
||||
player.message(bot, player.role.powerdesc.format(gamename=self.name))
|
||||
# Aggiorna lo stato dei mifiosi
|
||||
if newrole == Mifioso:
|
||||
text = s.mifia_team_intro
|
||||
for player in self.playersinrole['Mifioso']:
|
||||
text += s.mifia_team_player.format(icon=player.role.icon, name=player.tusername)
|
||||
for player in self.playersinrole['Mifioso']:
|
||||
player.message(bot, text)
|
||||
# Manda ai mifiosi l'elenco dei loro compagni di squadra
|
||||
text = s.mifia_team_intro
|
||||
for player in self.playersinrole['Mifioso']:
|
||||
text += s.mifia_team_player.format(icon=player.role.icon, name=player.tusername)
|
||||
for player in self.playersinrole['Corrotto']:
|
||||
text += s.mifia_team_player.format(icon=player.role.icon, name=player.tusername)
|
||||
for player in self.playersinrole['Mifioso']:
|
||||
player.message(bot, text)
|
||||
for player in self.playersinrole['Corrotto']:
|
||||
player.message(bot, text)
|
||||
|
||||
def joinplayer(self, bot, player, silent=False):
|
||||
self.players.append(player)
|
||||
if not silent:
|
||||
self.message(bot, s.player_joined.format(name=player.tusername))
|
||||
self.message(bot, s.player_joined.format(name=player.tusername, players=len(self.players)))
|
||||
# Se è il primo giocatore ad unirsi, diventa admin
|
||||
if len(self.players) == 1:
|
||||
self.admin = player
|
||||
|
@ -596,7 +598,7 @@ def newgame(bot, update):
|
|||
if game is None:
|
||||
game = Game(update.message.chat.id)
|
||||
inprogress.append(game)
|
||||
game.message(bot, s.new_game.format(groupid=game.groupid, name=game.name))
|
||||
game.message(bot, s.new_game.format(name=game.name))
|
||||
join(bot, update)
|
||||
else:
|
||||
bot.sendMessage(update.message.chat.id, s.error_game_in_progress, parse_mode=ParseMode.MARKDOWN)
|
||||
|
@ -626,7 +628,7 @@ def join(bot, update):
|
|||
return
|
||||
p = Player(update.message.from_user.id, update.message.from_user.username)
|
||||
try:
|
||||
p.message(bot, s.you_joined.format(game=game.name))
|
||||
p.message(bot, s.you_joined.format(game=game.name, adminname=game.admin.tusername))
|
||||
except Unauthorized:
|
||||
# Bot bloccato dall'utente
|
||||
game.message(bot, s.error_chat_unavailable)
|
||||
|
@ -710,8 +712,10 @@ def vote(bot, update):
|
|||
# Genera la tastiera
|
||||
table = list()
|
||||
for player in game.players:
|
||||
if not player.alive:
|
||||
continue
|
||||
row = list()
|
||||
row.append(InlineKeyboardButton(s.vote_keyboard_line.format(name=player.tusername), callback_data=player.tusername))
|
||||
row.append(InlineKeyboardButton(s.vote_keyboard_line.format(name=player.tusername, votes=player.votes), callback_data=player.tusername))
|
||||
table.append(row)
|
||||
keyboard = InlineKeyboardMarkup(table)
|
||||
# Manda la tastiera
|
||||
|
|
60
strings.py
60
strings.py
|
@ -77,11 +77,11 @@ terrorist_power_description = "Puoi fare saltare in aria un sacco di persone!\n"
|
|||
"La mifia non sa chi sei, ma fai parte della squadra dei malvagi.\n"
|
||||
|
||||
# Terrorista: esplosione
|
||||
terrorist_kaboom = "Boom! Il terrorista si è fatto esplodere prima che poteste ucciderlo, mietendo vittime tra tutti" \
|
||||
terrorist_kaboom = "\U0001F4A3 *Boom!* Il terrorista si è fatto esplodere prima che poteste ucciderlo, mietendo vittime tra tutti" \
|
||||
" quelli che lo hanno votato!"
|
||||
|
||||
# Terrorista: bersaglio ucciso
|
||||
terrorist_target_killed = "Boom! @{target} è esploso!\n" \
|
||||
terrorist_target_killed = "\U0001F4A3 *Boom!* @{target} è morto a causa dell'esplosione!\n" \
|
||||
"Era un *{icon} {role}*."
|
||||
|
||||
# Derek: icona
|
||||
|
@ -92,7 +92,7 @@ derek_name = "Derek"
|
|||
|
||||
# Derek: descrizione del potere
|
||||
derek_power_description = "Puoi decidere di suicidarti alla fine di un round.\n" \
|
||||
"Potresti farlo per confondere le idee ai Royal, o per ragequittare malissimo.\n" \
|
||||
"Potresti farlo per confondere le idee ai Royal, o per ragequittare con stile.\n" \
|
||||
"Sta a te la scelta.\n" \
|
||||
"Per lasciare questo mondo alla fine del giorno, scrivi in questa chat:\n" \
|
||||
"`/power {gamename} banana`\n"
|
||||
|
@ -104,7 +104,7 @@ derek_deathwish_set = "*Morirai* alla fine di questo giorno."
|
|||
derek_deathwish_unset = "*Vivrai* per morire un altro giorno."
|
||||
|
||||
# Derek: morte
|
||||
derek_deathwish_successful = "SPOILER: alla fine di questa giornata *\U0001F635 Derek* (@{name}) muore schiacciato da un container.\n"
|
||||
derek_deathwish_successful = "*SPOILER:* alla fine di questo giorno *\U0001F635 Derek Shepard* (@{name}) è morto schiacciato da un container.\n"
|
||||
|
||||
# Disastro: icona
|
||||
disaster_icon = "\U0001F46E"
|
||||
|
@ -176,7 +176,7 @@ chaos_lord_power_description = "Sei il *SIGNORE DEL CAOS*!\n" \
|
|||
"`/power {gamename} nomeutentebersaglio`"
|
||||
|
||||
# Signore del Caos: bersaglio selezionato
|
||||
chaos_lord_target_selected = "BWHAHAHA. Hai deciso di usare i tuoi poteri del Caos su {target}."
|
||||
chaos_lord_target_selected = "BWHAHAHA. Hai deciso di usare i tuoi poteri del Caos su @{target}."
|
||||
|
||||
# Signore del Caos: bersaglio randomizzato
|
||||
chaos_lord_randomized = "Il Caos è nell'aria...\n" \
|
||||
|
@ -184,7 +184,7 @@ chaos_lord_randomized = "Il Caos è nell'aria...\n" \
|
|||
|
||||
# Signore del Caos: randomizzazione fallita
|
||||
chaos_lord_failed = "Il Caos è nell'aria...\n" \
|
||||
"_Ma non succede nulla._"
|
||||
"_Ma non è successo nulla!?_"
|
||||
|
||||
# Servitore del Caos: nome ruolo
|
||||
chaos_servant_name = "Servitore del Caos"
|
||||
|
@ -211,14 +211,15 @@ no_players_lynched = "La Royal Games non è giunta a una decisione in questo gio
|
|||
|
||||
# Generale: partita creata
|
||||
new_game = "E' stata creata una nuova partita in questo gruppo.\n" \
|
||||
"*ID:* {groupid}\n" \
|
||||
"*Nome:* {name}"
|
||||
|
||||
# Generale: un giocatore si è unito
|
||||
player_joined = "@{name} si è unito alla partita!"
|
||||
player_joined = "@{name} si è unito alla partita!\n" \
|
||||
"Adesso ci sono {players} giocatori in partita."
|
||||
|
||||
# Generale: ti sei unito alla partita, in chat privata
|
||||
you_joined = "Ti sei unito alla partita _{game}_!"
|
||||
you_joined = "Ti sei unito alla partita _{game}_!\n" \
|
||||
"Il ruolo ti verrà assegnato appena @{adminname} chiuderà le iscrizioni."
|
||||
|
||||
# Generale: fine della fase di join
|
||||
join_phase_ended = "La fase di join è terminata."
|
||||
|
@ -248,7 +249,7 @@ check_private = "Messaggio inviato in chat privata.\n" \
|
|||
"Controlla @mifiabot."
|
||||
|
||||
# Generale: partita salvata
|
||||
game_saved = "Partita salvata su file."
|
||||
game_saved = "Partita _{name}_ salvata su file."
|
||||
|
||||
# Generale: partita caricata
|
||||
game_loaded = "Partita caricata da file."
|
||||
|
@ -273,16 +274,16 @@ end_game_chaos = "Sei un Signore del Caos."
|
|||
vote_keyboard = "Chi vuoi votare...?"
|
||||
|
||||
# Generale: riga della tastiera del voto
|
||||
vote_keyboard_line = "@{name}"
|
||||
vote_keyboard_line = "@{name} - {votes}"
|
||||
|
||||
# Generale: inizia un nuovo giorno
|
||||
new_day = "Sorge l'alba del giorno **{day}**!"
|
||||
new_day = "Sorge l'alba del giorno *{day}*!"
|
||||
|
||||
# Vittoria: team Royal
|
||||
victory_royal = "**La Royal Games vince!**"
|
||||
victory_royal = "*La Royal Games vince!*"
|
||||
|
||||
# Vittoria: team Mifia
|
||||
victory_mifia = "**La Mifia vince!**"
|
||||
victory_mifia = "*La Mifia vince!*"
|
||||
|
||||
# Vittoria!
|
||||
victory = "*Hai vinto!*"
|
||||
|
@ -366,7 +367,7 @@ error_chat_unavailable = "\U000026A0 Non hai mai scritto un messaggio in chat pr
|
|||
|
||||
# Erorre: nessun username
|
||||
error_no_username = "\U000026A0 Non hai nessun username di Telegram!\n" \
|
||||
"Specificane uno nelle opzioni!"
|
||||
"Vai nelle impostazioni e inseriscine uno!"
|
||||
|
||||
# Errore: non si può votare nella prima giornata
|
||||
error_no_votes_on_first_day = "\U000026A0 I Royal non votano nella prima giornata, dato che non si sono ancora verificati omicidii."
|
||||
|
@ -388,8 +389,8 @@ preset_simple = "Semplice"
|
|||
preset_simple_selected = "Selezionato il preset *Semplice*.\n" \
|
||||
"In partita saranno presenti:\n" \
|
||||
"*{mifioso}* Mifiosi,\n" \
|
||||
"*{investigatore}* Investigatori,\n" \
|
||||
"*{royal}* Royal."
|
||||
"*{investigatore}* Investigatori\n" \
|
||||
"e *{royal}* Royal."
|
||||
|
||||
# Preset classico
|
||||
preset_classic = "Classico"
|
||||
|
@ -400,8 +401,8 @@ preset_classic_selected = "Selezionato il preset *Classico*.\n" \
|
|||
"*{mifioso}* Mifiosi,\n" \
|
||||
"*{investigatore}* Investigatori,\n" \
|
||||
"*{angelo}* Angeli,\n" \
|
||||
"*forse* un Terrorista, \n" \
|
||||
"e *{royal}* o *{royalmenouno}* Royal.\n" \
|
||||
"*forse* un Terrorista \n" \
|
||||
"e *{royalmenouno}* o *{royal}* Royal.\n" \
|
||||
|
||||
# Preset avanzato
|
||||
preset_advanced = "Avanzato"
|
||||
|
@ -409,8 +410,25 @@ preset_advanced = "Avanzato"
|
|||
# Preset avanzato selezionato
|
||||
preset_advanced_selected = "Selezionato il preset *Avanzato*.\n" \
|
||||
"I ruoli in questa partita sono casuali!\n" \
|
||||
"Il punteggio di bilanciamento è {balancescore}.\n" \
|
||||
"Inoltre, ogni mifioso può uccidere una persona diversa ogni giorno..."
|
||||
"Inoltre, ogni mifioso può uccidere una persona diversa ogni giorno...\n"
|
||||
|
||||
# Partita in cui i Mifiosi hanno un grande vantaggio (<-30)
|
||||
balance_mifia_big = "La mifia ha un grande vantaggio in questa partita." \
|
||||
"Buona fortuna, Royal Games, ne avrete bisogno!"
|
||||
|
||||
# Partita in cui i Royal hanno un grande vantaggio (>+30)
|
||||
balance_royal_big = "La Royal Games ha un grande vantaggio in questa partita." \
|
||||
"State attenti, Mifiosi!"
|
||||
|
||||
# Partita in cui i Mifiosi hanno un leggero vantaggio (>-30)
|
||||
balance_mifia_small = "La mifia è leggermente avvantaggiata in questa partita."
|
||||
|
||||
# Partita in cui i Royal hanno un leggero vantaggio (<+30)
|
||||
balance_royal_small = "La Royal Games è leggermente avvantaggiata in questa partita."
|
||||
|
||||
# Partita bilanciata (-5<x<5)
|
||||
balance_perfect = "La partita è perfettamente bilanciata per entrambe le squadre, nessuno sembra avere un grosso vantaggio.\n" \
|
||||
"Buona fortuna a tutti!"
|
||||
|
||||
# Preset con uno di tutti
|
||||
preset_oneofall = "Round Robin"
|
||||
|
|
Loading…
Add table
Reference in a new issue