.novel done, waifutransfer almost done

This commit is contained in:
Master Kwoth
2017-11-02 18:22:17 +01:00
parent e581419945
commit 6aeec724c0
9 changed files with 1013 additions and 922 deletions

View File

@ -9,13 +9,15 @@ namespace NadekoBot.Modules.Gambling.Services
public class WaifuService : INService
{
private readonly DbService _db;
private readonly CurrencyService _cs;
public ConcurrentDictionary<ulong, DateTime> DivorceCooldowns { get; } = new ConcurrentDictionary<ulong, DateTime>();
public ConcurrentDictionary<ulong, DateTime> AffinityCooldowns { get; } = new ConcurrentDictionary<ulong, DateTime>();
public WaifuService(DbService db)
public WaifuService(DbService db, CurrencyService cs)
{
_db = db;
_cs = cs;
}
public async Task<bool> WaifuTransfer(IUser owner, ulong waifuId, IUser newOwner)
@ -29,12 +31,22 @@ namespace NadekoBot.Modules.Gambling.Services
if (waifu.ClaimerId != ownerUser.Id)
return false;
if (!await _cs.RemoveAsync(owner.Id,
"Waifu Transfer",
waifu.Price / 10,
uow).ConfigureAwait(false))
{
return false;
}
//new claimerId is the id of the new owner
var newOwnerUser = uow.DiscordUsers.GetOrCreate(newOwner);
waifu.ClaimerId = newOwnerUser.Id;
await uow.CompleteAsync().ConfigureAwait(false);
}
return true;
}
}
}