Chapter 1 - Generating Enhancive Mementos
To generate an enhancive memento:
say "Generating an enhancive memento. ";
blank out the whole of the Table of Available Memento Types;
let the temporary count be 1 + the current danger level;
while the temporary count > 0:
let K be a random number between 1 and 8;
if K is 1:
now the attack boost of the current memento is 1 + the attack boost of the current memento;
otherwise if K is 2:
now the speed boost of the current memento is 1 + the speed boost of the current memento;
otherwise if K is 3:
now the defense boost of the current memento is 1 + the defense boost of the current memento;
otherwise if K is 4:
now the movement boost of the current memento is 1 + the movement boost of the current memento;
otherwise if K is 5:
now the awareness boost of the current memento is 1 + the awareness boost of the current memento;
otherwise if K is 6:
now the stealth boost of the current memento is 1 + the stealth boost of the current memento;
otherwise:
let L be a random number between 1 and 7;
if L is 1:
now the attack boost of the current memento is the attack boost of the current memento - 1;
otherwise if L is 2:
now the speed boost of the current memento is the speed boost of the current memento - 1;
otherwise if L is 3:
now the defense boost of the current memento is the defense boost of the current memento - 1;
otherwise if L is 4:
now the movement boost of the current memento is the movement boost of the current memento - 1;
otherwise if L is 5:
now the awareness boost of the current memento is the awareness boost of the current memento - 1;
otherwise if L is 6:
now the stealth boost of the current memento is the stealth boost of the current memento - 1;
otherwise:
now the temporary count is the temporary count + 1;
now the temporary count is the temporary count - 1;
now the table_target is 1;
repeat with Q running from 1 to the number of rows in the Table of Defined Memento Types:
now the table_origin is Q;
if the attack boost of the current memento > 0 and is_weapon in row table_origin of the Table of Defined Memento Types is true:
copy the memento type tables entry;
otherwise if the speed boost of the current memento > 0 and is_gloves in row table_origin of the Table of Defined Memento Types is true:
copy the memento type tables entry;
otherwise if the defense boost of the current memento > 0 and is_shield in row table_origin of the Table of Defined Memento Types is true:
copy the memento type tables entry;
otherwise if the stealth boost of the current memento > 0 and is_cloak in row table_origin of the Table of Defined Memento Types is true:
copy the memento type tables entry;
otherwise if the awareness boost of the current memento > 0 and is_boots in row table_origin of the Table of Defined Memento Types is true:
copy the memento type tables entry;
otherwise if the movement boost of the current memento > 0 and is_specs in row table_origin of the Table of Defined Memento Types is true:
copy the memento type tables entry;
repeat with R running from 1 to the number of rows in the Table of Available Memento Types:
if the Table of Available Memento Types is not empty:
if the attack boost of the current memento < 0 and is_weapon in row table_origin of the Table of Available Memento Types is true:
say "...removing [memento-type in row R of the Table of Available Memento Types] from the table because this memento has an attack boost of [attack boost of the current memento]... ";
choose row R in the Table of Available Memento Types;
blank out the whole row;
if the speed boost of the current memento < 0 and is_gloves in row table_origin of the Table of Available Memento Types is true:
say "...removing [memento-type in row R of the Table of Available Memento Types] from the table because this memento has a speed boost of [speed boost of the current memento]... ";
choose row R in the Table of Available Memento Types;
blank out the whole row;
if the defense boost of the current memento < 0 and is_shield in row table_origin of the Table of Available Memento Types is true:
say "...removing [memento-type in row R of the Table of Available Memento Types] from the table because this memento has a defense boost of [defense boost of the current memento]... ";
choose row R in the Table of Available Memento Types;
blank out the whole row;
if the stealth boost of the current memento < 0 and is_cloak in row table_origin of the Table of Available Memento Types is true:
say "...removing [memento-type in row R of the Table of Available Memento Types] from the table because this memento has a stealth boost of [stealth boost of the current memento]... ";
choose row R in the Table of Available Memento Types;
blank out the whole row;
if the awareness boost of the current memento < 0 and is_boots in row table_origin of the Table of Available Memento Types is true:
say "...removing [memento-type in row R of the Table of Available Memento Types] from the table because this memento has an awareness boost of [awareness boost of the current memento]... ";
choose row R in the Table of Available Memento Types;
blank out the whole row;
if the movement boost of the current memento < 0 and is_specs in row table_origin of the Table of Available Memento Types is true:
say "...removing [memento-type in row R of the Table of Available Memento Types] from the table because this memento has a movement boost of [movement boost of the current memento]... ";
choose row R in the Table of Available Memento Types;
blank out the whole row;
if the Table of Available Memento Types is empty:
say "Adding jinx memento types. ";
now the table_target is 1;
repeat with Q running from 1 to the number of rows in the Table of Defined Memento Types:
now the table_origin is Q;
if is_jinx in row table_origin of the Table of Defined Memento Types is true:
copy the memento type tables entry;
choose a random row in the Table of Available Memento Types;
now the memento-type of the current memento is the memento-type entry;
now the wear_at of the current memento is the wear_at entry;
if the wear_at of the current memento is not 0:
now the current memento is wearable;
say "... memento generation complete. The memento is a [current memento] with bonuses for [if the attack boost of the current memento is not 0] attack [attack boost of the current memento],[end if] speed [speed boost of the current memento], defense [defense boost of the current memento], stealth [stealth boost of the current memento], awareness [awareness boost of the current memento], and movement [movement boost of the current memento].)"
To copy the memento type tables entry:
say "...copying [memento-type in row table_origin of the Table of Defined Memento Types] into row [table_target] of the Table of Available Memento Types... ";
now the memento-type in row table_target of the Table of Available Memento Types is the memento-type in row table_origin of the Table of Defined Memento Types;
now the wear_at in row table_target of the Table of Available Memento Types is the wear_at in row table_origin of the Table of Defined Memento Types;
now the is_weapon in row table_target of the Table of Available Memento Types is the is_weapon in row table_origin of the Table of Defined Memento Types;
now the is_shield in row table_target of the Table of Available Memento Types is the is_shield in row table_origin of the Table of Defined Memento Types;
now the is_gloves in row table_target of the Table of Available Memento Types is the is_gloves in row table_origin of the Table of Defined Memento Types;
now the is_cloak in row table_target of the Table of Available Memento Types is the is_cloak in row table_origin of the Table of Defined Memento Types;
now the is_boots in row table_target of the Table of Available Memento Types is the is_boots in row table_origin of the Table of Defined Memento Types;
now the is_specs in row table_target of the Table of Available Memento Types is the is_specs in row table_origin of the Table of Defined Memento Types;
now the wear_at in row table_target of the Table of Available Memento Types is the wear_at in row table_origin of the Table of Defined Memento Types;
now the table_target is the table_target + 1.