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 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/decks.cc') 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) -- cgit v1.2.3-54-g00ecf