summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/decks.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-04 14:47:09 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-04 14:47:09 +0000
commitca98a8399e80e0fa440298a6ddf383d706343088 (patch)
treeefb9093515837fa9c2137965baf513cc447d308d /crawl-ref/source/decks.cc
parent7326d539ae67aba12e9a49dd94b2fe419845c759 (diff)
downloadcrawl-ref-ca98a8399e80e0fa440298a6ddf383d706343088.tar.gz
crawl-ref-ca98a8399e80e0fa440298a6ddf383d706343088.zip
Disallow vampires from draining summoned creatures to be consistent with
summoned creatures being incapable of bleeding on the floor. This makes things more difficult for Vampires; on the other hand there was a (more or less) recent change that lets them regain 1 hp *per turn* when draining corpses. We might also increase the duration of blood potions... Apart from that, various clean-ups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6393 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/decks.cc')
-rw-r--r--crawl-ref/source/decks.cc352
1 files changed, 177 insertions, 175 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index d2a47c5ab0..17e6c65210 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -320,7 +320,7 @@ const char* card_name(card_type card)
static const deck_archetype* _random_sub_deck(unsigned char deck_type)
{
const deck_archetype *pdeck = NULL;
- switch ( deck_type )
+ switch (deck_type)
{
case MISC_DECK_OF_ESCAPE:
pdeck = (coinflip() ? deck_of_transport : deck_of_emergency);
@@ -331,7 +331,7 @@ static const deck_archetype* _random_sub_deck(unsigned char deck_type)
case MISC_DECK_OF_WONDERS: pdeck = deck_of_wonders; break;
case MISC_DECK_OF_PUNISHMENT: pdeck = deck_of_punishment; break;
case MISC_DECK_OF_WAR:
- switch ( random2(6) )
+ switch (random2(6))
{
case 0: pdeck = deck_of_destruction; break;
case 1: pdeck = deck_of_enchantments; break;
@@ -342,7 +342,7 @@ static const deck_archetype* _random_sub_deck(unsigned char deck_type)
}
break;
case MISC_DECK_OF_CHANGES:
- switch ( random2(3) )
+ switch (random2(3))
{
case 0: pdeck = deck_of_battle; break;
case 1: pdeck = deck_of_dungeons; break;
@@ -354,9 +354,9 @@ static const deck_archetype* _random_sub_deck(unsigned char deck_type)
break;
}
- ASSERT( pdeck );
+ ASSERT(pdeck);
- return pdeck;
+ return (pdeck);
}
static card_type _choose_from_archetype(const deck_archetype* pdeck,
@@ -369,15 +369,13 @@ static card_type _choose_from_archetype(const deck_archetype* pdeck,
// duplicating the implementation.
int totalweight = 0;
- int i = 0;
card_type result = NUM_CARDS;
- while ( pdeck[i].card != NUM_CARDS )
+ for (int i = 0; pdeck[i].card != NUM_CARDS; ++i)
{
const card_with_weights& cww = pdeck[i];
totalweight += cww.weight[rarity];
- if ( random2(totalweight) < cww.weight[rarity] )
+ if (random2(totalweight) < cww.weight[rarity])
result = cww.card;
- ++i;
}
return result;
}
@@ -387,7 +385,7 @@ static card_type _random_card(unsigned char deck_type, deck_rarity_type rarity,
{
const deck_archetype *pdeck = _random_sub_deck(deck_type);
- if ( one_chance_in(100) )
+ if (one_chance_in(100))
{
pdeck = deck_of_oddities;
was_oddity = true;
@@ -465,11 +463,11 @@ static void _remember_drawn_card(item_def& deck, card_type card)
const std::vector<card_type> get_drawn_cards(const item_def& deck)
{
std::vector<card_type> result;
- if ( is_deck(deck) )
+ if (is_deck(deck))
{
const CrawlHashTable &props = deck.props;
const CrawlVector &drawn = props["drawn_cards"].get_vector();
- for ( unsigned int i = 0; i < drawn.size(); ++i )
+ for (unsigned int i = 0; i < drawn.size(); ++i)
{
const char tmp = drawn[i];
result.push_back(static_cast<card_type>(tmp));
@@ -528,7 +526,7 @@ static bool _check_buggy_deck(item_def& deck)
"and whisks it away."
<< std::endl;
- if ( deck.link == you.equip[EQ_WEAPON] )
+ if (deck.link == you.equip[EQ_WEAPON])
unwield_item();
dec_inv_item_quantity( deck.link, 1 );
@@ -588,7 +586,7 @@ static bool _check_buggy_deck(item_def& deck)
<< "A swarm of software bugs snatches the deck from you "
"and whisks it away." << std::endl;
- if ( deck.link == you.equip[EQ_WEAPON] )
+ if (deck.link == you.equip[EQ_WEAPON])
unwield_item();
dec_inv_item_quantity( deck.link, 1 );
@@ -719,7 +717,7 @@ static int _choose_inventory_deck( const char* prompt )
if (prompt_failed(slot))
return -1;
- if ( !is_deck(you.inv[slot]) )
+ if (!is_deck(you.inv[slot]))
{
mpr("That isn't a deck!");
return -1;
@@ -821,8 +819,8 @@ bool deck_peek()
if (flags2 & CFLAG_SEEN)
already_seen++;
- // always increase if seen 2, 50% increase if seen 1
- if ( already_seen && random2(2) < already_seen )
+ // Always increase if seen 2, 50% increase if seen 1.
+ if (already_seen && random2(2) < already_seen)
deck.props["non_brownie_draws"]++;
mprf("You draw two cards from the deck. They are: %s and %s.",
@@ -1003,22 +1001,23 @@ bool deck_stack()
while (true)
{
const int c = getch();
- if ( c == CK_ENTER )
+ if (c == CK_ENTER)
{
cgotoxy(1,11);
textcolor(LIGHTGREY);
cprintf("Are you sure? (press y or Y to confirm)");
if (toupper(getch()) == 'Y')
break;
+
cgotoxy(1,11);
clear_to_end_of_line();
continue;
}
- if ( c >= '1' && c <= '0' + static_cast<int>(draws.size()) )
+ if (c >= '1' && c <= '0' + static_cast<int>(draws.size()))
{
const unsigned int new_selected = c - '1';
- if ( selected < draws.size() )
+ if (selected < draws.size())
{
std::swap(draws[selected], draws[new_selected]);
std::swap(flags[selected], flags[new_selected]);
@@ -1195,7 +1194,7 @@ void evoke_deck( item_def& deck )
// Passive Nemelex retribution: sometimes a card gets swapped out.
// More likely to happen with marked decks.
- if ( you.penance[GOD_NEMELEX_XOBEH] )
+ if (you.penance[GOD_NEMELEX_XOBEH])
{
int c = 1;
if ( (flags & (CFLAG_MARKED | CFLAG_SEEN))
@@ -1203,11 +1202,11 @@ void evoke_deck( item_def& deck )
{
c = 3;
}
- if ( random2(3000) < c * you.penance[GOD_NEMELEX_XOBEH] )
+ if (random2(3000) < c * you.penance[GOD_NEMELEX_XOBEH])
{
card_type old_card = card;
card = _choose_from_archetype(deck_of_punishment, rarity);
- if ( card != old_card )
+ if (card != old_card)
{
simple_god_message(" seems to have exchanged this card "
"behind your back!", GOD_NEMELEX_XOBEH);
@@ -1237,7 +1236,7 @@ void evoke_deck( item_def& deck )
// in which case we don't want an empty deck to go through the
// swapping process.
const bool deck_gone = (cards_in_deck(deck) == 0);
- if ( deck_gone )
+ if (deck_gone)
{
mpr("The deck of cards disappears in a puff of smoke.");
dec_inv_item_quantity( deck.link, 1 );
@@ -1247,7 +1246,7 @@ void evoke_deck( item_def& deck )
}
const bool fake_draw = !card_effect(card, rarity, flags, false);
- if ( fake_draw && !deck_gone )
+ if (fake_draw && !deck_gone)
props["non_brownie_draws"]++;
if (!(flags & CFLAG_MARKED))
@@ -1288,16 +1287,16 @@ void evoke_deck( item_def& deck )
int get_power_level(int power, deck_rarity_type rarity)
{
int power_level = 0;
- switch ( rarity )
+ switch (rarity)
{
case DECK_RARITY_COMMON:
break;
case DECK_RARITY_LEGENDARY:
- if ( random2(500) < power )
+ if (random2(500) < power)
++power_level;
// deliberate fall-through
case DECK_RARITY_RARE:
- if ( random2(700) < power )
+ if (random2(700) < power)
++power_level;
break;
}
@@ -1310,24 +1309,24 @@ static void _portal_card(int power, deck_rarity_type rarity)
const int control_level = get_power_level(power, rarity);
bool instant = false;
bool controlled = false;
- if ( control_level >= 2 )
+ if (control_level >= 2)
{
instant = true;
controlled = true;
}
- else if ( control_level == 1 )
+ else if (control_level == 1)
{
- if ( coinflip() )
+ if (coinflip())
instant = true;
else
controlled = true;
}
const bool was_controlled = player_control_teleport();
- if ( controlled && !was_controlled )
- you.duration[DUR_CONTROL_TELEPORT] = 6; // long enough to kick in
+ if (controlled && !was_controlled)
+ you.duration[DUR_CONTROL_TELEPORT] = 6; // Long enough to kick in.
- if ( instant )
+ if (instant)
you_teleport_now( true );
else
you_teleport();
@@ -1336,9 +1335,9 @@ static void _portal_card(int power, deck_rarity_type rarity)
static void _warp_card(int power, deck_rarity_type rarity)
{
const int control_level = get_power_level(power, rarity);
- if ( control_level >= 2 )
+ if (control_level >= 2)
blink(1000, false);
- else if ( control_level == 1 )
+ else if (control_level == 1)
cast_semi_controlled_blink(power / 4);
else
random_blink(false);
@@ -1412,7 +1411,7 @@ static void _velocity_card(int power, deck_rarity_type rarity)
const int power_level = get_power_level(power, rarity);
if (power_level >= 2)
potion_effect( POT_SPEED, random2(power / 4) );
- else if ( power_level == 1 )
+ else if (power_level == 1)
{
cast_fly( random2(power/4) );
cast_swiftness( random2(power/4) );
@@ -1423,7 +1422,7 @@ static void _velocity_card(int power, deck_rarity_type rarity)
static void _damnation_card(int power, deck_rarity_type rarity)
{
- if ( you.level_type != LEVEL_DUNGEON )
+ if (you.level_type != LEVEL_DUNGEON)
{
canned_msg(MSG_NOTHING_HAPPENS);
return;
@@ -1432,24 +1431,25 @@ static void _damnation_card(int power, deck_rarity_type rarity)
// Calculate how many extra banishments you get.
const int power_level = get_power_level(power, rarity);
int nemelex_bonus = 0;
- if ( you.religion == GOD_NEMELEX_XOBEH && !player_under_penance() )
+ if (you.religion == GOD_NEMELEX_XOBEH && !player_under_penance())
nemelex_bonus = you.piety / 20;
+
int extra_targets = power_level + random2(you.skills[SK_EVOCATIONS] +
nemelex_bonus) / 12;
- for ( int i = 0; i < 1 + extra_targets; ++i )
+ for (int i = 0; i < 1 + extra_targets; ++i)
{
- // pick a random monster nearby to banish (or yourself)
+ // Pick a random monster nearby to banish (or yourself).
monsters *mon_to_banish = choose_random_nearby_monster(1);
- // bonus banishments only banish monsters
- if ( i != 0 && !mon_to_banish )
+ // Bonus banishments only banish monsters.
+ if (i != 0 && !mon_to_banish)
continue;
- if ( !mon_to_banish ) // banish yourself!
+ if (!mon_to_banish) // Banish yourself!
{
banished(DNGN_ENTER_ABYSS, "drawing a card");
- break; // don't banish anything else
+ break; // Don't banish anything else.
}
else
mon_to_banish->banish();
@@ -1459,7 +1459,7 @@ static void _damnation_card(int power, deck_rarity_type rarity)
static void _warpwright_card(int power, deck_rarity_type rarity)
{
- if ( you.level_type == LEVEL_ABYSS )
+ if (you.level_type == LEVEL_ABYSS)
{
mpr("The power of the Abyss blocks your magic.");
return;
@@ -1467,8 +1467,8 @@ static void _warpwright_card(int power, deck_rarity_type rarity)
int count = 0;
int fx = -1, fy = -1;
- for ( int dx = -1; dx <= 1; ++dx )
- for ( int dy = -1; dy <= 1; ++dy )
+ for (int dx = -1; dx <= 1; ++dx)
+ for (int dy = -1; dy <= 1; ++dy)
{
if ( dx == 0 && dy == 0 )
continue;
@@ -1476,20 +1476,20 @@ static void _warpwright_card(int power, deck_rarity_type rarity)
const int rx = you.x_pos + dx;
const int ry = you.y_pos + dy;
- if ( grd[rx][ry] == DNGN_FLOOR && trap_at_xy(rx,ry) == -1
- && one_chance_in(++count) )
+ if (grd[rx][ry] == DNGN_FLOOR && trap_at_xy(rx,ry) == -1
+ && one_chance_in(++count))
{
fx = rx;
fy = ry;
}
}
- if ( fx >= 0 ) // found a spot
+ if (fx >= 0) // found a spot
{
- if ( place_specific_trap(fx, fy, TRAP_TELEPORT) )
+ if (place_specific_trap(fx, fy, TRAP_TELEPORT))
{
- // mark it discovered if enough power
- if ( get_power_level(power, rarity) >= 1 )
+ // Mark it discovered if enough power.
+ if (get_power_level(power, rarity) >= 1)
{
const int i = trap_at_xy(fx, fy);
if (i != -1) // should always happen
@@ -1526,7 +1526,7 @@ static void _flight_card(int power, deck_rarity_type rarity)
{
if (is_valid_shaft_level() && grd[you.x_pos][you.y_pos] == DNGN_FLOOR)
{
- if ( place_specific_trap(you.x_pos, you.y_pos, TRAP_SHAFT) )
+ if (place_specific_trap(you.x_pos, you.y_pos, TRAP_SHAFT))
{
const int i = trap_at_xy(you.x_pos, you.y_pos);
grd[you.x_pos][you.y_pos] = trap_category(env.trap[i].type);
@@ -1544,23 +1544,24 @@ static void _minefield_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
const int radius = power_level * 2 + 2;
- for ( int dx = -radius; dx <= radius; ++dx )
- for ( int dy = -radius; dy <= radius; ++dy )
+ for (int dx = -radius; dx <= radius; ++dx)
+ for (int dy = -radius; dy <= radius; ++dy)
{
- if ( dx*dx + dy*dy > radius*radius + 1 )
+ if (dx == 0 && dy == 0)
continue;
- if ( dx == 0 && dy == 0 )
+
+ if (dx*dx + dy*dy > radius*radius + 1)
continue;
const int rx = you.x_pos + dx;
const int ry = you.y_pos + dy;
- if ( !in_bounds(rx, ry) )
+ if (!in_bounds(rx, ry))
continue;
- if ( grd[rx][ry] == DNGN_FLOOR && trap_at_xy(rx,ry) == -1
- && one_chance_in(4 - power_level) )
+ if (grd[rx][ry] == DNGN_FLOOR && trap_at_xy(rx,ry) == -1
+ && one_chance_in(4 - power_level))
{
- if ( you.level_type == LEVEL_ABYSS )
+ if (you.level_type == LEVEL_ABYSS)
grd[rx][ry] = coinflip() ? DNGN_DEEP_WATER : DNGN_LAVA;
else
place_specific_trap(rx, ry, TRAP_RANDOM);
@@ -1571,7 +1572,7 @@ static void _minefield_card(int power, deck_rarity_type rarity)
static int _drain_monsters(int x, int y, int pow, int garbage)
{
UNUSED( garbage );
- if ( coord_def(x,y) == you.pos() )
+ if (coord_def(x,y) == you.pos())
drain_exp();
else
{
@@ -1602,7 +1603,7 @@ static int _drain_monsters(int x, int y, int pow, int garbage)
if (mon.hit_dice < 1)
mon.hit_points = 0;
- if ( mon.hit_points <= 0 )
+ if (mon.hit_points <= 0)
monster_die( &mon, KILL_YOU, 0 );
}
}
@@ -1693,22 +1694,22 @@ static void _elixir_card(int power, deck_rarity_type rarity)
{
int power_level = get_power_level(power, rarity);
- if ( power_level == 1 && you.hp * 2 > you.hp_max )
+ if (power_level == 1 && you.hp * 2 > you.hp_max)
power_level = 0;
- if ( power_level == 0 )
+ if (power_level == 0)
{
- if ( coinflip() )
+ if (coinflip())
potion_effect( POT_HEAL_WOUNDS, 40 ); // power doesn't matter
else
cast_regen( random2(power / 4) );
}
- else if ( power_level == 1 )
+ else if (power_level == 1)
{
you.hp = you.hp_max;
you.magic_points = 0;
}
- else if ( power_level >= 2 )
+ else if (power_level >= 2)
{
you.hp = you.hp_max;
you.magic_points = you.max_magic_points;
@@ -1720,17 +1721,17 @@ static void _elixir_card(int power, deck_rarity_type rarity)
static void _battle_lust_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- if ( power_level >= 2 )
+ if (power_level >= 2)
{
you.duration[DUR_SLAYING] = random2(power/6) + 1;
mpr("You feel deadly.");
}
- else if ( power_level == 1 )
+ else if (power_level == 1)
{
you.duration[DUR_BUILDING_RAGE] = 1;
mpr("You feel your rage building.");
}
- else if ( power_level == 0 )
+ else if (power_level == 0)
potion_effect(POT_MIGHT, random2(power/4));
}
@@ -1759,36 +1760,38 @@ static void _metamorphosis_card(int power, deck_rarity_type rarity)
static void _helm_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- bool do_forescry = false;
+ bool do_forescry = false;
bool do_stoneskin = false;
- bool do_shield = false;
+ bool do_shield = false;
int num_resists = 0;
- if ( power_level >= 2 )
+
+ // Chances are cummulative.
+ if (power_level >= 2)
{
- if ( coinflip() ) do_forescry = true;
- if ( coinflip() ) do_stoneskin = true;
- if ( coinflip() ) do_shield = true;
+ if (coinflip()) do_forescry = true;
+ if (coinflip()) do_stoneskin = true;
+ if (coinflip()) do_shield = true;
num_resists = random2(4);
}
- if ( power_level >= 1 )
+ if (power_level >= 1)
{
- if ( coinflip() ) do_forescry = true;
- if ( coinflip() ) do_stoneskin = true;
- if ( coinflip() ) do_shield = true;
+ if (coinflip()) do_forescry = true;
+ if (coinflip()) do_stoneskin = true;
+ if (coinflip()) do_shield = true;
}
- if ( power_level >= 0 )
+ if (power_level >= 0)
{
- if ( coinflip() )
+ if (coinflip())
do_forescry = true;
else
do_stoneskin = true;
}
- if ( do_forescry )
+ if (do_forescry)
cast_forescry( random2(power/4) );
- if ( do_stoneskin )
+ if (do_stoneskin)
cast_stoneskin( random2(power/4) );
- if ( num_resists )
+ if (num_resists)
{
const duration_type possible_resists[4] = {
DUR_RESIST_POISON, DUR_INSULATION,
@@ -1798,13 +1801,13 @@ static void _helm_card(int power, deck_rarity_type rarity)
"poison", "electricity", "fire", "cold"
};
- for ( int i = 0; i < 4 && num_resists; ++i )
+ for (int i = 0; i < 4 && num_resists; ++i)
{
- // if there are n left, of which we need to choose
+ // If there are n left, of which we need to choose
// k, we have chance k/n of selecting the next item.
if ( random2(4-i) < num_resists )
{
- // Add a temporary resist
+ // Add a temporary resistance.
you.duration[possible_resists[i]] += random2(power/7) + 1;
msg::stream << "You feel resistant to " << resist_names[i]
<< '.' << std::endl;
@@ -1813,9 +1816,9 @@ static void _helm_card(int power, deck_rarity_type rarity)
}
}
- if ( do_shield )
+ if (do_shield)
{
- if ( you.duration[DUR_MAGIC_SHIELD] == 0 )
+ if (you.duration[DUR_MAGIC_SHIELD] == 0)
mpr("A magical shield forms in front of you.");
you.duration[DUR_MAGIC_SHIELD] += random2(power/6) + 1;
}
@@ -1859,7 +1862,7 @@ static void _shadow_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- if ( power_level >= 1 )
+ if (power_level >= 1)
{
mpr( you.duration[DUR_STEALTH] ? "You feel more catlike."
: "You feel stealthy.");
@@ -1881,10 +1884,10 @@ static void _potion_card(int power, deck_rarity_type rarity)
potion_type pot = RANDOM_ELEMENT(pot_effects);
- if ( power_level >= 1 && coinflip() )
+ if (power_level >= 1 && coinflip())
pot = (coinflip() ? POT_CURE_MUTATION : POT_MUTATION);
- if ( power_level >= 2 && one_chance_in(5) )
+ if (power_level >= 2 && one_chance_in(5))
pot = POT_MAGIC;
potion_effect(pot, random2(power/4));
@@ -1897,18 +1900,18 @@ static void _focus_card(int power, deck_rarity_type rarity)
int best_stat = 0;
int worst_stat = 0;
- for ( int i = 1; i < 3; ++i )
+ for (int i = 1; i < 3; ++i)
{
const int best_diff = *max_statp[i] - *max_statp[best_stat];
- if ( best_diff > 0 || (best_diff == 0 && coinflip()) )
+ if (best_diff > 0 || best_diff == 0 && coinflip())
best_stat = i;
const int worst_diff = *max_statp[i] - *max_statp[worst_stat];
- if ( worst_diff < 0 || (worst_diff == 0 && coinflip()) )
+ if (worst_diff < 0 || worst_diff == 0 && coinflip())
worst_stat = i;
}
- while ( best_stat == worst_stat )
+ while (best_stat == worst_stat)
{
best_stat = random2(3);
worst_stat = random2(3);
@@ -1942,14 +1945,14 @@ static void _focus_card(int power, deck_rarity_type rarity)
}
}
- for ( int i = 0; i < 3; ++i )
+ for (int i = 0; i < 3; ++i)
if (*max_statp[i] < 1 || *base_statp[i] < 1)
ouch(INSTANT_DEATH, 0, kill_types[i], cause.c_str(), true);
- // The player survived!
- you.redraw_strength = true;
+ // The player survived! Yay!
+ you.redraw_strength = true;
you.redraw_intelligence = true;
- you.redraw_dexterity = true;
+ you.redraw_dexterity = true;
burden_change();
}
@@ -1957,23 +1960,23 @@ static void _focus_card(int power, deck_rarity_type rarity)
static void _shuffle_card(int power, deck_rarity_type rarity)
{
stat_type stats[3] = {STAT_STRENGTH, STAT_DEXTERITY, STAT_INTELLIGENCE};
- int old_base[3] = { you.strength, you.dex, you.intel};
+ int old_base[3] = {you.strength, you.dex, you.intel};
int old_max[3] = {you.max_strength, you.max_dex, you.max_intel};
int modifiers[3];
int perm[3] = { 0, 1, 2 };
- for ( int i = 0; i < 3; ++i )
+ for (int i = 0; i < 3; ++i)
modifiers[i] = stat_modifier(stats[i]);
std::random_shuffle( perm, perm + 3 );
int new_base[3];
int new_max[3];
- for ( int i = 0; i < 3; ++i )
+ for (int i = 0; i < 3; ++i)
{
new_base[perm[i]] = old_base[i] - modifiers[i] + modifiers[perm[i]];
- new_max[perm[i]] = old_max[i] - modifiers[i] + modifiers[perm[i]];
+ new_max[perm[i]] = old_max[i] - modifiers[i] + modifiers[perm[i]];
}
// Did the shuffling kill the player?
@@ -1999,7 +2002,7 @@ static void _shuffle_card(int power, deck_rarity_type rarity)
}
}
- for ( int i = 0; i < 3; ++i )
+ for (int i = 0; i < 3; ++i)
if (new_base[i] < 1 || new_max[i] < 1)
ouch(INSTANT_DEATH, 0, kill_types[i], cause.c_str(), true);
@@ -2007,17 +2010,17 @@ static void _shuffle_card(int power, deck_rarity_type rarity)
// Sometimes you just long for Python.
you.strength = new_base[0];
- you.dex = new_base[1];
- you.intel = new_base[2];
+ you.dex = new_base[1];
+ you.intel = new_base[2];
you.max_strength = new_max[0];
- you.max_dex = new_max[1];
- you.max_intel = new_max[2];
+ you.max_dex = new_max[1];
+ you.max_intel = new_max[2];
- you.redraw_strength = true;
+ you.redraw_strength = true;
you.redraw_intelligence = true;
- you.redraw_dexterity = true;
- you.redraw_evasion = true;
+ you.redraw_dexterity = true;
+ you.redraw_evasion = true;
burden_change();
}
@@ -2026,13 +2029,13 @@ static void _experience_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- if ( you.experience_level < 27 )
+ if (you.experience_level < 27)
{
mpr("You feel more experienced.");
const unsigned long xp_cap = 1 + exp_needed(2 + you.experience_level);
- // power_level 2 means automatic level gain
- if ( power_level == 2 )
+ // power_level 2 means automatic level gain.
+ if (power_level == 2)
you.experience = xp_cap;
else
{
@@ -2041,7 +2044,7 @@ static void _experience_card(int power, deck_rarity_type rarity)
// But not guaranteed.
// Overrides archmagi effect, like potions of experience.
you.experience += power * 100;
- if ( you.experience > xp_cap )
+ if (you.experience > xp_cap)
you.experience = xp_cap;
}
}
@@ -2050,7 +2053,7 @@ static void _experience_card(int power, deck_rarity_type rarity)
// Put some free XP into pool; power_level 2 means fill pool
you.exp_available += power * 50;
- if ( power_level >= 2 || you.exp_available > 20000)
+ if (power_level >= 2 || you.exp_available > 20000)
you.exp_available = 20000;
level_change();
@@ -2066,9 +2069,9 @@ static void _helix_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- if ( power_level == 0 )
+ if (power_level == 0)
{
- switch ( how_mutated() ? random2(3) : 0 )
+ switch (how_mutated() ? random2(3) : 0)
{
case 0:
mutate(RANDOM_MUTATION);
@@ -2082,23 +2085,23 @@ static void _helix_card(int power, deck_rarity_type rarity)
break;
}
}
- else if ( power_level == 1 )
+ else if (power_level == 1)
{
- switch ( how_mutated() ? random2(3) : 0 )
+ switch (how_mutated() ? random2(3) : 0)
{
case 0:
mutate(coinflip() ? RANDOM_GOOD_MUTATION : RANDOM_MUTATION);
break;
case 1:
- if ( coinflip() )
+ if (coinflip())
_remove_bad_mutation();
else
delete_mutation(RANDOM_MUTATION);
break;
case 2:
- if ( coinflip() )
+ if (coinflip())
{
- if ( coinflip() )
+ if (coinflip())
{
_remove_bad_mutation();
mutate(RANDOM_MUTATION);
@@ -2119,7 +2122,7 @@ static void _helix_card(int power, deck_rarity_type rarity)
}
else
{
- switch ( random2(3) )
+ switch (random2(3))
{
case 0:
_remove_bad_mutation();
@@ -2128,7 +2131,7 @@ static void _helix_card(int power, deck_rarity_type rarity)
mutate(RANDOM_GOOD_MUTATION);
break;
case 2:
- if ( coinflip() )
+ if (coinflip())
{
// If you get unlucky, you could get here with no bad
// mutations and simply get a mutation effect. Oh well.
@@ -2149,9 +2152,9 @@ static void _sage_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
int c; // how much to weight your skills
- if ( power_level == 0 )
+ if (power_level == 0)
c = 0;
- else if ( power_level == 1 )
+ else if (power_level == 1)
c = random2(10) + 1;
else
c = 10;
@@ -2163,22 +2166,20 @@ static void _sage_card(int power, deck_rarity_type rarity)
int result = -1;
for (int i = 0; i < NUM_SKILLS; ++i )
{
- if ( skill_name(i) == NULL )
+ if (skill_name(i) == NULL)
continue;
- if ( you.skills[i] < MAX_SKILL_LEVEL )
+ if (you.skills[i] < MAX_SKILL_LEVEL)
{
const int curweight = 1 + you.skills[i] * (40-you.skills[i]) * c;
totalweight += curweight;
- if ( random2(totalweight) < curweight )
+ if (random2(totalweight) < curweight)
result = i;
}
}
- if ( result == -1 )
- {
- mpr("You feel omnipotent."); // all skills maxed
- }
+ if (result == -1)
+ mpr("You feel omnipotent."); // All skills maxed.
else
{
you.duration[DUR_SAGE] = random2(1800) + 200;
@@ -2194,9 +2195,9 @@ static void _create_pond(const coord_def& center, int radius, bool allow_deep)
for ( ; ri; ++ri )
{
const coord_def p = *ri;
- if ( p != you.pos() && coinflip() )
+ if (p != you.pos() && coinflip())
{
- if ( grd(p) == DNGN_FLOOR )
+ if (grd(p) == DNGN_FLOOR)
{
dungeon_feature_type feat;
@@ -2220,15 +2221,15 @@ static void _deepen_water(const coord_def& center, int radius)
// same iteration, i.e., a newly-flooded square shouldn't count
// in the decision as to whether to make the next square flooded.
const coord_def p = *ri;
- if ( grd(p) == DNGN_SHALLOW_WATER &&
- p != you.pos() &&
- random2(8) < 1 + count_neighbours(p.x, p.y, DNGN_DEEP_WATER) )
+ if (grd(p) == DNGN_SHALLOW_WATER
+ && p != you.pos()
+ && random2(8) < 1 + count_neighbours(p.x, p.y, DNGN_DEEP_WATER))
{
dungeon_terrain_changed(p, DNGN_DEEP_WATER);
}
- if (grd(p) == DNGN_FLOOR &&
- random2(3) < random2(count_neighbours(p.x,p.y,DNGN_DEEP_WATER) +
- count_neighbours(p.x,p.y,DNGN_SHALLOW_WATER)))
+ if (grd(p) == DNGN_FLOOR
+ && random2(3) < random2(count_neighbours(p.x,p.y,DNGN_DEEP_WATER)
+ + count_neighbours(p.x,p.y,DNGN_SHALLOW_WATER)))
{
dungeon_terrain_changed(p, DNGN_SHALLOW_WATER);
}
@@ -2238,16 +2239,16 @@ static void _deepen_water(const coord_def& center, int radius)
static void _water_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- if ( power_level == 0 )
+ if (power_level == 0)
{
mpr("You create a pond!");
_create_pond(you.pos(), 4, false);
}
- else if ( power_level == 1 )
+ else if (power_level == 1)
{
mpr("You feel the tide rushing in!");
_create_pond(you.pos(), 6, true);
- for ( int i = 0; i < 2; ++i )
+ for (int i = 0; i < 2; ++i)
_deepen_water(you.pos(), 6);
}
else
@@ -2260,10 +2261,10 @@ static void _water_card(int power, deck_rarity_type rarity)
{
coord_def p = *ri;
destroy_trap(p);
- if ( grd(p) == DNGN_FLOOR )
+ if (grd(p) == DNGN_FLOOR)
{
dungeon_feature_type new_feature = DNGN_SHALLOW_WATER;
- if ( p != you.pos() && coinflip() )
+ if (p != you.pos() && coinflip())
new_feature = DNGN_DEEP_WATER;
dungeon_terrain_changed(p, new_feature);
}
@@ -2274,7 +2275,7 @@ static void _water_card(int power, deck_rarity_type rarity)
static void _glass_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- const int radius = ( power_level == 2 ) ? 1000 : random2(power/40) + 2;
+ const int radius = (power_level == 2) ? 1000 : random2(power/40) + 2;
vitrify_area(radius);
}
@@ -2289,7 +2290,7 @@ static void _dowsing_card(int power, deck_rarity_type rarity)
if (power_level >= 2)
{
- for ( int i = 0; i < 3; ++i )
+ for (int i = 0; i < 3; ++i)
things_to_do[i] = true;
}
@@ -2369,15 +2370,16 @@ static bool _trowel_card(int power, deck_rarity_type rarity)
num_made++;
}
- if ( num_made == 2 )
+ if (num_made == 2)
mpr("The constructs glare at each other.");
+
done_stuff = (num_made > 0);
}
else
{
// Do-nothing (effectively): create a cosmetic feature
const coord_def pos = pick_adjacent_free_square(you.pos());
- if ( pos.x >= 0 && pos.y >= 0 )
+ if (pos.x >= 0 && pos.y >= 0)
{
const dungeon_feature_type statfeat[] = {
DNGN_GRANITE_STATUE, DNGN_ORCISH_IDOL
@@ -2391,14 +2393,14 @@ static bool _trowel_card(int power, deck_rarity_type rarity)
}
else
{
- // generate an altar
- if ( grd[you.x_pos][you.y_pos] == DNGN_FLOOR )
+ // Generate an altar.
+ if (grd[you.x_pos][you.y_pos] == DNGN_FLOOR)
{
- // might get GOD_NO_GOD and no altar
+ // Might get GOD_NO_GOD and no altar.
god_type rgod = static_cast<god_type>(random2(NUM_GODS));
grd[you.x_pos][you.y_pos] = altar_for_god(rgod);
- if ( grd[you.x_pos][you.y_pos] != DNGN_FLOOR )
+ if (grd[you.x_pos][you.y_pos] != DNGN_FLOOR)
{
done_stuff = true;
mprf("An altar to %s grows from the floor before you!",
@@ -2407,15 +2409,15 @@ static bool _trowel_card(int power, deck_rarity_type rarity)
}
}
- if ( !done_stuff )
+ if (!done_stuff)
canned_msg(MSG_NOTHING_HAPPENS);
- return done_stuff;
+ return (done_stuff);
}
static void _genie_card(int power, deck_rarity_type rarity)
{
- if ( coinflip() )
+ if (coinflip())
{
mpr("A genie takes form and thunders: "
"\"Choose your reward, mortal!\"");
@@ -2462,7 +2464,7 @@ static void _curse_card(int power, deck_rarity_type rarity)
{
// Curse 1.5 items on average.
curse_an_item(false);
- if ( coinflip() )
+ if (coinflip())
curse_an_item(false);
}
}
@@ -2470,10 +2472,10 @@ static void _curse_card(int power, deck_rarity_type rarity)
static void _crusade_card(int power, deck_rarity_type rarity)
{
const int power_level = get_power_level(power, rarity);
- if ( power_level >= 1 )
+ if (power_level >= 1)
{
// A chance to convert opponents.
- for ( int i = 0; i < MAX_MONSTERS; ++i )
+ for (int i = 0; i < MAX_MONSTERS; ++i)
{
monsters* const monster = &menv[i];
if (monster->type == -1 || !mons_near(monster)
@@ -2556,14 +2558,14 @@ static void _summon_any_monster(int power, deck_rarity_type rarity)
dx = random2(3) - 1;
dy = random2(3) - 1;
}
- while ( dx == 0 && dy == 0 );
+ while (dx == 0 && dy == 0);
monster_type cur_try;
do
{
cur_try = random_monster_at_grid(you.x_pos + dx, you.y_pos + dy);
}
- while ( mons_is_unique(cur_try) );
+ while (mons_is_unique(cur_try));
if (mon_chosen == NUM_MONSTERS
|| mons_power(mon_chosen) < mons_power(cur_try))
@@ -2661,10 +2663,10 @@ static void _summon_flying(int power, deck_rarity_type rarity)
{
result = flytypes[random2(4) + power_level];
}
- while ( friendly && mons_class_flag(result, M_INVIS)
- && !player_see_invis() );
+ while (friendly && mons_class_flag(result, M_INVIS)
+ && !player_see_invis());
- for ( int i = 0; i < power_level * 5 + 2; ++i )
+ for (int i = 0; i < power_level * 5 + 2; ++i)
{
create_monster(
mgen_data(result,
@@ -2728,12 +2730,12 @@ static int _card_power(deck_rarity_type rarity)
}
result += you.skills[SK_EVOCATIONS] * 9;
- if ( rarity == DECK_RARITY_RARE )
+ if (rarity == DECK_RARITY_RARE)
result += 150;
- else if ( rarity == DECK_RARITY_LEGENDARY )
+ else if (rarity == DECK_RARITY_LEGENDARY)
result += 300;
- return result;
+ return (result);
}
bool card_effect(card_type which_card, deck_rarity_type rarity,
@@ -2820,7 +2822,7 @@ bool card_effect(card_type which_card, deck_rarity_type rarity,
case CARD_TORMENT: torment(TORMENT_CARDS, you.x_pos, you.y_pos); break;
case CARD_VENOM:
- if ( coinflip() )
+ if (coinflip())
{
mprf("You have drawn %s.", card_name(which_card));
your_spells(SPELL_OLGREBS_TOXIC_RADIANCE,random2(power/4), false);