/// <summary> /// Get the position the team finished after taking in their results over all the races /// </summary> public static int GetCupPosition() { var totalScore = 0; var raceResults = RaceHistory.Select(r => new KeyValuePair <int, int>(r.Score, r.PositionCount)).ToList(); var racePositions = new List <int>(); var finalPosition = 1; var finalPositionLocked = false; foreach (var result in raceResults) { var position = GetRacePosition(result.Key, result.Value); totalScore += position; racePositions.Add(position); } while (!finalPositionLocked && finalPosition < 10) { var otherTeamTotal = racePositions.Sum(r => finalPosition < r ? finalPosition : finalPosition + 1); if (otherTeamTotal < totalScore) { finalPosition++; } else { finalPositionLocked = true; } } return(finalPosition); }
/// <summary> /// Check if the next PromotionTrigger criteria has been completed /// </summary> private string PromotionTriggerCheck() { var possibleTypes = ConfigStore.GameConfig.PromotionTriggers.Where(pt => pt.StartType == Boat.Type); var validRaces = RaceHistory.Where(pb => pb.Type == Boat.Type).ToList(); foreach (var type in possibleTypes) { var consecutiveMatches = 0; foreach (var boat in validRaces) { if (boat.Score >= type.ScoreRequired) { consecutiveMatches++; if (consecutiveMatches >= type.ScoreMetSinceLast) { return(type.NewType); } } else { consecutiveMatches = 0; } } } return(string.Empty); }
/// <summary> /// Get how many races this CrewMember has won /// </summary> public static int RacesWon(this CrewMember member) { return(RaceHistory.Count(boat => boat.PositionCrew.Values.Any(cm => member.Name == cm.Name) && GetRacePosition(boat.Score, boat.PositionCount) == 1)); }
public async Task Update(RaceHistory raceHistory, CancellationToken cancellationToken) { await repository.Update(raceHistory, cancellationToken); }
public async Task <RaceHistory> Add(RaceHistory raceHistory, CancellationToken cancellationToken) { return(await repository.Add(raceHistory, cancellationToken)); }