Skip to content

Commit

Permalink
Update protos (#113)
Browse files Browse the repository at this point in the history
* Update protos

* Use generic PokemonType enum for serialization
  • Loading branch information
versx authored Dec 28, 2020
1 parent 64f5cd6 commit d1d244e
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/Alarms/Filters/Filters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
using System;

using POGOProtos.Enums;
using Gender = POGOProtos.Rpc.PokemonDisplayProto.Types.Gender;

using WhMgr.Diagnostics;
using WhMgr.Net.Models;
Expand Down
4 changes: 2 additions & 2 deletions src/Alarms/Filters/Models/FilterWeatherObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;

using Newtonsoft.Json;
using POGOProtos.Map.Weather;
using WeatherCondition = POGOProtos.Rpc.GameplayWeatherProto.Types.WeatherCondition;

/// <summary>
/// Weather filters
Expand All @@ -21,6 +21,6 @@ public class FilterWeatherObject
/// Filter by in-game weather type
/// </summary>
[JsonProperty("types")]
public List<GameplayWeather.Types.WeatherCondition> WeatherTypes { get; set; }
public List<WeatherCondition> WeatherTypes { get; set; }
}
}
1 change: 0 additions & 1 deletion src/Commands/Nests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using POGOProtos.Enums;
using ServiceStack;
using ServiceStack.OrmLite;

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/Notifications.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ namespace WhMgr.Commands
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Newtonsoft.Json;
using POGOProtos.Enums;

using WhMgr.Commands.Input;
using WhMgr.Data;
using WhMgr.Data.Models;
using WhMgr.Data.Subscriptions;
using WhMgr.Data.Subscriptions.Models;
using WhMgr.Diagnostics;
Expand Down
4 changes: 2 additions & 2 deletions src/Data/MasterFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using InvasionCharacter = POGOProtos.Enums.EnumWrapper.Types.InvasionCharacter;
using POGOProtos.Enums;
using POGOProtos.Rpc;
using InvasionCharacter = POGOProtos.Rpc.EnumWrapper.Types.InvasionCharacter;

using WhMgr.Data.Models;
using WhMgr.Diagnostics;
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Models/PokedexPokemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;

using Newtonsoft.Json;
using POGOProtos.Enums;
using POGOProtos.Rpc;

public class PokedexPokemon
{
Expand Down
10 changes: 10 additions & 0 deletions src/Data/Models/PokemonGender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace WhMgr.Data.Models
{
public enum PokemonGender
{
}
}
29 changes: 29 additions & 0 deletions src/Data/Models/PokemonType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace WhMgr.Data.Models
{
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

[JsonConverter(typeof(StringEnumConverter))]
public enum PokemonType
{
None = 0,
Normal = 1,
Fighting = 2,
Flying = 3,
Poison = 4,
Ground = 5,
Rock = 6,
Bug = 7,
Ghost = 8,
Steel = 9,
Fire = 10,
Water = 11,
Grass = 12,
Electric = 13,
Psychic = 14,
Ice = 15,
Dragon = 16,
Dark = 17,
Fairy = 18
}
}
6 changes: 3 additions & 3 deletions src/Data/Models/Pokestop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using ServiceStack.DataAnnotations;
using ServiceStack.OrmLite;
using Newtonsoft.Json;
using POGOProtos.Enums;
using POGOProtos.Inventory.Item;
using QuestRewardType = POGOProtos.Data.Quests.QuestReward.Types.Type;
using POGOProtos.Rpc;
using ItemId = POGOProtos.Rpc.Item;
using QuestRewardType = POGOProtos.Rpc.QuestRewardProto.Types.Type;

using WhMgr.Diagnostics;
using WhMgr.Net.Models;
Expand Down
19 changes: 9 additions & 10 deletions src/Extensions/DiscordExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using POGOProtos.Map.Weather;
using ServiceStack;
using WeatherCondition = POGOProtos.Rpc.GameplayWeatherProto.Types.WeatherCondition;

using WhMgr.Configuration;
using WhMgr.Diagnostics;
Expand Down Expand Up @@ -515,30 +514,30 @@ public static DiscordColor BuildLureColor(this PokestopLureType lureType, Discor
return new DiscordColor(color);
}

public static DiscordColor BuildWeatherColor(this GameplayWeather.Types.WeatherCondition weather, DiscordServerConfig server)
public static DiscordColor BuildWeatherColor(this WeatherCondition weather, DiscordServerConfig server)
{
var color = "#808080";
switch (weather)
{
case GameplayWeather.Types.WeatherCondition.Clear:
case WeatherCondition.Clear:
color = server.DiscordEmbedColors.Weather.Clear;
break;
case GameplayWeather.Types.WeatherCondition.Overcast:
case WeatherCondition.Overcast:
color = server.DiscordEmbedColors.Weather.Cloudy;
break;
case GameplayWeather.Types.WeatherCondition.Fog:
case WeatherCondition.Fog:
color = server.DiscordEmbedColors.Weather.Fog;
break;
case GameplayWeather.Types.WeatherCondition.PartlyCloudy:
case WeatherCondition.PartlyCloudy:
color = server.DiscordEmbedColors.Weather.PartlyCloudy;
break;
case GameplayWeather.Types.WeatherCondition.Rainy:
case WeatherCondition.Rainy:
color = server.DiscordEmbedColors.Weather.Rain;
break;
case GameplayWeather.Types.WeatherCondition.Snow:
case WeatherCondition.Snow:
color = server.DiscordEmbedColors.Weather.Snow;
break;
case GameplayWeather.Types.WeatherCondition.Windy:
case WeatherCondition.Windy:
color = server.DiscordEmbedColors.Weather.Windy;
break;
}
Expand Down
9 changes: 5 additions & 4 deletions src/Extensions/PokemonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
using System.Collections.Generic;
using System.Linq;

using POGOProtos.Enums;
using POGOProtos.Map.Weather;
using POGOProtos.Rpc;
using Gender = POGOProtos.Rpc.PokemonDisplayProto.Types.Gender;
using WeatherCondition = POGOProtos.Rpc.GameplayWeatherProto.Types.WeatherCondition;

using WhMgr.Data;
using WhMgr.Data.Models;
Expand Down Expand Up @@ -129,7 +130,7 @@ public static string GetTypeEmojiIcons(this List<PokemonType> pokemonTypes)
return string.Join(" ", list);
}

public static string GetWeatherEmojiIcon(this GameplayWeather.Types.WeatherCondition weather)
public static string GetWeatherEmojiIcon(this WeatherCondition weather)
{
var key = $"weather_{Convert.ToInt32(weather)}";
var emojiId = MasterFile.Instance.Emojis[key];
Expand Down Expand Up @@ -270,7 +271,7 @@ public static PokemonValidation ValidatePokemon(this IEnumerable<string> pokemon
return new PokemonValidation { Valid = valid, Invalid = invalid };
}

public static bool IsWeatherBoosted(this PokedexPokemon pkmn, GameplayWeather.Types.WeatherCondition weather)
public static bool IsWeatherBoosted(this PokedexPokemon pkmn, WeatherCondition weather)
{
var types = pkmn?.Types;
var isBoosted = types?.Exists(x => Strings.WeatherBoosts[weather].Contains(x)) ?? false;
Expand Down
13 changes: 7 additions & 6 deletions src/Extensions/QuestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
using System.Collections.Generic;
using System.Linq;

using POGOProtos.Data;
using POGOProtos.Enums;
using QuestConditionType = POGOProtos.Data.Quests.QuestCondition.Types.ConditionType;
using QuestRewardType = POGOProtos.Data.Quests.QuestReward.Types.Type;
using CharacterCategory = POGOProtos.Enums.EnumWrapper.Types.CharacterCategory;
using POGOProtos.Rpc;
using AlignmentId = POGOProtos.Rpc.PokemonDisplayProto.Types.Alignment;
using CharacterCategory = POGOProtos.Rpc.EnumWrapper.Types.CharacterCategory;
using TemporaryEvolutionId = POGOProtos.Rpc.HoloTemporaryEvolutionId;
using QuestConditionType = POGOProtos.Rpc.QuestConditionProto.Types.ConditionType;
using QuestRewardType = POGOProtos.Rpc.QuestRewardProto.Types.Type;

using WhMgr.Data.Models;
using WhMgr.Localization;
Expand Down Expand Up @@ -96,7 +97,7 @@ public static string GetCondition(this QuestConditionMessage condition)
default:
return Translator.Instance.Translate(conditionKey);
case QuestConditionType.WithPokemonAlignment:
return string.Join(", ", condition.Info.AlignmentIds?.Select(x => Translator.Instance.GetAlignmentName((PokemonDisplay.Types.Alignment)x)));
return string.Join(", ", condition.Info.AlignmentIds?.Select(x => Translator.Instance.GetAlignmentName((AlignmentId)x)));
case QuestConditionType.WithInvasionCharacter:
return string.Join(", ", condition.Info.CharacterCategoryIds?.Select(x => Translator.Instance.GetCharacterCategoryName((CharacterCategory)x)));
case QuestConditionType.WithTempEvoPokemon: // Mega evo
Expand Down
10 changes: 5 additions & 5 deletions src/IconFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
using System.Text;

using Newtonsoft.Json;
using InvasionCharacter = POGOProtos.Enums.EnumWrapper.Types.InvasionCharacter;
using QuestRewardType = POGOProtos.Data.Quests.QuestReward.Types.Type;
using POGOProtos.Enums;
using POGOProtos.Map.Weather;
using Gender = POGOProtos.Rpc.PokemonDisplayProto.Types.Gender;
using InvasionCharacter = POGOProtos.Rpc.EnumWrapper.Types.InvasionCharacter;
using QuestRewardType = POGOProtos.Rpc.QuestRewardProto.Types.Type;
using WeatherCondition = POGOProtos.Rpc.GameplayWeatherProto.Types.WeatherCondition;
using ServiceStack;

using WhMgr.Net.Models;
Expand Down Expand Up @@ -139,7 +139,7 @@ public string GetInvasionIcon(string style, InvasionCharacter gruntType)
return _iconStyles[style] + "invasion/" + (int)gruntType + ".png";
}

public string GetWeatherIcon(string style, GameplayWeather.Types.WeatherCondition weatherType)
public string GetWeatherIcon(string style, WeatherCondition weatherType)
{
return _iconStyles[style] + "weather/" + (int)weatherType + ".png";
}
Expand Down
16 changes: 8 additions & 8 deletions src/Localization/Translator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
using System;
using System.Collections.Generic;

using CharacterCategory = POGOProtos.Enums.EnumWrapper.Types.CharacterCategory;
using POGOProtos.Data;
using POGOProtos.Enums;
using POGOProtos.Inventory.Item;
using POGOProtos.Map.Weather;
using ActivityType = POGOProtos.Rpc.HoloActivityType;
using AlignmentType = POGOProtos.Rpc.PokemonDisplayProto.Types.Alignment;
using CharacterCategory = POGOProtos.Rpc.EnumWrapper.Types.CharacterCategory;
using ItemId = POGOProtos.Rpc.Item;
using TemporaryEvolutionId = POGOProtos.Rpc.HoloTemporaryEvolutionId;
using WeatherCondition = POGOProtos.Rpc.GameplayWeatherProto.Types.WeatherCondition;

using WhMgr.Diagnostics;
using WhMgr.Net.Models;

public class Translator : Language<string, string, Dictionary<string, string>>
{
Expand Down Expand Up @@ -118,12 +118,12 @@ public string GetItem(ItemId item)
return Translate($"item_{(int)item}");
}

public string GetWeather(GameplayWeather.Types.WeatherCondition weather)
public string GetWeather(WeatherCondition weather)
{
return Translate($"weather_{(int)weather}");
}

public string GetAlignmentName(PokemonDisplay.Types.Alignment alignment)
public string GetAlignmentName(AlignmentType alignment)
{
return Translate($"alignment_{(int)alignment}");
}
Expand Down
4 changes: 2 additions & 2 deletions src/Net/HttpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
using System.Threading;

using Newtonsoft.Json;
using POGOProtos.Enums;
using InvasionCharacter = POGOProtos.Enums.EnumWrapper.Types.InvasionCharacter;
using POGOProtos.Rpc;
using InvasionCharacter = POGOProtos.Rpc.EnumWrapper.Types.InvasionCharacter;

using WhMgr.Comparers;
using WhMgr.Diagnostics;
Expand Down
17 changes: 9 additions & 8 deletions src/Net/Models/PokemonData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
using DSharpPlus;
using DSharpPlus.Entities;
using Newtonsoft.Json;
using POGOProtos.Enums;
using POGOProtos.Map.Weather;
using POGOProtos.Rpc;
using Gender = POGOProtos.Rpc.PokemonDisplayProto.Types.Gender;
using WeatherCondition = POGOProtos.Rpc.GameplayWeatherProto.Types.WeatherCondition;
using ServiceStack.DataAnnotations;

using WhMgr.Alarms.Alerts;
Expand Down Expand Up @@ -209,7 +210,7 @@ public string IVRounded
JsonProperty("weather"),
Alias("weather")
]
public GameplayWeather.Types.WeatherCondition? Weather { get; set; }
public WeatherCondition? Weather { get; set; }

[
JsonProperty("form"),
Expand Down Expand Up @@ -469,12 +470,12 @@ private IReadOnlyDictionary<string, string> GetProperties(MessageProperties prop
var level = Level;
var size = Size?.ToString();
var weather = Weather?.ToString();
var hasWeather = Weather.HasValue && Weather != GameplayWeather.Types.WeatherCondition.None;
var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? GameplayWeather.Types.WeatherCondition.None);
var weatherKey = $"weather_{Convert.ToInt32(Weather ?? GameplayWeather.Types.WeatherCondition.None)}";
var hasWeather = Weather.HasValue && Weather != WeatherCondition.None;
var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? WeatherCondition.None);
var weatherKey = $"weather_{Convert.ToInt32(Weather ?? WeatherCondition.None)}";
var weatherEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[weatherKey])
? MasterFile.Instance.CustomEmojis.ContainsKey(weatherKey) && Weather != GameplayWeather.Types.WeatherCondition.None
? (Weather ?? GameplayWeather.Types.WeatherCondition.None).GetWeatherEmojiIcon()
? MasterFile.Instance.CustomEmojis.ContainsKey(weatherKey) && Weather != WeatherCondition.None
? (Weather ?? WeatherCondition.None).GetWeatherEmojiIcon()
: string.Empty
: MasterFile.Instance.CustomEmojis[weatherKey];
var move1 = int.TryParse(FastMove, out var fastMoveId) ? Translator.Instance.GetMoveName(fastMoveId) : "Unknown";
Expand Down
7 changes: 4 additions & 3 deletions src/Net/Models/PokestopData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
using DSharpPlus;
using DSharpPlus.Entities;
using Newtonsoft.Json;
using POGOProtos.Enums;
using InvasionCharacter = POGOProtos.Enums.EnumWrapper.Types.InvasionCharacter;
using InvasionCharacter = POGOProtos.Rpc.EnumWrapper.Types.InvasionCharacter;

using WhMgr.Alarms.Alerts;
using WhMgr.Alarms.Models;
using WhMgr.Commands;
using WhMgr.Configuration;
using WhMgr.Data;
using WhMgr.Extensions;
using WhMgr.Geofence;
using WhMgr.Localization;
using WhMgr.Utilities;
using WhMgr.Data.Models;

/// <summary>
/// RealDeviceMap Pokestop (lure/invasion) webhook model class.
Expand Down Expand Up @@ -158,7 +159,7 @@ private IReadOnlyDictionary<string, string> GetProperties(DiscordGuild guild, Wh
//var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink);
var invasion = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? MasterFile.Instance.GruntTypes[GruntType] : null;
var leaderString = Translator.Instance.Translate("grunt_" + Convert.ToInt32(GruntType));
var pokemonType = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? Commands.Notifications.GetPokemonTypeFromString(invasion?.Type) : PokemonType.None;
var pokemonType = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? Notifications.GetPokemonTypeFromString(invasion?.Type) : PokemonType.None;
var invasionTypeEmoji = pokemonType == PokemonType.None
? leaderString
: pokemonType.GetTypeEmojiIcons();
Expand Down
9 changes: 5 additions & 4 deletions src/Net/Models/QuestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using DSharpPlus;
using DSharpPlus.Entities;
using Newtonsoft.Json;
using POGOProtos.Enums;
using POGOProtos.Inventory.Item;
using QuestConditionType = POGOProtos.Data.Quests.QuestCondition.Types.ConditionType;
using QuestRewardType = POGOProtos.Data.Quests.QuestReward.Types.Type;
using POGOProtos.Rpc;
using ItemId = POGOProtos.Rpc.Item;
using ActivityType = POGOProtos.Rpc.HoloActivityType;
using QuestConditionType = POGOProtos.Rpc.QuestConditionProto.Types.ConditionType;
using QuestRewardType = POGOProtos.Rpc.QuestRewardProto.Types.Type;

using WhMgr.Alarms.Alerts;
using WhMgr.Alarms.Models;
Expand Down
Loading

0 comments on commit d1d244e

Please sign in to comment.