summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/religion.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-23 21:14:20 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-23 21:14:20 +0000
commit11adfeb2d7e54e3a43e518785c4d34cb3d4e8df1 (patch)
tree3ac81c28321340b54afd099f219caf7ea58be6ab /crawl-ref/source/religion.cc
parentd01f16731de6b52c31bf8c600ccdbca515b960d7 (diff)
downloadcrawl-ref-11adfeb2d7e54e3a43e518785c4d34cb3d4e8df1.tar.gz
crawl-ref-11adfeb2d7e54e3a43e518785c4d34cb3d4e8df1.zip
Some code cleanup.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2524 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/religion.cc')
-rw-r--r--crawl-ref/source/religion.cc174
1 files changed, 89 insertions, 85 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 172160cfe0..2b7ec23128 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -553,6 +553,94 @@ static void show_pure_deck_chances()
}
#endif
+static void give_nemelex_gift()
+{
+ if (random2(MAX_PIETY) <= you.piety
+ && one_chance_in(3)
+ && !you.attribute[ATTR_CARD_COUNTDOWN]
+ && !grid_destroys_items(grd[you.x_pos][you.y_pos]))
+ {
+ misc_item_type gift_type;
+ if ( random2(MAX_PIETY) <= you.piety )
+ {
+ // make a pure deck
+ const misc_item_type pure_decks[] = {
+ MISC_DECK_OF_ESCAPE,
+ MISC_DECK_OF_DESTRUCTION,
+ MISC_DECK_OF_DUNGEONS,
+ MISC_DECK_OF_SUMMONING,
+ MISC_DECK_OF_WONDERS
+ };
+ int weights[5];
+ get_pure_deck_weights(weights);
+ gift_type = pure_decks[choose_random_weighted(weights, weights+5)];
+
+#if DEBUG_GIFTS || DEBUG_CARDS
+ show_pure_deck_chances();
+#endif
+ }
+ else
+ {
+ // make a mixed deck
+ const misc_item_type mixed_decks[] = {
+ MISC_DECK_OF_WAR,
+ MISC_DECK_OF_CHANGES,
+ MISC_DECK_OF_DEFENSE
+ };
+ gift_type = RANDOM_ELEMENT(mixed_decks);
+ }
+
+ int thing_created = items( 1, OBJ_MISCELLANY, gift_type,
+ true, 1, MAKE_ITEM_RANDOM_RACE );
+
+ if (thing_created != NON_ITEM)
+ {
+ // Piety|Common | Rare |Legendary
+ // --------------------------------
+ // 0: 95.00%, 5.00%, 0.00%
+ // 20: 86.00%, 10.50%, 3.50%
+ // 40: 77.00%, 16.00%, 7.00%
+ // 60: 68.00%, 21.50%, 10.50%
+ // 80: 59.00%, 27.00%, 14.00%
+ // 100: 50.00%, 32.50%, 17.50%
+ // 120: 41.00%, 38.00%, 21.00%
+ // 140: 32.00%, 43.50%, 24.50%
+ // 160: 23.00%, 49.00%, 28.00%
+ // 180: 14.00%, 54.50%, 31.50%
+ // 200: 5.00%, 60.00%, 35.00%
+ int common_weight = 95 - (90 * you.piety / MAX_PIETY);
+ int rare_weight = 5 + (55 * you.piety / MAX_PIETY);
+ int legend_weight = 0 + (35 * you.piety / MAX_PIETY);
+
+ deck_rarity_type rarity = static_cast<deck_rarity_type>(
+ random_choose_weighted(common_weight,
+ DECK_RARITY_COMMON,
+ rare_weight,
+ DECK_RARITY_RARE,
+ legend_weight,
+ DECK_RARITY_LEGENDARY,
+ 0));
+
+ item_def &deck(mitm[thing_created]);
+
+ deck.special = rarity;
+ deck.colour = deck_rarity_to_color(rarity);
+
+ move_item_to_grid( &thing_created, you.x_pos, you.y_pos );
+ origin_acquired(deck, you.religion);
+
+ simple_god_message(" grants you a gift!");
+ more();
+ canned_msg(MSG_SOMETHING_APPEARS);
+
+ you.attribute[ATTR_CARD_COUNTDOWN] = 10;
+ inc_gift_timeout(5 + random2avg(9, 2));
+ you.num_gifts[you.religion]++;
+ take_note(Note(NOTE_GOD_GIFT, you.religion));
+ }
+ }
+}
+
static void do_god_gift(bool prayed_for)
{
// Zin worshippers are the only ones that can pray to ask Zin for stuff.
@@ -591,91 +679,7 @@ static void do_god_gift(bool prayed_for)
break;
case GOD_NEMELEX_XOBEH:
- if (random2(MAX_PIETY) <= you.piety
- && one_chance_in(3)
- && !you.attribute[ATTR_CARD_COUNTDOWN]
- && !grid_destroys_items(grd[you.x_pos][you.y_pos]))
- {
- misc_item_type gift_type;
- if ( random2(MAX_PIETY) <= you.piety )
- {
- // make a pure deck
- const misc_item_type pure_decks[] = {
- MISC_DECK_OF_ESCAPE,
- MISC_DECK_OF_DESTRUCTION,
- MISC_DECK_OF_DUNGEONS,
- MISC_DECK_OF_SUMMONING,
- MISC_DECK_OF_WONDERS
- };
- int weights[5];
- get_pure_deck_weights(weights);
- gift_type = pure_decks[choose_random_weighted(weights,
- weights+5)];
-
-#if DEBUG_GIFTS || DEBUG_CARDS
- show_pure_deck_chances();
-#endif
- }
- else
- {
- // make a mixed deck
- const misc_item_type mixed_decks[] = {
- MISC_DECK_OF_WAR,
- MISC_DECK_OF_CHANGES,
- MISC_DECK_OF_DEFENSE
- };
- gift_type = RANDOM_ELEMENT(mixed_decks);
- }
-
- int thing_created = items( 1, OBJ_MISCELLANY, gift_type,
- true, 1, MAKE_ITEM_RANDOM_RACE );
-
- if (thing_created != NON_ITEM)
- {
- // Piety|Common | Rare |Legendary
- // --------------------------------
- // 0: 95.00%, 5.00%, 0.00%
- // 20: 86.00%, 10.50%, 3.50%
- // 40: 77.00%, 16.00%, 7.00%
- // 60: 68.00%, 21.50%, 10.50%
- // 80: 59.00%, 27.00%, 14.00%
- // 100: 50.00%, 32.50%, 17.50%
- // 120: 41.00%, 38.00%, 21.00%
- // 140: 32.00%, 43.50%, 24.50%
- // 160: 23.00%, 49.00%, 28.00%
- // 180: 14.00%, 54.50%, 31.50%
- // 200: 5.00%, 60.00%, 35.00%
- int common_weight = 95 - (90 * you.piety / MAX_PIETY);
- int rare_weight = 5 + (55 * you.piety / MAX_PIETY);
- int legend_weight = 0 + (35 * you.piety / MAX_PIETY);
-
- deck_rarity_type rarity = (deck_rarity_type)
- random_choose_weighted(common_weight,
- DECK_RARITY_COMMON,
- rare_weight,
- DECK_RARITY_RARE,
- legend_weight,
- DECK_RARITY_LEGENDARY,
- 0);
-
- item_def &deck(mitm[thing_created]);
-
- deck.special = rarity;
- deck.colour = deck_rarity_to_color(rarity);
-
- move_item_to_grid( &thing_created, you.x_pos, you.y_pos );
- origin_acquired(deck, you.religion);
-
- simple_god_message(" grants you a gift!");
- more();
- canned_msg(MSG_SOMETHING_APPEARS);
-
- you.attribute[ATTR_CARD_COUNTDOWN] = 10;
- inc_gift_timeout(5 + random2avg(9, 2));
- you.num_gifts[you.religion]++;
- take_note(Note(NOTE_GOD_GIFT, you.religion));
- }
- }
+ give_nemelex_gift();
break;
case GOD_OKAWARU: