internal License(ItemLicense license, DateTimeOffset firstCompletedDate, int timesCompleted) { Id = LicenseIdGenerator.GetNextId(); ItemLicense = license; FirstCompletedDate = firstCompletedDate; _timesCompleted = timesCompleted; }
/// <summary> /// Removes the license /// </summary> /// <returns>true if the license was removed and false if the license does not exist</returns> public bool Remove(ItemLicense itemLicense) { var license = this[itemLicense]; if (license == null) { return(false); } _licenses.Remove(itemLicense); if (license.ExistsInDatabase) { _licensesToRemove.Push(license); } return(true); }
public License Acquire(ItemLicense itemLicense) { _logger.Debug() .Account(_player) .Message("Acquiring license {0}", itemLicense) .Write(); var shop = GameServer.Instance.ResourceCache.GetShop(); var licenseReward = shop.Licenses.GetValueOrDefault(itemLicense); // ToDo Should we require license rewards or no? // If no we need some other way to determine if a license is available to be acquired or no //if (!shop.Licenses.TryGetValue(license, out licenseInfo)) //throw new LicenseNotFoundException($"License {license} does not exist"); var license = this[itemLicense]; // If this is the first time completing this license // give the player the item reward [TEMP: if available] if (license == null && licenseReward != null) { _player.Inventory.Create(licenseReward.ShopItemInfo, licenseReward.ShopPrice, licenseReward.Color, 0, 0); } if (license != null) { license.TimesCompleted++; } else { license = new License(itemLicense, DateTimeOffset.Now, 1); _licenses.TryAdd(itemLicense, license); _player.Session.Send(new SLicensedAckMessage(itemLicense, licenseReward?.ItemNumber ?? 0)); _logger.Info() .Account(_player) .Message("Acquired license {0}", itemLicense) .Write(); } return(license); }
public License Acquire(ItemLicense itemLicense) { _logger.Information("Acquiring {License}", itemLicense); var licenseReward = _gameDataService.LicenseRewards.GetValueOrDefault(itemLicense); // TODO Should we require license rewards or no? // If no we need some other way to determine if a license is available to be acquired or no //if (!shop.Licenses.TryGetValue(license, out licenseInfo)) //throw new LicenseNotFoundException($"License {license} does not exist"); var license = this[itemLicense]; // If this is the first time completing this license // give the player the item reward if (license == null && licenseReward != null) { _player.Inventory.Create(licenseReward.ShopItemInfo, licenseReward.ShopPrice, licenseReward.Color, 0, 0); _player.Session.Send(new SLicensedAckMessage(itemLicense, licenseReward.ItemNumber)); } if (license != null) { ++license.TimesCompleted; } else { license = new License(_idGeneratorService.GetNextId(IdKind.License), itemLicense, DateTimeOffset.Now, 1); _licenses.TryAdd(itemLicense, license); // _player.Session.SendAsync(new SLicensedAckMessage(itemLicense, licenseReward?.ItemNumber ?? 0)); _logger.Information("Acquired {License}", itemLicense); } return(license); }
/// <summary> /// Returns the license or null if the license does not exist /// </summary> public License GetLicense(ItemLicense license) { return(_licenses.GetValueOrDefault(license)); }
/// <summary> /// Returns the license or null if the license does not exist /// </summary> public License this[ItemLicense license] => GetLicense(license);
public bool Contains(ItemLicense license) { return(_licenses.ContainsKey(license)); }
public SLicensedAckMessage(ItemLicense itemLicense, ItemNumber itemNumber) { ItemLicense = itemLicense; ItemNumber = itemNumber; }
/// <summary> /// Returns the license or null if the license does not exist /// </summary> public License GetLicense(ItemLicense license) { return(CollectionExtensions.GetValueOrDefault(_licenses, license)); }