コード例 #1
0
        /*
         * Hack -- allow user to "prevent" certain choices.
         *
         * The item can be negative to mean "item on floor".
         */
        static bool get_item_allow(int item, char ch, bool is_harmless)
        {
            Object o_ptr;
            //char verify_inscrip[] = "!*";
            string verify_inscrip = "!*";

            int n;

            /* Inventory or floor */
            if (item >= 0)
            {
                o_ptr = Misc.p_ptr.inventory[item];
            }
            else
            {
                o_ptr = Object.byid((short)(0 - item));
            }

            /* Check for a "prevention" inscription */
            verify_inscrip = verify_inscrip[0].ToString() + ch.ToString();

            /* Find both sets of inscriptions, add together, and prompt that number of times */
            n = o_ptr.check_for_inscrip(verify_inscrip)?1:0;

            if (!is_harmless)
            {
                n += o_ptr.check_for_inscrip("!*") ? 1:0;
            }

            while (n-- != 0)
            {
                if (!verify_item("Really try", item))
                {
                    return(false);
                }
            }

            /* Allow it */
            return(true);
        }