Skip to content

Commit

Permalink
Merge pull request #72 from cmu-sei/bug/update-player-scores
Browse files Browse the repository at this point in the history
Bug - update player scores
  • Loading branch information
sei-bstein authored Nov 17, 2022
2 parents 823377e + bf8e78b commit e64ea45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Gameboard.Api/Features/UnityGames/UnityGameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
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;
using Microsoft.AspNetCore.Authentication;
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;
Expand All @@ -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<AppHub, IAppHubEvent> _hub;
private readonly LinkGenerator _linkGenerator;
private readonly IMapper _mapper;
private readonly IUnityGameService _unityGameService;

Expand All @@ -41,18 +41,19 @@ public UnityGameController(
// other stuff
ConsoleActorMap actorMap,
GameService gameService,
PlayerService playerService,
IChallengeStore challengeStore,
IHttpClientFactory httpClientFactory,
IUnityGameService unityGameService,
IHubContext<AppHub, IAppHubEvent> 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;
}
Expand Down Expand Up @@ -179,7 +180,10 @@ public async Task<IActionResult> 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);
}

Expand Down
1 change: 1 addition & 0 deletions src/Gameboard.Api/Features/UnityGames/UnityGameService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e64ea45

Please sign in to comment.