Example #1
0
    def dies(self, opponent=None, auto_loot=False, teleport_corpse=False):
        force_return = check_trigger(self, "before_die", self, opponent)
        if force_return:
            return
        if opponent:
            force_return = check_trigger(opponent, "before_dies", self, opponent)
            if force_return:
                return

        #self.send_output('''<script>$("#output").vibrate();</script>''')  # (bb)
        if not self.location:
            log.always("%s è mort%s." % (self.get_name(), grammar_gender(self)), log_stack=False)
        else:
            log.always("%s è mort%s a %s" % (self.get_name(), grammar_gender(self), self.location.get_name()), log_stack=False)
        self.life = 1
        remains, use_repop = self.make_remains(auto_loot)
        remains.corpse_type.was_player = True
        if teleport_corpse:
            self.recall(also_entities=[remains])
        else:
            self.recall()
        self.flags -= FLAG.BEATEN

        if self.action_in_progress and self.action_in_progress.defer_later:
            self.action_in_progress.stop()
        self.action_in_progress = None

        force_return = check_trigger(self, "after_die", self, opponent)
        if force_return:
            return
        if opponent:
            force_return = check_trigger(opponent, "after_dies", self, opponent)
            if force_return:
                return
Example #2
0
def command_quit(entity, argument=""):
    """
    Permette di uscire dal gioco.
    """
    # È possibile se il comando è stato deferrato
    if not entity:
        return False

    # (TD) eventuale utilizzo di argument, come emote del messaggio di uscita

    if not entity.game_request:
        entity.send_output("Non ti è possibile fuggire dalla realtà...")
        return False

    send_audio(entity.get_conn(), "quit.mid")
    entity.send_output("Chiudi gli %s come per addormentarti e ti senti portat%s via poco a poco..." % (
        entity.eye_colorize("occhi"), grammar_gender(entity)))
    entity.send_output("=============================================================================")
    entity.send_output("</body>", break_line=False)
    entity.send_output("</html>", break_line=False)

    if entity.account and OPTION.COMET in entity.account.options:
        entity.game_request.finish()
    else:
        # Utilizza questo attributo come indicatore che al prossimo invio del
        # buffer al giocatore viene chiusa la connessione, inoltre gli evita
        # di ricevere altro buffer
        entity.get_conn().stop_buffering = True

    return True
Example #3
0
def command_quit(entity, argument=""):
    """
    Permette di uscire dal gioco.
    """
    # È possibile se il comando è stato deferrato
    if not entity:
        return False

    # (TD) eventuale utilizzo di argument, come emote del messaggio di uscita

    if not entity.game_request:
        entity.send_output("Non ti è possibile fuggire dalla realtà...")
        return False

    send_audio(entity.get_conn(), "quit.mid")
    entity.send_output(
        "Chiudi gli %s come per addormentarti e ti senti portat%s via poco a poco..."
        % (entity.eye_colorize("occhi"), grammar_gender(entity)))
    entity.send_output(
        "============================================================================="
    )
    entity.send_output("</body>", break_line=False)
    entity.send_output("</html>", break_line=False)

    if entity.account and OPTION.COMET in entity.account.options:
        entity.game_request.finish()
    else:
        # Utilizza questo attributo come indicatore che al prossimo invio del
        # buffer al giocatore viene chiusa la connessione, inoltre gli evita
        # di ricevere altro buffer
        entity.get_conn().stop_buffering = True

    return True
Example #4
0
def get_formatted_equipment_list(entity, target, show_header=True, show_footer=True):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return ""

    if not target:
        log.bug("target non è un parametro valido: %r" % target)
        return ""

    # -------------------------------------------------------------------------

    output = get_equipment_list(entity, target)

    if show_header:
        if target == entity:
            if output:
                output = ["[red]Stai utilizzando[close]:\n"] + output
            else:
                output.append("Non stai utilizzando nulla, sei %s!\n" % entity.skin_colorize("nud$o"))
        else:
            if output:
                output = ["%s [red]sta utilizzando[close]:\n" % color_first_upper(target.get_name(entity))] + output
            else:
                output.append("%s non sta utilizzando nulla, è %s!\n" % (
                    color_first_upper(target.get_name(looker=entity)),
                    target.skin_colorize("nud%s" % grammar_gender(target))))

    if show_footer:
        carry_equip_descr = get_weight_descr(target.get_equipped_weight())
        output.append(create_demi_line(entity))
        output.append("Stai indossando un peso totale di %s." % carry_equip_descr)

    return "".join(output)
Example #5
0
    def defeat(self, active_entity, passive_entity, active, passive):
        # Può accadere visto che il metodo è deferrato
        if not passive_entity:
            return

        if not passive_entity.IS_ITEM:
            if active_entity.IS_MOB:
                passive_entity.defeat_from_mob_counter += 1
            elif active_entity.IS_ITEM:
                passive_entity.defeat_from_item_counter += 1
            elif active_entity.IS_PLAYER:
                passive_entity.defeat_from_player_counter += 1

        if passive_entity.IS_ITEM:
            active_entity.item_defeated_counter += 1
        elif passive_entity.IS_PLAYER:
            active_entity.player_defeated_counter += 1
        else:
            active_entity.mob_defeated_counter += 1

        if passive_entity.IS_ITEM:
            if self.code.startswith("rip_item_broken-"):
                active_entity.act("\nDopo il colpo che gli hai inferto $N si polverizza.",  TO.ENTITY, passive_entity)
                active_entity.act("Dopo il colpo che $n gli ha inferto $N si polverizza.", TO.OTHERS, passive_entity)
                active_entity.act("Dopo il colpo che $n ti ha inferto ti polverizzi.",   TO.TARGET, passive_entity)
            else:
                active_entity.act("\nDopo il colpo che gli hai inferto $N si rompe.",  TO.ENTITY, passive_entity)
                active_entity.act("Dopo il colpo che $n gli ha inferto $N si rompe.", TO.OTHERS, passive_entity)
                active_entity.act("Dopo il colpo che $n ti ha inferto ti rompi.",   TO.TARGET, passive_entity)
            active_entity.send_prompt(show_opponent=False)
        else:
            active_entity.act("\nDopo il colpo che gli hai inferto $N stramazza al suolo.",  TO.ENTITY, passive_entity)
            active_entity.act("Dopo il colpo che $n gli ha inferto $N stramazza al suolo.", TO.OTHERS, passive_entity)
            active_entity.act("Dopo il colpo che $n ti ha inferto stramazzi al suolo.",   TO.TARGET, passive_entity)
            #passive_entity.send_output('''<script>$("#output").vibrate()</script>''')  # (bb)
            self.gain_xp(active_entity, passive_entity, active, passive)

            # A seconda del numero di morti il gap dei px persi è maggiore,
            # alle prime morti è zero
            died_counter = passive_entity.defeat_from_mob_counter + passive_entity.defeat_from_item_counter + passive_entity.death_from_player_counter
            malus = 1
            if died_counter > 0:
                malus = math.log(died_counter)
            self.loose_xp(active_entity, passive_entity, active, passive)

        # Se è un giocatore bisogna digitare il comando kill per finirlo
        if active_entity.IS_PLAYER and passive_entity.IS_PLAYER:
            from src.interpret import translate_input
            passive_entity.flags += FLAG.BEATEN
            kill_translation = translate_input(active_entity, "kill", "en")
            javascript_code = '''javascript:parent.sendInput('%s %s');''' % (
                kill_translation, passive_entity.get_numbered_keyword(looker=active_entity))
            active_entity.send_output('''\nHai vinto! Se vuoi finire %s <a href="%s">uccidil%s</a>.\n''' % (
                passive_entity.get_name(active_entity), javascript_code, grammar_gender(passive_entity)))
        else:
            # Altrimenti se è un'entità muore o di rompe in automatico
            if active_entity.IS_PLAYER and active_entity.account and OPTION.AUTO_LOOT in active_entity.account.options:
                passive_entity.dies(opponent=active_entity, auto_loot=True)
            else:
                passive_entity.dies(opponent=active_entity)
Example #6
0
def get_syntax_template(entity):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return ""

    # -------------------------------------------------------------------------

    syntax = ""
    syntax += "title <titolo con cui vuoi essere conosciut%s>\n" % grammar_gender(entity)
    syntax += "title cancella"

    return syntax
Example #7
0
def get_formatted_equipment_list(entity,
                                 target,
                                 show_header=True,
                                 show_footer=True):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return ""

    if not target:
        log.bug("target non è un parametro valido: %r" % target)
        return ""

    # -------------------------------------------------------------------------

    output = get_equipment_list(entity, target)

    if show_header:
        if target == entity:
            if output:
                output = ["[red]Stai utilizzando[close]:\n"] + output
            else:
                output.append("Non stai utilizzando nulla, sei %s!\n" %
                              entity.skin_colorize("nud$o"))
        else:
            if output:
                output = [
                    "%s [red]sta utilizzando[close]:\n" %
                    color_first_upper(target.get_name(entity))
                ] + output
            else:
                output.append(
                    "%s non sta utilizzando nulla, è %s!\n" %
                    (color_first_upper(target.get_name(looker=entity)),
                     target.skin_colorize("nud%s" % grammar_gender(target))))

    if show_footer:
        carry_equip_descr = get_weight_descr(target.get_equipped_weight())
        output.append(create_demi_line(entity))
        output.append("Stai indossando un peso totale di %s." %
                      carry_equip_descr)

    return "".join(output)
Example #8
0
def get_equipment_list(entity, target):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    if not target:
        log.bug("target non è un parametro valido: %r" % target)
        return False

    # -------------------------------------------------------------------------

    look_translation = translate_input(entity, "look", "en")
    if not look_translation:
        log.bug("look_translation non è valida: %r" % look_translation)
        look_translation = "guarda"

    location = None
    if entity != target:
        location = target

    output = []
    # Questo serve ad evitare di visualizzare tot volte la stessa entità se
    # questa copre più parti del corpo
    already_founds = []
    # (TD) NO non va bene, bisogna farlo ordinato a seconda delle dichiarazioni
    # fatte nei vari bodies files, devo aggiungere un numero alla classe Part
    # e fare un ordinamento come ho fatto con gli EnumElement
    body_parts = target.get_body_parts()
    for part in PART.elements:
        # Evita di visualizzare parti estranee (check che in realtà non dovrebbe
        # servire essendo controllato nel wear) o organi interni
        if part not in body_parts:
            continue
        # Gli admin vedono anche gli organi interni, se eventualmente vestiti
        if PARTFLAG.INTERNAL in body_parts[
                part].flags and entity.trust == TRUST.PLAYER:
            continue
        if PARTFLAG.NO_EQUIP_LIST in body_parts[part].flags:
            continue

        under_weareds = []
        for weared_entity in target.iter_contains():
            if weared_entity.under_weared and weared_entity.under_weared():
                under_weareds.append(weared_entity.under_weared())

        for weared_entity in target.iter_contains():
            if weared_entity in already_founds:
                continue
            if weared_entity in under_weareds:
                continue
            if len(weared_entity.wear_mode) > 0:
                part_descriptions = get_part_descriptions(
                    weared_entity, "equip", target, entity)
                if entity == target:
                    part_descr = part_descriptions[TO.ENTITY]
                else:
                    part_descr = part_descriptions[TO.OTHERS]
                if part in weared_entity.wear_mode:
                    output.append(
                        '''%s %s\n''' % (weared_entity.get_formatted_name(
                            looker=entity,
                            location=location,
                            look_translation=look_translation), part_descr))
                    already_founds.append(weared_entity)

    holded = target.get_holded_entity()
    wielded = target.get_wielded_entity()
    if holded or wielded:
        look_translation = translate_input(entity, "look", "en")
        if not look_translation:
            log.bug("look_translation non è valida: %r" % look_translation)
            look_translation = "guarda"
        if holded:
            if holded.weapon_type:
                holded_verb = "impugnat%s" % grammar_gender(holded)
            else:
                holded_verb = "tenut%s" % grammar_gender(holded)
            holded_name = holded.get_formatted_name(
                looker=entity,
                location=location,
                look_translation=look_translation)
        if wielded:
            if wielded.weapon_type:
                wielded_verb = "impugnat%s" % grammar_gender(wielded)
            else:
                wielded_verb = "tenut%s" % grammar_gender(wielded)
            wielded_name = wielded.get_formatted_name(
                looker=entity,
                location=location,
                look_translation=look_translation)

    equipment_line_hold = ""
    equipment_line_wield = ""
    if target == entity:
        if holded and holded == wielded:
            equipment_line_hold = "%s %s con tutte e due le $hands\n" % (
                holded_name, holded_verb)
        else:
            if holded:
                equipment_line_hold = "%s %s nella $hand2\n" % (holded_name,
                                                                holded_verb)
            if wielded:
                equipment_line_wield = "%s %s nella $hand1\n" % (wielded_name,
                                                                 wielded_verb)
    else:
        if holded and holded == wielded:
            equipment_line_hold = "%s %s con tutte e due le $HANDS\n" % (
                holded_name, holded_verb)
        else:
            if holded:
                equipment_line_hold = "%s %s nella $HAND2\n" % (holded_name,
                                                                holded_verb)
            if wielded:
                equipment_line_wield = "%s %s nella $HAND1\n" % (wielded_name,
                                                                 wielded_verb)
    if equipment_line_hold:
        output.append(
            entity.replace_act_tags(equipment_line_hold, target=target))
    if equipment_line_wield:
        output.append(
            entity.replace_act_tags(equipment_line_wield, target=target))

    return output
Example #9
0
def interpret(entity, argument, use_check_alias=True, force_position=True, show_input=True, show_prompt=True, behavioured=False):
    """
    Funzione che interpreta gli inputi inviati dalle entità.
    L'argomento use_check_alias a False viene passato dalla find_alias per
    evitare chiamate di alias da altri alias e quindi ricorsioni.
    """
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return

    if not argument:
        log.bug("argument non è un parametro valido: %r" % argument)
        return

    # -------------------------------------------------------------------------

    # Si assicura che colui che esegue l'azione sia un'entità unica e
    # non un mucchio fisico
    entity = entity.split_entity(1)

    if FLAG.CONVERSING in entity.flags and len(argument) == 1 and is_number(argument):
        # (TD)
        return

    arg, argument = one_argument(argument, search_separator=False)
    arg = arg.lower()

    input, huh_input, lang = multiple_search_on_inputs(entity, arg, use_check_alias=use_check_alias, argument=argument)
    # Utilizzo bislacco di lang per indicare che è stato trovato un alias
    # e che questo verrà processato tramite un'altra chiamata all'interpret
    if use_check_alias and lang == "alias":
        return

    # Resetta l'inattività di un player se ha inviato un comando
    if entity.IS_PLAYER:
        entity.inactivity = 0

    # Se non ha trovato nulla invia un messaggio apposito
    if not input:
        if show_input:
            entity.send_output(''' <span class="system">%s %s</span>''' % (remove_colors(arg), argument))
        entity.send_output("Huh?")
        # Se l'input non è stato trovato neanche nell'altra lingua allora
        # esegue il log dell'input, potrebbero esservene alcuni di sensati
        # da utilizzare in futuro come sinonimi
        # Scrive anche gli huh input dei mob così da ricavare gamescript o
        # random_do_inputs errati
        if not huh_input:
            log.huh_inputs(entity, arg)
        # Se serve visualizza il prompt
        if show_input:
            entity.send_prompt()
        return False

    # Poiché alcune words nello stesso input a volte hanno prefisso differente
    # tra loro allora cerca quello più simile possibile per farlo visualizzare
    # all'utente
    founded_input = input.findable_words[0]
    for word in input.findable_words:
        if is_prefix(arg, word):
            founded_input = word
            break

    # Se il giocatore è in stato di wait e l'input è un comando interattivo
    # allora evita di inviarlo subito ma lo mette in coda
    if entity.deferred_wait and CMDFLAG.INTERACT in input.command.flags:
        entity.waiting_inputs.append("%s %s" % (founded_input, argument))
        return False
    else:
        # Altrimenti scrive anche l'input a fianco del prompt
        if show_input:
            entity.send_output(''' <span class="system">%s %s</span>''' % (founded_input, argument))

    # Se il pg si è scollegato dalla pagina di gioco non esegue il comando
    if not entity.location:
        return False

    # Vengono salvate le informazioni sull'ultimo input inviato
    if argument:
        last_input = "%s %s" % (arg, argument)
    else:
        last_input = arg
    engine.last_input_sender = entity
    engine.last_input_sended = last_input
    # Si salva l'ultimo input inviato con successo
    if show_input and entity.IS_PLAYER and CMDFLAG.NO_LAST_INPUT not in input.command.flags:
        entity.last_input = last_input

    if CMDFLAG.GDR in input.command.flags:
        entity.sended_inputs.append("%s %s" % (founded_input, argument))

    if argument:
        argument = html_escape(argument)

    # Gestisce i comandi che devono essere digitati per intero
    command = input.command
    if CMDFLAG.TYPE_ALL in command.flags and not is_same(arg, input.findable_words):
        first_words, other_words = one_argument(input.words, search_separator=False)
        entity.send_output("Se vuoi veramente farlo devi scrivere per intero [limegreen]%s[close]." % first_words)
        execution_result = False
    elif not check_position(entity, command.position, force_position):
        # Se la posizione non è corretta invia il relativo messaggio d'errore
        vowel_of_genre = grammar_gender(entity)
        if entity.position == POSITION.DEAD:
            entity.send_output("Un po' difficile fino a che rimani MORT%s.." % vowel_of_genre.upper())
        elif (entity.position == POSITION.MORTAL
        or    entity.position == POSITION.INCAP):
            entity.send_output("Sei troppo ferit%s per farlo." % vowel_of_genre)
        elif entity.position == POSITION.STUN:
            entity.send_output("Sei troppo intontit%s per farlo." % vowel_of_genre)
        elif entity.position == POSITION.SLEEP:
            entity.send_output("Nei tuoi sogni, o cosa?")
        elif entity.position == POSITION.REST:
            entity.send_output("Nah.. Sei troppo rilassat%s ora.." % vowel_of_genre)
        elif entity.position == POSITION.KNEE:
            entity.send_output("Non puoi farlo da inginocchiat%s" % vowel_of_genre)
        elif entity.position == POSITION.SIT:
            entity.send_output("Non puoi farlo da sedut%s." % vowel_of_genre)
        else:
            log.bug("Manca la posizione %r" % entity.position)
        execution_result = False
    else:
        if command.type == CMDTYPE.SOCIAL:
            check_social(entity, command, argument=argument, behavioured=behavioured)

        if CMDFLAG.PRIVATE not in command.flags and (entity.IS_PLAYER or config.print_entity_inputs) and show_input and show_prompt:
            if entity.IS_PLAYER:
                write_on_file = True
            else:
                write_on_file = False
            log.input("'%s%s%s' digitato da %s in %s" % (
                founded_input,
                " " if argument else "",
                argument,
                entity.code,
                entity.location.get_name()), write_on_file=write_on_file)

        # Per comodità di sviluppo ricarica il modulo relativo al comando ogni
        # volta che lo si digita, così da poter testare le modifiche al codice
        # dei comandi senza aver bisogno di riavviare il gioco tutte le volte
        if config.reload_commands:
            reload(command.module)
            command.import_module_and_function()

        # Se si sta eseguendo un'azione che richiede tempo la interrompe
        if entity.action_in_progress and CMDFLAG.INTERACT in command.flags:
            if entity.action_in_progress.defer_later:
                entity.action_in_progress.stop()
            entity.action_in_progress = None

        # Esegue la funzione del comando cronometrandola
        input.counter_use += 1
        starting_time = time.time()
        execution_result = (command.function)(entity, argument)
        if command.fun_name[ : 8] == "command_" and execution_result != True and execution_result != False:
            log.bug("execution_result non è valido per il comando %s: %r" % (command.fun_name, execution_result))
        if command.fun_name[ : 6] == "skill_" and execution_result != "clumsy" and execution_result != "failure" and execution_result != "success" and execution_result != "magistral":
            log.bug("execution_result non è valido per la skill %s: %r" % (command.fun_name, execution_result))
        execution_time = time.time() - starting_time
        # Comandi che superano il tempo definito nella max_execution_time
        # possono portare a bachi creati dalla deferred impostata nel metodo
        # split_entity (nello stesso metodo c'è un commento con più informazioni)
        # Quindi devono essere il più possibile da evitare, allo stesso tempo
        # sarebbe meglio che il max_execution_time sia relativamente basso.
        if execution_time > config.max_execution_time:
            log.time("Il comando %s è stato eseguito in troppo tempo: %f secondi" % (command.fun_name, execution_time))
        command.timer += execution_time

    # Gestisce i comandi da loggare
    if CMDFLAG.LOG in command.flags:
        log.command("%s %s" % (command.fun_name, argument))

    if FLAG.AFK in entity.flags and command.fun_name != "command_afk":
        command_afk(entity)

    # Infine visualizza il prompt
    if show_prompt:
        entity.send_prompt()

    # Se la lista di input ancora da inviare non è vuota allora crea un
    # "falso wait" per forzarne l'invio. In teoria potrei inviarlo da qui, ma
    # il codice di ritorno execution_result andrebbe perduto, ecco perché
    # si fa uso della wait().
    if not entity.deferred_wait and entity.waiting_inputs:
        entity.wait(0.001)

    # Questa parte è da attivare con l'opzione check_references solo nei
    # server di test perché consuma molta cpu essendo eseguita su migliaia
    # di dati ad ogni invio di input, è una modalità di diagnostica
    # che non bada a spese in termini prestazionali
    if config.check_references and not database.reference_error_found:
        database.check_all_references()

    return execution_result
Example #10
0
def get_equipment_list(entity, target):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    if not target:
        log.bug("target non è un parametro valido: %r" % target)
        return False

    # -------------------------------------------------------------------------

    look_translation = translate_input(entity, "look", "en")
    if not look_translation:
        log.bug("look_translation non è valida: %r" % look_translation)
        look_translation = "guarda"

    location = None
    if entity != target:
        location = target

    output = []
    # Questo serve ad evitare di visualizzare tot volte la stessa entità se
    # questa copre più parti del corpo
    already_founds = []
    # (TD) NO non va bene, bisogna farlo ordinato a seconda delle dichiarazioni
    # fatte nei vari bodies files, devo aggiungere un numero alla classe Part
    # e fare un ordinamento come ho fatto con gli EnumElement
    body_parts = target.get_body_parts()
    for part in PART.elements:
        # Evita di visualizzare parti estranee (check che in realtà non dovrebbe
        # servire essendo controllato nel wear) o organi interni
        if part not in body_parts:
            continue
        # Gli admin vedono anche gli organi interni, se eventualmente vestiti
        if PARTFLAG.INTERNAL in body_parts[part].flags and entity.trust == TRUST.PLAYER:
            continue
        if PARTFLAG.NO_EQUIP_LIST in body_parts[part].flags:
            continue

        under_weareds = []
        for weared_entity in target.iter_contains():
            if weared_entity.under_weared and weared_entity.under_weared():
                under_weareds.append(weared_entity.under_weared())

        for weared_entity in target.iter_contains():
            if weared_entity in already_founds:
                continue
            if weared_entity in under_weareds:
                continue
            if len(weared_entity.wear_mode) > 0:
                part_descriptions = get_part_descriptions(weared_entity, "equip", target, entity)
                if entity == target:
                    part_descr = part_descriptions[TO.ENTITY]
                else:
                    part_descr = part_descriptions[TO.OTHERS]
                if part in weared_entity.wear_mode:
                    output.append('''%s %s\n''' % (
                        weared_entity.get_formatted_name(looker=entity, location=location, look_translation=look_translation),
                        part_descr))
                    already_founds.append(weared_entity)

    holded = target.get_holded_entity()
    wielded = target.get_wielded_entity()
    if holded or wielded:
        look_translation = translate_input(entity, "look", "en")
        if not look_translation:
            log.bug("look_translation non è valida: %r" % look_translation)
            look_translation = "guarda"
        if holded:
            if holded.weapon_type:
                holded_verb = "impugnat%s" % grammar_gender(holded)
            else:
                holded_verb = "tenut%s" % grammar_gender(holded)
            holded_name = holded.get_formatted_name(looker=entity, location=location, look_translation=look_translation)
        if wielded:
            if wielded.weapon_type:
                wielded_verb = "impugnat%s" % grammar_gender(wielded)
            else:
                wielded_verb = "tenut%s" % grammar_gender(wielded)
            wielded_name = wielded.get_formatted_name(looker=entity, location=location, look_translation=look_translation)

    equipment_line_hold = ""
    equipment_line_wield = ""
    if target == entity:
        if holded and holded == wielded:
            equipment_line_hold = "%s %s con tutte e due le $hands\n" % (holded_name, holded_verb)
        else:
            if holded:
                equipment_line_hold = "%s %s nella $hand2\n" % (holded_name, holded_verb)
            if wielded:
                equipment_line_wield = "%s %s nella $hand1\n" % (wielded_name, wielded_verb)
    else:
        if holded and holded == wielded:
            equipment_line_hold = "%s %s con tutte e due le $HANDS\n" % (holded_name, holded_verb)
        else:
            if holded:
                equipment_line_hold = "%s %s nella $HAND2\n" % (holded_name, holded_verb)
            if wielded:
                equipment_line_wield = "%s %s nella $HAND1\n" % (wielded_name, wielded_verb)
    if equipment_line_hold:
        output.append(entity.replace_act_tags(equipment_line_hold, target=target))
    if equipment_line_wield:
        output.append(entity.replace_act_tags(equipment_line_wield, target=target))

    return output
Example #11
0
    def defeat(self, active_entity, passive_entity, active, passive):
        # Può accadere visto che il metodo è deferrato
        if not passive_entity:
            return

        if not passive_entity.IS_ITEM:
            if active_entity.IS_MOB:
                passive_entity.defeat_from_mob_counter += 1
            elif active_entity.IS_ITEM:
                passive_entity.defeat_from_item_counter += 1
            elif active_entity.IS_PLAYER:
                passive_entity.defeat_from_player_counter += 1

        if passive_entity.IS_ITEM:
            active_entity.item_defeated_counter += 1
        elif passive_entity.IS_PLAYER:
            active_entity.player_defeated_counter += 1
        else:
            active_entity.mob_defeated_counter += 1

        if passive_entity.IS_ITEM:
            if self.code.startswith("rip_item_broken-"):
                active_entity.act(
                    "\nDopo il colpo che gli hai inferto $N si polverizza.",
                    TO.ENTITY, passive_entity)
                active_entity.act(
                    "Dopo il colpo che $n gli ha inferto $N si polverizza.",
                    TO.OTHERS, passive_entity)
                active_entity.act(
                    "Dopo il colpo che $n ti ha inferto ti polverizzi.",
                    TO.TARGET, passive_entity)
            else:
                active_entity.act(
                    "\nDopo il colpo che gli hai inferto $N si rompe.",
                    TO.ENTITY, passive_entity)
                active_entity.act(
                    "Dopo il colpo che $n gli ha inferto $N si rompe.",
                    TO.OTHERS, passive_entity)
                active_entity.act(
                    "Dopo il colpo che $n ti ha inferto ti rompi.", TO.TARGET,
                    passive_entity)
            active_entity.send_prompt(show_opponent=False)
        else:
            active_entity.act(
                "\nDopo il colpo che gli hai inferto $N stramazza al suolo.",
                TO.ENTITY, passive_entity)
            active_entity.act(
                "Dopo il colpo che $n gli ha inferto $N stramazza al suolo.",
                TO.OTHERS, passive_entity)
            active_entity.act(
                "Dopo il colpo che $n ti ha inferto stramazzi al suolo.",
                TO.TARGET, passive_entity)
            #passive_entity.send_output('''<script>$("#output").vibrate()</script>''')  # (bb)
            self.gain_xp(active_entity, passive_entity, active, passive)

            # A seconda del numero di morti il gap dei px persi è maggiore,
            # alle prime morti è zero
            died_counter = passive_entity.defeat_from_mob_counter + passive_entity.defeat_from_item_counter + passive_entity.death_from_player_counter
            malus = 1
            if died_counter > 0:
                malus = math.log(died_counter)
            self.loose_xp(active_entity, passive_entity, active, passive)

        # Se è un giocatore bisogna digitare il comando kill per finirlo
        if active_entity.IS_PLAYER and passive_entity.IS_PLAYER:
            from src.interpret import translate_input
            passive_entity.flags += FLAG.BEATEN
            kill_translation = translate_input(active_entity, "kill", "en")
            javascript_code = '''javascript:parent.sendInput('%s %s');''' % (
                kill_translation,
                passive_entity.get_numbered_keyword(looker=active_entity))
            active_entity.send_output(
                '''\nHai vinto! Se vuoi finire %s <a href="%s">uccidil%s</a>.\n'''
                % (passive_entity.get_name(active_entity), javascript_code,
                   grammar_gender(passive_entity)))
        else:
            # Altrimenti se è un'entità muore o di rompe in automatico
            if active_entity.IS_PLAYER and active_entity.account and OPTION.AUTO_LOOT in active_entity.account.options:
                passive_entity.dies(opponent=active_entity, auto_loot=True)
            else:
                passive_entity.dies(opponent=active_entity)
Example #12
0
def command_kill(entity, argument="", verbs=VERBS, behavioured=False):
    if not verbs:
        log.bug("verbs non è un parametro valido: %r" % verbs)
        return False

    # -------------------------------------------------------------------------

    # È possibile se il comando è stato deferrato
    if not entity:
        return False

    entity = entity.split_entity(1)

    if not argument:
        entity.send_output("Chi o che cosa vorresti %s?" % verbs["infinitive"])
        if entity.IS_PLAYER and OPTION.NEWBIE in entity.account.options:
            syntax = get_command_syntax(entity, "command_kill")
            entity.send_output(syntax, break_line=False)
        return False

    # (TD) Controllo sul mental state

    # Cerca la vittima da attaccare
    entity_tables = ["mobs", "players"]
    target = entity.find_entity(argument,
                                location=entity.location,
                                entity_tables=entity_tables,
                                avoid_equipment=True)
    if not target:
        target = entity.find_entity(argument,
                                    location=entity.location,
                                    entity_tables=["items"],
                                    avoid_equipment=True,
                                    compare_functions=[is_same])
        if target:
            destroy_translation = translate_input(entity, "destroy", "en")
            javascript_code = '''javascript:parent.sendInput('%s %s');''' % (
                destroy_translation,
                target.get_numbered_keyword(looker=entity))
            destroy_verb = DESTROY_VERBS["noun"] % grammar_gender(target)
            html_code = '''<a href="%s">%s</a>''' % (javascript_code,
                                                     destroy_verb)
            entity.act(
                "Non puoi %s $N ma puoi sempre %s!" %
                (verbs["infinitive"], html_code), TO.ENTITY, target)
            entity.act(
                "$n si guarda attorno con [red]brama di sangue[close]...",
                TO.OTHERS, target)
            entity.act("$N ti guarda con [red]brama di sangue[close]...",
                       TO.TARGET, target)
        else:
            entity.act(
                "Non trovi nessun [white]%s[close] da %s" %
                (argument, verbs["infinitive"]), TO.ENTITY)
            entity.act(
                "$n si guarda attorno con [red]brama di sangue[close]...",
                TO.OTHERS)
        return False

    if FLAG.BEATEN in target.flags:
        force_return = check_trigger(entity, "before_kill", entity, target,
                                     behavioured)
        if force_return:
            return True
        force_return = check_trigger(target, "before_killed", entity, target,
                                     behavioured)
        if force_return:
            return True

        entity.act("Dai il [red]colpo di grazia[close] a $N!", TO.ENTITY,
                   target)
        entity.act("$n dà il [red]colpo di grazia[close] a $N!", TO.OTHERS,
                   target)
        entity.act("$n ti dà il [red]colpo di grazia[close]!", TO.TARGET,
                   target)
        target.dies(opponent=entity)
        entity.player_killed_counter += 1
        target.death_from_player_counter += 1

        force_return = check_trigger(entity, "after_kill", entity, target,
                                     behavioured)
        if force_return:
            return True
        force_return = check_trigger(target, "after_killed", entity, target,
                                     behavioured)
        if force_return:
            return True
        return True

    # Se non sta combattendo procede all'attacco o alla distruzione della vittima
    if entity.is_fighting(with_him=target):
        entity.act(
            "Non è ancora giusto il momento di dare il colpo di grazia a $N.",
            TO.ENTITY, target)
        entity.act(
            "$n vorrebbe dare il colpo di grazia a $N, ma non è ancora giunto il suo momento...",
            TO.OTHERS, target)
        entity.act(
            "$n vorrebbe darti il colpo di grazia, ma non è ancora giunto il tuo momento...",
            TO.TARGET, target)
        return False

    if target.IS_ITEM:
        execution_result = kill_handler(entity,
                                        argument,
                                        "command_kill",
                                        entity_tables,
                                        verbs=DESTROY_VERBS,
                                        behavioured=behavioured)
    else:
        execution_result = kill_handler(entity,
                                        argument,
                                        "command_kill",
                                        entity_tables,
                                        verbs=ATTACK_VERBS,
                                        behavioured=behavioured)
    return execution_result
Example #13
0
def rpg_channel(entity,
                argument,
                channel,
                ask=False,
                exclaim=False,
                behavioured=False):
    """
    Gestisce i canali rpg, ha le seguenti caratteristiche:
    - supporto per gli smile
    - supporto per i modi di esprimersi con esclamativo e punto di domanda
    - supporto per gli emote
    - gestione del bersaglio che può essere un'entità, il gruppo o sé stessi
    - (TD) parlata da ubriaco
    - (TD) espansione della potenza della voce in altre stanze
    - (TD) espressioni per le stanze attorno, anche per coloro che riconoscono la voce,
           pensare anche alla suddivisione tra social gestuali e 'rumorosi' per gli smile-espressioni around
    - (TD) modulazione della voce a seconda delle dimensioni di chi parla e della sua voice_potence
    """
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    if not channel:
        log.bug("channel non è un parametro valido: %r" % channel)
        return False

    # -------------------------------------------------------------------------

    if entity.IS_ROOM:
        return False

    objective = OBJECTIVE_ROOM  # obiettivo del messaggio
    # Linguaggio utilizzato per dire il messaggio
    if entity.IS_ITEM:
        language = LANGUAGE.COMMON
    else:
        language = entity.speaking
    smile = ""  # conterrà l'eventuale espressione di uno smile-social
    emote = ""  # conterrà l'eventuale emote inviato con il messaggio tra due asterischi
    expres_entity = ""  # espressione per chi parla
    expres_room = ""  # espressione per chi sta ascoltando nella stanza
    expres_objective = ""  # espressione per chi riceverà il messaggio

    # Ricava i verbi e il colore relativi al canale
    # Se si sta parlando normalmente la propria lingua vengono utilizzati
    # i verbi razziali per descriverne timbro, flessione o pronuncia
    if channel == CHANNEL.SAY:
        verb_you, verb_it = entity.race.say_verb_you, entity.race.say_verb_it
    else:
        verb_you, verb_it = channel.verb_you, channel.verb_it
    color = get_first_color(channel.name)

    # Se non è stato passato nessun messaggio esce
    if not argument or not remove_colors(argument):
        entity.send_output("Cosa vorresti %s?" % channel)
        return False

    if len(argument) > config.max_google_translate:
        entity.send_output("Non puoi %s un messaggio così logorroico." %
                           channel)
        return False

    # Copia l'argomento originale, in alcuni casi serve recuperarlo poi
    original_argument = argument

    # Controlla se si sta parlando a qualcuno, il controllo sulla particella
    # la esegue in minuscolo, dando per sottinteso che quando uno scrive
    # maiuscolo voglia iniziare un discorso
    target = None
    if argument[0:2] == "a ":
        arg, argument = one_argument(argument)
        # Se sta parlando a qualcuno cerca di acquisirlo dal nome successivo
        objective_name, argument = one_argument(argument)
        target = entity.find_entity_extensively(objective_name)
        # con me e self esegue un check senza la is_same volutamente, per evitare
        # ricerche con nome di player che iniziano con Me o Self
        if target == entity or objective_name in ("me", "self"):
            objective = OBJECTIVE_SELF
            # Se si parla da soli lo si fa utilizzando la lingua madre
            language = entity.race.natural_language
        elif target:
            objective = OBJECTIVE_TARGET
            # Se si parla con qualcuno della stessa razza lo si fa utilizzando
            # la lingua preferita dalla razza, è un fattore culturale
            if entity.race == target.race:
                language = entity.race.natural_language
        else:
            # Se non ha trovato nessun 'a <nome bersaglio>' riprende
            # l'argument originale
            argument = original_argument
    # Stessa cosa di sopra ma qui controlla se si stia parlando al gruppo
    elif argument[0:3] == "al ":
        arg, argument = one_argument(argument)
        objective_name, argument = one_argument(argument)
        if is_prefix(objective_name, "gruppo"):
            if not entity.group:
                entity.send_output("Non fai parte di nessun gruppo.")
                return False
            # Questa variabile verrà utilizza poi nell'invio del messaggio
            group_members = entity.get_members_here(entity.location)
            if not group_members:
                entity.send_output(
                    "Non trovi nessun membro del gruppo vicino a te con cui poter parlare."
                )
                return False
            objective = OBJECTIVE_GROUP
            # Se si parla in un gruppo in cui tutti sono formati dalla stessa
            # razza si preferirà parlare con la lingua della propria razza
            for group_member in group_members:
                if group_member.race != entity.race:
                    break
            else:
                language = entity.race.natural_language
        else:
            # Se il personaggio non vuole parlare al gruppo recupera
            # il valore originale inviato
            argument = original_argument

    # (TD) Gestisce il caso in cui l'entità si trovi immersa in un liquido
    #if entity.is_immersed():
    #    entity.send_output("Tenti di %s qualcosa ma subito l'acqua ti riempie la gola soffocandoti!" % channel)
    #    entity.points.life -= random.randint(entity.level / 6, entity.level / 4) + 1
    #    return False

    if not entity.location:
        log.bug(
            "entity %s non si trova in una locazione valida: %r (original_argument: %s)"
            % (entity.code, entity.location, original_argument))
        return False

    # Gestisce le stanze che obbligano al silenzio
    if entity.location.IS_ROOM:
        if ROOM.SILENCE in entity.location.flags:
            entity.send_output(
                "Il silenzio del luogo ti blocca la gola impedendoti di %s." %
                channel)
            return False

        # (TT) Se nella stanza c'è molto casino, tante persone etc etc è difficile
        # parlare piano
        if entity.location.mod_noise > 75 and channel <= CHANNEL.SAY:
            entity.send_output("Non puoi %s con tutta questa confusione!" %
                               channel)
            return False

    # Invia l'appropriato messaggio nel caso in cui trovi argument vuoto
    if not argument:
        send_not_argument_message(entity, objective, channel)
        return False

    # Cerca eventuali smiles nella stringa controllando gli ultimi caratteri
    for social in database["socials"].itervalues():
        if not social.smiles:
            continue
        for single_smile in social.smiles.split():
            if single_smile in argument[-config.chars_for_smile:]:
                break
        else:
            # Se non trova nessun smile esce dal ciclo dei social e continua
            # col prossimo set di smiles trovato
            continue

        cut_smile = argument.rfind(single_smile)
        # Se argument è formato solo dallo smile invia il corrispondente social
        if cut_smile == 0:
            social_name = social.fun_name[len("social_"):]
            if objective == OBJECTIVE_TARGET:
                input_to_send = "%s %s" % (social_name, target.name)
            elif objective == OBJECTIVE_SELF:
                input_to_send = "%s %s" % (social_name, entity.name)
            else:
                input_to_send = social_name

            send_input(entity,
                       input_to_send,
                       "en",
                       show_input=False,
                       show_prompt=False)
            return True

        # Altrimenti ne ricava l'espressione dello smile-social e toglie lo
        # smile da argument, se il carattere dopo lo smile era un simbolo di
        # punteggiatura lo attacca alla frase togliendo gli spazi
        first_part = argument[:cut_smile]
        second_part = argument[cut_smile + len(single_smile):]
        if second_part.strip() and second_part.strip()[0] in "!?.,:;":
            first_part = first_part.rstrip()
            second_part = second_part.lstrip()
        argument = first_part.rstrip() + second_part.rstrip()
        smile = " %s" % social.expression
        break

    # Elabora i punti esclamativi e interrogativi per il canale say.
    # Qui viene utilizzata l'opzione chars_for_smile visto che si sta facendo
    # una cosa simile a sopra, ovvero considerare solo l'ultima parte
    # dell'argomento passato.
    exclamations = argument[-config.chars_for_smile:].count("!")
    questions = argument[-config.chars_for_smile:].count("?")
    if exclamations > questions:
        if channel == CHANNEL.SAY:
            verb_you = "Esclami"
            verb_it = " esclama"
        exclaim = True
    elif exclamations < questions:
        if channel == CHANNEL.SAY:
            verb_you = "Domandi"
            verb_it = " domanda"
        ask = True
    # Questo elif sottintende che exclamations e questions siano uguali
    elif exclamations != 0 and questions != 0:
        # Con una stessa quantità di ! e di ? l'ultimo che viene trovato
        # ha maggiore peso rispetto all'altro
        exclamation_pos = argument.rfind("!")
        question_pos = argument.rfind("?")
        if exclamation_pos > question_pos:
            if channel == CHANNEL.SAY:
                verb_you = "Esclami"
                verb_it = " esclama"
            exclaim = True
        else:
            if channel == CHANNEL.SAY:
                verb_you = "Domandi"
                verb_it = " domanda"
            ask = True

    # Supporto per piccoli emote separati da * ad inizio argument
    if argument[0] == "*":
        cut_emote = argument[1:].find("*")
        if cut_emote != -1:
            emote = " %s" % argument[1:cut_emote + 1].strip()
            if smile:
                emote = " e%s" % emote
            argument = argument[cut_emote + 2:].strip()

    # Unisce i vari pezzi per formare l'output
    expres_entity = verb_you
    expres_room = verb_it
    expres_target = ""
    if objective == OBJECTIVE_TARGET:
        name = target.get_name(entity)
        expres_entity += " a %s" % name
        expres_room += " a %s" % name
        expres_target += " ti%s" % verb_it
    elif objective == OBJECTIVE_SELF:
        expres_entity += " a te stess%s" % grammar_gender(entity)
        expres_room += " a sé stess%s" % grammar_gender(entity)
    elif objective == OBJECTIVE_GROUP:
        members = entity.get_members_here(entity.location)
        if len(members) == 1:
            expres_entity += " a %s" % members[0].name
            expres_room += " a %s" % members[0].name
            expres_target += " ti%s" % verb_it
        else:
            if len(members) > 5:
                many = "folto "
            else:
                many = ""
            expres_entity += " al gruppo"
            expres_room += " ad un %sgruppo" % many
            expres_target += "%s al gruppo" % verb_it
    # Aggiunge le eventuali espressioni dello smile e dell'emote
    expres_entity += smile + emote
    expres_room += smile + emote
    expres_target += smile + emote

    if not argument:
        send_not_argument_message(entity, objective, channel)
        return False

    # Prepara il pezzo riguardante la lingua utilizzata
    language = ""
    if not entity.IS_ITEM and entity.speaking != LANGUAGE.COMMON:
        language = " in lingua %s" % entity.speaking

    # Mischia il testo se si è ubriachi
    original_argument = argument = color_first_upper(argument)
    argument = drunk_speech(argument, entity)

    # Parlando si impara la lingua
    if not entity.IS_ITEM:
        learn_language(entity, channel, entity.speaking)

    # Controlla se vi sono parolacce o parole offrpg e logga i relativi argument
    if entity.IS_PLAYER:
        check_for_badwords(entity, argument)

    # Invia il messaggio a tutti coloro che lo possono sentire
    for location in expand_voice_around(entity, channel):
        if not location:
            log.bug(
                "location per il canale %s e per l'entità %s non è valida: %r"
                % (channel, entity.code, location))
            continue
        for listener in location.iter_contains(use_reversed=True):
            if listener.position <= POSITION.SLEEP:
                continue

            if listener == entity:
                force_return = check_trigger(entity, "before_rpg_channel",
                                             listener, entity, target,
                                             argument, ask, exclaim,
                                             behavioured)
                if force_return:
                    continue
                force_return = check_trigger(
                    entity, "before_" + channel.trigger_suffix, listener,
                    entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue

                # Invia all'entità il suo stesso messaggio
                first_part = (close_color(color) + expres_entity).rstrip()
                message = "%s: '%s'" % (first_part, close_color(argument))
                send_channel_message(entity, message, True)

                force_return = check_trigger(entity, "after_rpg_channel",
                                             listener, entity, target,
                                             argument, ask, exclaim,
                                             behavioured)
                if force_return:
                    continue
                force_return = check_trigger(entity,
                                             "after_" + channel.trigger_suffix,
                                             listener, entity, target,
                                             argument, ask, exclaim,
                                             behavioured)
                if force_return:
                    continue
            else:
                # Fa ascoltare solo ad un'entità di un eventuale gruppo fisico
                listener = listener.split_entity(1)

                force_return = check_trigger(listener,
                                             "before_listen_rpg_channel",
                                             listener, entity, target,
                                             argument, ask, exclaim,
                                             behavioured)
                if force_return:
                    continue
                force_return = check_trigger(
                    listener, "before_listen_" + channel.trigger_suffix,
                    listener, entity, target, argument, ask, exclaim,
                    behavioured)
                if force_return:
                    continue

                # Prepara alcune cose a seconda della stanza di provenienza del messaggio
                if entity.location == listener.location:
                    entity_name = entity.get_name(listener)
                    entity_name = color_first_upper(entity_name)
                    from_direction = ""
                elif entity.location.IS_ROOM:
                    # (TD) invia qualcuno a meno che non lo si abbia conosciuto
                    # precedentemente con il sistema di presentazione
                    entity_name = "Qualcuno"
                    from_direction = get_from_direction(
                        listener.location.x, listener.location.y,
                        listener.location.z, entity.location.x,
                        entity.location.y, entity.location.z)
                elif entity.location.IS_ACTOR:
                    if entity.location != listener:
                        entity_name = "Qualcuno"  # (TD) come sopra
                    from_direction = " dall'inventario di %s" % entity.location.get_name(
                        listener)
                else:
                    entity_name = "Qualcuno"  # (TD) come sopra
                    from_direction = " da dentro %s" % entity.location.get_name(
                        listener)

                # Prepara la prima parte, quella senza il messaggio
                if objective == OBJECTIVE_ROOM:
                    output = "%s%s%s%s" % (entity_name,
                                           close_color(color) + expres_room,
                                           language, from_direction)
                elif objective == OBJECTIVE_TARGET or OBJECTIVE_SELF:
                    if listener == target:
                        output = "%s%s%s%s" % (
                            entity_name, close_color(color) + expres_target,
                            language, from_direction)
                    else:
                        output = "%s%s%s%s" % (
                            entity_name, close_color(color) + expres_room,
                            language, from_direction)
                elif objective == OBJECTIVE_GROUP:
                    if listener in group_members:
                        output = "%s%s%s%s" % (
                            entity_name, close_color(color) + expres_target,
                            language, from_direction)
                    else:
                        output = "%s%s%s%s" % (
                            entity_name, close_color(color) + expres_room,
                            language, from_direction)

                output = "<br>%s: '%s'" % (close_color(output).rstrip(),
                                           close_color(argument))
                send_channel_message(listener, output, False)
                listener.send_prompt()

                force_return = check_trigger(listener,
                                             "after_listen_rpg_channel",
                                             listener, entity, target,
                                             argument, ask, exclaim,
                                             behavioured)
                if force_return:
                    continue
                force_return = check_trigger(
                    listener, "after_listen_" + channel.trigger_suffix,
                    listener, entity, target, argument, ask, exclaim,
                    behavioured)
                if force_return:
                    continue

    return True
Example #14
0
def command_force(entity, argument=""):
    """
    Forza l'esecuzione di un comando da parte di un'altra entità.
    """
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    # -------------------------------------------------------------------------

    if not argument:
        syntax = get_command_syntax(entity, "command_force")
        entity.send_output(syntax, break_line=False)
        return False

    arg1, argument = one_argument(argument)
    target = entity.find_entity_extensively(arg1, inventory_pos="first")
    if not target:
        target = entity.find_entity_extensively(arg1)
        if not target:
            entity.send_output("Nessuna entità trovata con argomento [white]%s[close]" % arg1)
            return False

    arg2, argument = one_argument(argument)
    if not arg2:
        entity.send_output("Che comando vorresti [red]forzare[close] a %s?" % target.get_name(entity))
        return False

    input, huh_input, input_lang = multiple_search_on_inputs(entity, arg2)
    if not input:
        entity.send_output("L'argomento %s non è relativo ad un comando valido." % arg2)
        return False

    if input.command and input.command.fun_name == "command_force":
        entity.send_output("Non puoi forzare un force.")
        return False

    translated_input = translate_input(target, arg2, input_lang)
    if not translated_input:
        entity.send_output("Non è stato possibile tradurre l'input %s per %s (lingua originale: %s)" % (
            arg2, target.get_name(entity), input_lang))
        return False

    target.send_output("\n")
    execution_result = interpret(target, "%s %s" % (translated_input, argument), force_position=True, show_input=False)
    if not execution_result:
        if target == entity:
            entity.send_output("\nL'esecuzione dell'input [limegreen]%s[close] forzato su di [white]te stess%c[close] non è andata a buon fine." % (
                arg2, grammar_gender(entity)))
        else:
            entity.send_output("\nL'esecuzione dell'input %s forzato su di %s non è andata a buon fine." % (
                arg2, target.get_name(entity)))
            if not entity.incognito:
                target.send_output("\n%s ti ha forzato a fare qualcosa." % entity.get_name(target))
            log.admin("%s ha cercato di forzare %s a fare: %s %s" % (entity.name, target.name, arg2, argument))
        return False

    if target == entity:
        message = "\n" + format_for_admin("Il force dell'input [green]%s[close] su [white]te stess%c[close] sembra essere andato a buon fine." % (
            arg2, grammar_gender(entity)))
        entity.send_output(message)
    else:
        message = "\n" + format_for_admin("Il force dell'input [green]%s[close] su di %s sembra andato a buon fine." % (
            arg2, target.get_name(entity)))
        entity.send_output(message)
        if not entity.incognito:
            target.send_output("\n%s ti ha forzato a fare qualcosa." % entity.get_name(target))
        log.admin("%s ha forzato %s a fare: %s %s" % (entity.name, target.name, arg2, argument))

    return True
Example #15
0
def goto_entity_handler(entity, argument, table_name):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return None, None, ""

    if not argument:
        log.bug("argument non è un parametro valido: %r" % argument)
        return None, None, ""

    if not table_name:
        log.bug("table_name non è un parametro valido: %r" % table_name)
        return None, None, ""

    # -------------------------------------------------------------------------

    # Se si vuole cercare tra i giocatori allora cerca prima tra quelli online
    if table_name == "players":
        from src.player import search_online_player
        player = search_online_player(argument)
        if player == entity:
            entity.send_output("L'obiettivo del goto sei [white]tu[close]!")
            return None, None, ""
        if player:
            return player, player.get_in_room(
            ), "\nL'obiettivo del goto era %s" % player.get_name(entity)

    target = entity.find_entity(argument,
                                entity_tables=[table_name],
                                avoid_equipment=False,
                                avoid_doors=False)
    if not target:
        entity.send_output(
            "Nessun %s trovato con argomento [green]%s[close]." %
            (table_name[:-1], argument))
        return None, None, ""

    if target.IS_PLAYER and not target.game_request:
        room = target.get_in_room()
        if not room:
            entity.send_output(
                "Il giocatore offline %s non ha una stanza valida: %r" %
                (target.name, room))
            return None, None, ""
        if not room.IS_ROOM:
            entity.send_output(
                "Il giocatore offline %s non si trova in una stanza: %s (normale se il giocatore non si è mai collegato o se sono state rimosse le persistenze)"
                % (target.name, room))
            return None, None, ""
        return target, room, "Il giocatore %s ha quittato in questa stanza." % target.name

    if not target.location:
        entity.send_output(
            "%s %s esiste ma non è raggiungibile perché non ha location valida: %r"
            % (target.__class__.__name__, target.code, target.location))
        return None, None, ""

    if target.location == entity:
        if len(target.wear_mode) > 0:
            where_is = "equipaggiamento"
        elif FLAG.INGESTED in target.flags:
            where_is = "stomaco"
        else:
            where_is = "inventario"
        entity.send_output("L'entità %s si trova nel tuo %s." %
                           (target.get_name(), where_is))
        return None, None, ""

    room = target.get_in_room()
    if not room:
        entity.send_output(
            "Per qualche strano motivo bacoso l'entità %s (contenuta o meno) non si trova in una stanza."
            % target.get_name())
        return None, None, ""

    if target == entity:
        entity.send_output("L'obiettivo del goto sei [white]tu[close]!")
        return None, None, ""

    last_message = "\nL'obiettivo del goto era %s" % target.get_name()
    player_carrier = target.get_player_previous_carrier()
    if player_carrier and not player_carrier.game_request:
        last_message += " contenuto da %s che ha quittato in questa stanza." % target.location.get_name(
        )
    elif target.location:
        # (TT) qui forse dovrei utilizzare la get_in_room
        last_message += " contenuto da %s, sei stat$o spostat$o nel luogo in cui si trova quest'ultim%s." % (
            target.location.get_name(), grammar_gender(target))

    return target, room, last_message
Example #16
0
def command_snoop(entity, argument=""):
    """
    Permette di visualizzare tutto l'output di uno o più entità.
    """
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    # -------------------------------------------------------------------------

    if not argument:
        syntax = get_command_syntax(entity, "command_snoop")
        entity.send_output(syntax, break_line=False)

        being_watched = []
        for other in database["players"].values() + database["mobs"].values() + database["items"].values():
            if entity in other.snoopers:
                being_watched.append(other)

        if being_watched:
            entity.send_output("Entità che stai snoopando:")
            for other in being_watched:
                if other.IS_ITEM:
                    goto_input = "igoto"
                elif other.IS_ROOM:
                    goto_input = "rgoto"
                elif other.IS_MOB:
                    goto_input = "mgoto"
                else:
                    goto_input = "goto"
                javascript_code = '''javascript:parent.sendInput("%s %s");''' % (goto_input, other.code)
                entity.send_output('''- <a href='%s'>%s</a>''' % (javascript_code, other.get_name(entity)))
        else:
            entity.send_output("Non stai snoopando nessuno.")
        return False

    # -------------------------------------------------------------------------

    if is_same(argument, "stop"):
        counter = remove_and_count_snooped_by(entity)
        if counter > 0:
            entity.send_output("Smetti di snoopare %d entità." % counter)
            log.admin("%s smette di snoopare %d entità" % (entity.name, counter))
        else:
            entity.send_output("Non hai nessuna entità snoopata.")
        return True

    target = entity.find_entity_extensively(argument, inventory_pos="first")
    if not target:
        target = entity.find_entity(argument)
        if not target:
            entity.send_output("Nessuna entità trovata con argomento [green]%s[close]" % argument)
            return False

    if entity == target:
        entity.send_output("Non puoi snoopare te stesso.")
        return False

    if entity in target.snoopers:
        target.snoopers.remove(entity)
        entity.send_output("Smetti di snoopare %s." % target.get_name(entity))
        log.admin("%s smette di snoopare %s" % (entity.name, target.name))
    else:
        snoopers = []
        for snooper in target.snoopers:
            if snooper.trust > entity.trust:
                continue
            snoopers.append(snooper.name)
        if snoopers:
            entity.send_output("%s viene comunque già snoopat%s da: %s" % (
                target, grammar_gender(target), ",".join(snoopers)))

        target.snoopers.append(entity)
        entity.send_output("Incominci a snoopare %s." % target.get_name(entity))
        log.admin("%s incomincia a snoopare %s" % (entity.name, target.name))

    return True
Example #17
0
def give_or_put(entity, argument, verbs, behavioured, entity_tables, noflag, noroom, gamescript_suffix1, gamescript_suffix2, gamescript_suffix3, preposition):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    # argument può essere una stringa vuota

    if not verbs:
        log.bug("verbs non è un parametro valido: %r" % verbs)
        return False

    if not entity_tables:
        log.bug("entity_tables non è un parametro valido: %r" % entity_tables)
        return False

    if noflag not in (FLAG.NO_PUT, FLAG.NO_GIVE):
        log.bug("noflag non è un parametro valido: %r" % noflag)
        return False

    if noroom not in (ROOM.NO_PUT, ROOM.NO_GIVE):
        log.bug("noroom non è un parametro valido: %r" % noroom)
        return False

    if gamescript_suffix1 not in ("put", "give"):
        log.bug("gamescript_suffix1 non è un parametro valido: %r" % gamescript_suffix1)
        return False

    if gamescript_suffix2 not in ("putted", "gave"):
        log.bug("gamescript_suffix2 non è un parametro valido: %r" % gamescript_suffix2)
        return False

    if gamescript_suffix3 not in ("putting", "giving"):
        log.bug("gamescript_suffix3 non è un parametro valido: %r" % gamescript_suffix3)
        return False

    if preposition not in ("in", "a"):
        log.bug("gamescript_suffix non è un parametro valido: %r" % gamescript_suffix)
        return False

    # -------------------------------------------------------------------------

    entity = entity.split_entity(1)

    if not argument:
        entity.send_output("Che [white]cosa[close] vorresti %s %s [white]%s[close]?" % (verbs["infinitive"], preposition, "qualcuno" if preposition == "a" else "qualcosa"))
        if entity.IS_PLAYER and OPTION.NEWBIE in entity.account.options:
            syntax = get_command_syntax(entity, "command_put")
            entity.send_output(syntax)
        return False

    # Ricava l'eventuale quantità d'oggetti da posare
    quantity, argument = quantity_argument(argument)
    arg1, argument = one_argument(argument)

    # (TD) Controllo del mental state deviato

    # Ricerca nell'inventario dell'entità quella da dare o mettere
    target = entity.find_entity(arg1, quantity=quantity, location=entity)

    arg2 = ""
    receiver = None
    if argument:
        arg2, argument = one_argument(argument)
        # Rimuove eventuali argomenti facoltativi
        if argument and arg2 == "a":
            arg2, argument = one_argument(argument)
        # Ricerca dell'entità bersaglio a cui dare l'entità target
        receiver = entity.find_entity_extensively(arg2, entity_tables=entity_tables)

        # Controlla se si vuole inserire una porta sui cardini di un'uscita
        direction = get_direction(arg2)
        if target and not receiver and direction != DIR.NONE:
            if not entity.location.IS_ROOM:
                entity.act("Vorresti %s $N sui cardini di un'eventuale uscita %s, ma non ti trovi in una stanza." % (verbs["infinitive"], direction.to_dir), TO.ENTITY, target)
                entity.act("$n vorrebbe %s $N sui cardini di un'eventuale uscita %s, ma non vi trovate in una stanza." % (verbs["infinitive"], direction.to_dir), TO.OTHERS, target)
                entity.act("$n ti vorrebbe %s sui cardini di un'eventuale uscita %s, ma non vi trovate in una stanza." % (verbs["infinitive"], direction.to_dir), TO.TARGET, target)
                return False
            if not direction in entity.location.exits:
                entity.act("Vorresti %s $N sui cardini di un'eventuale uscita %s, ma questa non esiste." % (verbs["infinitive"], direction.to_dir), TO.ENTITY, target)
                entity.act("$n vorrebbe %s $N sui cardini di un'eventuale uscita %s, ma questa non esiste." % (verbs["infinitive"], direction.to_dir), TO.OTHERS, target)
                entity.act("$n ti vorrebbe %s sui cardini di un'eventuale uscita %s, ma questa non esiste." % (verbs["infinitive"], direction.to_dir), TO.TARGET, target)
                return False
            exit_door = entity.location.exits[direction].door
            if exit_door:
                entity.act("Vorresti %s $N sui cardini dell'uscita %s, ma questa possiede già $a." % (verbs["infinitive"], direction.to_dir), TO.ENTITY, target, exit_door)
                entity.act("$n vorrebbe %s $N sui cardini dell'uscita %s, ma questa possiede già $a." % (verbs["infinitive"], direction.to_dir), TO.OTHERS, target, exit_door)
                entity.act("$n ti vorrebbe %s sui cardini dell'uscita %s, ma questa possiede già $a." % (verbs["infinitive"], direction.to_dir), TO.TARGET, target, exit_door)
                return False
            if not target.door_type:
                entity.act("Vorresti %s sui cardini dell'uscita %s $N, ma quest'ultim$O non è una porta." % (verbs["infinitive"], direction.to_dir), TO.ENTITY, target, exit_door)
                entity.act("$n vorrebbe %s sui cardini dell'uscita %s $N, ma quest'ultim$O non è una porta." % (verbs["infinitive"], direction.to_dir), TO.OTHERS, target, exit_door)
                entity.act("$n ti vorrebbe %s sui cardini dell'uscita %s, ma non sei una porta." % (verbs["infinitive"], direction.to_dir), TO.TARGET, target, exit_door)
                return False
            if quantity > 1:
                entity.act("Vorresti %s sui cardini dell'uscita %s $N, ma è possibile inserirne solo un$O." % (verbs["infinitive"], direction.to_dir), TO.ENTITY, target, exit_door)
                entity.act("$n vorrebbe %s sui cardini dell'uscita %s $N, ma è possibile inserirne solo un$O" % (verbs["infinitive"], direction.to_dir), TO.OTHERS, target, exit_door)
                entity.act("$n ti vorrebbe %s sui cardini dell'uscita %s, ma è possibile inserirti solo in un'unità." % (verbs["infinitive"], direction.to_dir), TO.TARGET, target, exit_door)
                return False

            force_return = check_trigger(entity, "before_" + gamescript_suffix1, entity, target, None, direction, behavioured)
            if force_return:
                return True
            force_return = check_trigger(target, "before_" + gamescript_suffix2, entity, target, None, direction, behavioured)
            if force_return:
                return True
            force_return = check_trigger(receiver, "before_" + gamescript_suffix3, entity, target, None, direction, behavioured)
            if force_return:
                return True

            entity.act("%s $N sui cardini dell'uscita %s." % (verbs["you"], direction.to_dir), TO.ENTITY, target)
            entity.act("$n %s $N sui cardini dell'uscita %s." % (verbs["it"], direction.to_dir), TO.OTHERS, target)
            entity.act("$n ti %s sui cardini dell'uscita %s." % (verbs["it"], direction.to_dir), TO.TARGET, target)
            target = target.from_location(1)
            target.to_location(entity.location)
            entity.location.exits[direction].door = target

            force_return = check_trigger(entity, "after_" + gamescript_suffix1, entity, target, None, direction, behavioured)
            if force_return:
                return True
            force_return = check_trigger(target, "after_" + gamescript_suffix2, entity, target, None, direction, behavioured)
            if force_return:
                return True
            force_return = check_trigger(receiver, "after_" + gamescript_suffix3, entity, target, None, direction, behavioured)
            if force_return:
                return True

            return True

    # -------------------------------------------------------------------------

    if not arg2:
        arg2 = "qualcuno" if preposition == "a" else "qualcosa"

    # Se l'entità a cui dare si trova nell'inventario allora lo indica
    on_message_you = ""
    on_message_it = ""
    if receiver and receiver.location and receiver.location == entity:
        if receiver and len(receiver.wear_mode) > 0:
            on_message_you = " che stai [khaki]indossando[close]"
            on_message_it  = " che sta [khaki]indossando[close]"
        else:
            on_message_you = " nel tuo [yellow]inventario[close]"
            on_message_it  = " nel suo [yellow]inventario[close]"

    # Gestisce le varie combinazioni di entità non trovate e/o uguali
    # all'entità che ha digitato il comando
    if target:
        if not receiver:
            entity.act("Cerchi di %s $N %s [white]%s[close] che non trovi da nessuna parte." % (verbs["infinitive"], preposition, arg2), TO.ENTITY, target)
            entity.act("$n cerca di %s $N %s [white]%s[close] che non sembra trovare da nessuna parte." % (verbs["infinitive"], preposition, arg2), TO.OTHERS, target)
            entity.act("$n cerca di %s %s [white]%s[close] che non sembra trovare da nessuna parte." % (verbs["you2"], preposition, arg2), TO.TARGET, target)
            return False
        elif receiver == entity:
            entity.act("Cerchi di %s $N %s te stess$o, ma è già tu$O!" % (verbs["infinitive"], preposition), TO.ENTITY, target)
            entity.act("$n cerca di %s $N %s se stess$o, ma è già su$O." % (verbs["infinitive"], preposition), TO.OTHERS, target)
            entity.act("$n cerca di %s $N %s se stess$o, ma è già su$O." % (verbs["infinitive"], preposition), TO.TARGET, target)
            return False
        elif receiver == target:
            entity.act("Cerchi di %s $N %s se stess$o, ma ciò è impossibile!" % (verbs["infinitive"], preposition), TO.ENTITY, target)
            entity.act("$n cerca di %s $N %s se stess$o, ma ciò è impossibile." % (verbs["infinitive"], preposition), TO.OTHERS, target)
            entity.act("$n cerca di %s $N %s te stess$o, ciò è impossibile." % (verbs["infinitive"], preposition), TO.TARGET, target)
            return False
    elif not target:
        if not receiver:
            entity.act("Cerchi di %s [white]%s[close] %s [white]%s[close], ma non trovi nulla e nessuno nel tuo inventario." % (verbs["infinitive"], arg1, preposition, arg2), TO.ENTITY)
            entity.act("$n cerca di %s [white]qualcosa[close] %s [white]quacuno[close], ma senza molti risultati nel suo inventario." % (verbs["infinitive"], preposition), TO.OTHERS)
            return False
        elif receiver == entity:
            if entity.IS_ITEM:
                entity.act("Cerchi di [orange]passarti [white]%s[close], ma non trovi [gray]nulla del genere[close] nel tuo [yellow]inventario[close]." % arg1, TO.ENTITY, receiver)
                entity.act("$n cerca di [orange]passarsi [white]qualcosa[close] che [gray]non sembra trovare[close] nel suo [yellow]inventario[close].", TO.OTHERS, receiver)
            else:
                entity.act("Cerchi di [orange]passarti[close] da una $hand all'altra [white]%s[close], ma non trovi [gray]nulla del genere[close] nel tuo [yellow]inventario[close]." % arg1, TO.ENTITY, receiver)
                entity.act("$n cerca di [orange]passarsi[close] da una $hand all'altra [white]qualcosa[close] che [gray]non sembra trovare[close] nel suo [yellow]inventario[close].", TO.OTHERS, receiver)
            return False
        else:
            if on_message_you and on_message_it:
                entity.act("Cerchi di %s un [white]%s[close] %s $N%s, ma non trovi [gray]nulla del genere[close]." % (verbs["infinitive"], arg1, preposition, on_message_you), TO.ENTITY, receiver)
                entity.act("$n cerca di %s [white]qualcosa[close] %s $N%s, ma non sembra trovare [gray]nulla del genere[close]." % (verbs["infinitive"], preposition, on_message_it), TO.OTHERS, receiver)
                entity.act("$n cerca di %s [white]qualcosa[close], ma non sembra trovare [gray]nulla del genere[close]." % (verbs["infinitive"]), TO.TARGET, receiver)
            else:
                entity.act("Cerchi di %s un [white]%s[close] %s $N, ma non trovi [gray]nulla del genere[close] nel tuo [yellow]inventario[close]." % (verbs["infinitive"], arg1, preposition), TO.ENTITY, receiver)
                entity.act("$n cerca di %s [white]qualcosa[close] %s $N, ma non sembra trovare [gray]nulla del genere[close] nel suo [yellow]inventario[close]." % (verbs["infinitive"], preposition[2 : ]), TO.OTHERS, receiver)
                entity.act("$n cerca di %s [white]qualcosa[close], ma non sembra trovare [gray]nulla del genere[close] nel suo [yellow]inventario[close]." % (verbs["infinitive"]), TO.TARGET, receiver)
            return False

    if quantity == 0:
        quantity = target.quantity
    elif target.quantity < quantity:
        entity.act("Non puoi %s $N perché ne possiedi solo %d e non %d." % (verbs["infinitive"], target.quantity, quantity), TO.ENTITY, target)
        entity.act("$n sta cercando di ammucchiare un quantitativo voluto di $N per poterlo %s" % verbs["infinitive"], TO.OTHERS, target)
        entity.act("$n sta cercando di ammucchiarti per un quantitativo voluto per poterti %s" % verbs["infinitive"], TO.TARGET, target)
        return False

    if receiver.container_type and CONTAINER.CLOSED in receiver.container_type.flags:
        entity.act("Cerchi di %s $a %s $N ma l$O trovi chius$O." % (verbs["infinitive"], preposition), TO.ENTITY, receiver, target)
        entity.act("$n cerca di %s $a %s $N ma l$O trova chius$O." % (verbs["infinitive"], preposition), TO.OTHERS, receiver, target)
        return False

    # Se l'obiettivo a cui dare l'entità è un oggetto e non è un contenitore
    # allora solo gli admin possono eseguire l'azione
    if receiver.IS_ITEM and not receiver.container_type:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin("Il ricevitore non è un contenitore ma tu puoi eseguire comunque l'azione")
        else:
            entity.act("Cerchi di %s $N %s $a, ma quest'ultimo non ti sembra un contenitore." % (verbs["infinitive"], preposition), TO.ENTITY, target, receiver)
            entity.act("$n cerca di %s $N %s $a, ma non riesce a trovare modo per farlo non essendo un contenitore." % (verbs["infinitive"], preposition), TO.OTHERS, target, receiver)
            entity.act("$n cerca di %s %s $a, ma non sembra riuscirvi visto che quest'ultimo non è un contenitore." % (verbs["you2"], preposition), TO.TARGET, target, receiver)
            entity.act("$n cerca di %s $a, ma avrà ben poca fortuna visto che non sei un contenitore." % verbs["you"], TO.TARGET, receiver, target)
            return False
    
    # Se l'entità che ha inviato il comando ha la noflag viene evitata
    # l'azione
    if noflag in entity.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin("Tu avresti in realtà la flag NO_GIVE")
        else:
            entity.act("Cerchi di %s $N %s $a, ma qualche [blueroyal]forza misteriosa[close] ti blocca l'azione." % (verbs["infinitive"], preposition), TO.ENTITY, target, receiver)
            entity.act("$n cerca di %s $N %s $a, ma sembra essere bloccat$n da una [royalblue]forza misteriosa[close]." % (verbs["infinitive"], preposition), TO.OTHERS, target, receiver)
            entity.act("$n cerca di %s %s $a, ma sembra essere essere bloccat$o da una [royalblue]forza misteriosa[close]." % (verbs["you2"], preposition), TO.TARGET, target, receiver)
            entity.act("$n cerca di %s $a, ma sembre essere bloccat$o da una [royalblue]forza misteriosa[close]." % verbs["you"], TO.TARGET, receiver, target)
            return False

    # Se l'oggetto da dare ha la flag NO_GIVE allora evita di farsi
    if noflag in target.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin("L'entità da dare avrebbe in realtà la flag NO_GIVE")
        else:
            if entity.IS_ITEM:
                entity.act("Appena cerchi di %s $N %s $a te lo ritrovi, con un [cyan]balzo[close] addosso." % (verbs["infinitive"], preposition), TO.ENTITY, target, receiver)
                entity.act("Appena $n cerca di %s $N %s $a se lo ritrova, con un [cyan]balzo[close] addosso." % (verbs["infinitive"], preposition), TO.OTHERS, target, receiver)
                entity.act("Appena $n cerca di %s %s $a gli [cyan]rimbalzi[close] addosso." % (verbs["you2"], preposition), TO.TARGET, target, receiver)
                entity.act("Appena $n cerca di %s $a se lo ritrova, con un [cyan]balzo[close] addosso." % verbs["you2"], TO.TARGET, receiver, target)
            else:
                entity.act("Appena cerchi di %s $N %s $a te lo ritrovi, con un [cyan]balzo[close], in $hand." % (verbs["infinitive"], preposition), TO.ENTITY, target, receiver)
                entity.act("Appena $n cerca di %s $N %s $a se lo ritrova, con un [cyan]balzo[close], in $hand." % (verbs["infinitive"], preposition), TO.OTHERS, target, receiver)
                entity.act("Appena $n cerca di %s %s $a gli [cyan]rimbalzi[close] in $hand." % (verbs["you2"], preposition), TO.TARGET, target, receiver)
                entity.act("Appena $n cerca di %s $a se lo ritrova, con un [cyan]balzo[close], in $hand." % verbs["you2"], TO.TARGET, receiver, target)
            return False

    # Se l'entità a cui dare l'oggetto ha la flag NO_GIVE allora non lo accetta
    if noflag in receiver.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin("L'entità a cui dare avrebbe in realtà la flag NO_GIVE")
        else:
            if entity.IS_ITEM:
                entity.act("Cerchi di %s $N %s $a, ma questi te l$O ridà." % (verbs["infinitive"], preposition), TO.ENTITY, target, receiver)
                entity.act("$n cerca di %s $N %s $a, ma questi gliel$O ridà." % (verbs["infinitive"], preposition), TO.OTHERS, target, receiver)
                entity.act("$n cerca di %s %s $a, ma questi gliel$O ridà." % (verbs["you2"], preposition), TO.TARGET, target, receiver)
                entity.act("$n cerca di %s $a, ma gliel%s ridai." % (verbs["you2"], grammar_gender(target)), TO.TARGET, receiver, target)
            else:
                entity.act("Cerchi di %s $N %s $a, ma questi te l$O ridà in $hand." % (verbs["infinitive"], preposition), TO.ENTITY, target, receiver)
                entity.act("$n cerca di %s $N %s $a, ma questi gliel$O ridà in $hand." % (verbs["infinitive"], preposition), TO.OTHERS, target, receiver)
                entity.act("$n cerca di %s %s $a, ma questi gliel$O ridà in $hand." % (verbs["you2"], preposition), TO.TARGET, target, receiver)
                entity.act("$n cerca di %s $a, ma gliel%s ridai in $hand." % (verbs["you2"], grammar_gender(target)), TO.TARGET, receiver, target)
            return False

    # Se la stanza ha la flag NO_GIVE non permette di dare oggetti
    if entity.location.IS_ROOM and noroom in entity.location.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin("Questa stanza avrebbe in realtà la flag di NO_GIVE")
        else:
            if entity.IS_ITEM:
                entity.act("Appena cerchi di %s $N %s $a%s te l$O ritrovi addosso come se una [royalblue]forza misteriosa[close] nel luogo ti impedisse quest'azione!" % (
                    verbs["infinitive"], preposition, on_message_you), TO.ENTITY, target, receiver)
                entity.act("Appena $n cerca di %s %s $a%s $N se l$O ritrova addosso come se vi fosse una [royalblue]forza misteriosa[close] nel luogo!" % (
                    verbs["infinitive"], preposition, on_message_it), TO.OTHERS, target, receiver)
                entity.act("Appena $n cerca di %s %s $a%s gli ritorni addosso grazie ad una [royalblue]forza misteriosa[close] del luogo!" % (
                    verbs["you2"], preposition, on_message_it), TO.TARGET, target, receiver)
                entity.act("Appena $n cerca di %s $a gli ritorna addosso grazie ad una [royalblue]forza misteriosa[close] del luogo!" % (
                    verbs["you2"]), TO.TARGET, receiver, target)
            else:
                entity.act("Appena cerchi di %s $N %s $a%s te l$O ritrovi in $hand come se una [royalblue]forza misteriosa[close] nel luogo ti impedisse quest'azione!" % (
                    verbs["infinitive"], preposition, on_message_you), TO.ENTITY, target, receiver)
                entity.act("Appena $n cerca di %s %s $a%s $N se l$O ritrova in $hand come se vi fosse una [royalblue]forza misteriosa[close] nel luogo!" % (
                    verbs["infinitive"], preposition, on_message_it), TO.OTHERS, target, receiver)
                entity.act("Appena $n cerca di %s %s $a%s gli ritorni in $hand grazie ad una [royalblue]forza misteriosa[close] del luogo!" % (
                    verbs["you2"], preposition, on_message_it), TO.TARGET, target, receiver)
                entity.act("Appena $n cerca di %s $a gli ritorna in $hand grazie ad una [royalblue]forza misteriosa[close] del luogo!" % (
                    verbs["you2"]), TO.TARGET, receiver, target)
            return False

    # (TD) dare monete

    # (TD) gestione dell'argomento all, ultima cosa da supportare

    # Se il peso dell'entità da dare supera quello sopportabile dall'obiettivo
    # a cui darlo allora avverte e evita l'azione
    # (TD) size e carry_number come il get?
    if not receiver.can_carry_target(target, quantity=quantity):
        if receiver.trust > TRUST.PLAYER:
            receiver.send_to_admin("Riesci comunque a %s %s anche se è troppo pesante per te." % (
                verbs["infinitive"], target.get_name(entity)))
        elif entity.trust > TRUST.PLAYER and not receiver.IS_PLAYER:
            entity.send_to_admin("Riesci comunque a %s %s anche se è troppo pesante per %s." % (
                verbs["infinitive"], target.get_name(entity), receiver.get_name(entity)))
        else:
            entity.act("Non riesci %s %s $N a $a, non può portare con sé tutto quel peso." % (verbs["infinitive"], preposition), TO.ENTITY, target, receiver)
            entity.act("$n non riesce a %s $N %s $a, non può portare con sé tutto quel peso." % (verbs["infinitive"], preposition), TO.OTHERS, target, receiver)
            entity.act("$n non riesce a %s %s $a, non può portare con sé tutto il tuo peso." % (verbs["you2"], preposition), TO.TARGET, target, receiver)
            entity.act("$n non riesce a %s $a, non puoi portare con te tutto quel peso." % verbs["you2"], TO.TARGET, receiver, target)
            return False

    force_return = check_trigger(entity, "before_" + gamescript_suffix1, entity, target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "before_" + gamescript_suffix2, entity, target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True
    force_return = check_trigger(receiver, "before_" + gamescript_suffix3, entity, target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True

    if on_message_you and on_message_it:
        entity.act("%s $N %s $a%s." % (color_first_upper(verbs["you"]), preposition, on_message_you), TO.ENTITY, target, receiver)
        entity.act("$n %s $N %s $a%s." % (verbs["it"], preposition, on_message_it), TO.OTHERS, target, receiver)
        entity.act("$n ti %s %s $a%s." % (verbs["it"], preposition, on_message_it), TO.TARGET, target, receiver)
        entity.act("$n ti %s $a." % verbs["it"], TO.TARGET, receiver, target)
    else:
        entity.act("%s $N %s $a." % (color_first_upper(verbs["you"]), preposition), TO.ENTITY, target, receiver)
        entity.act("$n %s $N %s $a." % (verbs["it"], preposition), TO.OTHERS, target, receiver)
        entity.act("$n ti %s %s $a." % (verbs["it"], preposition), TO.TARGET, target, receiver)
        entity.act("$n ti %s $a." % verbs["it"], TO.TARGET, receiver, target)

    target = target.from_location(quantity, use_repop=True)
    target.to_location(receiver)

    force_return = check_trigger(entity, "after_" + gamescript_suffix1, entity, target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "after_" + gamescript_suffix2, entity, target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True
    force_return = check_trigger(receiver, "after_" + gamescript_suffix3, entity, target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True

    return True
Example #18
0
def command_kill(entity, argument="", verbs=VERBS, behavioured=False):
    if not verbs:
        log.bug("verbs non è un parametro valido: %r" % verbs)
        return False

    # -------------------------------------------------------------------------

    # È possibile se il comando è stato deferrato
    if not entity:
        return False

    entity = entity.split_entity(1)

    if not argument:
        entity.send_output("Chi o che cosa vorresti %s?" % verbs["infinitive"])
        if entity.IS_PLAYER and OPTION.NEWBIE in entity.account.options:
            syntax = get_command_syntax(entity, "command_kill")
            entity.send_output(syntax, break_line=False)
        return False

    # (TD) Controllo sul mental state

    # Cerca la vittima da attaccare
    entity_tables = ["mobs", "players"]
    target = entity.find_entity(argument, location=entity.location, entity_tables=entity_tables, avoid_equipment=True)
    if not target:
        target = entity.find_entity(argument, location=entity.location, entity_tables=["items"], avoid_equipment=True, compare_functions=[is_same])
        if target:
            destroy_translation = translate_input(entity, "destroy", "en")
            javascript_code = '''javascript:parent.sendInput('%s %s');''' % (destroy_translation, target.get_numbered_keyword(looker=entity))
            destroy_verb = DESTROY_VERBS["noun"] % grammar_gender(target)
            html_code = '''<a href="%s">%s</a>''' % (javascript_code, destroy_verb)
            entity.act("Non puoi %s $N ma puoi sempre %s!" % (verbs["infinitive"], html_code), TO.ENTITY, target)
            entity.act("$n si guarda attorno con [red]brama di sangue[close]...", TO.OTHERS, target)
            entity.act("$N ti guarda con [red]brama di sangue[close]...", TO.TARGET, target)
        else:
            entity.act("Non trovi nessun [white]%s[close] da %s" % (argument, verbs["infinitive"]), TO.ENTITY)
            entity.act("$n si guarda attorno con [red]brama di sangue[close]...", TO.OTHERS)
        return False

    if FLAG.BEATEN in target.flags:
        force_return = check_trigger(entity, "before_kill", entity, target, behavioured)
        if force_return:
            return True
        force_return = check_trigger(target, "before_killed", entity, target, behavioured)
        if force_return:
            return True

        entity.act("Dai il [red]colpo di grazia[close] a $N!", TO.ENTITY, target)
        entity.act("$n dà il [red]colpo di grazia[close] a $N!", TO.OTHERS, target)
        entity.act("$n ti dà il [red]colpo di grazia[close]!", TO.TARGET, target)
        target.dies(opponent=entity)
        entity.player_killed_counter += 1
        target.death_from_player_counter += 1

        force_return = check_trigger(entity, "after_kill", entity, target, behavioured)
        if force_return:
            return True
        force_return = check_trigger(target, "after_killed", entity, target, behavioured)
        if force_return:
            return True
        return True

    # Se non sta combattendo procede all'attacco o alla distruzione della vittima
    if entity.is_fighting(with_him=target):
        entity.act("Non è ancora giusto il momento di dare il colpo di grazia a $N.", TO.ENTITY, target)
        entity.act("$n vorrebbe dare il colpo di grazia a $N, ma non è ancora giunto il suo momento...", TO.OTHERS, target)
        entity.act("$n vorrebbe darti il colpo di grazia, ma non è ancora giunto il tuo momento...", TO.TARGET, target)
        return False

    if target.IS_ITEM:
        execution_result = kill_handler(entity, argument, "command_kill", entity_tables, verbs=DESTROY_VERBS, behavioured=behavioured)
    else:
        execution_result = kill_handler(entity, argument, "command_kill", entity_tables, verbs=ATTACK_VERBS, behavioured=behavioured)
    return execution_result
Example #19
0
def command_buy(entity, argument="", verbs=VERBS, behavioured=False):
    """
    Permette di comprare entità da un commerciante.
    """
    # È possibile se il comando è stato deferrato
    if not entity:
        return False

    entity = entity.split_entity(1)

    if not argument:
        entity.send_output("Cosa vorresti %s?" % verbs["infinitive"])
        if entity.IS_PLAYER and OPTION.NEWBIE in entity.account.options:
            syntax = get_command_syntax(entity, "command_buy")
            entity.send_output(syntax, break_line=False)
        return False

    # Ricava la quantità di entità da comprare
    quantity, argument = quantity_argument(argument)
    arg, argument = one_argument(argument)

    # Cerca specificatamente il negoziante con l'argomento passato
    if argument:
        dealer = entity.find_entity_extensively(argument, quantity=quantity)
        if not dealer:
            entity.act("Non trovi nessun negoziante chiamato [white]%s[close]." % argument, TO.ENTITY)
            entity.act("$n sembra cercare qualcuno da cui %s qualcosa." % verbs["infinitive"], TO.OTHERS)
            return False
        if not dealer.shop:
            entity.act("$N non sembra essere un negoziante da cui %s qualcosa." % verbs["infinitive"], TO.ENTITY, dealer)
            entity.act("$n si accorge che $N non è un negoziante da cui %s qualcosa." % verbs["infinitive"], TO.OTHERS, dealer)
            entity.act("$n si accorge che tu non sei un negoziante da cui %s qualcosa." % verbs["infinitive"], TO.TARGET, dealer)
            return False
    # Altrimenti cerca il primo negoziante che si trova nella locazione del giocatore
    else:
        for dealer in entity.location.iter_contains():
            if dealer.shop:
                break
        else:
            entity.act("Qui non trovi nessun [white]negoziante[close].", TO.ENTITY)
            entity.act("$n non sembra trovare qualcuno da cui %s qualcosa." % verbs["infinitive"], TO.OTHERS)
            return False

    # Controlla se il negoziante si trova in una locazione che fa, per lui, da negozio
    if not dealer.shop.in_location(dealer):
        entity.act("Non puoi %s nulla da $N se non si trova nel suo negozio." % verbs["infinitive"], TO.ENTITY, dealer)
        entity.act("$n non può %s nulla da $N se non si trova nel suo negozio." % verbs["infinitive"], TO.OTHERS, dealer)
        entity.act("$n non può %s nulla da te se non ti trovi nel tuo negozio." % verbs["infinitive"], TO.TARGET, dealer)
        return False

    # Indica che un'entità vuole interagire con il dealer
    if entity not in dealer.interactions:
        dealer.interactions.append(entity)

    # Ricava il magazzino del negoziante
    storage = dealer.shop.get_storage(dealer)
    if not storage:
        if dealer.shop.proto_storages and dealer.shop.proto_storages[0].IS_MOB:
            from_where = "da chi"
        else:
            from_where = "da dove"
        entity.act("Non puoi %s nulla da $N perché non ha %s prendere la mercanzia!" % (verbs["infinitive"], from_where), TO.ENTITY, dealer)
        entity.act("$n non può %s nulla da $N perché non ha %s prendere la mercanzia!" % (verbs["infinitive"], from_where), TO.OTHERS, dealer)
        entity.act("$n non può %s nulla perché non hai %s prendere la mercanzia!" % (verbs["you2"], from_where), TO.TARGET, dealer)
        return False

    # Cerca l'oggetto voluto nel magazzino del negoziante
    target = dealer.find_entity(arg, location=storage)
    if not target:
        descr = ""
        if SHOP.DISPENSER in dealer.shop.types:
            descr = "tra i prodotti esposti nel distributore"
        else:
            descr = "nella mercanzia esposta"
        entity.act("Non trovi nessun [white]%s[close] %s." % (arg, descr), TO.ENTITY, dealer)
        entity.act("$n non trova tra gli oggetti esposti da $N una [white]cosa[close] in particolare.", TO.OTHERS, dealer)
        entity.act("$n non trova tra i tuoi oggetti esposti una [white]cosa[close] in particolare.", TO.TARGET, dealer)
        return False

    if quantity != 1 and SHOP.DISPENSER in dealer.shop.types:
        entity.act("Non riesci in alcuni modo a %s %d quantità di $a da $N." % verbs["infinitive"], TO.ENTITY, dealer, target)
        entity.act("$n non riesce in alcun modo a %s $a in quantità maggiore di una da $N." % verbs["infinitive"], TO.OTHERS, dealer, target)
        entity.act("$n non riesce in alcun modo a %s $a in quantità maggiore di una da te." % verbs["infinitive"], TO.TARGET, dealer, target)
        entity.act("$n non riesce in alcun modo a %s in quantità maggiore di una da $a." % verbs["you2"], TO.TARGET, target, dealer)
        return False

    # Controlla se in magazzino vi sia la quantità voluta dell'oggetto da comprare
    if quantity == 0:
        quantity = target.quantity
    elif target.quantity < quantity:
        entity.act("Puoi %s solo %d quantità di $N da $a, riprova più tardi." % (verbs["infinitive"], target.quantity), TO.ENTITY, target, dealer)
        entity.act("$n può %s solo %d quantità di $N da $a." % (verbs["infinitive"], target.quantity), TO.OTHERS, target, dealer)
        entity.act("$n può %s da $a solo in %d quantità." % (verbs["you2"], target.quantity), TO.TARGET, target, dealer)
        entity.act("$n può %s $a da te solo in %d quantità." % (verbs["infinitive"], target.quantity), TO.TARGET, dealer, target)
        return False

    buyable = dealer.shop.get_buyable(target)
    if not buyable:
        entity.act("Ti accorgi che $N non è nel listino delle cose possibili da %s." % verbs["infinitive"], TO.ENTITY, target)
        entity.act("$n si accorge che $N non è nel listino delle cose possibili da %s." % verbs["infinitive"], TO.OTHERS, target)
        entity.act("$n si accorge che non sei nel listino delle cose possibili da %s." % verbs["infinitive"], TO.TARGET, target)
        return False

    price, discount = buyable.get_price(target, quantity=quantity)
    pretty_price = pretty_money_value(price, extended=True)

    # Controlla se il giocatore possa comprare un determinato articolo
    if not can_afford(target.value * quantity, entity, race=dealer.race):
        dealer.shop.send_cannot_afford_messages(entity, target, dealer, verbs, quantity, pretty_price)
        return False

    # Controlla se il giocatore può portare il peso dell'oggetto con sé
    if not entity.can_carry_target(target, quantity=quantity):
        if quantity <= 1:
            entity.act("$N è troppo pesante perché tu possa portarl$O assieme alle tue cose.", TO.ENTITY, target, dealer)
            entity.act("$N è troppo pesante perché $n lo possa portare assieme alle sue cose.", TO.OTHERS, target, dealer)
            entity.act("Sei troppo pesante perché $n ti possa portare assieme alle sue cose.", TO.TARGET, target, dealer)
            # l'act TO.OTHERS fa da 4° messaggio per dealer
        else:
            plural = grammar_gender(target, masculine="i", feminine="e")
            entity.act("%d $N sono troppo pesanti perché tu possa portarl%s assieme alle tue cose." % (quantity, plural), TO.ENTITY, target, dealer)  # (GR) plurare di $N
            entity.act("%d $N sono troppo pesanti perché $n l%s possa portare assieme alle sue cose." % (quantity, plural), TO.OTHERS, target, dealer)  # (GR) plurare di $N
            entity.act("Siete troppo pesanti perché $n vi possa portare assieme alle sue cose.", TO.TARGET, target, dealer)
            # l'act TO.OTHERS fa da 4° messaggio per dealer
        return False

    force_return = check_trigger(entity, "before_buy", entity, dealer, target, quantity, behavioured)
    if force_return:
        return True
    force_return = check_trigger(dealer, "before_buying", entity, dealer, target, quantity, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "before_bought", entity, dealer, target, quantity, behavioured)
    if force_return:
        return True

    dealer.shop.send_buy_messages(entity, target, dealer, verbs, quantity, pretty_price, discount)

    give_moneys(entity, dealer, price, race=dealer.race)
    target = target.from_location(quantity)
    target.to_location(entity)

    # Dona un po' di esperienza ai giocatori che hanno comprato per la prima
    # volta l'entità
    if entity.IS_PLAYER:
        if target.prototype.code in entity.bought_entities:
            entity.bought_entities[target.prototype.code] += 1
        else:
            entity.bought_entities[target.prototype.code] = 1
            reason = "per aver comprato per la prima volta %s" % target.get_name(looker=entity)
            entity.give_experience(target.level*10, reason=reason)

    force_return = check_trigger(entity, "after_buy", entity, dealer, target, quantity, behavioured)
    if force_return:
        return True
    force_return = check_trigger(dealer, "after_buying", entity, dealer, target, quantity, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "after_bought", entity, dealer, target, quantity, behavioured)
    if force_return:
        return True

    return True
Example #20
0
def command_destroy(entity, argument="", verbs=VERBS, behavioured=False):
    # È possibile se il comando è stato deferrato
    if not entity:
        return False

    entity = entity.split_entity(1)

    if entity.sended_inputs and is_prefix("romp", entity.sended_inputs[-1]):
        verbs = VERBS2

    if not argument:
        entity.send_output("Che cosa vorresti %s?" % verbs["infinitive"])
        if entity.IS_PLAYER and OPTION.NEWBIE in entity.account.options:
            syntax = get_command_syntax(entity, "command_destroy")
            entity.send_output(syntax, destroy_line=False)
        return False

    # Solo gli oggetti animati possono utilizzare tale comando
    if entity.IS_ITEM and FLAG.CAN_DAMAGING not in entity.flags:
        entity.act("Non ti è possibile %s nulla di nulla.", TO.ENTITY)
        entity.act("$n sembra vibrare per un attimo... ma forse è stato un abbaglio.", TO.OTHERS)
        return False

    # Ricava l'eventuale quantità d'oggetti da raccogliere
    quantity, argument = quantity_argument(argument)
    arg, argument = one_argument(argument)

    target = entity.find_entity_extensively(arg, entity_tables=["items"], inventory_pos="first")
    if not target:
        target = entity.find_entity_extensively(arg, inventory_pos="first")
        if target:
            attack_translation = translate_input(entity, "attack", "en")
            javascript_code = '''javascript:parent.sendInput('%s %s');''' % (attack_translation, target.get_numbered_keyword(looker=entity))
            destroy_noun = verbs["noun"] % grammar_gender(target)
            attack_noun = ATTACK_VERBS["noun"] % grammar_gender(target)
            html_code = '''<a href="%s">%s</a>''' % (javascript_code, attack_noun)
            entity.act("$N non è un oggetto quindi non puoi %s, ma puoi sempre %s." % (destroy_noun, html_code), TO.ENTITY, target)
            entity.act("$n posa uno sguardo indagatore su $N.", TO.OTHERS, target)
            entity.act("$n posa uno sguardo indagatore su di te.", TO.TARGET, target)
        else:
            entity.act("Non riesci a trovare nessun [white]%s[close] da %s" % (arg, verbs["infinitive"]), TO.ENTITY)
            entity.act("$n cerca qualcosa che però non trova.", TO.OTHERS)
        return False

    # (TD) resistenza al comando se charmati

    # (TD) skill di forza bruta

    if quantity == 0:
        quantity = target.quantity
    elif target.quantity < quantity:
        entity.act("Non puoi %s $N perché ve ne sono solo %d e non %d." % (verbs["infinitive"], target.quantity, quantity), TO.ENTITY, target)
        entity.act("$n sta cercando di ammucchiare un quantitativo voluto di $N per poterlo %s" % verbs["infinitive"], TO.OTHERS, target)
        entity.act("$n sta cercando di ammucchiarti per un quantitativo voluto per %s" % ["you2"], TO.TARGET, target)
        return False

    # In questa maniera crea l'entità finale che verrà manipolata dai trigger
    # in maniera omogenea senza dover attendere la chiamata della from_location
    target = target.split_entity(quantity)

    force_return = check_trigger(entity, "before_destroy", entity, target, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "before_broken", entity, target, behavioured)
    if force_return:
        return True

    damage = damage_target(entity, target)
    index, dam_verb_you, dam_verb_it = get_destroy_verbs(damage)

    if target.life <= 0:
        end_destroy(entity, target, verbs, behavioured)
    else:
        messages = {
            "entity" : "%s $N." % dam_verb_you,
            "others" : "$n %s $N." % dam_verb_it,
            "target" : "$n ti %s." % dam_verb_it}
        send_destroy_messages(messages, "start_destroy", entity, target, verbs)
        if index != 0:
            entity.action_in_progress = ActionInProgress(DESTROY_SECONDS, continue_destroy, stop_destroy, entity, target, verbs, behavioured)

    return True
Example #21
0
    def recall(self, message=True, also_entities=None):
        if not also_entities:
            also_entities = []

        if message:
            self.send_output("Verrai teletrasportat%s al [white]Menhir della Vita[close] più vicino." % grammar_gender(self))
            self.send_prompt(show_opponent=False)

        destination_room = config.initial_destination.get_room()
        if not destination_room:
            log.bug("destination_room non valida: %r" % destination_room)
            return

        self = self.from_location(1, use_repop=False)
        self.to_location(destination_room, use_look=True)
        self.send_prompt()

        for entity in also_entities:
            entity = entity.from_location(entity.quantity, use_repop=False)
            entity.to_location(destination_room, use_look=True)
            entity.send_prompt()
Example #22
0
def give_or_put(entity, argument, verbs, behavioured, entity_tables, noflag,
                noroom, gamescript_suffix1, gamescript_suffix2,
                gamescript_suffix3, preposition):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    # argument può essere una stringa vuota

    if not verbs:
        log.bug("verbs non è un parametro valido: %r" % verbs)
        return False

    if not entity_tables:
        log.bug("entity_tables non è un parametro valido: %r" % entity_tables)
        return False

    if noflag not in (FLAG.NO_PUT, FLAG.NO_GIVE):
        log.bug("noflag non è un parametro valido: %r" % noflag)
        return False

    if noroom not in (ROOM.NO_PUT, ROOM.NO_GIVE):
        log.bug("noroom non è un parametro valido: %r" % noroom)
        return False

    if gamescript_suffix1 not in ("put", "give"):
        log.bug("gamescript_suffix1 non è un parametro valido: %r" %
                gamescript_suffix1)
        return False

    if gamescript_suffix2 not in ("putted", "gave"):
        log.bug("gamescript_suffix2 non è un parametro valido: %r" %
                gamescript_suffix2)
        return False

    if gamescript_suffix3 not in ("putting", "giving"):
        log.bug("gamescript_suffix3 non è un parametro valido: %r" %
                gamescript_suffix3)
        return False

    if preposition not in ("in", "a"):
        log.bug("gamescript_suffix non è un parametro valido: %r" %
                gamescript_suffix)
        return False

    # -------------------------------------------------------------------------

    entity = entity.split_entity(1)

    if not argument:
        entity.send_output(
            "Che [white]cosa[close] vorresti %s %s [white]%s[close]?" %
            (verbs["infinitive"], preposition,
             "qualcuno" if preposition == "a" else "qualcosa"))
        if entity.IS_PLAYER and OPTION.NEWBIE in entity.account.options:
            syntax = get_command_syntax(entity, "command_put")
            entity.send_output(syntax)
        return False

    # Ricava l'eventuale quantità d'oggetti da posare
    quantity, argument = quantity_argument(argument)
    arg1, argument = one_argument(argument)

    # (TD) Controllo del mental state deviato

    # Ricerca nell'inventario dell'entità quella da dare o mettere
    target = entity.find_entity(arg1, quantity=quantity, location=entity)

    arg2 = ""
    receiver = None
    if argument:
        arg2, argument = one_argument(argument)
        # Rimuove eventuali argomenti facoltativi
        if argument and arg2 == "a":
            arg2, argument = one_argument(argument)
        # Ricerca dell'entità bersaglio a cui dare l'entità target
        receiver = entity.find_entity_extensively(arg2,
                                                  entity_tables=entity_tables)

        # Controlla se si vuole inserire una porta sui cardini di un'uscita
        direction = get_direction(arg2)
        if target and not receiver and direction != DIR.NONE:
            if not entity.location.IS_ROOM:
                entity.act(
                    "Vorresti %s $N sui cardini di un'eventuale uscita %s, ma non ti trovi in una stanza."
                    % (verbs["infinitive"], direction.to_dir), TO.ENTITY,
                    target)
                entity.act(
                    "$n vorrebbe %s $N sui cardini di un'eventuale uscita %s, ma non vi trovate in una stanza."
                    % (verbs["infinitive"], direction.to_dir), TO.OTHERS,
                    target)
                entity.act(
                    "$n ti vorrebbe %s sui cardini di un'eventuale uscita %s, ma non vi trovate in una stanza."
                    % (verbs["infinitive"], direction.to_dir), TO.TARGET,
                    target)
                return False
            if not direction in entity.location.exits:
                entity.act(
                    "Vorresti %s $N sui cardini di un'eventuale uscita %s, ma questa non esiste."
                    % (verbs["infinitive"], direction.to_dir), TO.ENTITY,
                    target)
                entity.act(
                    "$n vorrebbe %s $N sui cardini di un'eventuale uscita %s, ma questa non esiste."
                    % (verbs["infinitive"], direction.to_dir), TO.OTHERS,
                    target)
                entity.act(
                    "$n ti vorrebbe %s sui cardini di un'eventuale uscita %s, ma questa non esiste."
                    % (verbs["infinitive"], direction.to_dir), TO.TARGET,
                    target)
                return False
            exit_door = entity.location.exits[direction].door
            if exit_door:
                entity.act(
                    "Vorresti %s $N sui cardini dell'uscita %s, ma questa possiede già $a."
                    % (verbs["infinitive"], direction.to_dir), TO.ENTITY,
                    target, exit_door)
                entity.act(
                    "$n vorrebbe %s $N sui cardini dell'uscita %s, ma questa possiede già $a."
                    % (verbs["infinitive"], direction.to_dir), TO.OTHERS,
                    target, exit_door)
                entity.act(
                    "$n ti vorrebbe %s sui cardini dell'uscita %s, ma questa possiede già $a."
                    % (verbs["infinitive"], direction.to_dir), TO.TARGET,
                    target, exit_door)
                return False
            if not target.door_type:
                entity.act(
                    "Vorresti %s sui cardini dell'uscita %s $N, ma quest'ultim$O non è una porta."
                    % (verbs["infinitive"], direction.to_dir), TO.ENTITY,
                    target, exit_door)
                entity.act(
                    "$n vorrebbe %s sui cardini dell'uscita %s $N, ma quest'ultim$O non è una porta."
                    % (verbs["infinitive"], direction.to_dir), TO.OTHERS,
                    target, exit_door)
                entity.act(
                    "$n ti vorrebbe %s sui cardini dell'uscita %s, ma non sei una porta."
                    % (verbs["infinitive"], direction.to_dir), TO.TARGET,
                    target, exit_door)
                return False
            if quantity > 1:
                entity.act(
                    "Vorresti %s sui cardini dell'uscita %s $N, ma è possibile inserirne solo un$O."
                    % (verbs["infinitive"], direction.to_dir), TO.ENTITY,
                    target, exit_door)
                entity.act(
                    "$n vorrebbe %s sui cardini dell'uscita %s $N, ma è possibile inserirne solo un$O"
                    % (verbs["infinitive"], direction.to_dir), TO.OTHERS,
                    target, exit_door)
                entity.act(
                    "$n ti vorrebbe %s sui cardini dell'uscita %s, ma è possibile inserirti solo in un'unità."
                    % (verbs["infinitive"], direction.to_dir), TO.TARGET,
                    target, exit_door)
                return False

            force_return = check_trigger(entity,
                                         "before_" + gamescript_suffix1,
                                         entity, target, None, direction,
                                         behavioured)
            if force_return:
                return True
            force_return = check_trigger(target,
                                         "before_" + gamescript_suffix2,
                                         entity, target, None, direction,
                                         behavioured)
            if force_return:
                return True
            force_return = check_trigger(receiver,
                                         "before_" + gamescript_suffix3,
                                         entity, target, None, direction,
                                         behavioured)
            if force_return:
                return True

            entity.act(
                "%s $N sui cardini dell'uscita %s." %
                (verbs["you"], direction.to_dir), TO.ENTITY, target)
            entity.act(
                "$n %s $N sui cardini dell'uscita %s." %
                (verbs["it"], direction.to_dir), TO.OTHERS, target)
            entity.act(
                "$n ti %s sui cardini dell'uscita %s." %
                (verbs["it"], direction.to_dir), TO.TARGET, target)
            target = target.from_location(1)
            target.to_location(entity.location)
            entity.location.exits[direction].door = target

            force_return = check_trigger(entity, "after_" + gamescript_suffix1,
                                         entity, target, None, direction,
                                         behavioured)
            if force_return:
                return True
            force_return = check_trigger(target, "after_" + gamescript_suffix2,
                                         entity, target, None, direction,
                                         behavioured)
            if force_return:
                return True
            force_return = check_trigger(receiver,
                                         "after_" + gamescript_suffix3, entity,
                                         target, None, direction, behavioured)
            if force_return:
                return True

            return True

    # -------------------------------------------------------------------------

    if not arg2:
        arg2 = "qualcuno" if preposition == "a" else "qualcosa"

    # Se l'entità a cui dare si trova nell'inventario allora lo indica
    on_message_you = ""
    on_message_it = ""
    if receiver and receiver.location and receiver.location == entity:
        if receiver and len(receiver.wear_mode) > 0:
            on_message_you = " che stai [khaki]indossando[close]"
            on_message_it = " che sta [khaki]indossando[close]"
        else:
            on_message_you = " nel tuo [yellow]inventario[close]"
            on_message_it = " nel suo [yellow]inventario[close]"

    # Gestisce le varie combinazioni di entità non trovate e/o uguali
    # all'entità che ha digitato il comando
    if target:
        if not receiver:
            entity.act(
                "Cerchi di %s $N %s [white]%s[close] che non trovi da nessuna parte."
                % (verbs["infinitive"], preposition, arg2), TO.ENTITY, target)
            entity.act(
                "$n cerca di %s $N %s [white]%s[close] che non sembra trovare da nessuna parte."
                % (verbs["infinitive"], preposition, arg2), TO.OTHERS, target)
            entity.act(
                "$n cerca di %s %s [white]%s[close] che non sembra trovare da nessuna parte."
                % (verbs["you2"], preposition, arg2), TO.TARGET, target)
            return False
        elif receiver == entity:
            entity.act(
                "Cerchi di %s $N %s te stess$o, ma è già tu$O!" %
                (verbs["infinitive"], preposition), TO.ENTITY, target)
            entity.act(
                "$n cerca di %s $N %s se stess$o, ma è già su$O." %
                (verbs["infinitive"], preposition), TO.OTHERS, target)
            entity.act(
                "$n cerca di %s $N %s se stess$o, ma è già su$O." %
                (verbs["infinitive"], preposition), TO.TARGET, target)
            return False
        elif receiver == target:
            entity.act(
                "Cerchi di %s $N %s se stess$o, ma ciò è impossibile!" %
                (verbs["infinitive"], preposition), TO.ENTITY, target)
            entity.act(
                "$n cerca di %s $N %s se stess$o, ma ciò è impossibile." %
                (verbs["infinitive"], preposition), TO.OTHERS, target)
            entity.act(
                "$n cerca di %s $N %s te stess$o, ciò è impossibile." %
                (verbs["infinitive"], preposition), TO.TARGET, target)
            return False
    elif not target:
        if not receiver:
            entity.act(
                "Cerchi di %s [white]%s[close] %s [white]%s[close], ma non trovi nulla e nessuno nel tuo inventario."
                % (verbs["infinitive"], arg1, preposition, arg2), TO.ENTITY)
            entity.act(
                "$n cerca di %s [white]qualcosa[close] %s [white]quacuno[close], ma senza molti risultati nel suo inventario."
                % (verbs["infinitive"], preposition), TO.OTHERS)
            return False
        elif receiver == entity:
            if entity.IS_ITEM:
                entity.act(
                    "Cerchi di [orange]passarti [white]%s[close], ma non trovi [gray]nulla del genere[close] nel tuo [yellow]inventario[close]."
                    % arg1, TO.ENTITY, receiver)
                entity.act(
                    "$n cerca di [orange]passarsi [white]qualcosa[close] che [gray]non sembra trovare[close] nel suo [yellow]inventario[close].",
                    TO.OTHERS, receiver)
            else:
                entity.act(
                    "Cerchi di [orange]passarti[close] da una $hand all'altra [white]%s[close], ma non trovi [gray]nulla del genere[close] nel tuo [yellow]inventario[close]."
                    % arg1, TO.ENTITY, receiver)
                entity.act(
                    "$n cerca di [orange]passarsi[close] da una $hand all'altra [white]qualcosa[close] che [gray]non sembra trovare[close] nel suo [yellow]inventario[close].",
                    TO.OTHERS, receiver)
            return False
        else:
            if on_message_you and on_message_it:
                entity.act(
                    "Cerchi di %s un [white]%s[close] %s $N%s, ma non trovi [gray]nulla del genere[close]."
                    % (verbs["infinitive"], arg1, preposition, on_message_you),
                    TO.ENTITY, receiver)
                entity.act(
                    "$n cerca di %s [white]qualcosa[close] %s $N%s, ma non sembra trovare [gray]nulla del genere[close]."
                    % (verbs["infinitive"], preposition, on_message_it),
                    TO.OTHERS, receiver)
                entity.act(
                    "$n cerca di %s [white]qualcosa[close], ma non sembra trovare [gray]nulla del genere[close]."
                    % (verbs["infinitive"]), TO.TARGET, receiver)
            else:
                entity.act(
                    "Cerchi di %s un [white]%s[close] %s $N, ma non trovi [gray]nulla del genere[close] nel tuo [yellow]inventario[close]."
                    % (verbs["infinitive"], arg1, preposition), TO.ENTITY,
                    receiver)
                entity.act(
                    "$n cerca di %s [white]qualcosa[close] %s $N, ma non sembra trovare [gray]nulla del genere[close] nel suo [yellow]inventario[close]."
                    % (verbs["infinitive"], preposition[2:]), TO.OTHERS,
                    receiver)
                entity.act(
                    "$n cerca di %s [white]qualcosa[close], ma non sembra trovare [gray]nulla del genere[close] nel suo [yellow]inventario[close]."
                    % (verbs["infinitive"]), TO.TARGET, receiver)
            return False

    if quantity == 0:
        quantity = target.quantity
    elif target.quantity < quantity:
        entity.act(
            "Non puoi %s $N perché ne possiedi solo %d e non %d." %
            (verbs["infinitive"], target.quantity, quantity), TO.ENTITY,
            target)
        entity.act(
            "$n sta cercando di ammucchiare un quantitativo voluto di $N per poterlo %s"
            % verbs["infinitive"], TO.OTHERS, target)
        entity.act(
            "$n sta cercando di ammucchiarti per un quantitativo voluto per poterti %s"
            % verbs["infinitive"], TO.TARGET, target)
        return False

    if receiver.container_type and CONTAINER.CLOSED in receiver.container_type.flags:
        entity.act(
            "Cerchi di %s $a %s $N ma l$O trovi chius$O." %
            (verbs["infinitive"], preposition), TO.ENTITY, receiver, target)
        entity.act(
            "$n cerca di %s $a %s $N ma l$O trova chius$O." %
            (verbs["infinitive"], preposition), TO.OTHERS, receiver, target)
        return False

    # Se l'obiettivo a cui dare l'entità è un oggetto e non è un contenitore
    # allora solo gli admin possono eseguire l'azione
    if receiver.IS_ITEM and not receiver.container_type:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin(
                "Il ricevitore non è un contenitore ma tu puoi eseguire comunque l'azione"
            )
        else:
            entity.act(
                "Cerchi di %s $N %s $a, ma quest'ultimo non ti sembra un contenitore."
                % (verbs["infinitive"], preposition), TO.ENTITY, target,
                receiver)
            entity.act(
                "$n cerca di %s $N %s $a, ma non riesce a trovare modo per farlo non essendo un contenitore."
                % (verbs["infinitive"], preposition), TO.OTHERS, target,
                receiver)
            entity.act(
                "$n cerca di %s %s $a, ma non sembra riuscirvi visto che quest'ultimo non è un contenitore."
                % (verbs["you2"], preposition), TO.TARGET, target, receiver)
            entity.act(
                "$n cerca di %s $a, ma avrà ben poca fortuna visto che non sei un contenitore."
                % verbs["you"], TO.TARGET, receiver, target)
            return False

    # Se l'entità che ha inviato il comando ha la noflag viene evitata
    # l'azione
    if noflag in entity.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin("Tu avresti in realtà la flag NO_GIVE")
        else:
            entity.act(
                "Cerchi di %s $N %s $a, ma qualche [blueroyal]forza misteriosa[close] ti blocca l'azione."
                % (verbs["infinitive"], preposition), TO.ENTITY, target,
                receiver)
            entity.act(
                "$n cerca di %s $N %s $a, ma sembra essere bloccat$n da una [royalblue]forza misteriosa[close]."
                % (verbs["infinitive"], preposition), TO.OTHERS, target,
                receiver)
            entity.act(
                "$n cerca di %s %s $a, ma sembra essere essere bloccat$o da una [royalblue]forza misteriosa[close]."
                % (verbs["you2"], preposition), TO.TARGET, target, receiver)
            entity.act(
                "$n cerca di %s $a, ma sembre essere bloccat$o da una [royalblue]forza misteriosa[close]."
                % verbs["you"], TO.TARGET, receiver, target)
            return False

    # Se l'oggetto da dare ha la flag NO_GIVE allora evita di farsi
    if noflag in target.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin(
                "L'entità da dare avrebbe in realtà la flag NO_GIVE")
        else:
            if entity.IS_ITEM:
                entity.act(
                    "Appena cerchi di %s $N %s $a te lo ritrovi, con un [cyan]balzo[close] addosso."
                    % (verbs["infinitive"], preposition), TO.ENTITY, target,
                    receiver)
                entity.act(
                    "Appena $n cerca di %s $N %s $a se lo ritrova, con un [cyan]balzo[close] addosso."
                    % (verbs["infinitive"], preposition), TO.OTHERS, target,
                    receiver)
                entity.act(
                    "Appena $n cerca di %s %s $a gli [cyan]rimbalzi[close] addosso."
                    % (verbs["you2"], preposition), TO.TARGET, target,
                    receiver)
                entity.act(
                    "Appena $n cerca di %s $a se lo ritrova, con un [cyan]balzo[close] addosso."
                    % verbs["you2"], TO.TARGET, receiver, target)
            else:
                entity.act(
                    "Appena cerchi di %s $N %s $a te lo ritrovi, con un [cyan]balzo[close], in $hand."
                    % (verbs["infinitive"], preposition), TO.ENTITY, target,
                    receiver)
                entity.act(
                    "Appena $n cerca di %s $N %s $a se lo ritrova, con un [cyan]balzo[close], in $hand."
                    % (verbs["infinitive"], preposition), TO.OTHERS, target,
                    receiver)
                entity.act(
                    "Appena $n cerca di %s %s $a gli [cyan]rimbalzi[close] in $hand."
                    % (verbs["you2"], preposition), TO.TARGET, target,
                    receiver)
                entity.act(
                    "Appena $n cerca di %s $a se lo ritrova, con un [cyan]balzo[close], in $hand."
                    % verbs["you2"], TO.TARGET, receiver, target)
            return False

    # Se l'entità a cui dare l'oggetto ha la flag NO_GIVE allora non lo accetta
    if noflag in receiver.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin(
                "L'entità a cui dare avrebbe in realtà la flag NO_GIVE")
        else:
            if entity.IS_ITEM:
                entity.act(
                    "Cerchi di %s $N %s $a, ma questi te l$O ridà." %
                    (verbs["infinitive"], preposition), TO.ENTITY, target,
                    receiver)
                entity.act(
                    "$n cerca di %s $N %s $a, ma questi gliel$O ridà." %
                    (verbs["infinitive"], preposition), TO.OTHERS, target,
                    receiver)
                entity.act(
                    "$n cerca di %s %s $a, ma questi gliel$O ridà." %
                    (verbs["you2"], preposition), TO.TARGET, target, receiver)
                entity.act(
                    "$n cerca di %s $a, ma gliel%s ridai." %
                    (verbs["you2"], grammar_gender(target)), TO.TARGET,
                    receiver, target)
            else:
                entity.act(
                    "Cerchi di %s $N %s $a, ma questi te l$O ridà in $hand." %
                    (verbs["infinitive"], preposition), TO.ENTITY, target,
                    receiver)
                entity.act(
                    "$n cerca di %s $N %s $a, ma questi gliel$O ridà in $hand."
                    % (verbs["infinitive"], preposition), TO.OTHERS, target,
                    receiver)
                entity.act(
                    "$n cerca di %s %s $a, ma questi gliel$O ridà in $hand." %
                    (verbs["you2"], preposition), TO.TARGET, target, receiver)
                entity.act(
                    "$n cerca di %s $a, ma gliel%s ridai in $hand." %
                    (verbs["you2"], grammar_gender(target)), TO.TARGET,
                    receiver, target)
            return False

    # Se la stanza ha la flag NO_GIVE non permette di dare oggetti
    if entity.location.IS_ROOM and noroom in entity.location.flags:
        if entity.trust > TRUST.PLAYER:
            entity.send_to_admin(
                "Questa stanza avrebbe in realtà la flag di NO_GIVE")
        else:
            if entity.IS_ITEM:
                entity.act(
                    "Appena cerchi di %s $N %s $a%s te l$O ritrovi addosso come se una [royalblue]forza misteriosa[close] nel luogo ti impedisse quest'azione!"
                    % (verbs["infinitive"], preposition, on_message_you),
                    TO.ENTITY, target, receiver)
                entity.act(
                    "Appena $n cerca di %s %s $a%s $N se l$O ritrova addosso come se vi fosse una [royalblue]forza misteriosa[close] nel luogo!"
                    % (verbs["infinitive"], preposition, on_message_it),
                    TO.OTHERS, target, receiver)
                entity.act(
                    "Appena $n cerca di %s %s $a%s gli ritorni addosso grazie ad una [royalblue]forza misteriosa[close] del luogo!"
                    % (verbs["you2"], preposition, on_message_it), TO.TARGET,
                    target, receiver)
                entity.act(
                    "Appena $n cerca di %s $a gli ritorna addosso grazie ad una [royalblue]forza misteriosa[close] del luogo!"
                    % (verbs["you2"]), TO.TARGET, receiver, target)
            else:
                entity.act(
                    "Appena cerchi di %s $N %s $a%s te l$O ritrovi in $hand come se una [royalblue]forza misteriosa[close] nel luogo ti impedisse quest'azione!"
                    % (verbs["infinitive"], preposition, on_message_you),
                    TO.ENTITY, target, receiver)
                entity.act(
                    "Appena $n cerca di %s %s $a%s $N se l$O ritrova in $hand come se vi fosse una [royalblue]forza misteriosa[close] nel luogo!"
                    % (verbs["infinitive"], preposition, on_message_it),
                    TO.OTHERS, target, receiver)
                entity.act(
                    "Appena $n cerca di %s %s $a%s gli ritorni in $hand grazie ad una [royalblue]forza misteriosa[close] del luogo!"
                    % (verbs["you2"], preposition, on_message_it), TO.TARGET,
                    target, receiver)
                entity.act(
                    "Appena $n cerca di %s $a gli ritorna in $hand grazie ad una [royalblue]forza misteriosa[close] del luogo!"
                    % (verbs["you2"]), TO.TARGET, receiver, target)
            return False

    # (TD) dare monete

    # (TD) gestione dell'argomento all, ultima cosa da supportare

    # Se il peso dell'entità da dare supera quello sopportabile dall'obiettivo
    # a cui darlo allora avverte e evita l'azione
    # (TD) size e carry_number come il get?
    if not receiver.can_carry_target(target, quantity=quantity):
        if receiver.trust > TRUST.PLAYER:
            receiver.send_to_admin(
                "Riesci comunque a %s %s anche se è troppo pesante per te." %
                (verbs["infinitive"], target.get_name(entity)))
        elif entity.trust > TRUST.PLAYER and not receiver.IS_PLAYER:
            entity.send_to_admin(
                "Riesci comunque a %s %s anche se è troppo pesante per %s." %
                (verbs["infinitive"], target.get_name(entity),
                 receiver.get_name(entity)))
        else:
            entity.act(
                "Non riesci %s %s $N a $a, non può portare con sé tutto quel peso."
                % (verbs["infinitive"], preposition), TO.ENTITY, target,
                receiver)
            entity.act(
                "$n non riesce a %s $N %s $a, non può portare con sé tutto quel peso."
                % (verbs["infinitive"], preposition), TO.OTHERS, target,
                receiver)
            entity.act(
                "$n non riesce a %s %s $a, non può portare con sé tutto il tuo peso."
                % (verbs["you2"], preposition), TO.TARGET, target, receiver)
            entity.act(
                "$n non riesce a %s $a, non puoi portare con te tutto quel peso."
                % verbs["you2"], TO.TARGET, receiver, target)
            return False

    force_return = check_trigger(entity, "before_" + gamescript_suffix1,
                                 entity, target, receiver, DIR.NONE,
                                 behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "before_" + gamescript_suffix2,
                                 entity, target, receiver, DIR.NONE,
                                 behavioured)
    if force_return:
        return True
    force_return = check_trigger(receiver, "before_" + gamescript_suffix3,
                                 entity, target, receiver, DIR.NONE,
                                 behavioured)
    if force_return:
        return True

    if on_message_you and on_message_it:
        entity.act(
            "%s $N %s $a%s." %
            (color_first_upper(verbs["you"]), preposition, on_message_you),
            TO.ENTITY, target, receiver)
        entity.act(
            "$n %s $N %s $a%s." % (verbs["it"], preposition, on_message_it),
            TO.OTHERS, target, receiver)
        entity.act(
            "$n ti %s %s $a%s." % (verbs["it"], preposition, on_message_it),
            TO.TARGET, target, receiver)
        entity.act("$n ti %s $a." % verbs["it"], TO.TARGET, receiver, target)
    else:
        entity.act(
            "%s $N %s $a." % (color_first_upper(verbs["you"]), preposition),
            TO.ENTITY, target, receiver)
        entity.act("$n %s $N %s $a." % (verbs["it"], preposition), TO.OTHERS,
                   target, receiver)
        entity.act("$n ti %s %s $a." % (verbs["it"], preposition), TO.TARGET,
                   target, receiver)
        entity.act("$n ti %s $a." % verbs["it"], TO.TARGET, receiver, target)

    target = target.from_location(quantity, use_repop=True)
    target.to_location(receiver)

    force_return = check_trigger(entity, "after_" + gamescript_suffix1, entity,
                                 target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "after_" + gamescript_suffix2, entity,
                                 target, receiver, DIR.NONE, behavioured)
    if force_return:
        return True
    force_return = check_trigger(receiver, "after_" + gamescript_suffix3,
                                 entity, target, receiver, DIR.NONE,
                                 behavioured)
    if force_return:
        return True

    return True
Example #23
0
def interpret(entity,
              argument,
              use_check_alias=True,
              force_position=True,
              show_input=True,
              show_prompt=True,
              behavioured=False):
    """
    Funzione che interpreta gli inputi inviati dalle entità.
    L'argomento use_check_alias a False viene passato dalla find_alias per
    evitare chiamate di alias da altri alias e quindi ricorsioni.
    """
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return

    if not argument:
        log.bug("argument non è un parametro valido: %r" % argument)
        return

    # -------------------------------------------------------------------------

    # Si assicura che colui che esegue l'azione sia un'entità unica e
    # non un mucchio fisico
    entity = entity.split_entity(1)

    if FLAG.CONVERSING in entity.flags and len(argument) == 1 and is_number(
            argument):
        # (TD)
        return

    arg, argument = one_argument(argument, search_separator=False)
    arg = arg.lower()

    input, huh_input, lang = multiple_search_on_inputs(
        entity, arg, use_check_alias=use_check_alias, argument=argument)
    # Utilizzo bislacco di lang per indicare che è stato trovato un alias
    # e che questo verrà processato tramite un'altra chiamata all'interpret
    if use_check_alias and lang == "alias":
        return

    # Resetta l'inattività di un player se ha inviato un comando
    if entity.IS_PLAYER:
        entity.inactivity = 0

    # Se non ha trovato nulla invia un messaggio apposito
    if not input:
        if show_input:
            entity.send_output(''' <span class="system">%s %s</span>''' %
                               (remove_colors(arg), argument))
        entity.send_output("Huh?")
        # Se l'input non è stato trovato neanche nell'altra lingua allora
        # esegue il log dell'input, potrebbero esservene alcuni di sensati
        # da utilizzare in futuro come sinonimi
        # Scrive anche gli huh input dei mob così da ricavare gamescript o
        # random_do_inputs errati
        if not huh_input:
            log.huh_inputs(entity, arg)
        # Se serve visualizza il prompt
        if show_input:
            entity.send_prompt()
        return False

    # Poiché alcune words nello stesso input a volte hanno prefisso differente
    # tra loro allora cerca quello più simile possibile per farlo visualizzare
    # all'utente
    founded_input = input.findable_words[0]
    for word in input.findable_words:
        if is_prefix(arg, word):
            founded_input = word
            break

    # Se il giocatore è in stato di wait e l'input è un comando interattivo
    # allora evita di inviarlo subito ma lo mette in coda
    if entity.deferred_wait and CMDFLAG.INTERACT in input.command.flags:
        entity.waiting_inputs.append("%s %s" % (founded_input, argument))
        return False
    else:
        # Altrimenti scrive anche l'input a fianco del prompt
        if show_input:
            entity.send_output(''' <span class="system">%s %s</span>''' %
                               (founded_input, argument))

    # Se il pg si è scollegato dalla pagina di gioco non esegue il comando
    if not entity.location:
        return False

    # Vengono salvate le informazioni sull'ultimo input inviato
    if argument:
        last_input = "%s %s" % (arg, argument)
    else:
        last_input = arg
    engine.last_input_sender = entity
    engine.last_input_sended = last_input
    # Si salva l'ultimo input inviato con successo
    if show_input and entity.IS_PLAYER and CMDFLAG.NO_LAST_INPUT not in input.command.flags:
        entity.last_input = last_input

    if CMDFLAG.GDR in input.command.flags:
        entity.sended_inputs.append("%s %s" % (founded_input, argument))

    if argument:
        argument = html_escape(argument)

    # Gestisce i comandi che devono essere digitati per intero
    command = input.command
    if CMDFLAG.TYPE_ALL in command.flags and not is_same(
            arg, input.findable_words):
        first_words, other_words = one_argument(input.words,
                                                search_separator=False)
        entity.send_output(
            "Se vuoi veramente farlo devi scrivere per intero [limegreen]%s[close]."
            % first_words)
        execution_result = False
    elif not check_position(entity, command.position, force_position):
        # Se la posizione non è corretta invia il relativo messaggio d'errore
        vowel_of_genre = grammar_gender(entity)
        if entity.position == POSITION.DEAD:
            entity.send_output("Un po' difficile fino a che rimani MORT%s.." %
                               vowel_of_genre.upper())
        elif (entity.position == POSITION.MORTAL
              or entity.position == POSITION.INCAP):
            entity.send_output("Sei troppo ferit%s per farlo." %
                               vowel_of_genre)
        elif entity.position == POSITION.STUN:
            entity.send_output("Sei troppo intontit%s per farlo." %
                               vowel_of_genre)
        elif entity.position == POSITION.SLEEP:
            entity.send_output("Nei tuoi sogni, o cosa?")
        elif entity.position == POSITION.REST:
            entity.send_output("Nah.. Sei troppo rilassat%s ora.." %
                               vowel_of_genre)
        elif entity.position == POSITION.KNEE:
            entity.send_output("Non puoi farlo da inginocchiat%s" %
                               vowel_of_genre)
        elif entity.position == POSITION.SIT:
            entity.send_output("Non puoi farlo da sedut%s." % vowel_of_genre)
        else:
            log.bug("Manca la posizione %r" % entity.position)
        execution_result = False
    else:
        if command.type == CMDTYPE.SOCIAL:
            check_social(entity,
                         command,
                         argument=argument,
                         behavioured=behavioured)

        if CMDFLAG.PRIVATE not in command.flags and (
                entity.IS_PLAYER
                or config.print_entity_inputs) and show_input and show_prompt:
            if entity.IS_PLAYER:
                write_on_file = True
            else:
                write_on_file = False
            log.input("'%s%s%s' digitato da %s in %s" %
                      (founded_input, " " if argument else "", argument,
                       entity.code, entity.location.get_name()),
                      write_on_file=write_on_file)

        # Per comodità di sviluppo ricarica il modulo relativo al comando ogni
        # volta che lo si digita, così da poter testare le modifiche al codice
        # dei comandi senza aver bisogno di riavviare il gioco tutte le volte
        if config.reload_commands:
            reload(command.module)
            command.import_module_and_function()

        # Se si sta eseguendo un'azione che richiede tempo la interrompe
        if entity.action_in_progress and CMDFLAG.INTERACT in command.flags:
            if entity.action_in_progress.defer_later:
                entity.action_in_progress.stop()
            entity.action_in_progress = None

        # Esegue la funzione del comando cronometrandola
        input.counter_use += 1
        starting_time = time.time()
        execution_result = (command.function)(entity, argument)
        if command.fun_name[:
                            8] == "command_" and execution_result != True and execution_result != False:
            log.bug("execution_result non è valido per il comando %s: %r" %
                    (command.fun_name, execution_result))
        if command.fun_name[:
                            6] == "skill_" and execution_result != "clumsy" and execution_result != "failure" and execution_result != "success" and execution_result != "magistral":
            log.bug("execution_result non è valido per la skill %s: %r" %
                    (command.fun_name, execution_result))
        execution_time = time.time() - starting_time
        # Comandi che superano il tempo definito nella max_execution_time
        # possono portare a bachi creati dalla deferred impostata nel metodo
        # split_entity (nello stesso metodo c'è un commento con più informazioni)
        # Quindi devono essere il più possibile da evitare, allo stesso tempo
        # sarebbe meglio che il max_execution_time sia relativamente basso.
        if execution_time > config.max_execution_time:
            log.time(
                "Il comando %s è stato eseguito in troppo tempo: %f secondi" %
                (command.fun_name, execution_time))
        command.timer += execution_time

    # Gestisce i comandi da loggare
    if CMDFLAG.LOG in command.flags:
        log.command("%s %s" % (command.fun_name, argument))

    if FLAG.AFK in entity.flags and command.fun_name != "command_afk":
        command_afk(entity)

    # Infine visualizza il prompt
    if show_prompt:
        entity.send_prompt()

    # Se la lista di input ancora da inviare non è vuota allora crea un
    # "falso wait" per forzarne l'invio. In teoria potrei inviarlo da qui, ma
    # il codice di ritorno execution_result andrebbe perduto, ecco perché
    # si fa uso della wait().
    if not entity.deferred_wait and entity.waiting_inputs:
        entity.wait(0.001)

    # Questa parte è da attivare con l'opzione check_references solo nei
    # server di test perché consuma molta cpu essendo eseguita su migliaia
    # di dati ad ogni invio di input, è una modalità di diagnostica
    # che non bada a spese in termini prestazionali
    if config.check_references and not database.reference_error_found:
        database.check_all_references()

    return execution_result
Example #24
0
def rpg_channel(entity, argument, channel, ask=False, exclaim=False, behavioured=False):
    """
    Gestisce i canali rpg, ha le seguenti caratteristiche:
    - supporto per gli smile
    - supporto per i modi di esprimersi con esclamativo e punto di domanda
    - supporto per gli emote
    - gestione del bersaglio che può essere un'entità, il gruppo o sé stessi
    - (TD) parlata da ubriaco
    - (TD) espansione della potenza della voce in altre stanze
    - (TD) espressioni per le stanze attorno, anche per coloro che riconoscono la voce,
           pensare anche alla suddivisione tra social gestuali e 'rumorosi' per gli smile-espressioni around
    - (TD) modulazione della voce a seconda delle dimensioni di chi parla e della sua voice_potence
    """
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    if not channel:
        log.bug("channel non è un parametro valido: %r" % channel)
        return False

    # -------------------------------------------------------------------------

    if entity.IS_ROOM:
        return False

    objective = OBJECTIVE_ROOM  # obiettivo del messaggio
    # Linguaggio utilizzato per dire il messaggio
    if entity.IS_ITEM:
        language = LANGUAGE.COMMON
    else:
        language = entity.speaking
    smile = ""            # conterrà l'eventuale espressione di uno smile-social
    emote = ""            # conterrà l'eventuale emote inviato con il messaggio tra due asterischi
    expres_entity = ""    # espressione per chi parla
    expres_room   = ""    # espressione per chi sta ascoltando nella stanza
    expres_objective = "" # espressione per chi riceverà il messaggio

    # Ricava i verbi e il colore relativi al canale
    # Se si sta parlando normalmente la propria lingua vengono utilizzati
    # i verbi razziali per descriverne timbro, flessione o pronuncia
    if channel == CHANNEL.SAY:
        verb_you, verb_it = entity.race.say_verb_you, entity.race.say_verb_it
    else:
        verb_you, verb_it = channel.verb_you, channel.verb_it
    color = get_first_color(channel.name)

    # Se non è stato passato nessun messaggio esce
    if not argument or not remove_colors(argument):
        entity.send_output("Cosa vorresti %s?" % channel)
        return False

    if len(argument) > config.max_google_translate:
        entity.send_output("Non puoi %s un messaggio così logorroico." % channel)
        return False

    # Copia l'argomento originale, in alcuni casi serve recuperarlo poi
    original_argument = argument

    # Controlla se si sta parlando a qualcuno, il controllo sulla particella
    # la esegue in minuscolo, dando per sottinteso che quando uno scrive
    # maiuscolo voglia iniziare un discorso
    target = None
    if argument[0 : 2] == "a ":
        arg, argument = one_argument(argument)
        # Se sta parlando a qualcuno cerca di acquisirlo dal nome successivo
        objective_name, argument = one_argument(argument)
        target = entity.find_entity_extensively(objective_name)
        # con me e self esegue un check senza la is_same volutamente, per evitare
        # ricerche con nome di player che iniziano con Me o Self
        if target == entity or objective_name in ("me", "self"):
            objective = OBJECTIVE_SELF
            # Se si parla da soli lo si fa utilizzando la lingua madre
            language = entity.race.natural_language
        elif target:
            objective = OBJECTIVE_TARGET
            # Se si parla con qualcuno della stessa razza lo si fa utilizzando
            # la lingua preferita dalla razza, è un fattore culturale
            if entity.race == target.race:
                language = entity.race.natural_language
        else:
            # Se non ha trovato nessun 'a <nome bersaglio>' riprende
            # l'argument originale
            argument = original_argument
    # Stessa cosa di sopra ma qui controlla se si stia parlando al gruppo
    elif argument[0 : 3] == "al ":
        arg, argument = one_argument(argument)
        objective_name, argument = one_argument(argument)
        if is_prefix(objective_name, "gruppo"):
            if not entity.group:
                entity.send_output("Non fai parte di nessun gruppo.")
                return False
            # Questa variabile verrà utilizza poi nell'invio del messaggio
            group_members = entity.get_members_here(entity.location)
            if not group_members:
                entity.send_output("Non trovi nessun membro del gruppo vicino a te con cui poter parlare.")
                return False
            objective = OBJECTIVE_GROUP
            # Se si parla in un gruppo in cui tutti sono formati dalla stessa
            # razza si preferirà parlare con la lingua della propria razza
            for group_member in group_members:
                if group_member.race != entity.race:
                    break
            else:
                language = entity.race.natural_language
        else:
            # Se il personaggio non vuole parlare al gruppo recupera
            # il valore originale inviato
            argument = original_argument

    # (TD) Gestisce il caso in cui l'entità si trovi immersa in un liquido
    #if entity.is_immersed():
    #    entity.send_output("Tenti di %s qualcosa ma subito l'acqua ti riempie la gola soffocandoti!" % channel)
    #    entity.points.life -= random.randint(entity.level / 6, entity.level / 4) + 1
    #    return False

    if not entity.location:
        log.bug("entity %s non si trova in una locazione valida: %r (original_argument: %s)" % (
            entity.code, entity.location, original_argument))
        return False

    # Gestisce le stanze che obbligano al silenzio
    if entity.location.IS_ROOM:
        if ROOM.SILENCE in entity.location.flags:
            entity.send_output("Il silenzio del luogo ti blocca la gola impedendoti di %s." % channel)
            return False

        # (TT) Se nella stanza c'è molto casino, tante persone etc etc è difficile
        # parlare piano
        if entity.location.mod_noise > 75 and channel <= CHANNEL.SAY:
            entity.send_output("Non puoi %s con tutta questa confusione!" % channel)
            return False

    # Invia l'appropriato messaggio nel caso in cui trovi argument vuoto
    if not argument:
        send_not_argument_message(entity, objective, channel)
        return False

    # Cerca eventuali smiles nella stringa controllando gli ultimi caratteri
    for social in database["socials"].itervalues():
        if not social.smiles:
            continue
        for single_smile in social.smiles.split():
            if single_smile in argument[-config.chars_for_smile : ]:
                break
        else:
            # Se non trova nessun smile esce dal ciclo dei social e continua
            # col prossimo set di smiles trovato
            continue

        cut_smile = argument.rfind(single_smile)
        # Se argument è formato solo dallo smile invia il corrispondente social
        if cut_smile == 0:
            social_name = social.fun_name[len("social_") : ]
            if objective == OBJECTIVE_TARGET:
                input_to_send = "%s %s" % (social_name, target.name)
            elif objective == OBJECTIVE_SELF:
                input_to_send = "%s %s" % (social_name, entity.name)
            else:
                input_to_send = social_name

            send_input(entity, input_to_send, "en", show_input=False, show_prompt=False)
            return True

        # Altrimenti ne ricava l'espressione dello smile-social e toglie lo
        # smile da argument, se il carattere dopo lo smile era un simbolo di
        # punteggiatura lo attacca alla frase togliendo gli spazi
        first_part  = argument[ : cut_smile]
        second_part = argument[cut_smile + len(single_smile) : ]
        if second_part.strip() and second_part.strip()[0] in "!?.,:;":
            first_part = first_part.rstrip()
            second_part = second_part.lstrip()
        argument = first_part.rstrip() + second_part.rstrip()
        smile = " %s" % social.expression
        break

    # Elabora i punti esclamativi e interrogativi per il canale say.
    # Qui viene utilizzata l'opzione chars_for_smile visto che si sta facendo
    # una cosa simile a sopra, ovvero considerare solo l'ultima parte
    # dell'argomento passato.
    exclamations = argument[-config.chars_for_smile : ].count("!")
    questions    = argument[-config.chars_for_smile : ].count("?")
    if exclamations > questions:
        if channel == CHANNEL.SAY:
            verb_you = "Esclami"
            verb_it  = " esclama"
        exclaim = True
    elif exclamations < questions:
        if channel == CHANNEL.SAY:
            verb_you = "Domandi"
            verb_it  = " domanda"
        ask = True
    # Questo elif sottintende che exclamations e questions siano uguali
    elif exclamations != 0 and questions != 0:
        # Con una stessa quantità di ! e di ? l'ultimo che viene trovato
        # ha maggiore peso rispetto all'altro
        exclamation_pos = argument.rfind("!")
        question_pos = argument.rfind("?")
        if exclamation_pos > question_pos:
            if channel == CHANNEL.SAY:
                verb_you = "Esclami"
                verb_it  = " esclama"
            exclaim = True
        else:
            if channel == CHANNEL.SAY:
                verb_you = "Domandi"
                verb_it  = " domanda"
            ask = True

    # Supporto per piccoli emote separati da * ad inizio argument
    if argument[0] == "*":
        cut_emote = argument[1 : ].find("*")
        if cut_emote != -1:
            emote = " %s" % argument[1 : cut_emote+1].strip()
            if smile:
                emote = " e%s" % emote
            argument = argument[cut_emote+2 : ].strip()

    # Unisce i vari pezzi per formare l'output
    expres_entity = verb_you
    expres_room = verb_it
    expres_target = ""
    if objective == OBJECTIVE_TARGET:
        name = target.get_name(entity)
        expres_entity += " a %s" % name
        expres_room   += " a %s" % name
        expres_target += " ti%s" % verb_it
    elif objective == OBJECTIVE_SELF:
        expres_entity += " a te stess%s" % grammar_gender(entity)
        expres_room   += " a sé stess%s" % grammar_gender(entity)
    elif objective == OBJECTIVE_GROUP:
        members = entity.get_members_here(entity.location)
        if len(members) == 1:
            expres_entity += " a %s" % members[0].name
            expres_room   += " a %s" % members[0].name
            expres_target += " ti%s" % verb_it
        else:
            if len(members) > 5:
                many = "folto "
            else:
                many = ""
            expres_entity += " al gruppo"
            expres_room   += " ad un %sgruppo" % many
            expres_target += "%s al gruppo" % verb_it
    # Aggiunge le eventuali espressioni dello smile e dell'emote
    expres_entity += smile + emote
    expres_room   += smile + emote
    expres_target += smile + emote

    if not argument:
        send_not_argument_message(entity, objective, channel)
        return False

    # Prepara il pezzo riguardante la lingua utilizzata
    language = ""
    if not entity.IS_ITEM and entity.speaking != LANGUAGE.COMMON:
        language = " in lingua %s" % entity.speaking

    # Mischia il testo se si è ubriachi
    original_argument = argument = color_first_upper(argument)
    argument = drunk_speech(argument, entity)

    # Parlando si impara la lingua
    if not entity.IS_ITEM:
        learn_language(entity, channel, entity.speaking)

    # Controlla se vi sono parolacce o parole offrpg e logga i relativi argument
    if entity.IS_PLAYER:
        check_for_badwords(entity, argument)

    # Invia il messaggio a tutti coloro che lo possono sentire
    for location in expand_voice_around(entity, channel):
        if not location:
            log.bug("location per il canale %s e per l'entità %s non è valida: %r" % (channel, entity.code, location))
            continue
        for listener in location.iter_contains(use_reversed=True):
            if listener.position <= POSITION.SLEEP:
                continue

            if listener == entity:
                force_return = check_trigger(entity, "before_rpg_channel", listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue
                force_return = check_trigger(entity, "before_" + channel.trigger_suffix, listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue

                # Invia all'entità il suo stesso messaggio
                first_part = (close_color(color) + expres_entity).rstrip()
                message = "%s: '%s'" % (first_part, close_color(argument))
                send_channel_message(entity, message, True)

                force_return = check_trigger(entity, "after_rpg_channel", listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue
                force_return = check_trigger(entity, "after_" + channel.trigger_suffix, listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue
            else:
                # Fa ascoltare solo ad un'entità di un eventuale gruppo fisico
                listener = listener.split_entity(1)

                force_return = check_trigger(listener, "before_listen_rpg_channel", listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue
                force_return = check_trigger(listener, "before_listen_" + channel.trigger_suffix, listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue

                # Prepara alcune cose a seconda della stanza di provenienza del messaggio
                if entity.location == listener.location:
                    entity_name = entity.get_name(listener)
                    entity_name = color_first_upper(entity_name)
                    from_direction = ""
                elif entity.location.IS_ROOM:
                    # (TD) invia qualcuno a meno che non lo si abbia conosciuto
                    # precedentemente con il sistema di presentazione
                    entity_name = "Qualcuno"
                    from_direction = get_from_direction(listener.location.x, listener.location.y, listener.location.z,
                                                        entity.location.x, entity.location.y, entity.location.z)
                elif entity.location.IS_ACTOR:
                    if entity.location != listener:
                        entity_name = "Qualcuno"  # (TD) come sopra
                    from_direction = " dall'inventario di %s" % entity.location.get_name(listener)
                else:
                    entity_name = "Qualcuno"  # (TD) come sopra
                    from_direction = " da dentro %s" % entity.location.get_name(listener)

                # Prepara la prima parte, quella senza il messaggio
                if objective == OBJECTIVE_ROOM:
                    output = "%s%s%s%s" % (entity_name, close_color(color) + expres_room, language, from_direction)
                elif objective == OBJECTIVE_TARGET or OBJECTIVE_SELF:
                    if listener == target:
                        output = "%s%s%s%s" % (entity_name, close_color(color) + expres_target, language, from_direction)
                    else:
                        output = "%s%s%s%s" % (entity_name, close_color(color) + expres_room, language, from_direction)
                elif objective == OBJECTIVE_GROUP:
                    if listener in group_members:
                        output = "%s%s%s%s" % (entity_name, close_color(color) + expres_target, language, from_direction)
                    else:
                        output = "%s%s%s%s" % (entity_name, close_color(color) + expres_room, language, from_direction)

                output = "<br>%s: '%s'" % (close_color(output).rstrip(), close_color(argument))
                send_channel_message(listener, output, False)
                listener.send_prompt()

                force_return = check_trigger(listener, "after_listen_rpg_channel", listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue
                force_return = check_trigger(listener, "after_listen_" + channel.trigger_suffix, listener, entity, target, argument, ask, exclaim, behavioured)
                if force_return:
                    continue

    return True
Example #25
0
def command_force(entity, argument=""):
    """
    Forza l'esecuzione di un comando da parte di un'altra entità.
    """
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

    # -------------------------------------------------------------------------

    if not argument:
        syntax = get_command_syntax(entity, "command_force")
        entity.send_output(syntax, break_line=False)
        return False

    arg1, argument = one_argument(argument)
    target = entity.find_entity_extensively(arg1, inventory_pos="first")
    if not target:
        target = entity.find_entity_extensively(arg1)
        if not target:
            entity.send_output(
                "Nessuna entità trovata con argomento [white]%s[close]" % arg1)
            return False

    arg2, argument = one_argument(argument)
    if not arg2:
        entity.send_output("Che comando vorresti [red]forzare[close] a %s?" %
                           target.get_name(entity))
        return False

    input, huh_input, input_lang = multiple_search_on_inputs(entity, arg2)
    if not input:
        entity.send_output(
            "L'argomento %s non è relativo ad un comando valido." % arg2)
        return False

    if input.command and input.command.fun_name == "command_force":
        entity.send_output("Non puoi forzare un force.")
        return False

    translated_input = translate_input(target, arg2, input_lang)
    if not translated_input:
        entity.send_output(
            "Non è stato possibile tradurre l'input %s per %s (lingua originale: %s)"
            % (arg2, target.get_name(entity), input_lang))
        return False

    target.send_output("\n")
    execution_result = interpret(target,
                                 "%s %s" % (translated_input, argument),
                                 force_position=True,
                                 show_input=False)
    if not execution_result:
        if target == entity:
            entity.send_output(
                "\nL'esecuzione dell'input [limegreen]%s[close] forzato su di [white]te stess%c[close] non è andata a buon fine."
                % (arg2, grammar_gender(entity)))
        else:
            entity.send_output(
                "\nL'esecuzione dell'input %s forzato su di %s non è andata a buon fine."
                % (arg2, target.get_name(entity)))
            if not entity.incognito:
                target.send_output("\n%s ti ha forzato a fare qualcosa." %
                                   entity.get_name(target))
            log.admin("%s ha cercato di forzare %s a fare: %s %s" %
                      (entity.name, target.name, arg2, argument))
        return False

    if target == entity:
        message = "\n" + format_for_admin(
            "Il force dell'input [green]%s[close] su [white]te stess%c[close] sembra essere andato a buon fine."
            % (arg2, grammar_gender(entity)))
        entity.send_output(message)
    else:
        message = "\n" + format_for_admin(
            "Il force dell'input [green]%s[close] su di %s sembra andato a buon fine."
            % (arg2, target.get_name(entity)))
        entity.send_output(message)
        if not entity.incognito:
            target.send_output("\n%s ti ha forzato a fare qualcosa." %
                               entity.get_name(target))
        log.admin("%s ha forzato %s a fare: %s %s" %
                  (entity.name, target.name, arg2, argument))

    return True