For instance:
SHUFFLE: wW, 8$
will, if it swaps w and 8, also swap W and $. Block shuffles may have any number of comma-separated entries, provided each segment is the same length.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@923 c06c8d41-db1a-0410-9941-cceddc491573
UPU5QYUWCXSX233JNGE37QEN5TG5HDRGLNSCEKHH3GPU4AEXW3KAC
}
std::string map_lines::block_shuffle(const std::string &s)
{
std::vector<std::string> segs = split_string(",", s);
unsigned seglen = 0;
std::vector<std::string> shuffled;
for (int i = 0, size = segs.size(); i < size; ++i)
{
const int sel = random2(segs.size());
shuffled.push_back( segs[ sel ] );
segs.erase( segs.begin() + sel );
if (!seglen)
seglen = shuffled[i].length();
else if (seglen != shuffled[i].length())
{
mprf(MSGCH_DIAGNOSTICS, "Bad shuffle parameter: %s", s.c_str());
return ("");
}
}
return comma_separated_line(shuffled.begin(), shuffled.end(), ",", ",");