diff options
author | gammafunk <gammafunk@gmail.com> | 2014-03-30 15:10:30 -0500 |
---|---|---|
committer | gammafunk <gammafunk@gmail.com> | 2014-03-30 15:10:30 -0500 |
commit | 2f27df60033e70cae85f58705e9091beaba3d203 (patch) | |
tree | 6cd6576e83487e68a3bfca5c64ea34196587d867 /crawl-ref/source/traps.cc | |
parent | 1f4831d4572642bcf6c286a285b2319311a33b2e (diff) | |
download | crawl-ref-2f27df60033e70cae85f58705e9091beaba3d203.tar.gz crawl-ref-2f27df60033e70cae85f58705e9091beaba3d203.zip |
Simplify and document a function
Diffstat (limited to 'crawl-ref/source/traps.cc')
-rw-r--r-- | crawl-ref/source/traps.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 6ac00e14df..cde509de26 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -1821,19 +1821,23 @@ void handle_items_on_shaft(const coord_def& pos, bool open_shaft) } } +/** + * Get a number of traps to place on the current level. + * + * No traps are placed in either Temple or disconnected branches other than + * Pandemonium. For other branches, we place 0-8 traps a level, averaged over + * two dice. + * @returns A number of traps to be placed. +*/ int num_traps_for_place() { - switch (you.where_are_you) + if (you.where_are_you == BRANCH_TEMPLE + || (!player_in_connected_branch() + && you.where_are_you != BRANCH_PANDEMONIUM)) { - case BRANCH_TEMPLE: return 0; - default: - if (!player_in_connected_branch()) - return 0; - // Intentional fall-through. - case BRANCH_PANDEMONIUM: - return random2avg(9, 2); } + return random2avg(9, 2); } static trap_type _random_trap_slime(int level_number) |