From ff4ee087a15d08bd097552cd73f2508d5af78938 Mon Sep 17 00:00:00 2001
From: Pregmodder <pregmodder@gmail.com>
Date: Tue, 18 Dec 2018 22:32:42 -0500
Subject: [PATCH] child surname fix

---
 devNotes/twine JS.txt      | 112 +++++++++++++++++++++++++++++++++++++
 src/js/generateGenetics.tw | 112 +++++++++++++++++++++++++++++++++++++
 2 files changed, 224 insertions(+)

diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt
index 6172038987e..32841e6e974 100644
--- a/devNotes/twine JS.txt	
+++ b/devNotes/twine JS.txt	
@@ -10644,6 +10644,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		} else {
 			child.genes = "XY";
@@ -10687,6 +10715,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		}
 
@@ -10788,6 +10844,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		} else {
 			GenerateNewSlave("XY");
@@ -10832,6 +10916,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		}
 
diff --git a/src/js/generateGenetics.tw b/src/js/generateGenetics.tw
index 87987638965..eeee9419b8e 100644
--- a/src/js/generateGenetics.tw
+++ b/src/js/generateGenetics.tw
@@ -575,6 +575,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		} else {
 			child.genes = "XY";
@@ -618,6 +646,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		}
 
@@ -719,6 +775,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		} else {
 			GenerateNewSlave("XY");
@@ -763,6 +847,34 @@ window.generateChild = function(mother, ova, destination) {
 				}
 			} else {
 				child.slaveName = genes.name;
+				if (genes.mother == -1) {
+					child.slaveSurname = V.PC.surname;
+				} else {
+					if (genes.father == -1) {
+						child.slaveSurname = V.PC.surname;
+					} else if (genes.father > 0) {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						} else {
+							let currentFather = getSlave(genes.father);
+							if (currentFather !== undefined) {
+								if (currentFather.slaveSurname !== 0 && currentFather.slaveSurname !== "") {
+									child.slaveSurname = currentFather.slaveSurname;
+								}
+							}
+						}
+					} else {
+						let currentMother = getSlave(genes.mother);
+						if (currentMother !== undefined) {
+							if (currentMother.slaveSurname !== 0 && currentMother.slaveSurname !== "") {
+								child.slaveSurname = currentMother.slaveSurname;
+							}
+						}
+					}
+				}
 			}
 		}
 
-- 
GitLab