From 236b4e55ba1d823f5db9ad22119332254f99b530 Mon Sep 17 00:00:00 2001
From: corncobman21 <corncobman21@hotmail.com>
Date: Wed, 27 Dec 2017 21:29:06 -0500
Subject: [PATCH] check relations and get random relation as JS functions

---
 src/js/storyJS.tw | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/js/storyJS.tw b/src/js/storyJS.tw
index 099a05d0f16..b928d9ba217 100644
--- a/src/js/storyJS.tw
+++ b/src/js/storyJS.tw
@@ -670,6 +670,26 @@ window.relationTargetWord = function(slave) {
 	return slave.relation;
 };
 
+window.checkRelations = function(slave) {
+	if (!slave) {
+		return null;
+	} else {
+		var relations = State.variables.slaves.filter(function(s) { return areSisters(slave, s) > 0 || s.mother == slave.ID || s.father == slave.ID || s.ID == slave.mother || s.ID == slave.father; })
+	
+		return relations;
+	}
+};
+
+window.getRandomRelation = function(slave) {
+	var relations = checkRelations(slave)
+	
+	if (relations == null) {
+		return null;
+	} else {
+		return relations.random();
+	}
+};
+
 /* intended to condense the clothing/toy/etc availability checks into something less asinine */
 window.isItemAccessible = function(string) {
 	if (State.variables.cheatMode === 1){
-- 
GitLab