1010
1111namespace UncomplicatedEscapeZones . Managers ;
1212
13- public class EscapeManager
13+ public static class EscapeManager
1414{
1515 public static KeyValuePair < bool , object ? > ? ParseEscapeRole (
1616 Dictionary < string , List < Dictionary < string , string > > > roleAfterEscape , Player player )
@@ -34,10 +34,12 @@ public class EscapeManager
3434 List < Dictionary < string , string > > ? entries = ResolveEntries (
3535 roleAfterEscape ,
3636 $ "InternalTeam { playerTeamKey } ",
37- $ "IT { playerRoleKey } ",
37+ $ "IT { playerTeamKey } ",
3838 $ "InternalFaction { playerFactionKey } ",
3939 $ "IF { playerFactionKey } ",
40- playerRoleKey ) ;
40+ $ "InternalRole { playerRoleKey } ",
41+ $ "IR { playerRoleKey } ",
42+ "all" ) ;
4143
4244 if ( UCR . TryGetSummonedCustomRole ( player , out object summonedPlayer ) )
4345 {
@@ -48,7 +50,8 @@ public class EscapeManager
4850 List < Dictionary < string , string > > ? customEntries = ResolveEntries (
4951 roleAfterEscape ,
5052 $ "CustomRole { customRoleId } ",
51- $ "CR { customRoleId } ") ;
53+ $ "CR { customRoleId } ",
54+ "all" ) ;
5255 if ( customEntries is not null )
5356 {
5457 LogManager . Debug ( $ "Found { customEntries . Count } RoleAfterEscape entries for custom role '{ customRoleId } '.") ;
@@ -72,6 +75,7 @@ public class EscapeManager
7275 Dictionary < int , KeyValuePair < bool , object ? > ? > asCuffedByCustomRole = new ( ) ;
7376
7477 KeyValuePair < bool , object ? > ? defaultValue = new KeyValuePair < bool , object ? > ( false , null ) ;
78+ KeyValuePair < bool , object ? > ? defaultCuffedValue = new KeyValuePair < bool , object ? > ( false , null ) ;
7579
7680 // Flatten and parse all condition/value pairs for this role
7781 foreach ( Dictionary < string , string > dict in entries )
@@ -99,20 +103,34 @@ public class EscapeManager
99103
100104 LogManager . Debug ( $ "Parsing escape condition: { kvp . Key } -> { kvp . Value } ") ;
101105
102- switch ( elements [ 2 ] )
106+ switch ( elements [ 2 ] . ToLowerInvariant ( ) )
103107 {
104- case "InternalFaction" or "IF" when Enum . TryParse ( elements [ 3 ] , out Faction faction ) :
105- asCuffedByInternalFaction . TryAdd ( faction , data ) ;
108+ case "internalfaction" or "if" :
109+ if ( Enum . TryParse ( elements [ 3 ] , true , out Faction faction ) )
110+ asCuffedByInternalFaction . TryAdd ( faction , data ) ;
111+ else
112+ LogManager . Warn ( $ "Failed to parse faction '{ elements [ 3 ] } ' for escape condition '{ kvp . Key } '.") ;
106113 break ;
107- case "InternalTeam" or "IT" when Enum . TryParse ( elements [ 3 ] , out Team team ) :
108- asCuffedByInternalTeam . TryAdd ( team , data ) ;
114+ case "internalteam" or "it" :
115+ if ( Enum . TryParse ( elements [ 3 ] , true , out Team team ) )
116+ asCuffedByInternalTeam . TryAdd ( team , data ) ;
117+ else
118+ LogManager . Warn ( $ "Failed to parse team '{ elements [ 3 ] } ' for escape condition '{ kvp . Key } '.") ;
109119 break ;
110- case "InternalRole" or "IR" when Enum . TryParse ( elements [ 3 ] , out RoleTypeId id ) :
111- asCuffedByInternalRole . TryAdd ( id , data ) ;
120+ case "internalrole" or "ir" :
121+ if ( Enum . TryParse ( elements [ 3 ] , true , out RoleTypeId id ) )
122+ asCuffedByInternalRole . TryAdd ( id , data ) ;
123+ else
124+ LogManager . Warn ( $ "Failed to parse role '{ elements [ 3 ] } ' for escape condition '{ kvp . Key } '.") ;
112125 break ;
113- case "CustomRole" or "CR"
114- when int . TryParse ( elements [ 3 ] , out int id ) && UCR . TryGetCustomRole ( id , out _ ) :
115- asCuffedByCustomRole . TryAdd ( id , data ) ;
126+ case "customrole" or "cr" :
127+ if ( int . TryParse ( elements [ 3 ] , out int cid ) && UCR . TryGetCustomRole ( cid , out _ ) )
128+ asCuffedByCustomRole . TryAdd ( cid , data ) ;
129+ else
130+ LogManager . Warn ( $ "Failed to parse custom role id '{ elements [ 3 ] } ' for escape condition '{ kvp . Key } '.") ;
131+ break ;
132+ case "all" :
133+ defaultCuffedValue = data ;
116134 break ;
117135 default :
118136 {
@@ -152,6 +170,12 @@ when int.TryParse(elements[3], out int id) && UCR.TryGetCustomRole(id, out _):
152170
153171 if ( asCuffedByInternalFaction . TryGetValue ( player . DisarmedBy . Faction , out KeyValuePair < bool , object ? > ? factionValue ) && factionValue is not null )
154172 return factionValue ;
173+
174+ if ( defaultCuffedValue is not null )
175+ {
176+ LogManager . Debug ( $ "Applying default 'cuffed by all' escape outcome for player { player . PlayerId } .") ;
177+ return defaultCuffedValue ;
178+ }
155179 }
156180
157181 LogManager . Debug (
0 commit comments