public void Reset() { CharacterNameBiddings.Clear(); foreach (CharNames charName in CharNames.Core) { CharacterNameBiddings.Add(new CharacterNameBidding(charName, _charNameBiddingLogger)); } _dataStore.SaveData(CharacterNameBiddings.SelectMany(cnb => cnb.NameBids).ToList()); HandleNameRefresh(new RefreshEvent()); }
private void HandleNameVote(NameVoteReceived e) { try { CharacterNameBiddings.SingleOrDefault(x => x.CharName.Id == e.CharName.Id)?.HandleNameVote(e); _dataStore.SaveData(CharacterNameBiddings.SelectMany(cnb => cnb.NameBids).ToList()); } catch (Exception exception) { _logger.LogError(exception, "Failed to record name vote and save."); } }
private void HandleNameRemoval(RemovingName e) { try { foreach (var charBidding in CharacterNameBiddings) { charBidding.TryRemove(e.NameToRemove); } _dataStore.SaveData(CharacterNameBiddings.SelectMany(cnb => cnb.NameBids).ToList()); } catch (Exception exception) { _logger.LogError(exception, "Failed to remove Name."); } }
public void Load(List <CharacterNameBid> nameBids) { CharacterNameBiddings.Clear(); foreach (CharNames charName in CharNames.Core) { var nameBidding = new CharacterNameBidding(charName, _charNameBiddingLogger, false); var namesForChar = nameBids.Where(x => x.CharNameId == charName.Id) .OrderByDescending(x => x.TotalBits); foreach (var nameBid in namesForChar) { nameBidding.NameBids.Add(nameBid); } if (nameBidding.NameBids.Count == 0) { nameBidding.AddDefaultRecord(); } CharacterNameBiddings.Add(nameBidding); } }