Ejemplo n.º 1
0
        public static void cmd_rest()
        {
            /* Prompt for time if needed */
            if (Misc.p_ptr.command_arg <= 0)
            {
                string p = "Rest (0-9999, '!' for HP or SP, '*' for HP and SP, '&' as needed): ";

                string out_val = "& ";
                //char out_val[5] = "& ";

                /* Ask for duration */
                if (!Utilities.get_string(p, ref out_val, 4))
                {
                    return;
                }

                /* Rest until done */
                if (out_val[0] == '&')
                {
                    Game_Command.insert(Command_Code.REST);
                    Game_Command.get_top().set_arg_choice(0, (int)Misc.REST.COMPLETE);
                }

                /* Rest a lot */
                else if (out_val[0] == '*')
                {
                    Game_Command.insert(Command_Code.REST);
                    Game_Command.get_top().set_arg_choice(0, (int)Misc.REST.ALL_POINTS);
                }

                /* Rest until HP or SP filled */
                else if (out_val[0] == '!')
                {
                    Game_Command.insert(Command_Code.REST);
                    Game_Command.get_top().set_arg_choice(0, (int)Misc.REST.SOME_POINTS);
                }

                /* Rest some */
                else
                {
                    int turns = int.Parse(out_val);
                    if (turns <= 0)
                    {
                        return;
                    }
                    if (turns > 9999)
                    {
                        turns = 9999;
                    }

                    Game_Command.insert(Command_Code.REST);
                    Game_Command.get_top().set_arg_choice(0, (int)turns);
                }
            }
        }
Ejemplo n.º 2
0
        /* ------------------------------------------------------------------------
         * Asking for the player's chosen name.
         * ------------------------------------------------------------------------ */
        static birth_stage get_name_command()
        {
            birth_stage next;
            string      name = "";

            if (Utilities.get_name(ref name, 32))
            {
                Game_Command.insert(Command_Code.NAME_CHOICE);
                Game_Command.get_top().set_arg_choice(0, name);
                next = birth_stage.BIRTH_FINAL_CONFIRM;
            }
            else
            {
                next = birth_stage.BIRTH_BACK;
            }

            return(next);
        }
Ejemplo n.º 3
0
        static birth_stage point_based_command()
        {
            birth_stage next = birth_stage.BIRTH_POINTBASED;

            /*	point_based_display();*/
            /* Place cursor just after cost of current stat */
            /* Draw the Selection Cursor */
            new Region(COSTS_COL + 4, COSTS_ROW, 1, 6).erase();
            Utilities.put_str("<", COSTS_ROW + stat, COSTS_COL + 4);

            /* Get key */
            keypress ch = Utilities.inkey();

            if (ch.code == (keycode_t)UIEvent.KTRL('X'))
            {
                Game_Command.insert(Command_Code.QUIT);
                next = birth_stage.BIRTH_COMPLETE;
            }

            /* Go back a step, or back to the start of this step */
            else if (ch.code == keycode_t.ESCAPE)
            {
                next = birth_stage.BIRTH_BACK;
            }

            else if (ch.code == (keycode_t)'r' || ch.code == (keycode_t)'R')
            {
                Game_Command.insert(Command_Code.RESET_STATS);
                Game_Command.get_top().set_arg_choice(0, 0);
            }

            /* Done */
            else if ((ch.code == (keycode_t)'\r') || (ch.code == (keycode_t)'\n'))
            {
                next = birth_stage.BIRTH_NAME_CHOICE;
            }
            else
            {
                int dir = Utilities.target_dir(ch);

                /* Prev stat, looping round to the bottom when going off the top */
                if (dir == 8)
                {
                    stat = (stat + (int)Stat.Max - 1) % (int)Stat.Max;
                }

                /* Next stat, looping round to the top when going off the bottom */
                if (dir == 2)
                {
                    stat = (stat + 1) % (int)Stat.Max;
                }

                /* Decrease stat (if possible) */
                if (dir == 4)
                {
                    Game_Command.insert(Command_Code.SELL_STAT);
                    Game_Command.get_top().set_arg_choice(0, stat);
                }

                /* Increase stat (if possible) */
                if (dir == 6)
                {
                    Game_Command.insert(Command_Code.BUY_STAT);
                    Game_Command.get_top().set_arg_choice(0, stat);
                }
            }

            return(next);
        }
Ejemplo n.º 4
0
        /* Allow the user to select from the current menu, and return the
         * corresponding command to the game.  Some actions are handled entirely
         * by the UI (displaying help text, for instance). */
        static birth_stage menu_question(birth_stage current, Menu_Type current_menu, Command_Code choice_command)
        {
            birthmenu_data menu_data = current_menu.menu_data as birthmenu_data;

            birth_stage next = birth_stage.BIRTH_RESET;

            /* Print the question currently being asked. */
            clear_question();
            Term.putstr(QUESTION_COL, QUESTION_ROW, -1, ConsoleColor.Yellow, menu_data.hint);

            current_menu.cmd_keys = "?=*\x18";                   /* ?, =, *, <ctl-X> */

            while (next == birth_stage.BIRTH_RESET)
            {
                /* Display the menu, wait for a selection of some sort to be made. */
                ui_event cx = current_menu.select(ui_event_type.EVT_KBRD, false);

                /* As all the menus are displayed in "hierarchical" style, we allow
                 * use of "back" (left arrow key or equivalent) to step back in
                 * the proces as well as "escape". */
                if (cx.type == ui_event_type.EVT_ESCAPE)
                {
                    next = birth_stage.BIRTH_BACK;
                }
                else if (cx.type == ui_event_type.EVT_SELECT)
                {
                    if (current == birth_stage.BIRTH_ROLLER_CHOICE)
                    {
                        Game_Command.insert(Command_Code.FINALIZE_OPTIONS);

                        if (current_menu.cursor != 0)
                        {
                            /* Do a first roll of the stats */
                            Game_Command.insert(Command_Code.ROLL_STATS);
                            next = current + 2;
                        }
                        else
                        {
                            /*
                             * Make sure we've got a point-based char to play with.
                             * We call point_based_start here to make sure we get
                             * an update on the points totals before trying to
                             * display the screen.  The call to CMD_RESET_STATS
                             * forces a rebuying of the stats to give us up-to-date
                             * totals.  This is, it should go without saying, a hack.
                             */
                            point_based_start();
                            Game_Command.insert(Command_Code.RESET_STATS);
                            Game_Command.get_top().set_arg_choice(0, 1);
                            next = current + 1;
                        }
                    }
                    else
                    {
                        Game_Command.insert(choice_command);
                        Game_Command.get_top().set_arg_choice(0, current_menu.cursor);
                        next = current + 1;
                    }
                }
                else if (cx.type == ui_event_type.EVT_KBRD)
                {
                    /* '*' chooses an option at random from those the game's provided. */
                    if (cx.key.code == (keycode_t)'*' && menu_data.allow_random)
                    {
                        current_menu.cursor = Random.randint0(current_menu.count);
                        Game_Command.insert(choice_command);
                        Game_Command.get_top().set_arg_choice(0, current_menu.cursor);
                        current_menu.refresh(false);
                        next = current + 1;
                    }
                    else if (cx.key.code == (keycode_t)'=')
                    {
                        Do_Command.options_birth();
                        next = current;
                    }
                    else if (cx.key.code == (keycode_t)UIEvent.KTRL('X'))
                    {
                        Game_Command.insert(Command_Code.QUIT);
                        next = birth_stage.BIRTH_COMPLETE;
                    }
                    else if (cx.key.code == (keycode_t)'?')
                    {
                        Do_Command.help();
                    }
                }
            }

            return(next);
        }