@@ -72,6 +72,9 @@ public sealed class BotConfig {
7272 [ PublicAPI ]
7373 public const byte DefaultHoursUntilCardDrops = 3 ;
7474
75+ [ PublicAPI ]
76+ public const string ? DefaultMachineName = null ;
77+
7578 [ PublicAPI ]
7679 public const EPersonaStateFlag DefaultOnlineFlags = 0 ;
7780
@@ -237,6 +240,9 @@ public WebProxy? WebProxy {
237240 [ JsonInclude ]
238241 public ImmutableHashSet < EAssetType > LootableTypes { get ; init ; } = DefaultLootableTypes ;
239242
243+ [ JsonInclude ]
244+ public string ? MachineName { get ; init ; } = DefaultMachineName ;
245+
240246 [ JsonDisallowNull ]
241247 [ JsonInclude ]
242248 public ImmutableHashSet < EAssetType > MatchableTypes { get ; init ; } = DefaultMatchableTypes ;
@@ -409,6 +415,9 @@ public BotConfig() { }
409415 [ UsedImplicitly ]
410416 public bool ShouldSerializeLootableTypes ( ) => ! Saving || ( ( LootableTypes != DefaultLootableTypes ) && ! LootableTypes . SetEquals ( DefaultLootableTypes ) ) ;
411417
418+ [ UsedImplicitly ]
419+ public bool ShouldSerializeMachineName ( ) => ! Saving || ( MachineName != DefaultMachineName ) ;
420+
412421 [ UsedImplicitly ]
413422 public bool ShouldSerializeMatchableTypes ( ) => ! Saving || ( ( MatchableTypes != DefaultMatchableTypes ) && ! MatchableTypes . SetEquals ( DefaultMatchableTypes ) ) ;
414423
@@ -490,6 +499,28 @@ public static async Task<bool> Write(string filePath, BotConfig botConfig) {
490499 return ( false , Strings . FormatErrorConfigPropertyInvalid ( nameof ( BotBehaviour ) , BotBehaviour ) ) ;
491500 }
492501
502+ HashSet < EAssetType > ? completeTypesToSendValidTypes = null ;
503+
504+ foreach ( EAssetType completableType in CompleteTypesToSend ) {
505+ if ( ! Enum . IsDefined ( completableType ) ) {
506+ return ( false , Strings . FormatErrorConfigPropertyInvalid ( nameof ( CompleteTypesToSend ) , completableType ) ) ;
507+ }
508+
509+ if ( completeTypesToSendValidTypes == null ) {
510+ SwaggerValidValuesAttribute ? completeTypesToSendValidValues = typeof ( BotConfig ) . GetProperty ( nameof ( CompleteTypesToSend ) ) ? . GetCustomAttribute < SwaggerValidValuesAttribute > ( ) ;
511+
512+ if ( completeTypesToSendValidValues ? . ValidIntValues == null ) {
513+ throw new InvalidOperationException ( nameof ( completeTypesToSendValidValues ) ) ;
514+ }
515+
516+ completeTypesToSendValidTypes = completeTypesToSendValidValues . ValidIntValues . Select ( static value => ( EAssetType ) value ) . ToHashSet ( ) ;
517+ }
518+
519+ if ( ! completeTypesToSendValidTypes . Contains ( completableType ) ) {
520+ return ( false , Strings . FormatErrorConfigPropertyInvalid ( nameof ( CompleteTypesToSend ) , completableType ) ) ;
521+ }
522+ }
523+
493524 if ( ! string . IsNullOrEmpty ( CustomGamePlayedWhileFarming ) ) {
494525 try {
495526 // Test CustomGamePlayedWhileFarming against supported format, otherwise we'll throw later when used
@@ -519,25 +550,12 @@ public static async Task<bool> Write(string filePath, BotConfig botConfig) {
519550 return ( false , Strings . FormatErrorConfigPropertyInvalid ( nameof ( LootableTypes ) , lootableType ) ) ;
520551 }
521552
522- HashSet < EAssetType > ? completeTypesToSendValidTypes = null ;
523-
524- foreach ( EAssetType completableType in CompleteTypesToSend ) {
525- if ( ! Enum . IsDefined ( completableType ) ) {
526- return ( false , Strings . FormatErrorConfigPropertyInvalid ( nameof ( CompleteTypesToSend ) , completableType ) ) ;
527- }
528-
529- if ( completeTypesToSendValidTypes == null ) {
530- SwaggerValidValuesAttribute ? completeTypesToSendValidValues = typeof ( BotConfig ) . GetProperty ( nameof ( CompleteTypesToSend ) ) ? . GetCustomAttribute < SwaggerValidValuesAttribute > ( ) ;
531-
532- if ( completeTypesToSendValidValues ? . ValidIntValues == null ) {
533- throw new InvalidOperationException ( nameof ( completeTypesToSendValidValues ) ) ;
534- }
535-
536- completeTypesToSendValidTypes = completeTypesToSendValidValues . ValidIntValues . Select ( static value => ( EAssetType ) value ) . ToHashSet ( ) ;
537- }
538-
539- if ( ! completeTypesToSendValidTypes . Contains ( completableType ) ) {
540- return ( false , Strings . FormatErrorConfigPropertyInvalid ( nameof ( CompleteTypesToSend ) , completableType ) ) ;
553+ if ( ! string . IsNullOrEmpty ( MachineName ) ) {
554+ try {
555+ // Test MachineName against supported format, otherwise we'll throw later when used
556+ string _ = string . Format ( CultureInfo . CurrentCulture , MachineName , null , null , null ) ;
557+ } catch ( FormatException e ) {
558+ return ( false , Strings . FormatErrorConfigPropertyInvalid ( nameof ( MachineName ) , e . Message ) ) ;
541559 }
542560 }
543561
0 commit comments