git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9122 c06c8d41-db1a-0410-9941-cceddc491573
BAQ5ZQ3XMXTITZIDAGMES65SE6Y7VQYASNMTYPL3OOJEG4YMGVPAC
3CRSIZM7N5F46UWBKM2Y3CNKADWZGLI4JWMUO762ND2TT4247RGQC
CD4WP6WFJ4YLIBSQVDPE7QJNTOGJUV67IPZBZPCODRYHWZRWVIZAC
LS5XCCGKQHSJQGWLWLGTP2F5OYWK4ND5AQQAGRN6H2HVBSXNCCZAC
QXD3HX6QQ37PW6HVKIIKGFLO2ACROLUGKK66KFX7ED6SO4FDXB2AC
77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC
SOCJXX6MMOXLBEWBID4QN5FW2YNYULNNN7K3IRL7RSWK5EUNAZLQC
UKN6HTZXDUUOWKNWNKWPHKGUGL474JIAQN5JU3DM3DU26WGMNP4AC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
CCRQESB4ADT4WA7FGLNZZXAJ6G5QMCTYCZIWORBN45P6ZPILC34AC
2I5XEYRJKLUS7MO42MCR6KT2URGFQ3YDKTNTIBNKVKLX5LMG6CEQC
ED7MV353FW7C4KZWLXUOEULWZZWMRCJVWMLAFC5OLCKZNPDBLQAQC
UC6V7JDZ6CKQNL5AARWFJ4ZPX4ZYCO5J3FW52I52I3PBJO6T6VEAC
MT6WFYUIJ2MA3GIQ2MEHHKIQ6QT6IECFGO4BV4SB3GCGQUIWEYNAC
YDWBT7CZGY33CNDPF7S4LK7YULFMDUJAKIODKMGB2IYIWHF4SJWQC
TQOJIJP5MUILKWSEC3Q6BNGVFZJOYSCUR3DR4WPJQ4GGDEVQHEMQC
3KBPG2GCDMENTQJY6UARZAWI57CKHP5JO24LRN243OP4WTUPFK4QC
std::string lookup = spelltype_long_name(disc1);
if (highest_level >= 6 + random2(3))
owner = getRandNameString("high-level " + lookup + " owner");
bool highlevel = (highest_level >= 6 + random2(3));
if (disc1 != disc2)
{
std::string schools[2];
schools[0] = spelltype_long_name(disc1);
schools[1] = spelltype_long_name(disc2);
std::sort(schools, schools + 2);
std::string lookup = schools[0] + " " + schools[1];
if (highlevel)
owner = getRandNameString("highlevel " + lookup + " owner");
if (owner.empty() || owner == "__NONE")
owner = getRandNameString(lookup + " owner");
if (owner == "__NONE")
owner = "";
if (owner.empty() && all_spells_disc1)
{
std::string lookup = spelltype_long_name(disc1);
if (highlevel && disc1 == disc2)
owner = getRandNameString("highlevel " + lookup + " owner");
if (owner.empty() || owner == "__NONE")
owner = getRandNameString(lookup + " owner");
if (owner == "__NONE")
owner = "";
}
int total_weights = 0;
// Pick a random spellbook according to unknown spells contained.
int weights[MAX_NORMAL_BOOK+1];
for (int bk = 0; bk <= MAX_NORMAL_BOOK; bk++)
{
weights[bk] = _book_weight(bk);
total_weights += weights[bk];
}
if (total_weights > 0)
{
book.sub_type = choose_random_weighted(weights,
weights + ARRAYSZ(weights));
break;
}
// else intentional fall-through
}
default:
{
// Pick a random spellbook according to unknown spells contained.
int weights[MAX_NORMAL_BOOK+1];
for (int bk = 0; bk <= MAX_NORMAL_BOOK; bk++)
weights[bk] = _book_weight(bk);
book.sub_type = choose_random_weighted(weights,
weights + ARRAYSZ(weights));
#
# Books also may get previous "owners" (or authors) that may be the gifting
# god (if gifted), a name depending on school(s) as defined in this file,
# a random name, or an appropriate god (if not a god gift).
# The school dependant names consist of uniques or spell names that have a
# strong connection to one or more schools. Pandemonium or hell lords' names
# may only get used if a book is "highlevel", i.e. contains at least one
# spell of level 6 or higher.
# If the first and second school are different the two names are tested in
# combination, in alphabetical order. If this is not the case or nothing is
# found (or "__NONE" == the empty string was returned) and all spells match
# the primary school try again with only that one.