summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 13:47:27 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 13:47:27 +0000
commit85b02c94b3646a5201a7c45b742a4164821bfa87 (patch)
treeb26fe5cc88bbbe5b58623bb6ef14e3342a698927 /crawl-ref
parent8348fa729646872032b8231fee14d5dd35a3451a (diff)
downloadcrawl-ref-85b02c94b3646a5201a7c45b742a4164821bfa87.tar.gz
crawl-ref-85b02c94b3646a5201a7c45b742a4164821bfa87.zip
Implemented Spade and Trowel (except for vault generation.)
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1819 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/decks.cc69
-rw-r--r--crawl-ref/source/misc.cc23
-rw-r--r--crawl-ref/source/misc.h2
3 files changed, 87 insertions, 7 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 13c0ed201e..e69681a6b6 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -924,7 +924,66 @@ static void dowsing_card(int power, deck_rarity_type rarity)
static void trowel_card(int power, deck_rarity_type rarity)
{
- // XXX not yet implemented
+ const int power_level = get_power_level(power, rarity);
+ bool done_stuff = false;
+ if ( power_level >= 2 )
+ {
+ // XXX FIXME Vaults not implemented
+ // generate a vault
+ }
+ else if ( power_level == 1 )
+ {
+ if (coinflip())
+ {
+ // Create a random bad statue
+ // This could be really bad, because it's placed adjacent
+ // to you...
+ const monster_type statues[] = {
+ MONS_ORANGE_STATUE, MONS_SILVER_STATUE, MONS_ICE_STATUE
+ };
+ const monster_type mons = RANDOM_ELEMENT(statues);
+ if ( create_monster(mons, 0, BEH_HOSTILE, you.x_pos, you.y_pos,
+ MHITYOU, 250) != -1 )
+ {
+ mpr("A menacing statue appears!");
+ done_stuff = true;
+ }
+ }
+ else
+ {
+ coord_def pos = pick_adjacent_free_square(you.x_pos, you.y_pos);
+ if ( pos.x >= 0 && pos.y >= 0 )
+ {
+ const dungeon_feature_type statfeat[] = {
+ DNGN_GRANITE_STATUE, DNGN_ORCISH_IDOL
+ };
+ // We leave the items on the square
+ grd[pos.x][pos.y] = RANDOM_ELEMENT(statfeat);
+ mpr("A statue takes form beside you.");
+ done_stuff = true;
+ }
+ }
+ }
+ else
+ {
+ // generate an altar
+ if ( grd[you.x_pos][you.y_pos] == DNGN_FLOOR )
+ {
+ // might get GOD_NO_GOD and no altar
+ grd[you.x_pos][you.y_pos] =
+ altar_for_god(static_cast<god_type>(random2(NUM_GODS)));
+
+ if ( grd[you.x_pos][you.y_pos] != DNGN_FLOOR )
+ {
+ done_stuff = true;
+ mpr("An altar grows from the floor before you!");
+ }
+ }
+ }
+
+ if ( !done_stuff )
+ mprf("Nothing appears to happen.", power_level);
+
return;
}
@@ -1095,7 +1154,6 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
case CARD_EXPERIENCE: potion_effect(POT_EXPERIENCE, power/4); break;
case CARD_HELIX: helix_card(power, rarity); break;
case CARD_DOWSING: dowsing_card(power, rarity); break;
- case CARD_TROWEL: trowel_card(power, rarity); break;
case CARD_MINEFIELD: minefield_card(power, rarity); break;
case CARD_GENIE: genie_card(power, rarity); break;
case CARD_CURSE: curse_card(power, rarity); break;
@@ -1108,11 +1166,8 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
case CARD_SUMMON_ANY: summon_any_monster(power, rarity); break;
case CARD_XOM: xom_acts(5 + random2(power/10)); break;
case CARD_SUMMON_WEAPON: summon_dancing_weapon(power, rarity); break;
-
- case CARD_SPADE:
- // XXX not yet implemented
- mpr("Sorry, this card is not yet available.");
- break;
+ case CARD_TROWEL: trowel_card(power, rarity); break;
+ case CARD_SPADE: your_spells(SPELL_DIG, random2(power/4), false); break;
case CARD_VITRIOL: case CARD_FLAME: case CARD_FROST: case CARD_HAMMER:
damaging_card(which_card, power, rarity);
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index a78614471c..7d492a148b 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2264,3 +2264,26 @@ void run_environment_effects()
}
}
}
+
+coord_def pick_adjacent_free_square(int x, int y)
+{
+ int num_ok = 0;
+ coord_def result(-1, -1);
+ for ( int ux = x-1; ux <= x+1; ++ux )
+ {
+ for ( int uy = y-1; uy <= y+1; ++uy )
+ {
+ if ( ux == x && uy == y )
+ continue;
+
+ if ( ux >= 0 && ux < GXM && uy >= 0 && uy < GYM &&
+ grd[ux][uy] == DNGN_FLOOR && mgrd[ux][uy] == NON_MONSTER )
+ {
+ ++num_ok;
+ if ( one_chance_in(num_ok) )
+ result.set(ux, uy);
+ }
+ }
+ }
+ return result;
+}
diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h
index ce8b9ccd0c..c95f1bde66 100644
--- a/crawl-ref/source/misc.h
+++ b/crawl-ref/source/misc.h
@@ -206,4 +206,6 @@ bool do_autopray();
bool player_in_a_dangerous_place();
+coord_def pick_adjacent_free_square(int x, int y);
+
#endif