示例#1
0
    def render_GET(self, request, conn):
        if count_bans() == 0:
            player_bans = "[green]Nessuna punizione inflitta ai giocatori.[close]"
        else:
            player_bans = self.create_player_bans(conn)

        player_options = []
        for player_code, player in sort_datas(database["players"]):
            if not player.ban:
                player_options.append('''<option>%s</option>''' % player_code)

        day_options = []
        for day in range(1, 31):
            day_options.append('''<option>%d</option>''' % day)

        reason_tooltip = create_tooltip(conn, "Questo testo verrà letto dal giocatore come motivazione della punizione")

        comment_tooltip = create_tooltip(conn, "Questo commento verrà letto solo dagli amministratori, utile per aggiungere delle note per una gestione interna della punizione")

        mapping = {"player_options"  : "".join(player_options),
                   "day_options"     : "".join(day_options),
                   "reason_tooltip"  : reason_tooltip,
                   "comment_tooltip" : comment_tooltip,
                   "player_bans"     : player_bans}
        return self.PAGE_TEMPLATE.safe_substitute(mapping)
示例#2
0
    def create_page(self, request, conn,
                    race=RACE.NONE, sex=SEX.NONE, constellation=CONSTELLATION.NONE,
                    err_msg_race="", err_msg_sex="", err_msg_constellation=""):
        # Prepara il form con i dati per la creazione di un nuovo personaggio
        form = []

        row = create_form_row(form)
        row.label   = "Razza %s" % create_tooltip(conn, "Scegli con cura la razza che vuoi interpretare, cambierà di molto sia il tuo modo di giocare e il modo di comportarti con gli altri.")
        row.field   = create_checklist_of_elements("race", race, "description", RACE.get_playable_races())
        row.message = err_msg_race

        # (TD) allowed sex razziale
        row = create_form_row(form)
        row.label   = "Sesso %s" % create_tooltip(conn, "Scegli la sessualità che vuoi interpretare.<br> Essa potrebbe influenzare di un poco alcuni bonus o malus a seconda della razza scelta.<br> Per esempio le femmine umane hanno un malus alla forza ma un bonus alla costituzione.")
        row.field   = create_checklist_of_elements("sex", sex)
        row.message = err_msg_sex

        row = create_form_row(form)
        row.label   = "Costellazione %s" % create_tooltip(conn, "Costellazione sotto cui sarà nato il tuo personaggio, oltre a dare dei bonus o malus essa determina casualmente anche il giorno e il mese di nascita.")
        row.field   = create_checklist_of_elements("constellation", constellation, "description")
        row.message = err_msg_constellation

        row = create_form_row(form)
        row.label   = '''<input type="submit" value="Continua..." onclick="document.getElementById('form_create_player_1').submit();" />'''

        # Crea la pagina html
        page = create_form(form, "form_create_player_1", "create_player1.html", "Crea un nuovo Personaggio", border=1)
        # (bb) questa musica devo spostarla in un frame nascosto esterno
        # in maniera tale che non venga stoppata, oppure toglierla del tutto
        # (che mi sa che è la cosa più semplice, utilizzarla per il diario)
        #page += send_audio(conn, "creation.mid", loop=True)
        return page
示例#3
0
    def render_GET(self, request, conn):
        if count_bans() == 0:
            player_bans = "[green]Nessuna punizione inflitta ai giocatori.[close]"
        else:
            player_bans = self.create_player_bans(conn)

        player_options = []
        for player_code, player in sort_datas(database["players"]):
            if not player.ban:
                player_options.append('''<option>%s</option>''' % player_code)

        day_options = []
        for day in range(1, 31):
            day_options.append('''<option>%d</option>''' % day)

        reason_tooltip = create_tooltip(
            conn,
            "Questo testo verrà letto dal giocatore come motivazione della punizione"
        )

        comment_tooltip = create_tooltip(
            conn,
            "Questo commento verrà letto solo dagli amministratori, utile per aggiungere delle note per una gestione interna della punizione"
        )

        mapping = {
            "player_options": "".join(player_options),
            "day_options": "".join(day_options),
            "reason_tooltip": reason_tooltip,
            "comment_tooltip": comment_tooltip,
            "player_bans": player_bans
        }
        return self.PAGE_TEMPLATE.safe_substitute(mapping)
示例#4
0
    def create_page(self, request, conn, name="", password="", password2="", email="",
            err_msg_name="", err_msg_password="", err_msg_password2="", err_msg_email=""):
        # Prepara il form
        form = []
        row = create_form_row(form)
        row.label   = "Nome dell'account"
        row.field   = '''<input type="text" name="name" maxlength="%s" value="%s" />''' % (config.max_len_name, name)
        row.message = err_msg_name
        row = create_form_row(form)
        row.label = "Password dell'account %s" % create_tooltip(conn, "La password dell'account devi conoscerla tu e tu soltanto.<br>Nessun amministratore ti domanderà la password per nessun motivo.<br>Ricordatelo, così da evitare persone che si spacciano amministratori del<br>Mud per rubarti la password.")
        row.field = '''<input type="password" name="password" maxlength="%s" value="%s" />''' % (config.max_len_password, password)
        if err_msg_password:
            row.message = err_msg_password
        elif err_msg_password2:
            row.message = err_msg_password2
        row = create_form_row(form)
        row.label = "Conferma della password"
        row.field = '''<input type="password" name="password2" maxlength="%s" value="%s" />''' % (config.max_len_password, password2)
        row = create_form_row(form)
        row.label = "Indirizzo mail %s" % create_tooltip(conn, "L'inserimento è facoltativo.<br>L'indirizzo mail viene utilizzato per il recupero di nome e password dell'account<br>oppure dagli amministratori del Mud per contattarti riguardo a novità, raduni,<br>sondaggi o casi urgenti.<br>Non viene né venduto né utilizzato per inviare spam.")
        row.field = '''<input type="text" name="email" maxlength="%s" value="%s" />''' % (MAX_LEN_EMAIL, email)
        row.message = err_msg_email
        row = create_form_row(form)
        row.label = '''<input type="submit" value="Crea l'Account" onclick="document.getElementById('form_create_account').submit();" />'''

        # Crea la pagina html
        page = ""

        page += '''<h3>Crea un nuovo account:</h3>'''
        page += '''Esso conterrà le tue opzioni di gioco e la lista dei tuoi personaggi con cui giocare.<br><br>'''
        page += create_form(form, "form_create_account", "create_account.html")

        return page
示例#5
0
    def create_talents_body(self, conn):
        if not conn:
            log.bug("conn non è un parametro valido: %r" % conn)
            return ""

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

        player = conn.player
        if not player:
            log.bug("player non è valido %r per la connessione %s" % (player, conn.get_id()))
            return ""

        output = []

        ie_problem = ""
        # Per IE9 non c'è bisogno del messaggio, (TT) bisognerà testare piuttosto se per IE7 sì
        if conn.get_browser() == "IE_8":
            ie_problem = '''Se per caso visualizzate spostate in maniera errata le freccette per aumentare e diminuire i valori sottostanti allora potete risolvere cliccando sul bottone <img src="graphics/ie_broken_button.png" /> in alto.<br><br>'''
        output.append(ie_problem)

        if conn.player.talents == 0:
            talents_title = '''Non hai nessun talento da poter distribuire.'''
        else:
            talents_title = '''Hai [white]<span id="talents">%d</span>[close] talenti da poter distribuire in:''' % conn.player.talents
        output.append('''<center><span style="font-weight:bold;">%s</span></center><br>''' % talents_title)

        # Se non vi sono talenti da spendere allora ritorna l'html finora creato
        if conn.player.talents == 0:
            return "".join(output)

        output.append('''<script>initial_life = %d; initial_mana = %d; initial_vigour = %d; initial_talents = %d;</script>''' % (
            player.max_life, player.max_mana, player.max_vigour, player.talents))

        output.append('''<div class="ui-widget-content ui-corner-all" style="padding:5px">''')
        output.append('''<table align="center" class="ui-widget-content"><tr>''')
        output.append('''<td><span style="color:red">Vita</span>:</td>''')
        output.append('''<td><input type="text" id="life" class="spinner" value="%d" readonly="readonly" onChange="changeTalentPoints(this)" onBlur="changeTalentPoints(this)" /></td>''' % player.max_life)
        output.append('''<td>%s </td>''' % create_tooltip(conn, "La vita indica la quantità di danni che puoi sostenere prima di morire"))
        output.append('''<td><span style="color:royalblue">Mana</span>:</td>''')
        output.append('''<td><input type="text" id="mana" class="spinner" value="%d" readonly="readonly" onChange="changeTalentPoints(this)" onBlur="changeTalentPoints(this)" /></td>''' % player.max_mana)
        output.append('''<td>%s </td>''' % create_tooltip(conn, "Il mana è quell'energia utile nel pronunciare incantesimi o utilizzare oggetti magici"))
        output.append('''<td><span style="color:green">Vigore</span>:</td>''')
        output.append('''<td><input type="text" id="vigour" class="spinner" value="%d" readonly="readonly" onChange="changeTalentPoints(this)" onBlur="changeTalentPoints(this)" /></td>''' % player.max_vigour)
        output.append('''<td>%s </td>''' % create_tooltip(conn, "Il vigore indica quanto ti puoi muovere e quanto peso puoi trasportare"))
        output.append('''</tr></table>''')
        output.append('''</div><br>''')

        output.append('''<div class="ui-widget-content ui-corner-all" style="padding:5px; text-align:center">''')
        output.append('''<input type="submit" id="send" value="Distribuisci" onclick="distribute();"/> ''')
        output.append('''<input type="submit" id="close" value="Chiudi" onclick="$("#talents_title").parent().hide(); $("#game_tabs").tabs({selected: 0}"/><br>''')
        output.append('''<span id="error_message" style="color:red"></span>''')
        output.append('''</div>''')

        return "".join(output)
示例#6
0
    def create_page(self,
                    request,
                    conn,
                    race=RACE.NONE,
                    sex=SEX.NONE,
                    constellation=CONSTELLATION.NONE,
                    err_msg_race="",
                    err_msg_sex="",
                    err_msg_constellation=""):
        # Prepara il form con i dati per la creazione di un nuovo personaggio
        form = []

        row = create_form_row(form)
        row.label = "Razza %s" % create_tooltip(
            conn,
            "Scegli con cura la razza che vuoi interpretare, cambierà di molto sia il tuo modo di giocare e il modo di comportarti con gli altri."
        )
        row.field = create_checklist_of_elements("race", race, "description",
                                                 RACE.get_playable_races())
        row.message = err_msg_race

        # (TD) allowed sex razziale
        row = create_form_row(form)
        row.label = "Sesso %s" % create_tooltip(
            conn,
            "Scegli la sessualità che vuoi interpretare.<br> Essa potrebbe influenzare di un poco alcuni bonus o malus a seconda della razza scelta.<br> Per esempio le femmine umane hanno un malus alla forza ma un bonus alla costituzione."
        )
        row.field = create_checklist_of_elements("sex", sex)
        row.message = err_msg_sex

        row = create_form_row(form)
        row.label = "Costellazione %s" % create_tooltip(
            conn,
            "Costellazione sotto cui sarà nato il tuo personaggio, oltre a dare dei bonus o malus essa determina casualmente anche il giorno e il mese di nascita."
        )
        row.field = create_checklist_of_elements("constellation",
                                                 constellation, "description")
        row.message = err_msg_constellation

        row = create_form_row(form)
        row.label = '''<input type="submit" value="Continua..." onclick="document.getElementById('form_create_player_1').submit();" />'''

        # Crea la pagina html
        page = create_form(form,
                           "form_create_player_1",
                           "create_player1.html",
                           "Crea un nuovo Personaggio",
                           border=1)
        # (bb) questa musica devo spostarla in un frame nascosto esterno
        # in maniera tale che non venga stoppata, oppure toglierla del tutto
        # (che mi sa che è la cosa più semplice, utilizzarla per il diario)
        #page += send_audio(conn, "creation.mid", loop=True)
        return page
示例#7
0
    def create_page(self,
                    request,
                    conn,
                    name="",
                    password="",
                    password2="",
                    email="",
                    err_msg_name="",
                    err_msg_password="",
                    err_msg_password2="",
                    err_msg_email=""):
        # Prepara il form
        form = []
        row = create_form_row(form)
        row.label = "Nome dell'account"
        row.field = '''<input type="text" name="name" maxlength="%s" value="%s" />''' % (
            config.max_len_name, name)
        row.message = err_msg_name
        row = create_form_row(form)
        row.label = "Password dell'account %s" % create_tooltip(
            conn,
            "La password dell'account devi conoscerla tu e tu soltanto.<br>Nessun amministratore ti domanderà la password per nessun motivo.<br>Ricordatelo, così da evitare persone che si spacciano amministratori del<br>Mud per rubarti la password."
        )
        row.field = '''<input type="password" name="password" maxlength="%s" value="%s" />''' % (
            config.max_len_password, password)
        if err_msg_password:
            row.message = err_msg_password
        elif err_msg_password2:
            row.message = err_msg_password2
        row = create_form_row(form)
        row.label = "Conferma della password"
        row.field = '''<input type="password" name="password2" maxlength="%s" value="%s" />''' % (
            config.max_len_password, password2)
        row = create_form_row(form)
        row.label = "Indirizzo mail %s" % create_tooltip(
            conn,
            "L'inserimento è facoltativo.<br>L'indirizzo mail viene utilizzato per il recupero di nome e password dell'account<br>oppure dagli amministratori del Mud per contattarti riguardo a novità, raduni,<br>sondaggi o casi urgenti.<br>Non viene né venduto né utilizzato per inviare spam."
        )
        row.field = '''<input type="text" name="email" maxlength="%s" value="%s" />''' % (
            MAX_LEN_EMAIL, email)
        row.message = err_msg_email
        row = create_form_row(form)
        row.label = '''<input type="submit" value="Crea l'Account" onclick="document.getElementById('form_create_account').submit();" />'''

        # Crea la pagina html
        page = ""

        page += '''<h3>Crea un nuovo account:</h3>'''
        page += '''Esso conterrà le tue opzioni di gioco e la lista dei tuoi personaggi con cui giocare.<br><br>'''
        page += create_form(form, "form_create_account", "create_account.html")

        return page
示例#8
0
    def create_page(self, request, conn, password="", new_password="", new_password2="", new_email="",
            err_msg_password="", err_msg_new_password="", err_msg_new_password2="", err_msg_new_email=""):
        # Prepara il form delle opzioni
        form_options = []
        row = create_form_row(form_options)
        row.label = "Opzioni dell'account"
        row.field = create_checklist_of_flags("options", conn.account.options, "description", use_icons=True, avoid_elements=[OPTION.SOUND, OPTION.MUSIC, OPTION.LOOP])
        row = create_form_row(form_options)
        row.label = '''<input type="submit" value="Salva le Opzioni" onclick="document.getElementById('form_options').submit();" />'''
        if request.method == "POST" and "options" in request.args:
            row.label += '''<span style="color:green"> Opzioni salvate.</span>'''

        # Prepara il form degli account
        form_account = []
        row = create_form_row(form_account)
        row.label = '''Password attuale %s''' % create_tooltip(conn, "Devi digitare la tua password corrente se vuoi cambiarla con una nuova o con un nuovo indirizzo mail. In questa maniera i tuoi dati privati non vengono cambiati da chicchessia nel caso tu giocassi in luoghi pubblici.")
        row.field = '''<input type="password" name="password" maxlength="%s" value="%s" style="width:11em;" />''' % (config.max_len_password, password)
        row = err_msg_password
        row = create_form_row(form_account)
        row.label = '''Nuova password'''
        row.field = '''<input type="password" name="new_password" maxlength="%s" value="%s" style="width:11em;" />''' % (config.max_len_password, new_password)
        if err_msg_new_password != "":
            row.message = err_msg_new_password
        elif err_msg_new_password2 != "":
            row.message = err_msg_new_password2
        row = create_form_row(form_account)
        row.label = '''Conferma la nuova password'''
        row.field = '''<input type="password" name="new_password2" maxlength="%s" value="%s" style="width:11em;" />''' % (config.max_len_password, new_password2)
        row = create_form_row(form_account)
        row.label   = '''Nuovo indirizzo mail %s''' % create_tooltip(conn, "Facoltativo.")
        row.field   = '''<input type="text" name="new_email" maxlength="%s" value="%s" style="width:11em;" />''' % (MAX_LEN_EMAIL, new_email)
        row.message = err_msg_new_email
        row = create_form_row(form_account)
        row.label = '''<input type="submit" value="Salva i Dati" onclick="document.getElementById('form_account').submit();" />'''

        if (request.method == "POST" and "options" not in request.args
        and err_msg_password == "" and err_msg_new_password == ""
        and err_msg_new_password2 == "" and err_msg_new_email == ""
        and password == "" and new_password == ""
        and new_password2 == "" and new_email == ""):
            row.label += '''<span style="color:green"> Account salvato.</span>'''

        # Crea la pagina html
        page  = ""

        page += create_form(form_options, "form_options", "account.html", "Modifica le opzioni del tuo account", show_label=False)
        page += '''<br>'''

        page += create_form(form_account, "form_account", "account.html", "Modifica i dati del tuo account")

        return page
示例#9
0
    def create_table_of_areas(self, request, conn, areas):
        html_parts = []

        for area in areas:
            if " " in area.creators:
                creators = " &nbsp(Autori: %s)" % area.creators
            elif area.creators:
                creators = " &nbsp(Autore: %s)" % area.creators
            else:
                creators = ""
            html_parts.append(
                '''<span style='color:%s; font-size:larger;'>%s</span>.%s''' %
                (area.color.hex_code, area.name, creators))
            if conn and conn.account and conn.account.trust >= TRUST.BUILDER:
                html_parts.append(''' {Code: %s}''' % area.code)
                html_parts.append(''' {MaxPlayers: %d}''' % area.max_players)
                if area.comment:
                    html_parts.append(''' %s''' % create_tooltip(
                        conn, "[royalblue]Commento[close]:<br>%s" %
                        area.comment, "{C}"))
            html_parts.append(
                '''<div style="padding-left:1.9em;">%s</div><br>''' %
                area.descr.replace("\n", "<br>"))

        return html_parts
示例#10
0
def command_coords(entity, argument=""):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

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

    results = []

    if argument:
        area = nifty_value_search(database["areas"], argument)
        if not area:
            entity.send_output(
                "Codice d'area simile a [green]%s[close] inesistente." %
                argument)
            return False
    else:
        results.append(get_command_syntax(entity, "command_coords") + "\n")
        area = entity.area
        if not area:
            results.append("\nNon ti trovi in un'area valida.")
            entity.send_output("".join(results))
            return False

    results.append('''<table class="mud" rules="rows" frame="below">''')
    results.append('''<tr>''')
    results.append('''<th class="nowrap" align="left">X Y Z</th>''')
    results.append('''<th align="left">Code</th>''')
    results.append('''<th align="left">Name</th>''')
    results.append('''<th align="left">Short</th>''')
    results.append('''</tr>''')
    for coord in sorted(area.rooms):
        room = area.rooms[coord]
        short_tooltip = ""
        if room.short_night:
            short_tooltip = create_tooltip(entity.get_conn(),
                                           "ShortNight: %s" % room.short_night,
                                           room.short)
        else:
            short_tooltip = room.short
        javascript_code = '''javascript:parent.sendInput('rgoto %s');''' % room.get_destination(
        )
        results.append('''<tr>''')
        results.append(
            '''<td class="nowrap">%s</td><td><a href="%s">%s</a></td><td>%s</td><td>%s</td>'''
            % (coord, javascript_code, room.code, room.name, short_tooltip))
        results.append('''</tr>''')
    results.append('''</table>''')

    entity.send_output("".join(results), break_line=False)
    return True
示例#11
0
 def render_GET(self, request, conn):
     mapping = {
         "MAX_SUBJECT_LENGTH": self.MAX_SUBJECT_LENGTH,
         "MAX_MESSAGE_LENGTH": self.MAX_MESSAGE_LENGTH,
         "MAX_EMAIL_LENGTH": self.MAX_EMAIL_LENGTH,
         "EMPTY_SUBJECT_ERROR": self.EMPTY_SUBJECT_ERROR,
         "EMPTY_MESSAGE_ERROR": self.EMPTY_MESSAGE_ERROR,
         "TOO_LONG_SUBJECT_ERROR": self.TOO_LONG_SUBJECT_ERROR,
         "TOO_LONG_MESSAGE_ERROR": self.TOO_LONG_MESSAGE_ERROR,
         "TOO_LONG_EMAIL_ERROR": self.TOO_LONG_EMAIL_ERROR,
         "email": email_encoder(config.email),
         "email_tooltip": create_tooltip(conn, self.EMAIL_TOOLTIP_TEXT)
     }
     return self.PAGE_TEMPLATE.safe_substitute(mapping)
示例#12
0
    def raise_level(self, reason="", first_the_prompt=False):
        while self.level < config.max_level and self.experience >= experiences[self.level]:
            self.level     += 1
            self.talents   += 200
            self.practices += 2

        if config.leveling_restore_points:
            self.life   = self.max_life
            self.mana   = self.max_mana
            self.vigour = self.max_vigour

        if reason:
            tooltip = create_tooltip(self.get_conn(), "Sei passato al livello %d %s!" % (self.level, reason), "{?}")
        else:
            tooltip = create_tooltip(self.get_conn(), "Sei passato al livello %d!" % self.level, "{?}")
        if first_the_prompt:
            self.send_prompt()
        self.act("\nTi sembra di essere cambiat$o... di essere migliore! %s" % tooltip, TO.ENTITY)
        self.act("Hai come l'impressione che $n sia cambiat$o in qualcosa..", TO.OTHERS)
        self.send_output('''<script>$("#talents_title").parent().show();</script>''', break_line=False)
        if not first_the_prompt:
            self.send_prompt()

        log.monitor("%s è passato al livello %d" % (self.name, self.level))
示例#13
0
    def create_config_options(self, section_name, disabled, conn):
        rows = ['''<table>''']

        for option in CONFIG_OPTIONS:
            if option.section != section_name:
                continue

            value = getattr(config, option.name)
            if not option.online:
                input = str(value)
            elif hasattr(self, "create_" + option.name):
                input = getattr(self, "create_" + option.name)(option, value,
                                                               disabled)
            elif option.getter == "get":
                value = str(value)
                if value:
                    value = square_bracket_to_html_entities(value)
                size = ""
                if len(value) > 16:
                    size = ''' size="64"'''
                input = '''<input type="text" id="%s" name="%s" value="%s"%s%s />''' % (
                    option.name, option.name, value, size, disabled)
            elif option.getter in ("getint", "getfloat"):
                input = '''<input type="number" id="%s" name="%s" value="%d"%s />''' % (
                    option.name, option.name, value, disabled)
            elif option.getter == "getboolean":
                checked = ""
                if value:
                    checked = ''' checked="checked"'''
                input = '''<input type="checkbox" id="%s" name="%s"%s%s />''' % (
                    option.name, option.name, checked, disabled)
            elif option.getter == "getemail":
                input = '''<input type="email" id="%s" name="%s" value="%s"%s />''' % (
                    option.name, option.name, value, disabled)
            else:
                log.bug("getter non definito per l'opzione %s: %s" %
                        (option.name, option.getter))
                continue

            tooltip = create_tooltip(conn, option.minihelp)
            rows.append(
                '''<tr><td>%s %s:</td><td>%s</td><td id="%s_error" style="color:red"></td></tr>'''
                % (option.name, tooltip, input, option.name))

        rows.append('''</table>''')
        return "".join(rows)
示例#14
0
    def create_player_bans(self, conn):
        output = []

        output.append('''<table rules="rows">''')
        output.append('''<tr><th>Giocatore:</th><th>Punizione Dal:</th><th>Per:</th><th>Motivo:</th></tr>''')
        for player_code, player in sort_datas(database["players"]):
            if not player.ban:
                continue
            output.append('''<tr><td>%s</td><td>%s</td><td align="center">%d giorn%s</td><td>%s</td></tr>''' % (
                player.name,
                pretty_date(player.ban.starting_from) if player.ban.starting_from else "Deve collegarsi",
                player.ban.days,
                "o" if player.ban.days == 1 else "i",
                create_tooltip(conn, player.ban.comment, player.ban.reason) if player.ban.comment else player.ban.reason))
        output.append('''</table>''')

        return "".join(output)
示例#15
0
def command_coords(entity, argument=""):
    if not entity:
        log.bug("entity non è un parametro valido: %r" % entity)
        return False

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

    results = []

    if argument:
        area = nifty_value_search(database["areas"], argument)
        if not area:
            entity.send_output("Codice d'area simile a [green]%s[close] inesistente." % argument)
            return False
    else:
        results.append(get_command_syntax(entity, "command_coords") + "\n")
        area = entity.area
        if not area:
            results.append("\nNon ti trovi in un'area valida.")
            entity.send_output("".join(results))
            return False

    results.append('''<table class="mud" rules="rows" frame="below">''')
    results.append('''<tr>''')
    results.append('''<th class="nowrap" align="left">X Y Z</th>''')
    results.append('''<th align="left">Code</th>''')
    results.append('''<th align="left">Name</th>''')
    results.append('''<th align="left">Short</th>''')
    results.append('''</tr>''')
    for coord in sorted(area.rooms):
        room = area.rooms[coord]
        short_tooltip = ""
        if room.short_night:
            short_tooltip = create_tooltip(entity.get_conn(), "ShortNight: %s" % room.short_night, room.short)
        else:
            short_tooltip = room.short
        javascript_code = '''javascript:parent.sendInput('rgoto %s');''' % room.get_destination()
        results.append('''<tr>''')
        results.append('''<td class="nowrap">%s</td><td><a href="%s">%s</a></td><td>%s</td><td>%s</td>''' % (
            coord, javascript_code, room.code, room.name, short_tooltip))
        results.append('''</tr>''')
    results.append('''</table>''')

    entity.send_output("".join(results), break_line=False)
    return True
示例#16
0
    def create_player_bans(self, conn):
        output = []

        output.append('''<table rules="rows">''')
        output.append(
            '''<tr><th>Giocatore:</th><th>Punizione Dal:</th><th>Per:</th><th>Motivo:</th></tr>'''
        )
        for player_code, player in sort_datas(database["players"]):
            if not player.ban:
                continue
            output.append(
                '''<tr><td>%s</td><td>%s</td><td align="center">%d giorn%s</td><td>%s</td></tr>'''
                % (player.name, pretty_date(player.ban.starting_from)
                   if player.ban.starting_from else "Deve collegarsi",
                   player.ban.days, "o" if player.ban.days == 1 else "i",
                   create_tooltip(conn, player.ban.comment, player.ban.reason)
                   if player.ban.comment else player.ban.reason))
        output.append('''</table>''')

        return "".join(output)
示例#17
0
def get_gift_codes(player, conn):
    if not player:
        log.bug("player non è un parametro valido: %r" % player)
        return ""

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

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

    output = ""
    for gift in player.gifts:
        color_open = ""
        color_close = ""
        if player_has_gift(player, gift):
            color_open = "[green]"
            color_close = "[close]"
        output += create_tooltip(conn, gift.get_name(),
                                 color_open + gift.code + color_close) + ", "

    return output.strip(", ")
示例#18
0
    def create_config_options(self, section_name, disabled, conn):
        rows = ['''<table>''']

        for option in CONFIG_OPTIONS:
            if option.section != section_name:
                continue

            value = getattr(config, option.name)
            if not option.online:
                input = str(value)
            elif hasattr(self, "create_" + option.name):
                input = getattr(self, "create_" + option.name)(option, value, disabled)
            elif option.getter == "get":
                value = str(value)
                if value:
                    value = square_bracket_to_html_entities(value)
                size = ""
                if len(value) > 16:
                    size = ''' size="64"'''
                input = '''<input type="text" id="%s" name="%s" value="%s"%s%s />''' % (option.name, option.name, value, size, disabled)
            elif option.getter in ("getint", "getfloat"):
                input = '''<input type="number" id="%s" name="%s" value="%d"%s />''' % (option.name, option.name, value, disabled)
            elif option.getter == "getboolean":
                checked = ""
                if value:
                   checked = ''' checked="checked"'''
                input = '''<input type="checkbox" id="%s" name="%s"%s%s />''' % (option.name, option.name, checked, disabled)
            elif option.getter == "getemail":
                input = '''<input type="email" id="%s" name="%s" value="%s"%s />''' % (option.name, option.name, value, disabled)
            else:
                log.bug("getter non definito per l'opzione %s: %s" % (option.name, option.getter))
                continue

            tooltip = create_tooltip(conn, option.minihelp)
            rows.append('''<tr><td>%s %s:</td><td>%s</td><td id="%s_error" style="color:red"></td></tr>''' % (option.name, tooltip, input, option.name))

        rows.append('''</table>''')
        return "".join(rows)
示例#19
0
def command_list(entity, argument="", behavioured=False):
    """
    Permette di comprare entità da un commerciante.
    """
    # Può essere normale se il comando è stato deferrato
    if not entity:
        return False

    entity = entity.split_entity(1)

    if argument:
        dealer = entity.find_entity_extensively(argument)
        if not dealer:
            entity.act("Non trovi nessun negoziante chiamato [white]%s[close]." % argument, TO.ENTITY)
            entity.act("$n sembra cercare qualcuno un negoziante.", TO.OTHERS)
            return False
        if not dealer.shop:
            entity.act("$N non sembra essere un negoziante.", TO.ENTITY, dealer)
            entity.act("$n crede erroneamente che $N sia un negoziante.", TO.OTHERS, dealer)
            entity.act("$n crede erroneamente che tu sia un negoziante.", 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 nessun negoziante qui intorno.", TO.OTHERS)
            return False

    in_location = dealer.shop.in_location(dealer)
    if not in_location and SHOP.DISPENSER not in dealer.shop.types:
        entity.act("$N non ti mostra la merce perché non si trova nel suo negozio.", TO.ENTITY, dealer)
        entity.act("$N non mostra la merce a $n perché non si trova nel suo negozio.", TO.OTHERS, dealer)
        entity.act("Non mostri la tua merce a $n perché non ti trovi nel tuo negozio.", TO.TARGET, dealer)
        return False

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

    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 avere la lista da $N perché non ha %s prendere la mercanzia!" % from_where, TO.ENTITY, dealer)
        entity.act("$n non può avere la lista da $N perché non ha %s prendere la mercanzia!" % from_where, TO.OTHERS, dealer)
        entity.act("$n non può avere la lista perché non hai %s prendere la mercanzia!" % from_where, TO.TARGET, dealer)
        return False

    if not dealer.shop.buyables:
        entity.send_output("%s non possiede nessuna mercanzia" % dealer.get_name(looker=entity))
        log.bug("Non è stato trovato nessun buyable impostato per %s" % dealer.code)
        return False

    # Controlla se il magazzino contiene almeno un oggetto comprabile dall'utente
    if dealer.shop.storage_is_empty(storage):
        entity.act("Ti accorgi che il negozio non possiede mercanzia, meglio tornare più tardi, dopo il rifornimento.", TO.ENTITY, dealer)
        entity.act("$n si accorge che il negozio non possiede mercanzia.", TO.OTHERS, dealer)
        entity.act("$n si accorge che il tuo negozio non possiede mercanzia.", TO.TARGET, dealer)
        return False

    force_return = check_trigger(entity, "before_list", entity, dealer, behavioured)
    if force_return:
        return True
    force_return = check_trigger(dealer, "before_listed", entity, dealer, behavioured)
    if force_return:
        return True

    if SHOP.DISPENSER in dealer.shop.types:
        if not in_location:
            entity.act("Leggi su di una targetta la lista delle mercanzie di $N anche se non si trova nel suo negozio.", TO.OTHERS, dealer)
            entity.act("$n legge su di una targetta la lista delle mercanzie di $N anche se non si trova nel suo negozio.", TO.OTHERS, dealer)
            entity.act("$n legge la tua targetta con la lista delle mercanzie anche se non si trova nel suo negozio.", TO.TARGET, dealer)
        else:
            entity.act("Leggi su di una targetta la lista delle mercanzie di $N.", TO.OTHERS, dealer)
            entity.act("$n legge su di una targetta la lista delle mercanzie di $N.", TO.OTHERS, dealer)
            entity.act("$n legge la tua targetta con la lista delle mercanzie.", TO.TARGET, dealer)
    else:
        entity.act("Chiedi la lista delle mercanzie di $N.", TO.OTHERS, dealer)
        entity.act("$n chiede la lista delle mercanzie di $N.", TO.OTHERS, dealer)
        entity.act("$n ti chiede la lista delle mercanzie.", TO.TARGET, dealer)

    discount_exist = False
    for buyable in dealer.shop.buyables:
        if buyable.has_discount():
            discount_exist = True

    buy_translation = translate_input(entity, "buy", "en")
    rows = []
    rows.append('''<table class="mud">''')
    discount_cell = ""
    if SHOP.DISPENSER in dealer.shop.types:
        name_cell = "Prodotti"
    else:
        name_cell = "Mercanzia"
    if discount_exist:
        discount_cell = '''<th>Sconto</th>'''
    rows.append('''<tr><th></th><th>%s</th><th colspan="4">Prezzo</th><th>Livello</th><th></th><th></th>%s</tr>''' % (
        name_cell, discount_cell))
    for en in storage.get_list_of_entities(entity):
        en = en[INSTANCE]
        for buyable in dealer.shop.buyables:
            if en.prototype != buyable.proto_entity:
                continue

            # Purtroppo però il sistema di mucchio visivo non permetterà di
            # visualizzare quantità superiori ad 1 per oggetti di long uguali
            # tra loro, la quantità si deve per forza basare sul mucchio fisico
            quantity = 10
            if buyable.has_discount():
                quantity = buyable.discount_quantity
            if en.quantity < quantity:
                quantity = en.quantity

            name = en.get_name(looker=entity)
            single_price, dummy_discount = buyable.get_price(en, quantity=1)
            block_price, dummy_discount = buyable.get_price(en, quantity=quantity)
            mithril, gold, silver, copper = pretty_money_icons(single_price)
            rows.append('''<tr><td>%s</td>''' % create_icon(en.get_icon(), add_span=False))
            rows.append('''<td>%s </td>''' % create_tooltip(entity.get_conn(), en.get_descr(looker=entity), name))
            rows.append('''<td align="right">%s</td>''' % mithril)
            rows.append('''<td align="right">%s</td>''' % gold)
            rows.append('''<td align="right">%s</td>''' % silver)
            rows.append('''<td align="right">%s</td>''' % copper)
            rows.append('''<td align="center">%d</td>''' % en.level)
            rows.append('''<td><input type="submit" value="%s" onclick="sendInput('%s 1 %s')" title="Comprerai %s per un prezzo di %s"/></td>''' % (
                buy_translation.capitalize(),
                buy_translation,
                en.get_numbered_keyword(looker=entity),
                remove_colors(name),
                remove_colors(pretty_money_value(single_price))))
            rows.append('''<td><input type="submit" value="%s x %d" onclick="sendInput('%s %d %s')" title="Comprerai %d unità di %s per un prezzo di %s"/></td>''' % (
                buy_translation.capitalize(),
                quantity,
                buy_translation,
                quantity,
                en.get_numbered_keyword(looker=entity),
                quantity,
                remove_colors(name),
                remove_colors(pretty_money_value(block_price))))
            if discount_exist:
                if buyable.has_discount():
                    rows.append('''<td align="center">%d%% per quantità maggiori di %d</td>''' % (buyable.discount_percent, buyable.discount_quantity))
                else:
                    rows.append('''<td align="center">Nessuno</td>''')
            rows.append('''</tr>''')
    rows.append('''</table>''')
    entity.send_output("".join(rows), break_line=False)

    force_return = check_trigger(entity, "after_list", entity, dealer, behavioured)
    if force_return:
        return True
    force_return = check_trigger(dealer, "after_listed", entity, dealer, behavioured)
    if force_return:
        return True

    return True
示例#20
0
    def create_talents_body(self, conn):
        if not conn:
            log.bug("conn non è un parametro valido: %r" % conn)
            return ""

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

        player = conn.player
        if not player:
            log.bug("player non è valido %r per la connessione %s" %
                    (player, conn.get_id()))
            return ""

        output = []

        ie_problem = ""
        # Per IE9 non c'è bisogno del messaggio, (TT) bisognerà testare piuttosto se per IE7 sì
        if conn.get_browser() == "IE_8":
            ie_problem = '''Se per caso visualizzate spostate in maniera errata le freccette per aumentare e diminuire i valori sottostanti allora potete risolvere cliccando sul bottone <img src="graphics/ie_broken_button.png" /> in alto.<br><br>'''
        output.append(ie_problem)

        if conn.player.talents == 0:
            talents_title = '''Non hai nessun talento da poter distribuire.'''
        else:
            talents_title = '''Hai [white]<span id="talents">%d</span>[close] talenti da poter distribuire in:''' % conn.player.talents
        output.append(
            '''<center><span style="font-weight:bold;">%s</span></center><br>'''
            % talents_title)

        # Se non vi sono talenti da spendere allora ritorna l'html finora creato
        if conn.player.talents == 0:
            return "".join(output)

        output.append(
            '''<script>initial_life = %d; initial_mana = %d; initial_vigour = %d; initial_talents = %d;</script>'''
            % (player.max_life, player.max_mana, player.max_vigour,
               player.talents))

        output.append(
            '''<div class="ui-widget-content ui-corner-all" style="padding:5px">'''
        )
        output.append(
            '''<table align="center" class="ui-widget-content"><tr>''')
        output.append('''<td><span style="color:red">Vita</span>:</td>''')
        output.append(
            '''<td><input type="text" id="life" class="spinner" value="%d" readonly="readonly" onChange="changeTalentPoints(this)" onBlur="changeTalentPoints(this)" /></td>'''
            % player.max_life)
        output.append('''<td>%s </td>''' % create_tooltip(
            conn,
            "La vita indica la quantità di danni che puoi sostenere prima di morire"
        ))
        output.append(
            '''<td><span style="color:royalblue">Mana</span>:</td>''')
        output.append(
            '''<td><input type="text" id="mana" class="spinner" value="%d" readonly="readonly" onChange="changeTalentPoints(this)" onBlur="changeTalentPoints(this)" /></td>'''
            % player.max_mana)
        output.append('''<td>%s </td>''' % create_tooltip(
            conn,
            "Il mana è quell'energia utile nel pronunciare incantesimi o utilizzare oggetti magici"
        ))
        output.append('''<td><span style="color:green">Vigore</span>:</td>''')
        output.append(
            '''<td><input type="text" id="vigour" class="spinner" value="%d" readonly="readonly" onChange="changeTalentPoints(this)" onBlur="changeTalentPoints(this)" /></td>'''
            % player.max_vigour)
        output.append('''<td>%s </td>''' % create_tooltip(
            conn,
            "Il vigore indica quanto ti puoi muovere e quanto peso puoi trasportare"
        ))
        output.append('''</tr></table>''')
        output.append('''</div><br>''')

        output.append(
            '''<div class="ui-widget-content ui-corner-all" style="padding:5px; text-align:center">'''
        )
        output.append(
            '''<input type="submit" id="send" value="Distribuisci" onclick="distribute();"/> '''
        )
        output.append(
            '''<input type="submit" id="close" value="Chiudi" onclick="$("#talents_title").parent().hide(); $("#game_tabs").tabs({selected: 0}"/><br>'''
        )
        output.append('''<span id="error_message" style="color:red"></span>''')
        output.append('''</div>''')

        return "".join(output)
示例#21
0
def command_wield(entity, argument="", verbs=VERBS, behavioured=False, command_name="wield"):
    """
    Permette di prendere un oggetto nella mano secondaria o, se quest'ultima
    è occupata, in quella primaria.
    """
    if not verbs:
        log.bug("verbs non è un parametro valido: %r" % verbs)
        return False

    if command_name not in ("wield", "hold"):
        log.bug("command_name non è un parametro valido: %r" % command_name)
        return False

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

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

    entity = entity.split_entity(1)

    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_wield")
            entity.send_output(syntax, break_line=False)
        return False

    # (TD) Controllo sul mental state dell'entità

    target = entity.find_entity(argument, location=entity)
    if not target:
        entity.act("Non riesci a trovare nessun [white]%s[close] da %s." % (argument, verbs["infinitive"]), TO.ENTITY)
        entity.act("$n sembra voler %s qualcosa che non trova." % verbs["infinitive"], TO.OTHERS)
        return False

    if target == entity:
        entity.act("Cerchi di %s da sol$o... impossibile!" % verbs["you2_min"], TO.ENTITY)
        entity.act("$n cerca di %s da sol$o... sarà dura!" % verbs["self_min"], TO.OTHERS)
        return False

    if FLAG.NO_HOLD in target.flags:
        if entity.trust >= TRUST.MASTER:
            entity.send_to_admin("Raccogli l'oggetto anche se è NO_HOLD")
        else:
            entity.act("Cerchi di $a $N... ma [darkgray]senza successo[close].", TO.ENTITY, target, verbs["infinitive"])
            entity.act("$n cerca di $a $N... [darkgray]senza successo[close].", TO.OTHERS, target, verbs["infinitive"])
            entity.act("\n$n cerca di $a... [darkgray]senza successo[close].", TO.TARGET, target, verbs["you"])
            return False

    if ((    entity.location.IS_ROOM and ROOM.NO_HOLD in entity.location.flags)
    or  (not entity.location.IS_ROOM and FLAG.NO_HOLD in entity.location.flags)):
        if entity.trust >= TRUST.MASTER:
            entity.send_to_admin("Raccogli l'oggetto anche se la stanza è NO_HOLD")
        else:
            entity.act("Cerchi di %s $N, tuttavia una [royalblue]forza misteriosa[close] del luogo l$o respinge." % verbs["infinitive"], TO.ENTITY, target)
            entity.act("$n cerca di %s $N, tuttavia una [royalblue]forza misteriosa[close] del luogo sembra respingerl$o." % verbs["infinitive"], TO.OTHERS, target)
            entity.act("\n$n cerca di %s, tuttavia una [royalblue]forza misteriosa[close] del luogo sembra respingerl$o." % verbs["you2"], TO.TARGET, target)
            return False

    already_use_hold = entity.get_holded_entity()
    already_use_wield = entity.get_wielded_entity()
    if already_use_hold and already_use_wield:
        entity.act("Non puoi, hai tutte e due le $hands occupate per poter %s $N." % verbs["infinitive_min"], TO.ENTITY, target)
        entity.act("$n cerca di %s $N ma ha tutte e due le $hands occupate." % verbs["infinitive_min"], TO.OTHERS, target)
        entity.act("\n$n cerca di %s ma ha tutte e due le $hands occupate." % verbs["you2_min"], TO.TARGET, target)
        return False

    # Si salva quali mani si stanno utilizzando per l'operazione
    if command_name == "wield":
        if already_use_wield:
            if already_use_wield.weapon_type and WEAPONFLAG.TWO_HANDS in already_use_wield.weapon_type.flags:
                hands = [HAND.RIGHT, HAND.LEFT]
            else:
                if entity.IS_ITEM:
                    hands = [HAND.RIGHT]
                else:
                    hands = [entity.hand.reverse]
        else:
            if entity.IS_ITEM:
                hands = [HAND.LEFT]
            else:
                hands = [entity.hand]
    else:
        if already_use_hold:
            if already_use_hold.weapon_type and WEAPONFLAG.TWO_HANDS in already_use_hold.weapon_type.flags:
                hands = [HAND.RIGHT, HAND.LEFT]
            else:
                if entity.IS_ITEM:
                    hands = [HAND.LEFT]
                else:
                    hands = [entity.hand]
        else:
            if entity.IS_ITEM:
                hands = [HAND.RIGHT]
            else:
                hands = [entity.hand.reverse]

    # Raccoglie i dati per una successiva gestione generica dei due comandi
    if command_name == "wield":
        first_hand_to_use = "$hand1"
        second_hand_to_use = "$hand2"
        already_use_check = already_use_wield
        already_use_flag = PART.HOLD
        normal_flag = PART.WIELD
        if target.level > entity.level:
            tooltip = create_tooltip(entity.get_conn(), "Ciò significa che il suo livello è troppo alto rispetto al tuo", "{?}")
            entity.act("Senti che non potrai usufruire al meglio del danno di $N. %s" % tooltip, TO.ENTITY, target)
            entity.act("$n non si sente a suo agio con in mano $N.", TO.OTHERS, target)
            entity.act("$n non si sente a suo agio con te in mano.", TO.TARGET, target)
    else:
        first_hand_to_use = "$hand2"
        second_hand_to_use = "$hand1"
        already_use_check = already_use_hold
        already_use_flag = PART.WIELD
        normal_flag = PART.HOLD

    # Gestione delle armi a due mani
    if command_name == "wield" and target.weapon_type and WEAPONFLAG.TWO_HANDS in target.weapon_type.flags and (already_use_hold or already_use_wield):
        entity.act("Non puoi, devi avere tutte e due le $hands libere per poter %s $N." % WIELD_VERBS["infinitive_min"], TO.ENTITY, target)
        entity.act("$n cerca di %s $N ma non ha tutte e due le $hands libere." % WIELD_VERBS["infinitive_min"], TO.OTHERS, target)
        entity.act("\n$n cerca di %s ma non ha tutte e due le $hands libere." % WIELD_VERBS["you2_min"], TO.TARGET, target)
        return False
    if len(hands) == 2:
        entity.act("Non puoi, hai tutte e due le $hands occupate per poter %s $N." % WIELD_VERBS["infinitive_min"], TO.ENTITY, target)
        entity.act("$n cerca di %s $N ma ha tutte e due le $hands occupate." % WIELD_VERBS["infinitive_min"], TO.OTHERS, target)
        entity.act("\n$n cerca di %s ma ha tutte e due le $hands occupate." % WIELD_VERBS["you2_min"], TO.TARGET, target)
        return False

    force_return = check_trigger(entity, "before_" + command_name, entity, target, hands, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "before_" + command_name + "ed", entity, target, hands, behavioured)
    if force_return:
        return True

    # Gli oggetti non hanno le mani, quindi utilizzano dei verbi non specifici
    if entity.IS_ITEM:
        entity.act("%s $N." % (color_first_upper(verbs["you_min"])), TO.ENTITY, target)
        entity.act("$n %s $N." % (verbs["it_min"]), TO.OTHERS, target)
        entity.act("\n$n %s" % (verbs["you3_min"]), TO.TARGET, target)
        if already_use_check:
            target.wear_mode = Flags(already_use_flag)
        else:
            target.wear_mode = Flags(normal_flag)
    elif target.weapon_type and WEAPONFLAG.TWO_HANDS in target.weapon_type.flags:
        entity.act("%s $N con tutte e due le $hands." % color_first_upper(verbs["you_min"]), TO.ENTITY, target)
        entity.act("$n %s $N con tutte e due le $hands." % verbs["it_min"], TO.OTHERS, target)
        entity.act("\n$n %s con tutte e due le $hands," % verbs["you3_min"], TO.TARGET, target)
        target.wear_mode = Flags(normal_flag, already_use_flag)
    elif already_use_check:
        entity.act("Cerchi di %s con la %s $N ma essendo già occupata utilizzi la %s." % (
            verbs["infinitive_min"], first_hand_to_use, second_hand_to_use), TO.ENTITY, target)
        entity.act("$n cerca di %s $N con la %s ma essendo già occupata utilizza la %s." % (
            verbs["infinitive_min"], first_hand_to_use, second_hand_to_use), TO.OTHERS, target)
        entity.act("\n$n cerca di %s con la %s ma essendo già occupata utilizza la %s." % (
            verbs["you2_min"], first_hand_to_use, second_hand_to_use), TO.TARGET, target)
        target.wear_mode = Flags(already_use_flag)
    else:
        entity.act("%s $N con la %s." % (color_first_upper(verbs["you_min"]), first_hand_to_use), TO.ENTITY, target)
        entity.act("$n %s $N con la %s." % (verbs["it_min"], first_hand_to_use), TO.OTHERS, target)
        entity.act("\n$n %s con la %s" % (verbs["you3_min"], first_hand_to_use), TO.TARGET, target)
        target.wear_mode = Flags(normal_flag)

    for affect in target.affects:
        affect.apply()

    # Poiché l'entità è stata impugnata forse ha un valore nel gioco e non
    # verrà quindi purificata
    if target.deferred_purification:
        target.stop_purification()

    # Serve a cambiare il wear mode dell'oggetto allo stato originario
    if target.repop_later:
        target.deferred_repop = target.repop_later.defer_check_status()

    force_return = check_trigger(entity, "after_" + command_name, entity, target, hands, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "after_" + command_name + "ed", entity, target, hands, behavioured)
    if force_return:
        return True

    return True
示例#22
0
def command_wield(entity,
                  argument="",
                  verbs=VERBS,
                  behavioured=False,
                  command_name="wield"):
    """
    Permette di prendere un oggetto nella mano secondaria o, se quest'ultima
    è occupata, in quella primaria.
    """
    if not verbs:
        log.bug("verbs non è un parametro valido: %r" % verbs)
        return False

    if command_name not in ("wield", "hold"):
        log.bug("command_name non è un parametro valido: %r" % command_name)
        return False

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

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

    entity = entity.split_entity(1)

    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_wield")
            entity.send_output(syntax, break_line=False)
        return False

    # (TD) Controllo sul mental state dell'entità

    target = entity.find_entity(argument, location=entity)
    if not target:
        entity.act(
            "Non riesci a trovare nessun [white]%s[close] da %s." %
            (argument, verbs["infinitive"]), TO.ENTITY)
        entity.act(
            "$n sembra voler %s qualcosa che non trova." % verbs["infinitive"],
            TO.OTHERS)
        return False

    if target == entity:
        entity.act("Cerchi di %s da sol$o... impossibile!" % verbs["you2_min"],
                   TO.ENTITY)
        entity.act("$n cerca di %s da sol$o... sarà dura!" % verbs["self_min"],
                   TO.OTHERS)
        return False

    if FLAG.NO_HOLD in target.flags:
        if entity.trust >= TRUST.MASTER:
            entity.send_to_admin("Raccogli l'oggetto anche se è NO_HOLD")
        else:
            entity.act(
                "Cerchi di $a $N... ma [darkgray]senza successo[close].",
                TO.ENTITY, target, verbs["infinitive"])
            entity.act("$n cerca di $a $N... [darkgray]senza successo[close].",
                       TO.OTHERS, target, verbs["infinitive"])
            entity.act("\n$n cerca di $a... [darkgray]senza successo[close].",
                       TO.TARGET, target, verbs["you"])
            return False

    if ((entity.location.IS_ROOM and ROOM.NO_HOLD in entity.location.flags)
            or (not entity.location.IS_ROOM
                and FLAG.NO_HOLD in entity.location.flags)):
        if entity.trust >= TRUST.MASTER:
            entity.send_to_admin(
                "Raccogli l'oggetto anche se la stanza è NO_HOLD")
        else:
            entity.act(
                "Cerchi di %s $N, tuttavia una [royalblue]forza misteriosa[close] del luogo l$o respinge."
                % verbs["infinitive"], TO.ENTITY, target)
            entity.act(
                "$n cerca di %s $N, tuttavia una [royalblue]forza misteriosa[close] del luogo sembra respingerl$o."
                % verbs["infinitive"], TO.OTHERS, target)
            entity.act(
                "\n$n cerca di %s, tuttavia una [royalblue]forza misteriosa[close] del luogo sembra respingerl$o."
                % verbs["you2"], TO.TARGET, target)
            return False

    already_use_hold = entity.get_holded_entity()
    already_use_wield = entity.get_wielded_entity()
    if already_use_hold and already_use_wield:
        entity.act(
            "Non puoi, hai tutte e due le $hands occupate per poter %s $N." %
            verbs["infinitive_min"], TO.ENTITY, target)
        entity.act(
            "$n cerca di %s $N ma ha tutte e due le $hands occupate." %
            verbs["infinitive_min"], TO.OTHERS, target)
        entity.act(
            "\n$n cerca di %s ma ha tutte e due le $hands occupate." %
            verbs["you2_min"], TO.TARGET, target)
        return False

    # Si salva quali mani si stanno utilizzando per l'operazione
    if command_name == "wield":
        if already_use_wield:
            if already_use_wield.weapon_type and WEAPONFLAG.TWO_HANDS in already_use_wield.weapon_type.flags:
                hands = [HAND.RIGHT, HAND.LEFT]
            else:
                if entity.IS_ITEM:
                    hands = [HAND.RIGHT]
                else:
                    hands = [entity.hand.reverse]
        else:
            if entity.IS_ITEM:
                hands = [HAND.LEFT]
            else:
                hands = [entity.hand]
    else:
        if already_use_hold:
            if already_use_hold.weapon_type and WEAPONFLAG.TWO_HANDS in already_use_hold.weapon_type.flags:
                hands = [HAND.RIGHT, HAND.LEFT]
            else:
                if entity.IS_ITEM:
                    hands = [HAND.LEFT]
                else:
                    hands = [entity.hand]
        else:
            if entity.IS_ITEM:
                hands = [HAND.RIGHT]
            else:
                hands = [entity.hand.reverse]

    # Raccoglie i dati per una successiva gestione generica dei due comandi
    if command_name == "wield":
        first_hand_to_use = "$hand1"
        second_hand_to_use = "$hand2"
        already_use_check = already_use_wield
        already_use_flag = PART.HOLD
        normal_flag = PART.WIELD
        if target.level > entity.level:
            tooltip = create_tooltip(
                entity.get_conn(),
                "Ciò significa che il suo livello è troppo alto rispetto al tuo",
                "{?}")
            entity.act(
                "Senti che non potrai usufruire al meglio del danno di $N. %s"
                % tooltip, TO.ENTITY, target)
            entity.act("$n non si sente a suo agio con in mano $N.", TO.OTHERS,
                       target)
            entity.act("$n non si sente a suo agio con te in mano.", TO.TARGET,
                       target)
    else:
        first_hand_to_use = "$hand2"
        second_hand_to_use = "$hand1"
        already_use_check = already_use_hold
        already_use_flag = PART.WIELD
        normal_flag = PART.HOLD

    # Gestione delle armi a due mani
    if command_name == "wield" and target.weapon_type and WEAPONFLAG.TWO_HANDS in target.weapon_type.flags and (
            already_use_hold or already_use_wield):
        entity.act(
            "Non puoi, devi avere tutte e due le $hands libere per poter %s $N."
            % WIELD_VERBS["infinitive_min"], TO.ENTITY, target)
        entity.act(
            "$n cerca di %s $N ma non ha tutte e due le $hands libere." %
            WIELD_VERBS["infinitive_min"], TO.OTHERS, target)
        entity.act(
            "\n$n cerca di %s ma non ha tutte e due le $hands libere." %
            WIELD_VERBS["you2_min"], TO.TARGET, target)
        return False
    if len(hands) == 2:
        entity.act(
            "Non puoi, hai tutte e due le $hands occupate per poter %s $N." %
            WIELD_VERBS["infinitive_min"], TO.ENTITY, target)
        entity.act(
            "$n cerca di %s $N ma ha tutte e due le $hands occupate." %
            WIELD_VERBS["infinitive_min"], TO.OTHERS, target)
        entity.act(
            "\n$n cerca di %s ma ha tutte e due le $hands occupate." %
            WIELD_VERBS["you2_min"], TO.TARGET, target)
        return False

    force_return = check_trigger(entity, "before_" + command_name, entity,
                                 target, hands, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "before_" + command_name + "ed",
                                 entity, target, hands, behavioured)
    if force_return:
        return True

    # Gli oggetti non hanno le mani, quindi utilizzano dei verbi non specifici
    if entity.IS_ITEM:
        entity.act("%s $N." % (color_first_upper(verbs["you_min"])), TO.ENTITY,
                   target)
        entity.act("$n %s $N." % (verbs["it_min"]), TO.OTHERS, target)
        entity.act("\n$n %s" % (verbs["you3_min"]), TO.TARGET, target)
        if already_use_check:
            target.wear_mode = Flags(already_use_flag)
        else:
            target.wear_mode = Flags(normal_flag)
    elif target.weapon_type and WEAPONFLAG.TWO_HANDS in target.weapon_type.flags:
        entity.act(
            "%s $N con tutte e due le $hands." %
            color_first_upper(verbs["you_min"]), TO.ENTITY, target)
        entity.act("$n %s $N con tutte e due le $hands." % verbs["it_min"],
                   TO.OTHERS, target)
        entity.act("\n$n %s con tutte e due le $hands," % verbs["you3_min"],
                   TO.TARGET, target)
        target.wear_mode = Flags(normal_flag, already_use_flag)
    elif already_use_check:
        entity.act(
            "Cerchi di %s con la %s $N ma essendo già occupata utilizzi la %s."
            % (verbs["infinitive_min"], first_hand_to_use, second_hand_to_use),
            TO.ENTITY, target)
        entity.act(
            "$n cerca di %s $N con la %s ma essendo già occupata utilizza la %s."
            % (verbs["infinitive_min"], first_hand_to_use, second_hand_to_use),
            TO.OTHERS, target)
        entity.act(
            "\n$n cerca di %s con la %s ma essendo già occupata utilizza la %s."
            % (verbs["you2_min"], first_hand_to_use, second_hand_to_use),
            TO.TARGET, target)
        target.wear_mode = Flags(already_use_flag)
    else:
        entity.act(
            "%s $N con la %s." %
            (color_first_upper(verbs["you_min"]), first_hand_to_use),
            TO.ENTITY, target)
        entity.act(
            "$n %s $N con la %s." % (verbs["it_min"], first_hand_to_use),
            TO.OTHERS, target)
        entity.act(
            "\n$n %s con la %s" % (verbs["you3_min"], first_hand_to_use),
            TO.TARGET, target)
        target.wear_mode = Flags(normal_flag)

    for affect in target.affects:
        affect.apply()

    # Poiché l'entità è stata impugnata forse ha un valore nel gioco e non
    # verrà quindi purificata
    if target.deferred_purification:
        target.stop_purification()

    # Serve a cambiare il wear mode dell'oggetto allo stato originario
    if target.repop_later:
        target.deferred_repop = target.repop_later.defer_check_status()

    force_return = check_trigger(entity, "after_" + command_name, entity,
                                 target, hands, behavioured)
    if force_return:
        return True
    force_return = check_trigger(target, "after_" + command_name + "ed",
                                 entity, target, hands, behavioured)
    if force_return:
        return True

    return True
示例#23
0
    def create_page(self,
                    request,
                    conn,
                    password="",
                    new_password="",
                    new_password2="",
                    new_email="",
                    err_msg_password="",
                    err_msg_new_password="",
                    err_msg_new_password2="",
                    err_msg_new_email=""):
        # Prepara il form delle opzioni
        form_options = []
        row = create_form_row(form_options)
        row.label = "Opzioni dell'account"
        row.field = create_checklist_of_flags(
            "options",
            conn.account.options,
            "description",
            use_icons=True,
            avoid_elements=[OPTION.SOUND, OPTION.MUSIC, OPTION.LOOP])
        row = create_form_row(form_options)
        row.label = '''<input type="submit" value="Salva le Opzioni" onclick="document.getElementById('form_options').submit();" />'''
        if request.method == "POST" and "options" in request.args:
            row.label += '''<span style="color:green"> Opzioni salvate.</span>'''

        # Prepara il form degli account
        form_account = []
        row = create_form_row(form_account)
        row.label = '''Password attuale %s''' % create_tooltip(
            conn,
            "Devi digitare la tua password corrente se vuoi cambiarla con una nuova o con un nuovo indirizzo mail. In questa maniera i tuoi dati privati non vengono cambiati da chicchessia nel caso tu giocassi in luoghi pubblici."
        )
        row.field = '''<input type="password" name="password" maxlength="%s" value="%s" style="width:11em;" />''' % (
            config.max_len_password, password)
        row = err_msg_password
        row = create_form_row(form_account)
        row.label = '''Nuova password'''
        row.field = '''<input type="password" name="new_password" maxlength="%s" value="%s" style="width:11em;" />''' % (
            config.max_len_password, new_password)
        if err_msg_new_password != "":
            row.message = err_msg_new_password
        elif err_msg_new_password2 != "":
            row.message = err_msg_new_password2
        row = create_form_row(form_account)
        row.label = '''Conferma la nuova password'''
        row.field = '''<input type="password" name="new_password2" maxlength="%s" value="%s" style="width:11em;" />''' % (
            config.max_len_password, new_password2)
        row = create_form_row(form_account)
        row.label = '''Nuovo indirizzo mail %s''' % create_tooltip(
            conn, "Facoltativo.")
        row.field = '''<input type="text" name="new_email" maxlength="%s" value="%s" style="width:11em;" />''' % (
            MAX_LEN_EMAIL, new_email)
        row.message = err_msg_new_email
        row = create_form_row(form_account)
        row.label = '''<input type="submit" value="Salva i Dati" onclick="document.getElementById('form_account').submit();" />'''

        if (request.method == "POST" and "options" not in request.args
                and err_msg_password == "" and err_msg_new_password == ""
                and err_msg_new_password2 == "" and err_msg_new_email == ""
                and password == "" and new_password == ""
                and new_password2 == "" and new_email == ""):
            row.label += '''<span style="color:green"> Account salvato.</span>'''

        # Crea la pagina html
        page = ""

        page += create_form(form_options,
                            "form_options",
                            "account.html",
                            "Modifica le opzioni del tuo account",
                            show_label=False)
        page += '''<br>'''

        page += create_form(form_account, "form_account", "account.html",
                            "Modifica i dati del tuo account")

        return page