From b8d2917f82b71d0bbaa0d994b069dc586502e7b2 Mon Sep 17 00:00:00 2001
From: Shibari <ShibariTOME@Gmail.com>
Date: Wed, 20 Sep 2017 05:42:37 -0400
Subject: [PATCH] - Add a unique_ego flag that indicates if an ego can only be
 applied to an item once

---
 game/modules/tome/class/GameState.lua | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/game/modules/tome/class/GameState.lua b/game/modules/tome/class/GameState.lua
index 9804f0d96a..3f020cc203 100644
--- a/game/modules/tome/class/GameState.lua
+++ b/game/modules/tome/class/GameState.lua
@@ -1655,11 +1655,13 @@ function _M:egoFilter(zone, level, type, etype, e, ego_filter, egos_list, picked
 	local arcane_check = false
 	local nature_check = false
 	local am_check = false
+	local unique_check = false
 	for i = 1, #egos_list do
 		local e = egos_list[i]
 		if e.power_source and e.power_source.arcane then arcane_check = true end
 		if e.power_source and e.power_source.nature then nature_check = true end
 		if e.power_source and e.power_source.antimagic then am_check = true end
+		if e.unique_ego then unique_check = true end
 	end
 
 	local fcts = {}
@@ -1675,6 +1677,19 @@ function _M:egoFilter(zone, level, type, etype, e, ego_filter, egos_list, picked
 		fcts[#fcts+1] = function(ego) return not ego.power_source or not ego.power_source.arcane end
 	end
 
+	if unique_check then
+		fcts[#fcts+1] = function(ego) 
+			local check = false
+			-- Use keywords as a proxy for name, a bit simpler than going through Object.ego_list
+			for k,v in pairs(ego.keywords) do
+				if e.keywords and e.keywords[k] then 
+					check = true
+				end
+			end
+			return not check
+		end
+	end
+
 	if #fcts > 0 then
 		local old = ego_filter.special
 		ego_filter.special = function(ego)
-- 
GitLab