summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/randart.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-06 16:47:06 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-06 16:47:06 +0000
commit200b4c0e08504a7c8df898d77a9d72b3fa573c04 (patch)
treeb6cf73c902a55861ab60656e0225f0385c2c3a59 /crawl-ref/source/randart.cc
parent7f2ded93231941b48fba24bcc9a55602295f72bd (diff)
downloadcrawl-ref-200b4c0e08504a7c8df898d77a9d72b3fa573c04.tar.gz
crawl-ref-200b4c0e08504a7c8df898d77a9d72b3fa573c04.zip
Add a function x_chance_in_y(x,y) to replace the various
random2(y) < x checks, e.g. x_chance_in_y(weight, totalweight). This should make things a bit more readable. Apply it to a number of files. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6428 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/randart.cc')
-rw-r--r--crawl-ref/source/randart.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 15396bfd7c..63a85194a6 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -194,7 +194,7 @@ static std::string _replace_name_parts(const std::string name_in,
std::string place;
if (one_chance_in(5))
{
- switch(random2(8))
+ switch (random2(8))
{
case 0:
case 1:
@@ -804,7 +804,7 @@ void static _get_randart_properties(const item_def &item,
if (random2(15) >= power_level && aclass != OBJ_WEAPONS
&& (aclass != OBJ_JEWELLERY || atype != RING_SLAYING))
{
- // Weapons and rings of slaying can't get these
+ // Weapons and rings of slaying can't get these.
if (one_chance_in(4 + power_level)) // to-hit
{
proprt[RAP_ACCURACY] = 1 + random2(3) + random2(2);
@@ -867,7 +867,7 @@ void static _get_randart_properties(const item_def &item,
power_level++;
}
- if (random2(12) < power_level || power_level > 7)
+ if (x_chance_in_y(power_level, 12) || power_level > 7)
done_powers = true;
// res_elec
@@ -923,7 +923,7 @@ void static _get_randart_properties(const item_def &item,
power_level++;
}
- if (random2(12) < power_level || power_level > 10)
+ if (x_chance_in_y(power_level, 12) || power_level > 10)
done_powers = true;
// turn invis
@@ -981,7 +981,7 @@ void static _get_randart_properties(const item_def &item,
if (aclass == OBJ_ARMOUR)
power_level -= 4;
- if (power_level >= 2 && random2(17) < power_level)
+ if (power_level >= 2 && x_chance_in_y(power_level, 17))
{
switch (random2(9))
{
@@ -1488,8 +1488,8 @@ bool make_item_fixed_artefact( item_def &item, bool in_abyss, int which )
if (!force)
{
- which = SPWPN_START_FIXEDARTS +
- random2(SPWPN_START_NOGEN_FIXEDARTS - SPWPN_START_FIXEDARTS);
+ which = SPWPN_START_FIXEDARTS
+ + random2(SPWPN_START_NOGEN_FIXEDARTS - SPWPN_START_FIXEDARTS);
}
const unique_item_status_type status =