Пример #1
0
        static bool buy_stat(Stat choice, short[] stats, int[] points_spent, ref int points_left)
        {
            /* Must be a valid stat, and have a "base" of below 18 to be adjusted */
            if (!(choice >= Stat.Max || choice < 0) && (stats[(int)choice] < 18))
            {
                /* Get the cost of buying the extra point (beyond what
                 * it has already cost to get this far). */
                int stat_cost = birth_stat_costs[stats[(int)choice] + 1];

                if (stat_cost <= points_left)
                {
                    stats[(int)choice]++;
                    points_spent[(int)choice] += stat_cost;
                    points_left -= stat_cost;

                    /* Tell the UI the new points situation. */
                    Game_Event.signal_birthpoints(points_spent, points_left);

                    /* Recalculate everything that's changed because
                     * the stat has changed, and inform the UI. */
                    recalculate_stats(stats, points_left);

                    return(true);
                }
            }

            /* Didn't adjust stat. */
            return(false);
        }
Пример #2
0
        static void reset_stats(short[] stats, int[] points_spent, ref int points_left)
        {
            /* Calculate and signal initial stats and points totals. */
            points_left = MAX_BIRTH_POINTS;

            for (int i = 0; i < (int)Stat.Max; i++)
            {
                /* Initial stats are all 10 and costs are zero */
                stats[i]        = 10;
                points_spent[i] = 0;
            }

            /* Use the new "birth stat" values to work out the "other"
             * stat values (i.e. after modifiers) and tell the UI things have
             * changed. */
            recalculate_stats(stats, points_left);
            Game_Event.signal_birthpoints(points_spent, points_left);
        }
Пример #3
0
        static bool sell_stat(Stat choice, short[] stats, int[] points_spent, ref int points_left)
        {
            /* Must be a valid stat, and we can't "sell" stats below the base of 10. */
            if (!(choice >= Stat.Max || choice < 0) && (stats[(int)choice] > 10))
            {
                int stat_cost = birth_stat_costs[stats[(int)choice]];

                stats[(int)choice]--;
                points_spent[(int)choice] -= stat_cost;
                points_left += stat_cost;

                /* Tell the UI the new points situation. */
                Game_Event.signal_birthpoints(points_spent, points_left);

                /* Recalculate everything that's changed because
                 * the stat has changed, and inform the UI. */
                recalculate_stats(stats, points_left);

                return(true);
            }

            /* Didn't adjust stat. */
            return(false);
        }