From f82a63fbf0972d96271e354bc5f597dd3093824d Mon Sep 17 00:00:00 2001
From: DCoded <dcoded@live.com>
Date: Wed, 2 Sep 2020 23:45:46 -0400
Subject: [PATCH] Added completion(), completionCanine(), and getAnimal()

---
 src/facilities/farmyard/animals/animals.js |  9 +++
 src/npc/interaction/fAnimal.js             | 68 +++++++++++++++++++++-
 2 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/src/facilities/farmyard/animals/animals.js b/src/facilities/farmyard/animals/animals.js
index 2cacefd5d77..081fba93239 100644
--- a/src/facilities/farmyard/animals/animals.js
+++ b/src/facilities/farmyard/animals/animals.js
@@ -581,3 +581,12 @@ App.Data.animals = {
 		],
 	},
 };
+
+/**
+ * Returns an animal object for the active animal of type given
+ * @param {string} type One of "canine", "hooved", or "feline"
+ * FIXME: does not currently work
+ */
+globalThis.getAnimal = function(type) {
+	return _.find(App.Data.animals[type], V[`active${capFirstChar(type)}`]);
+};
diff --git a/src/npc/interaction/fAnimal.js b/src/npc/interaction/fAnimal.js
index c6e99d370c4..cecac6f5db8 100644
--- a/src/npc/interaction/fAnimal.js
+++ b/src/npc/interaction/fAnimal.js
@@ -23,7 +23,9 @@ App.Interact.fAnimal = function(slave, type) {
 	let
 		animal,
 		fetishDesc,
-		act;
+		act,
+		hole,
+		orifice = [];
 
 	switch (type) {
 		case "canine":
@@ -72,6 +74,22 @@ App.Interact.fAnimal = function(slave, type) {
 			slave.fetish === "cumslut" && act === oral ||
 			slave.sexualQuirk === "gagfuck queen" && act === oral;
 
+	switch (act) {
+		case oral:
+			orifice = ["mouth", "throat"];
+			break;
+		case vaginal:
+			orifice = ["pussy", "cunt"];
+			hole = 0;
+			break;
+		case anal:
+			orifice = ["asshole", "rectum"];
+			hole = 1;
+			break;
+		default:
+			throw new Error(`Unexpected act type '${act}' in fAnimal()`);
+	}
+
 	if (slave.fetish === "cumslut" && act === oral) {
 		fetishDesc = `getting to drink more cum`;
 	} else if (slave.fetish === "humiliation") {
@@ -120,6 +138,8 @@ App.Interact.fAnimal = function(slave, type) {
 		consummationResistant();
 	}
 
+	completion();
+
 	mainDiv.append(r.join(' '));
 
 	return frag;
@@ -505,6 +525,52 @@ App.Interact.fAnimal = function(slave, type) {
 
 
 
+	// MARK: Completion Function
+
+	function completion() {
+		switch (animal) {
+			case V.activeCanine:
+				completionCanine();
+				return;
+			case V.activeHooved:
+			case V.activeFeline:
+			default:
+				throw new Error(`Unexpected animal type '${type}' in completion()`);
+		}
+
+		function completionCanine() {
+			r.push(`The ${type === "canine" ? `hound` : animal} wastes no time in beginning to hammer away at ${his} ${orifice[0]}, causing ${slave.slaveName} to moan uncontrollably as its thick, veiny member probes the depths of ${his} ${orifice[1]}. A few short minutes later, ${he} gives a loud groan ${slaveApproves() ? `and shakes in orgasm ` : ``}as the ${animal}'s knot begins to swell and its dick begins to erupt a thick stream of jizz ${act === oral ? `down ${his} throat` : `into ${his} ${orifice[0]}`}. Soon enough, the ${animal} finally finishes cumming and its knot is sufficiently small enough to slip out of ${slave.slaveName}'s ${act === oral ?
+				`mouth` :
+				act === vaginal && slave.vagina < 3 || act === anal && slave.anus < 2 ?
+					`now-gaping ${orifice[0]}` :
+					orifice[0]}, causing ${act === oral ?
+				`${him} to immediately begin coughing and retching uncontrollably` :
+				`a thick stream of cum to slide out of it`}. Having finished its business, the ${animal} runs off, presumably in search of food.`);
+
+			if (act !== oral && canGetPregnant(slave) && canBreed(slave, animal)) {
+				knockMeUp(slave, 5, hole, -8);
+			}
+
+			switch (act) {
+				case oral:
+					slave.counter.oral++;
+					return;
+				case vaginal:
+					slave.vagina = slave.vagina < 3 ? 3 : slave.vagina;
+					slave.counter.vaginal++;
+					return;
+				case anal:
+					slave.anus = slave.anus < 2 ? 2 : slave.anus;
+					slave.counter.anal++;
+					return;
+				default:
+					throw new Error(`Unexpected act type '${act} in completion()`);
+			}
+		}
+	}
+
+
+
 	// MARK: Virginity Check Functions
 
 	function virginityCheck(type) {
-- 
GitLab