Ejemplo n.º 1
0
        /*
         * Format object o_ptr's name into 'buf'.
         */
        static int obj_desc_name(ref string buf, int max, int end, Object o_ptr, bool prefix, Detail mode, bool spoil)
        {
            bool known = o_ptr.is_known() || ((o_ptr.ident & Object.IDENT_STORE) != 0) || spoil;
            bool aware = o_ptr.flavor_is_aware() || ((o_ptr.ident & Object.IDENT_STORE) != 0) || spoil;

            string basename = obj_desc_get_basename(o_ptr, aware);
            string modstr   = obj_desc_get_modstr(o_ptr.kind);

            if (aware && !o_ptr.kind.everseen && !spoil)
            {
                o_ptr.kind.everseen = true;
            }

            if (prefix)
            {
                end = obj_desc_name_prefix(ref buf, max, end, o_ptr, known,
                                           basename, modstr);
            }

            /* Pluralize if (not forced singular) and
             * (not a known/visible artifact) and
             * (not one in stack or forced plural) */
            obj_desc_name_format(ref buf, basename, modstr,
                                 ((mode & Detail.SINGULAR) == 0) &&
                                 !(o_ptr.artifact == null && (o_ptr.name_is_visible() || known)) &&
                                 (o_ptr.number != 1 || ((mode & Detail.PLURAL) != 0)));


            /** Append extra names of various kinds **/

            if ((o_ptr.name_is_visible() || known) && o_ptr.artifact != null)
            {
                buf = buf + " " + o_ptr.artifact.Name;
            }

            else if ((spoil && o_ptr.ego != null) || o_ptr.ego_is_visible())
            {
                buf = buf + " " + o_ptr.ego.name;
            }

            else if (aware && o_ptr.artifact == null && (o_ptr.kind.flavor != null || o_ptr.kind.tval == TVal.TV_SCROLL))
            {
                buf = buf + " of " + o_ptr.kind.Name;
            }

            return(end);
        }
Ejemplo n.º 2
0
        static int obj_desc_name_prefix(ref string buf, int max, int end, Object o_ptr, bool known, string basename, string modstr)
        {
            if (o_ptr.number <= 0)
            {
                buf = buf + "no more ";
            }
            else if (o_ptr.number > 1)
            {
                buf = buf + o_ptr.number.ToString() + " ";
            }
            else if ((o_ptr.name_is_visible() || known) && o_ptr.artifact != null)
            {
                buf += "the ";
            }

            else if (basename[0] == '&')
            {
                bool   an        = false;
                string lookahead = basename.Substring(1);

                while (lookahead[0] == ' ')
                {
                    lookahead = lookahead.Substring(1);
                }

                if (lookahead[0] == '#')
                {
                    if (modstr != null && "aeiouAEIOU".Contains(modstr[0]))
                    {
                        an = true;
                    }
                }
                else if ("aeiouAEIOU".Contains(lookahead[0]))
                {
                    an = true;
                }

                if (an)
                {
                    buf = buf + "an ";
                }
                else
                {
                    buf = buf + "a ";
                }
            }

            return(end);
        }
Ejemplo n.º 3
0
        static int obj_desc_name_prefix(ref string buf, int max, int end, Object o_ptr, bool known, string basename, string modstr)
        {
            if(o_ptr.number <= 0)
                buf = buf + "no more ";
            else if(o_ptr.number > 1)
                buf = buf + o_ptr.number.ToString() + " ";
            else if((o_ptr.name_is_visible() || known) && o_ptr.artifact != null)
                buf += "the ";

            else if(basename[0] == '&') {
                bool an = false;
                string lookahead = basename.Substring(1);

                while(lookahead[0] == ' ')
                    lookahead = lookahead.Substring(1);

                if(lookahead[0] == '#') {
                    if(modstr != null && "aeiouAEIOU".Contains(modstr[0]))
                        an = true;
                } else if("aeiouAEIOU".Contains(lookahead[0])) {
                    an = true;
                }

                if(an)
                    buf = buf + "an ";
                else
                    buf = buf + "a ";
            }

            return end;
        }
Ejemplo n.º 4
0
        /*
         * Format object o_ptr's name into 'buf'.
         */
        static int obj_desc_name(ref string buf, int max, int end, Object o_ptr, bool prefix, Detail mode, bool spoil)
        {
            bool known = o_ptr.is_known() || ((o_ptr.ident & Object.IDENT_STORE) != 0) || spoil;
            bool aware = o_ptr.flavor_is_aware() || ((o_ptr.ident & Object.IDENT_STORE) != 0) || spoil;

            string basename = obj_desc_get_basename(o_ptr, aware);
            string modstr = obj_desc_get_modstr(o_ptr.kind);

            if (aware && !o_ptr.kind.everseen && !spoil)
                o_ptr.kind.everseen = true;

            if (prefix)
                end = obj_desc_name_prefix(ref buf, max, end, o_ptr, known,
                        basename, modstr);

            /* Pluralize if (not forced singular) and
             * (not a known/visible artifact) and
             * (not one in stack or forced plural) */
            obj_desc_name_format(ref buf, basename, modstr,
                    ((mode & Detail.SINGULAR) == 0) &&
                    !(o_ptr.artifact == null && (o_ptr.name_is_visible() || known)) &&
                    (o_ptr.number != 1 || ((mode & Detail.PLURAL) != 0)));

            /** Append extra names of various kinds **/

            if((o_ptr.name_is_visible() || known) && o_ptr.artifact != null)
                buf = buf + " " + o_ptr.artifact.Name;

            else if((spoil && o_ptr.ego != null) || o_ptr.ego_is_visible())
                buf = buf + " " + o_ptr.ego.name;

            else if(aware && o_ptr.artifact == null && (o_ptr.kind.flavor != null || o_ptr.kind.tval == TVal.TV_SCROLL))
                buf = buf + " of " + o_ptr.kind.Name;

            return end;
        }