From a0209552c4a8fd7e91ccad436cc9822b65bea7b0 Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 14 Jul 2007 19:59:20 +0000 Subject: Implemented Shuffle card. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1865 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/decks.cc | 36 ++++++++++++-- crawl-ref/source/player.cc | 115 +++++++++++++++++++++++++++++++++++++++++++- crawl-ref/source/player.h | 5 +- crawl-ref/source/skills2.cc | 2 +- 4 files changed, 152 insertions(+), 6 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index a67fc31d0c..9ad1b295ac 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -885,9 +885,39 @@ static void focus_card(int power, deck_rarity_type rarity) static void shuffle_card(int power, deck_rarity_type rarity) { - // not yet implemented - // should shuffle *base* stat levels - return; + stat_type stats[3] = {STAT_STRENGTH, STAT_DEXTERITY, STAT_INTELLIGENCE}; + 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 ) + 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 ) + { + new_base[perm[i]] = old_base[i] - modifiers[i] + modifiers[perm[i]]; + new_max[perm[i]] = old_max[i] - modifiers[i] + modifiers[perm[i]]; + } + + // Sometimes you just long for Python. + you.strength = new_base[0]; + 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.redraw_strength = true; + you.redraw_intelligence = true; + you.redraw_dexterity = true; + you.redraw_evasion = true; } static void helix_card(int power, deck_rarity_type rarity) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 7edefca883..4f58b6fcf0 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -475,7 +475,7 @@ int get_player_wielded_weapon() // Looks in equipment "slot" to see if there is an equiped "sub_type". // Returns number of matches (in the case of rings, both are checked) -int player_equip( int slot, int sub_type, bool calc_unid ) +int player_equip( equipment_type slot, int sub_type, bool calc_unid ) { int ret = 0; @@ -4482,6 +4482,119 @@ void rot_player( int amount ) } } + +int count_worn_ego( special_armour_type ego ) +{ + int result = 0; + for ( int slot = EQ_CLOAK; slot <= EQ_BODY_ARMOUR; ++slot ) + if (you.equip[slot] != -1 && + get_armour_ego_type(you.inv[you.equip[slot]]) == ego) + result++; + return result; +} + +static int strength_modifier() +{ + int result = 0; + if ( you.duration[DUR_MIGHT] ) + result += 5; + + // ego items of strength + result += 3 * count_worn_ego(SPARM_STRENGTH); + + // rings of strength + result += player_equip( EQ_RINGS_PLUS, RING_STRENGTH ); + + // randarts of strength + result += scan_randarts(RAP_STRENGTH); + + // mutations + result += you.mutation[MUT_STRONG] - you.mutation[MUT_WEAK]; + result += you.mutation[MUT_STRONG_STIFF]-you.mutation[MUT_FLEXIBLE_WEAK]; + + // transformations + switch ( you.attribute[ATTR_TRANSFORMATION] ) + { + case TRAN_STATUE: result += 2; break; + case TRAN_DRAGON: result += 10; break; + case TRAN_LICH: result += 3; break; + case TRAN_SERPENT_OF_HELL: result += 13; break; + default: break; + } + return result; +} + +static int dex_modifier() +{ + int result = 0; + + // ego items of dexterity + result += 3 * count_worn_ego(SPARM_DEXTERITY); + + // rings of dexterity + result += player_equip( EQ_RINGS_PLUS, RING_DEXTERITY ); + + // randarts of dexterity + result += scan_randarts(RAP_DEXTERITY); + + // mutations + result += you.mutation[MUT_AGILE] - you.mutation[MUT_CLUMSY]; + result += you.mutation[MUT_FLEXIBLE_WEAK]-you.mutation[MUT_STRONG_STIFF]; + result -= you.mutation[MUT_BLACK_SCALES]; + result -= you.mutation[MUT_BONEY_PLATES]; + const int grey2_modifier[] = { 0, -1, -1, -2 }; + const int metallic_modifier[] = { 0, -2, -3, -4 }; + const int yellow_modifier[] = { 0, 0, -1, -2 }; + const int red2_modifier[] = { 0, 0, -1, -2 }; + + result -= grey2_modifier[you.mutation[MUT_GREY2_SCALES]]; + result -= metallic_modifier[you.mutation[MUT_METALLIC_SCALES]]; + result -= yellow_modifier[you.mutation[MUT_YELLOW_SCALES]]; + result -= red2_modifier[you.mutation[MUT_RED2_SCALES]]; + + // transformations + switch ( you.attribute[ATTR_TRANSFORMATION] ) + { + case TRAN_SPIDER: result += 5; break; + case TRAN_STATUE: result -= 2; break; + case TRAN_AIR: result += 8; break; + default: break; + } + return result; +} + +static int int_modifier() +{ + int result = 0; + + // ego items of intelligence + result += 3 * count_worn_ego(SPARM_INTELLIGENCE); + + // rings of intelligence + result += player_equip( EQ_RINGS_PLUS, RING_INTELLIGENCE ); + + // randarts of intelligence + result += scan_randarts(RAP_INTELLIGENCE); + + // mutations + result += you.mutation[MUT_CLEVER] - you.mutation[MUT_DOPEY]; + return result; +} + +int stat_modifier( stat_type stat ) +{ + switch ( stat ) + { + case STAT_STRENGTH: return strength_modifier(); + case STAT_DEXTERITY: return dex_modifier(); + case STAT_INTELLIGENCE: return int_modifier(); + default: + mprf(MSGCH_DANGER, "Bad stat: %d", stat); + return 0; + } +} + + ////////////////////////////////////////////////////////////////////////////// // actor diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 9bc425f3de..04695039f3 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -24,7 +24,7 @@ bool player_in_branch( int branch ); bool player_in_hell( void ); int get_player_wielded_weapon(); -int player_equip( int slot, int sub_type, bool calc_unid = true ); +int player_equip( equipment_type slot, int sub_type, bool calc_unid = true ); int player_equip_ego_type( int slot, int sub_type ); int player_damage_type( void ); int player_damage_brand( void ); @@ -420,4 +420,7 @@ void run_macro(const char *macroname = NULL); int player_ghost_base_movement_speed(); +int count_worn_ego( special_armour_type ego ); +int stat_modifier( stat_type stat ); + #endif diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index 955b0dc657..4e9dbd8e6e 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -2208,7 +2208,7 @@ int calc_mp(void) if (you.magic_points > you.max_magic_points) you.magic_points = you.max_magic_points; - you.redraw_magic_points = 1; + you.redraw_magic_points = true; return (you.max_magic_points); } // end calc_mp() -- cgit v1.2.3-54-g00ecf