forked from NecronomiconCoding/NecroBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NecronomiconCoding#1439 from nicoschmitt/master
WebSocket Respond to EggsListEvent
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#region using directives | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using POGOProtos.Data; | ||
using POGOProtos.Inventory; | ||
|
||
#endregion | ||
|
||
namespace PoGo.NecroBot.Logic.Event | ||
{ | ||
public class EggsListEvent : IEvent | ||
{ | ||
public List<EggIncubator> Incubators { get; set; } | ||
public object UnusedEggs { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#region using directives | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using PoGo.NecroBot.Logic.DataDumper; | ||
using PoGo.NecroBot.Logic.Event; | ||
using PoGo.NecroBot.Logic.PoGoUtils; | ||
using PoGo.NecroBot.Logic.State; | ||
using POGOProtos.Inventory.Item; | ||
|
||
#endregion | ||
|
||
namespace PoGo.NecroBot.Logic.Tasks | ||
{ | ||
public class EggsListTask | ||
{ | ||
public static async Task Execute(ISession session) | ||
{ | ||
var incubators = (await session.Inventory.GetEggIncubators()) | ||
.Where(x => x.UsesRemaining > 0 || x.ItemId == ItemId.ItemIncubatorBasicUnlimited) | ||
.OrderByDescending(x => x.ItemId == ItemId.ItemIncubatorBasicUnlimited) | ||
.ToList(); | ||
|
||
var unusedEggs = (await session.Inventory.GetEggs()) | ||
.Where(x => string.IsNullOrEmpty(x.EggIncubatorId)) | ||
.OrderBy(x => x.EggKmWalkedTarget - x.EggKmWalkedStart) | ||
.ToList(); | ||
|
||
session.EventDispatcher.Send( | ||
new EggsListEvent | ||
{ | ||
Incubators = incubators, | ||
UnusedEggs = unusedEggs | ||
}); | ||
} | ||
} | ||
} |