Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 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.");
     }
 }
Esempio n. 3
0
 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.");
     }
 }
Esempio n. 4
0
        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);
            }
        }