Fixed bug in Wrath card.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1632 c06c8d41-db1a-0410-9941-cceddc491573
JP7SVXCIKEPVDD4Q5CDYDATPK7X5XOYW3T6QK2Y6EWHFH52LBK3QC }// Find a nearby monster to banish and return its index,// including you as a possibility with probability weight.static int choose_random_nearby_monster(int weight){int mons_count = weight;int result = NON_MONSTER;int ystart = you.y_pos - 9, xstart = you.x_pos - 9;int yend = you.y_pos + 9, xend = you.x_pos + 9;if ( xstart < 0 ) xstart = 0;if ( ystart < 0 ) ystart = 0;if ( xend >= GXM ) xend = GXM;if ( ystart >= GYM ) yend = GYM;/* monster check */for ( int y = ystart; y < yend; ++y )for ( int x = xstart; x < xend; ++x )if ( see_grid(x,y) && mgrd[x][y] != NON_MONSTER )if ( one_chance_in(++mons_count) )result = mgrd[x][y];return result;
// swap between you and another monster
// Swap between you and another monster.// Don't choose yourself unless there are no other monsters// nearby.const int mon_to_swap = choose_random_nearby_monster(0);if ( mon_to_swap == NON_MONSTER ){mpr("You spin around.");}else{monsters& mon = menv[mon_to_swap];const coord_def newpos = menv[mon_to_swap].pos();// pick the monster upmgrd[mon.x][mon.y] = NON_MONSTER;mon.x = you.x_pos;mon.y = you.y_pos;// plunk it downmgrd[mon.x][mon.y] = mon_to_swap;// move you to its previous locationyou.moveto(newpos);}
// pick a random monster nearby to banishint mons_count = 1; // youint mon_to_banish = NON_MONSTER;int ystart = you.y_pos - 9, xstart = you.x_pos - 9;int yend = you.y_pos + 9, xend = you.x_pos + 9;if ( xstart < 0 ) xstart = 0;if ( ystart < 0 ) ystart = 0;if ( xend >= GXM ) xend = GXM;if ( ystart >= GYM ) yend = GYM;
// pick a random monster nearby to banish (or yourself)const int mon_to_banish = choose_random_nearby_monster(1);
/* monster check */for ( int y = ystart; y < yend; ++y )for ( int x = xstart; x < xend; ++x )if ( see_grid(x,y) && mgrd[x][y] != NON_MONSTER )if ( one_chance_in(++mons_count) )mon_to_banish = mgrd[x][y];
case CARD_SUMMON_ANIMAL: break;case CARD_SUMMON_WEAPON: break;case CARD_SUMMON_ANY: break;
case CARD_SUMMON_ANIMAL: break; // not yet implementedcase CARD_SUMMON_WEAPON: break; // not yet implementedcase CARD_SUMMON_ANY: break; // not yet implemented