storiesCharacters = {
const isDebug = false;
if (useTestData) {
return [
{ storyID: 0, charID: 0},
{ storyID: 1, charID: 1},
{ storyID: 2, charID: 2},
{ storyID: 6, charID: 3},
{ storyID: 7, charID: 3},
{ storyID: 8, charID: 3},
{ storyID: 8, charID: 4},
{ storyID: 0, charID: 5},
{ storyID: 7, charID: 5}
];
} else {
let tempSCs = new Array();
for (const pv of biblePersonVerse) {
let person = characters.find(p => p.personID == pv.person_id);
let tempCharID = characters.indexOf(person);
let tempStoryID = 0;
let tempBookID = 0;
let newSC = null;
if (person != null){
for (const story of stories) {
tempBookID = bibleBooks.indexOf(bibleBooks.find(e => e.Book == story.book.name));
if(isDebug)
console.log(`Search the person verse reference (${pv.reference_id}) table includes
the book ${story.book.name} with id ${tempBookID}`);
if (pv.reference_id.includes(bibleBookRef[tempBookID])) {
let tempVerse = parseInt(pv.reference_id.split(" ")[1].split(":")[0]);
if(isDebug)
console.log(`Is the verse referenced in "${pv.reference_id}" between ${story.startChap}
and ${story.endChap} in the book of ${story.book.name}`);
if (tempVerse >= story.startChap && tempVerse <= story.endChap){
newSC = { storyID: tempStoryID, charID: tempCharID}
if(isDebug)
console.log(`Does the story and character relation exist for ${story.book.name}
and ${person.name}`);
if(!tempSCs.includes(e => e == newSC)) {
tempSCs.push(newSC);
}
}
}
tempStoryID++;
}
}
}
return tempSCs;
}
}