public void UserToUser(ulong sourceUserId, ulong targetUserId, ulong amount) { if (sourceUserId == targetUserId) { throw new InvalidOperationException(Constants.ExTransferSameUser); } if (targetUserId == discordClient.GetCurrentUser().Id) { throw new InvalidOperationException(Constants.ExTransferToMiunie); } var transferSource = globalUserAccountProvider.GetById(sourceUserId); if (transferSource.Miunies < amount) { throw new InvalidOperationException(Constants.ExTransferNotEnoughFunds); } var transferTarget = globalUserAccountProvider.GetById(targetUserId); transferSource.Miunies -= amount; transferTarget.Miunies += amount; globalUserAccountProvider.SaveAccounts(transferSource.Id, transferTarget.Id); }
public void GetDaily(ulong userId) { var account = globalUserAccountProvider.GetById(userId); var sinceLastDaily = DateTime.UtcNow - account.LastDaily; if (sinceLastDaily.TotalHours < 24) { var e = new InvalidOperationException(Constants.ExDailyTooSoon); e.Data.Add("sinceLastDaily", sinceLastDaily); throw e; } account.Miunies += Constants.DailyMuiniesGain; account.LastDaily = DateTime.UtcNow; globalUserAccountProvider.SaveAccounts(userId); }