Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions examples/filters/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@
"eggs":
{
"enabled": true, // Filter is enabled
"min_lvl": 1, // Minimum egg level to send
"max_lvl": 8, // Maximum egg level to send
"levels": [1, 2, 3, 4, 5, 6, 7, 8], // Raid levels to send
"only_ex": false, // Only send ex-eligible raids.
"team": "All", // All, Valor, Mystic, Instinct, Neutral
"power_level": {
Expand All @@ -74,8 +73,7 @@
"pokemon": [], // Raid bosses to include or none for all.
"forms": ["Alola","Galar"], // List of forms for the filter or empty for all
"costumes": ["Detective","Holiday"], // List of costumes for the filter or empty for all
"min_lvl": 1, // Minimum raid level to send
"max_lvl": 8, // Maximum raid level to send
"levels": [1, 2, 3, 4, 5, 6, 7, 8], // Raid levels to send
"type": "Include", // Include or Exclude the `pokemon` list
"only_ex": false, // Only send ex-eligible raids.
"team": "All", // All, Valor, Mystic, Instinct, Nuetral
Expand Down
6 changes: 2 additions & 4 deletions examples/filters/ex_raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"eggs":
{
"enabled": true,
"min_lvl": 1,
"max_lvl": 8,
"levels": [1, 2, 3, 4, 5, 6, 7, 8],
"only_ex": true
},
"raids":
{
"enabled": true,
"min_lvl": 1,
"max_lvl": 8,
"levels": [1, 2, 3, 4, 5, 6, 7, 8],
"pokemon": [],
"type": "Include",
"only_ex": true,
Expand Down
6 changes: 2 additions & 4 deletions examples/filters/legendary_raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
"eggs":
{
"enabled": true,
"min_lvl": 5,
"max_lvl": 5
"levels": [5, 7, 8]
},
"raids":
{
"enabled": true,
"min_lvl": 5,
"max_lvl": 5,
"levels": [5, 7, 8],
"pokemon": [],
"type": "Include",
"ignore_missing": false
Expand Down
3 changes: 1 addition & 2 deletions examples/filters/mawile_raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"raids":
{
"enabled": true,
"min_lvl": 1,
"max_lvl": 5,
"levels": [1, 2, 3, 4, 5, 6, 7, 8],
"pokemon": [303],
"type": "Include",
"onlyEx": false,
Expand Down
6 changes: 2 additions & 4 deletions examples/filters/mega_raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
"eggs":
{
"enabled": true,
"min_lvl": 6,
"max_lvl": 6
"levels": [6]
},
"raids":
{
"enabled": true,
"min_lvl": 6,
"max_lvl": 6,
"levels": [6],
"pokemon": [],
"type": "Include",
"ignore_missing": false
Expand Down
6 changes: 2 additions & 4 deletions examples/filters/raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
"eggs":
{
"enabled": true,
"min_lvl": 1,
"max_lvl": 4
"levels": [1, 2, 3, 4]
},
"raids":
{
"enabled": true,
"min_lvl": 1,
"max_lvl": 4,
"levels": [1, 2, 3, 4],
"pokemon": [],
"type": "Include",
"ignore_missing": false
Expand Down
3 changes: 1 addition & 2 deletions examples/filters/shinx_raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"raids":
{
"enabled": true,
"min_lvl": 1,
"max_lvl": 5,
"levels": [1, 2, 3, 4, 5, 6, 7, 8],
"pokemon": [403],
"type": "Include",
"only_ex": false,
Expand Down
3 changes: 1 addition & 2 deletions examples/filters/shiny_raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"raids":
{
"enabled": true,
"min_lvl": 1,
"max_lvl": 8,
"levels": [1, 2, 3, 4, 5, 6, 7, 8],
"pokemon": [1,4,7,10,25,26,27,32,58,74,77,81,88,90,92,96,98,104,105,127,129,133,138,140,142,144,145,146,147,152,155,158,177,179,191,198,200,204,209,225,228,249,250,261,278,296,302,303,307,315,320,333,353,355,359,361,370,374,403,425],
"type": "Include",
"only_ex": false,
Expand Down
10 changes: 4 additions & 6 deletions examples/filters/ultra_beast_raids.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@
"eggs":
{
"enabled": true,
"min_lvl": 7,
"max_lvl": 8,
"only_ex": true
"levels": [7, 8],
"only_ex": false
},
"raids":
{
"enabled": true,
"min_lvl": 7,
"max_lvl": 8,
"levels": [7, 8],
"pokemon": [],
"type": "Include",
"only_ex": true,
"only_ex": false,
"ignore_missing": false
}
}
9 changes: 9 additions & 0 deletions src/Defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ public class Defaults
[JsonPropertyName("pvp")]
public IReadOnlyDictionary<PvpLeague, PvpLeagueFilter> Pvp { get; set; }


// Default raid/egg settings
[JsonPropertyName("min_raid_level")]
public ushort MinimumRaidLevel { get; set; }

[JsonPropertyName("max_raid_level")]
public ushort MaximumRaidLevel { get; set; }


// Webhook and subscription queue settings
[JsonPropertyName("max_queue_batch_size")]
public ushort MaximumQueueBatchSize { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Alarms/AlarmControllerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void ProcessRaidAlarms(RaidData raid)
continue;
}

if (!(raid.Level >= alarm.Filters.Eggs.MinimumLevel && raid.Level <= alarm.Filters.Eggs.MaximumLevel))
if (!alarm.Filters.Eggs.Levels.Contains(raid.Level))
{
//_logger.LogDebug($"[{alarm.Name}] [{geofence.Name}] Skipping level {raid.Level} raid egg: '{raid.Level}' does not meet the MinimumLevel={alarm.Filters.Eggs.MinimumLevel} and MaximumLevel={alarm.Filters.Eggs.MaximumLevel} filters.");
continue;
Expand Down Expand Up @@ -283,7 +283,7 @@ public void ProcessRaidAlarms(RaidData raid)
continue;
}

if (!(raid.Level >= alarm.Filters.Raids.MinimumLevel && raid.Level <= alarm.Filters.Raids.MaximumLevel))
if (!alarm.Filters.Raids.Levels.Contains(raid.Level))
{
//_logger.LogDebug($"[{alarm.Name}] [{geofence.Name}] Skipping level {raid.Level} raid {raid.PokemonId}: '{raid.Level}' does not meet the MinimumLevel={alarm.Filters.Raids.MinimumLevel} and MaximumLevel={alarm.Filters.Raids.MaximumLevel} filters.");
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

public interface IWebhookFilterPokemonDetails
{
List<uint> Pokemon { get; }
IReadOnlyList<uint> Pokemon { get; }

List<string> Forms { get; }
IReadOnlyList<string> Forms { get; }

List<string> Costumes { get; }
IReadOnlyList<string> Costumes { get; }

FilterType FilterType { get; }
}
Expand Down
21 changes: 9 additions & 12 deletions src/Services/Alarms/Filters/Models/WebhookFilterEgg.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace WhMgr.Services.Alarms.Filters.Models
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;

using WhMgr.Common;
Expand All @@ -16,16 +19,10 @@ public class WebhookFilterEgg
public bool Enabled { get; set; }

/// <summary>
/// Minimum raid egg level
/// List of raid egg levels
/// </summary>
[JsonPropertyName("min_lvl")]
public uint MinimumLevel { get; set; }

/// <summary>
/// Maximum raid egg level
/// </summary>
[JsonPropertyName("max_lvl")]
public uint MaximumLevel { get; set; }
[JsonPropertyName("levels")]
public IReadOnlyList<ushort> Levels { get; set; }

/// <summary>
/// Only ex-eligible raids
Expand All @@ -50,9 +47,9 @@ public class WebhookFilterEgg
/// </summary>
public WebhookFilterEgg()
{
MinimumLevel = 1;
MaximumLevel = 8;

Levels = Enumerable.Range(Strings.Defaults.MinimumRaidLevel, Strings.Defaults.MaximumRaidLevel)
.Select(Convert.ToUInt16)
.ToList();
Team = PokemonTeam.All;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Services/Alarms/Filters/Models/WebhookFilterPokemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ public class WebhookFilterPokemon : IWebhookFilterPokemonDetails
/// Gets or sets the list of pokemon pokedex IDs to filter against
/// </summary>
[JsonPropertyName("pokemon")]
public List<uint> Pokemon { get; set; }
public IReadOnlyList<uint> Pokemon { get; set; }

/// <summary>
/// Gets or sets the list of pokemon Form strings to filter against
/// </summary>
[JsonPropertyName("forms")]
public List<string> Forms { get; set; }
public IReadOnlyList<string> Forms { get; set; }

/// <summary>
/// Gets or sets the list of Pokemon costume strings to filter against
/// </summary>
[JsonPropertyName("costumes")]
public List<string> Costumes { get; set; }
public IReadOnlyList<string> Costumes { get; set; }

/// <summary>
/// Gets or sets the minimum IV value to report
Expand Down Expand Up @@ -86,7 +86,7 @@ public class WebhookFilterPokemon : IWebhookFilterPokemonDetails
/// Gets or sets the Pokemon eligible PvP ranking filtering
/// </summary>
[JsonPropertyName("pvp")]
public Dictionary<PvpLeague, WebhookFilterPokemonPvp> Pvp { get; set; }
public IReadOnlyDictionary<PvpLeague, WebhookFilterPokemonPvp> Pvp { get; set; }

/// <summary>
/// Gets or sets a value determining if webhook Pokemon filter has PvP ranking filters
Expand Down
27 changes: 12 additions & 15 deletions src/Services/Alarms/Filters/Models/WebhookFilterRaid.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace WhMgr.Services.Alarms.Filters.Models
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;

using WhMgr.Common;
Expand All @@ -17,34 +19,28 @@ public class WebhookFilterRaid : IWebhookFilterPokemonDetails
public bool Enabled { get; set; }

/// <summary>
/// Gets or sets the minimum raid level
/// List of raid levels
/// </summary>
[JsonPropertyName("min_lvl")]
public uint MinimumLevel { get; set; }

/// <summary>
/// Gets or sets the maximum raid level
/// </summary>
[JsonPropertyName("max_lvl")]
public uint MaximumLevel { get; set; }
[JsonPropertyName("levels")]
public IReadOnlyList<ushort> Levels { get; set; }

/// <summary>
/// Gets or sets the Raid boss pokedex ID list to filter against
/// </summary>
[JsonPropertyName("pokemon")]
public List<uint> Pokemon { get; set; }
public IReadOnlyList<uint> Pokemon { get; set; }

/// <summary>
/// Gets or sets the list of Raid Boss Pokemon Form strings to filter against
/// </summary>
[JsonPropertyName("forms")]
public List<string> Forms { get; set; }
public IReadOnlyList<string> Forms { get; set; }

/// <summary>
/// Gets or sets the list of Raid Boss Pokemon costume strings to filter against
/// </summary>
[JsonPropertyName("costumes")]
public List<string> Costumes { get; set; }
public IReadOnlyList<string> Costumes { get; set; }

/// <summary>
/// Gets or sets the Raid boss filter type
Expand Down Expand Up @@ -77,15 +73,16 @@ public class WebhookFilterRaid : IWebhookFilterPokemonDetails
public bool IgnoreMissing { get; set; }

/// <summary>
/// Instantiate a new <see cref="FilterRaidObject"/> class
/// Instantiate a new <see cref="WebhookFilterRaid"/> class
/// </summary>
public WebhookFilterRaid()
{
Pokemon = new List<uint>();
Forms = new List<string>();
Costumes = new List<string>();
MinimumLevel = 1;
MaximumLevel = 8;
Levels = Enumerable.Range(Strings.Defaults.MinimumRaidLevel, Strings.Defaults.MaximumRaidLevel)
.Select(Convert.ToUInt16)
.ToList();
Team = PokemonTeam.All;
}
}
Expand Down
2 changes: 2 additions & 0 deletions static/data/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"max_league_cp": 2500,
}
},
"min_raid_level": 1,
"max_raid_level": 8,
"max_queue_batch_size": 25,
"max_queue_size_warning": 50,
"max_queue_capacity": 4096,
Expand Down
8 changes: 4 additions & 4 deletions test/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
{
using System;
using System.IO;

using System.Linq;
using NUnit.Framework;

using WhMgr.Services;
using WhMgr.Services.Subscriptions.Models;
using WhMgr.Utilities;

[TestFixture]
Expand All @@ -23,9 +22,10 @@ public void Setup()
}

[Test]
public void Test1()
public void Test_RaidLevel_Generate()
{
Assert.Pass();
var levels = Enumerable.Range(1, 8).Select(Convert.ToUInt16).ToList();
Assert.IsTrue(levels.Count == 8);
}

[TestCase]
Expand Down