Skip to content

Commit 0532e4f

Browse files
committed
Update JamlConfig.cs
1 parent bed4a2c commit 0532e4f

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

Motely/filters/JamlConfig.cs

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public sealed class JamlClauseSet
1515
public List<CommonJokerClause> CommonJokers { get; set; } = [];
1616
public List<UncommonJokerClause> UncommonJokers { get; set; } = [];
1717
public List<RareJokerClause> RareJokers { get; set; } = [];
18+
public List<MixedJokerClause> MixedJokers { get; set; } = [];
1819
public List<LegendaryJokerClause> LegendaryJokers { get; set; } = [];
1920
public List<VoucherClause> Vouchers { get; set; } = [];
2021
public List<TarotCardClause> TarotCards { get; set; } = [];
@@ -36,7 +37,7 @@ public sealed class JamlClauseSet
3637

3738
public bool HasAnyClauses =>
3839
Jokers.Count > 0 || CommonJokers.Count > 0 || UncommonJokers.Count > 0 ||
39-
RareJokers.Count > 0 || LegendaryJokers.Count > 0 ||
40+
RareJokers.Count > 0 || MixedJokers.Count > 0 || LegendaryJokers.Count > 0 ||
4041
Vouchers.Count > 0 || TarotCards.Count > 0 || SpectralCards.Count > 0 ||
4142
PlanetCards.Count > 0 || StandardCards.Count > 0 ||
4243
Bosses.Count > 0 || Tags.Count > 0 ||
@@ -300,6 +301,7 @@ private static void AddClauseToSet(JamlClauseSet set, IJamlClause clause)
300301
case CommonJokerClause c: set.CommonJokers.Add(c); break;
301302
case UncommonJokerClause c: set.UncommonJokers.Add(c); break;
302303
case RareJokerClause c: set.RareJokers.Add(c); break;
304+
case MixedJokerClause c: set.MixedJokers.Add(c); break;
303305
case LegendaryJokerClause c: set.LegendaryJokers.Add(c); break;
304306
case VoucherClause c: set.Vouchers.Add(c); break;
305307
case TarotCardClause c: set.TarotCards.Add(c); break;
@@ -329,18 +331,21 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
329331
{
330332
var antes = c.Antes ?? defaultAntes;
331333
int min = c.Min ?? 1;
334+
int score = c.Score ?? 1;
332335

333336
if (c.And != null)
334337
{
335338
return new AndClause
336339
{
340+
Score = score,
337341
Clauses = c.And.Select(sub => CreateClauseFromDto(sub, [], defaults)).ToArray()
338342
};
339343
}
340344
if (c.Or != null)
341345
{
342346
return new OrClause
343347
{
348+
Score = score,
344349
Min = min,
345350
Clauses = c.Or.Select(sub => CreateClauseFromDto(sub, [], defaults)).ToArray()
346351
};
@@ -369,7 +374,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
369374
{
370375
MotelyFilterItemType.Joker => new JokerClause
371376
{
372-
Label = label, Antes = antes, Min = min,
377+
Label = label, Score = score, Antes = antes, Min = min,
373378
Jokers = value != null
374379
? [Enum.Parse<MotelyJoker>(value, true)]
375380
: c.Jokers?.Select(j => Enum.Parse<MotelyJoker>(j, true)).ToArray() ?? [],
@@ -388,7 +393,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
388393
},
389394
MotelyFilterItemType.CommonJoker => new CommonJokerClause
390395
{
391-
Label = label, Antes = antes, Min = min,
396+
Label = label, Score = score, Antes = antes, Min = min,
392397
Jokers = value != null
393398
? [Enum.Parse<MotelyJokerCommon>(value, true)]
394399
: (c.CommonJokers ?? c.Jokers)?.Select(j => Enum.Parse<MotelyJokerCommon>(j, true)).ToArray() ?? [],
@@ -407,7 +412,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
407412
},
408413
MotelyFilterItemType.UncommonJoker => new UncommonJokerClause
409414
{
410-
Label = label, Antes = antes, Min = min,
415+
Label = label, Score = score, Antes = antes, Min = min,
411416
Jokers = value != null
412417
? [Enum.Parse<MotelyJokerUncommon>(value, true)]
413418
: (c.UncommonJokers ?? c.Jokers)?.Select(j => Enum.Parse<MotelyJokerUncommon>(j, true)).ToArray() ?? [],
@@ -426,7 +431,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
426431
},
427432
MotelyFilterItemType.RareJoker => new RareJokerClause
428433
{
429-
Label = label, Antes = antes, Min = min,
434+
Label = label, Score = score, Antes = antes, Min = min,
430435
Jokers = value != null
431436
? [Enum.Parse<MotelyJokerRare>(value, true)]
432437
: (c.RareJokers ?? c.Jokers)?.Select(j => Enum.Parse<MotelyJokerRare>(j, true)).ToArray() ?? [],
@@ -445,7 +450,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
445450
},
446451
MotelyFilterItemType.MixedJoker => new MixedJokerClause
447452
{
448-
Label = label, Antes = antes, Min = min,
453+
Label = label, Score = score, Antes = antes, Min = min,
449454
Jokers = value != null
450455
? [Enum.Parse<MotelyJoker>(value, true)]
451456
: (c.MixedJokers ?? c.Jokers)?.Select(j => Enum.Parse<MotelyJoker>(j, true)).ToArray() ?? [],
@@ -464,7 +469,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
464469
},
465470
MotelyFilterItemType.SoulJoker => new LegendaryJokerClause
466471
{
467-
Label = label, Antes = antes, Min = min,
472+
Label = label, Score = score, Antes = antes, Min = min,
468473
Jokers = value != null
469474
? [Enum.Parse<MotelyJoker>(value, true)]
470475
: c.Jokers?.Select(j => Enum.Parse<MotelyJoker>(j, true)).ToArray() ?? [],
@@ -477,14 +482,14 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
477482
},
478483
MotelyFilterItemType.Voucher => new VoucherClause
479484
{
480-
Label = label, Antes = antes, Min = min,
485+
Label = label, Score = score, Antes = antes, Min = min,
481486
Vouchers = value != null
482487
? [Enum.Parse<MotelyVoucher>(value, true)]
483488
: c.Vouchers?.Select(v => Enum.Parse<MotelyVoucher>(v, true)).ToArray() ?? [],
484489
},
485490
MotelyFilterItemType.TarotCard => new TarotCardClause
486491
{
487-
Label = label, Antes = antes, Min = min,
492+
Label = label, Score = score, Antes = antes, Min = min,
488493
Tarots = value != null ? [Enum.Parse<MotelyTarotCard>(value, true)] : [],
489494
Sources = new TarotCardSourceConfig
490495
{
@@ -495,7 +500,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
495500
},
496501
MotelyFilterItemType.SpectralCard => new SpectralCardClause
497502
{
498-
Label = label, Antes = antes, Min = min,
503+
Label = label, Score = score, Antes = antes, Min = min,
499504
Spectrals = value != null ? [Enum.Parse<MotelySpectralCard>(value, true)] : [],
500505
Sources = new SpectralCardSourceConfig
501506
{
@@ -506,7 +511,7 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
506511
},
507512
MotelyFilterItemType.PlanetCard => new PlanetCardClause
508513
{
509-
Label = label, Antes = antes, Min = min,
514+
Label = label, Score = score, Antes = antes, Min = min,
510515
Planets = value != null ? [Enum.Parse<MotelyPlanetCard>(value, true)] : [],
511516
Sources = new PlanetSourceConfig
512517
{
@@ -515,24 +520,24 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
515520
},
516521
MotelyFilterItemType.Boss => new BossClause
517522
{
518-
Label = label, Antes = antes, Min = min,
523+
Label = label, Score = score, Antes = antes, Min = min,
519524
Bosses = value != null ? [Enum.Parse<MotelyBossBlind>(value, true)] : [],
520525
},
521526
MotelyFilterItemType.SmallBlindTag => new TagClause
522527
{
523-
Label = label, Antes = antes, Min = min,
528+
Label = label, Score = score, Antes = antes, Min = min,
524529
Tags = value != null ? [Enum.Parse<MotelyTag>(value, true)] : [],
525530
Position = TagPosition.SmallBlind,
526531
},
527532
MotelyFilterItemType.BigBlindTag => new TagClause
528533
{
529-
Label = label, Antes = antes, Min = min,
534+
Label = label, Score = score, Antes = antes, Min = min,
530535
Tags = value != null ? [Enum.Parse<MotelyTag>(value, true)] : [],
531536
Position = TagPosition.BigBlind,
532537
},
533538
MotelyFilterItemType.PlayingCard => new StandardCardClause
534539
{
535-
Label = label, Antes = antes, Min = min,
540+
Label = label, Score = score, Antes = antes, Min = min,
536541
Rank = ParseEnum<MotelyPlayingCardRank>(c.Rank),
537542
Suit = ParseEnum<MotelyPlayingCardSuit>(c.Suit),
538543
Enhancement = ParseEnum<MotelyItemEnhancement>(c.Enhancement),
@@ -548,29 +553,29 @@ private static IJamlClause CreateClauseFromDto(JamlClauseDto c, int[] defaultAnt
548553
},
549554
MotelyFilterItemType.ErraticRank => new ErraticRankClause
550555
{
551-
Label = label, Antes = antes, Min = min,
556+
Label = label, Score = score, Antes = antes, Min = min,
552557
Rank = ParseEnum<MotelyPlayingCardRank>(c.Rank ?? value)
553558
?? throw new NotSupportedException("ErraticRank clause requires a rank value."),
554559
},
555560
MotelyFilterItemType.ErraticSuit => new ErraticSuitClause
556561
{
557-
Label = label, Antes = antes, Min = min,
562+
Label = label, Score = score, Antes = antes, Min = min,
558563
Suit = ParseEnum<MotelyPlayingCardSuit>(c.Suit ?? value)
559564
?? throw new NotSupportedException("ErraticSuit clause requires a suit value."),
560565
},
561-
MotelyFilterItemType.ErraticCard => CreateErraticCardClause(c, value, antes, min),
566+
MotelyFilterItemType.ErraticCard => CreateErraticCardClause(c, value, antes, min, score),
562567
MotelyFilterItemType.StartingDraw => new StartingDrawClause
563568
{
564-
Label = label, Antes = antes, Min = min,
569+
Label = label, Score = score, Antes = antes, Min = min,
565570
Rank = ParseEnum<MotelyPlayingCardRank>(c.Rank),
566571
Suit = ParseEnum<MotelyPlayingCardSuit>(c.Suit),
567572
},
568-
MotelyFilterItemType.Event => CreateEventClause(c.Event, c.Rolls, antes, min),
573+
MotelyFilterItemType.Event => CreateEventClause(c.Event, c.Rolls, antes, min, score),
569574
_ => throw new NotSupportedException($"Unsupported clause type: {itemType}"),
570575
};
571576
}
572577

573-
private static ErraticCardClause CreateErraticCardClause(JamlClauseDto c, string? value, int[] antes, int min)
578+
private static ErraticCardClause CreateErraticCardClause(JamlClauseDto c, string? value, int[] antes, int min, int score)
574579
{
575580
var rank = ParseEnum<MotelyPlayingCardRank>(c.Rank ?? value);
576581
var suit = ParseEnum<MotelyPlayingCardSuit>(c.Suit ?? value);
@@ -579,7 +584,7 @@ private static ErraticCardClause CreateErraticCardClause(JamlClauseDto c, string
579584
{
580585
return new ErraticCardClause
581586
{
582-
Antes = antes, Min = min,
587+
Score = score, Antes = antes, Min = min,
583588
Rank = rank.Value,
584589
Suit = suit.Value,
585590
};
@@ -599,20 +604,20 @@ private static ErraticCardClause CreateErraticCardClause(JamlClauseDto c, string
599604
throw new NotSupportedException("ErraticCard clause requires rank and suit.");
600605
}
601606

602-
private static IRollClause CreateEventClause(string? eventName, int[]? rolls, int[] antes, int min)
607+
private static IRollClause CreateEventClause(string? eventName, int[]? rolls, int[] antes, int min, int score)
603608
{
604609
if (string.IsNullOrEmpty(eventName))
605610
throw new NotSupportedException("Event clause is missing event type name.");
606611

607612
var r = rolls ?? [];
608613
return Enum.Parse<MotelyEventType>(eventName, true) switch
609614
{
610-
MotelyEventType.LuckyMoney => new LuckyMoneyClause { Antes = antes, Min = min, Rolls = r },
611-
MotelyEventType.LuckyMult => new LuckyMultClause { Antes = antes, Min = min, Rolls = r },
612-
MotelyEventType.MisprintMult => new MisprintMultClause { Antes = antes, Min = min, Rolls = r },
613-
MotelyEventType.WheelOfFortune => new WheelOfFortuneClause { Antes = antes, Min = min, Rolls = r },
614-
MotelyEventType.CavendishExtinct => new CavendishExtinctClause { Antes = antes, Min = min, Rolls = r },
615-
MotelyEventType.GrosMichelExtinct => new GrosMichelExtinctClause { Antes = antes, Min = min, Rolls = r },
615+
MotelyEventType.LuckyMoney => new LuckyMoneyClause { Score = score, Antes = antes, Min = min, Rolls = r },
616+
MotelyEventType.LuckyMult => new LuckyMultClause { Score = score, Antes = antes, Min = min, Rolls = r },
617+
MotelyEventType.MisprintMult => new MisprintMultClause { Score = score, Antes = antes, Min = min, Rolls = r },
618+
MotelyEventType.WheelOfFortune => new WheelOfFortuneClause { Score = score, Antes = antes, Min = min, Rolls = r },
619+
MotelyEventType.CavendishExtinct => new CavendishExtinctClause { Score = score, Antes = antes, Min = min, Rolls = r },
620+
MotelyEventType.GrosMichelExtinct => new GrosMichelExtinctClause { Score = score, Antes = antes, Min = min, Rolls = r },
616621
_ => throw new NotSupportedException($"Unsupported event type: {eventName}")
617622
};
618623
}

0 commit comments

Comments
 (0)