From e82180fc6d11095d917d1e88d218fa4be11a08a2 Mon Sep 17 00:00:00 2001
From: Lisa Greene <glisa825@gmail.com>
Date: Sun, 19 May 2019 05:03:43 +0200
Subject: [PATCH] Revert "Revert "Check for conflicts between power source and
 categories for mastery boosting""

This reverts commit a8b298b08acbefbe0daaa43ab6ba1ddaa34b8d64
---
 .../data/general/objects/egos/amulets.lua     | 20 +++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/game/modules/tome/data/general/objects/egos/amulets.lua b/game/modules/tome/data/general/objects/egos/amulets.lua
index 2565855acc..599cb5466e 100644
--- a/game/modules/tome/data/general/objects/egos/amulets.lua
+++ b/game/modules/tome/data/general/objects/egos/amulets.lua
@@ -100,12 +100,16 @@ newEntity{
 	rarity = 6,
 	cost = 2,
 	wielder = {},
-	resolvers.generic(function(e)
+	resolvers.genericlast(function(e)
 		local tts = {}
 		local p = game:getPlayer(true)
 		for i, def in ipairs(engine.interface.ActorTalents.talents_types_def) do
-			if p and def.allow_random and p:knowTalentType(def.type) or p:knowTalentType(def.type) == false then tts[#tts+1] = def.type end
-		end
+            if p and def.allow_random and p:knowTalentType(def.type) or p:knowTalentType(def.type) == false then 
+                if not (e.power_source.antimagic and def.is_spell) or (e.power_source.arcane and def.is_antimagic) then
+                    tts[#tts+1] = def.type
+                end
+            end
+        end
 		local tt = tts[rng.range(1, #tts)]
 
 		e.wielder.talents_types_mastery = {}
@@ -533,12 +537,16 @@ newEntity{
 	greater_ego = 1,
 	cost = 2,
 	wielder = {},
-	resolvers.generic(function(e)
+	resolvers.genericlast(function(e)
 		local tts = {}
 		local p = game:getPlayer(true)
 		for i, def in ipairs(engine.interface.ActorTalents.talents_types_def) do
-			if p and def.allow_random and p:knowTalentType(def.type) or p:knowTalentType(def.type) == false then tts[#tts+1] = def.type end
-		end
+            if p and def.allow_random and p:knowTalentType(def.type) or p:knowTalentType(def.type) == false then 
+                if not (e.power_source.antimagic and def.is_spell) or (e.power_source.arcane and def.is_antimagic) then
+                    tts[#tts+1] = def.type
+                end
+            end
+        end
 		--local tt = tts[rng.range(1, #tts)]
 		local tt = rng.tableRemove(tts)
 		local tt2 = rng.tableRemove(tts)
-- 
GitLab