private async Task AddVote(ChatInfo chat, PlayerInfo player, RewardModConfiguration.PlayerVote vote) { vote.Count++; Configuration.Save(); Log($"{player.playerName}/{vote.SteamId} claimed a voting reward for {vote.Count}"); bool getsome = false; if (Configuration.Current.Cumulative) { Configuration.Current.VotingRewards .Where(R => vote.Count % R.EveryXVotesGet == 0) .ToList() .ForEach(Rs => getsome = GivePlayerRewards(player, Rs.Rewards) || getsome); } else { getsome = GivePlayerRewards(player, Configuration.Current.VotingRewards .Last(R => vote.Count % R.EveryXVotesGet == 0).Rewards); } await MarkRewardClaimed(player); if (getsome) { await ShowDialog(chat.playerId, player, "Congratulation", "Your reward has been placed in your inventory"); } }
RewardModConfiguration.PlayerVote GetPlayerVote(PlayerInfo player) { if (Configuration.Current.PlayerVotes == null) { Configuration.Current.PlayerVotes = new List <RewardModConfiguration.PlayerVote>(); } var vote = Configuration.Current.PlayerVotes.FirstOrDefault(V => V.SteamId == player.steamId); if (vote == null) { Configuration.Current.PlayerVotes.Add(vote = new RewardModConfiguration.PlayerVote() { SteamId = player.steamId, Count = 0 }); } vote.PlayerName = player.playerName; return(vote); }
private async Task PlayLottery(ChatInfo chat, PlayerInfo player, RewardModConfiguration.PlayerVote vote) { Log($"{player.playerName}/{vote.SteamId} claimed a voting for lottery"); var reward = Configuration.Current.VotingLottery[new Random().Next(0, Configuration.Current.VotingLottery.Count - 1)]; var getsome = GivePlayerRewards(player, new[] { reward }); await MarkRewardClaimed(player); if (getsome) { await ShowDialog(chat.playerId, player, "Congratulation", "Your win has been placed in your inventory"); } else { await ShowDialog(chat.playerId, player, "Sorry", "No luck this time - next time new game new luck"); } }