diff --git a/src/Gameboard.Api/Features/UnityGames/UnityGameController.cs b/src/Gameboard.Api/Features/UnityGames/UnityGameController.cs index 41c02c15..aade1088 100644 --- a/src/Gameboard.Api/Features/UnityGames/UnityGameController.cs +++ b/src/Gameboard.Api/Features/UnityGames/UnityGameController.cs @@ -8,6 +8,7 @@ using System.Net.Http.Json; using System.Threading.Tasks; using AutoMapper; +using Gameboard.Api.Data.Abstractions; using Gameboard.Api.Features.UnityGames; using Gameboard.Api.Hubs; using Gameboard.Api.Services; @@ -15,7 +16,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Logging; @@ -25,11 +25,11 @@ namespace Gameboard.Api.Controllers; [Authorize] public class UnityGameController : _Controller { + private readonly IChallengeStore _challengeStore; private readonly ConsoleActorMap _actorMap; private readonly GameService _gameService; private readonly IHttpClientFactory _httpClientFactory; private readonly IHubContext _hub; - private readonly LinkGenerator _linkGenerator; private readonly IMapper _mapper; private readonly IUnityGameService _unityGameService; @@ -41,18 +41,19 @@ public UnityGameController( // other stuff ConsoleActorMap actorMap, GameService gameService, + PlayerService playerService, + IChallengeStore challengeStore, IHttpClientFactory httpClientFactory, IUnityGameService unityGameService, IHubContext hub, - LinkGenerator link, IMapper mapper ) : base(logger, cache, validator) { _actorMap = actorMap; + _challengeStore = challengeStore; _gameService = gameService; _httpClientFactory = httpClientFactory; _hub = hub; - _linkGenerator = link; _mapper = mapper; _unityGameService = unityGameService; } @@ -179,7 +180,10 @@ public async Task CreateMissionEvent([FromBody] UnityMissionUpdat return Accepted(); } - // this means we actually created an event + // this means we actually created an event, so also update player scores + await _challengeStore.UpdateTeam(model.TeamId); + + // call back with the event return Ok(challengeEvent); } diff --git a/src/Gameboard.Api/Features/UnityGames/UnityGameService.cs b/src/Gameboard.Api/Features/UnityGames/UnityGameService.cs index 1d2ded74..03aab839 100644 --- a/src/Gameboard.Api/Features/UnityGames/UnityGameService.cs +++ b/src/Gameboard.Api/Features/UnityGames/UnityGameService.cs @@ -215,6 +215,7 @@ public async Task DeleteChallengeData(string gameId) challenge.Events.Add(challengeEvent); // also update the score of the challenge + challenge.LastScoreTime = DateTimeOffset.UtcNow; challenge.Score += model.PointsScored; // save it up