2017-07-06 16:49:06 +00:00
|
|
|
from .Role import Role
|
|
|
|
import strings as s
|
2017-12-28 17:59:46 +00:00
|
|
|
import random
|
2017-07-06 16:49:06 +00:00
|
|
|
|
|
|
|
class Disastro(Role):
|
|
|
|
"""L'investigatore sbadato investiga, ma giunge a conclusioni sbagliate..."""
|
|
|
|
icon = s.detective_icon
|
|
|
|
team = 'Good'
|
|
|
|
name = s.detective_name
|
|
|
|
powerdesc = s.detective_power_description
|
|
|
|
|
|
|
|
def __init__(self, player):
|
|
|
|
super().__init__(player)
|
2017-12-28 17:59:46 +00:00
|
|
|
self.power_was_used = False
|
2017-07-06 16:49:06 +00:00
|
|
|
|
|
|
|
def __repr__(self) -> str:
|
2017-12-28 17:59:46 +00:00
|
|
|
return "<Role: Investigatore>"
|
2017-07-06 16:49:06 +00:00
|
|
|
|
2017-07-18 23:28:49 +00:00
|
|
|
def power(self, arg):
|
2017-07-06 16:49:06 +00:00
|
|
|
# Indaga sul vero ruolo di una persona, se sono ancora disponibili usi del potere.
|
2017-12-28 17:59:46 +00:00
|
|
|
if self.power_was_used:
|
|
|
|
# Non hai abbastanza cariche!
|
2017-07-18 23:28:49 +00:00
|
|
|
self.player.message(s.error_no_uses)
|
2017-12-28 17:59:46 +00:00
|
|
|
return
|
|
|
|
target = self.player.game.findplayerbyusername(arg)
|
|
|
|
if target is None:
|
|
|
|
# Username non valido
|
|
|
|
self.player.message(s.error_username)
|
|
|
|
return
|
|
|
|
# Utilizza il potere su quella persona
|
|
|
|
self.power_was_used = True
|
|
|
|
# Tira per investigare
|
2017-12-28 23:48:50 +00:00
|
|
|
target_score = random.randrange(0, 25) + 1
|
2017-12-28 17:59:46 +00:00
|
|
|
score = random.randrange(0, 100) + 1
|
2017-12-28 23:48:50 +00:00
|
|
|
if score < target_score:
|
2017-12-29 16:23:45 +00:00
|
|
|
role = target.role
|
2017-12-28 17:59:46 +00:00
|
|
|
else:
|
2017-12-29 16:23:45 +00:00
|
|
|
role = self.player.game.getrandomrole()
|
|
|
|
self.player.message(s.detective_discovery.format(target_score=100-target_score, target=target.tusername, icon=role.icon, role=role.name))
|
2017-07-06 16:49:06 +00:00
|
|
|
|
2017-07-18 23:28:49 +00:00
|
|
|
def onendday(self):
|
2017-07-06 16:49:06 +00:00
|
|
|
# Ripristina il potere
|
2017-12-28 17:59:46 +00:00
|
|
|
self.power_was_used = False
|
2017-07-06 16:49:06 +00:00
|
|
|
|
2017-07-18 23:28:49 +00:00
|
|
|
def ondeath(self):
|
2017-07-06 16:49:06 +00:00
|
|
|
self.icon = s.disaster_icon
|
|
|
|
self.name = s.disaster_name
|