public void PayOut(Character member, double amount, Character issuer) { if (amount <= 0) { return; } CanPayOut(issuer).ThrowIfFalse(ErrorCodes.InsufficientPrivileges); IsMember(member).ThrowIfFalse(ErrorCodes.NotMemberOfCorporation); var ceo = CEO; if (ceo != issuer) { CorporationManager.IsJoinPeriodExpired(member, Eid).ThrowIfFalse(ErrorCodes.corporationTransactionsFrozen); } var builder = TransactionLogEvent.Builder().SetCorporation(this).SetTransactionType(TransactionType.characterPayOut); var corporationWallet = new CorporationWallet(this); corporationWallet.Balance -= amount; LogTransaction(builder.SetCreditBalance(corporationWallet.Balance) .SetCreditChange(-amount) .SetCharacter(issuer) .SetInvolvedCharacter(member).Build()); var memberWallet = _characterWalletFactory(member, TransactionType.characterPayOut); memberWallet.Balance += amount; member.LogTransaction(builder.SetCreditBalance(memberWallet.Balance) .SetCreditChange(amount) .SetCharacter(member) .SetInvolvedCharacter(issuer).Build()); }
public void TrashItems(Character issuerCharacter, IEnumerable <long> target) { var trashableItems = GetItems(target).Where(i => i.IsTrashable).ToList(); using (var n = new ItemErrorNotifier(true)) { foreach (var item in trashableItems) { try { //selected robot now allowed issuerCharacter.IsRobotSelectedForCharacter(item as Robot).ThrowIfTrue(ErrorCodes.RobotMustBeDeselected); RemoveItemOrThrow(item); Repository.Delete(item); AddLogEntry(issuerCharacter, ContainerAccess.Delete, item.Definition, item.Quantity); var b = TransactionLogEvent.Builder() .SetTransactionType(TransactionType.TrashItem) .SetCharacter(issuerCharacter) .SetContainer(this) .SetItem(item.Definition, item.Quantity); issuerCharacter.LogTransaction(b); } catch (PerpetuumException gex) { Logger.Error("Failed to delete item:" + item.Eid + " " + item.ED.Name + " owner:" + item.Owner + " issuerCharacter:" + issuerCharacter.Id); n.AddError(item, gex); } } } }
public void PayOut(InsuranceDescription insurance, int definition) { if (!insurance.IsInsured) { return; } var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.InsurancePayOut) .SetCreditChange(insurance.payOutPrice) .SetCharacter(insurance.character) .SetItem(definition, 0); IWallet <double> wallet; if (insurance.corporationEid != null) { var corporation = Corporation.GetOrThrow((long)insurance.corporationEid); wallet = new CorporationWallet(corporation); wallet.Balance += insurance.payOutPrice; b.SetCreditBalance(wallet.Balance).SetCorporation(corporation); corporation.LogTransaction(b); Logger.Info($"insurance paid to corp:{insurance.corporationEid} amount:{insurance.payOutPrice}"); } else { wallet = insurance.character.GetWallet(TransactionType.InsurancePayOut); wallet.Balance += insurance.payOutPrice; b.SetCreditBalance(wallet.Balance); insurance.character.LogTransaction(b); Logger.Info($"insurance paid to character:{insurance.character.Id} amount:{insurance.payOutPrice}"); } _centralBank.SubAmount(insurance.payOutPrice, TransactionType.InsurancePayOut); }
public void Transfer(PrivateCorporation target, double amount, Character issuer) { if (Eid == target.Eid) { return; } CanTransfer(issuer).ThrowIfFalse(ErrorCodes.InsufficientPrivileges); target.IsActive.ThrowIfFalse(ErrorCodes.CorporationMustBeActive); var sourceWallet = new CorporationWallet(this); sourceWallet.Balance -= amount; LogTransaction(TransactionLogEvent.Builder() .SetTransactionType(TransactionType.corporationTransfer_to) .SetCreditBalance(sourceWallet.Balance) .SetCreditChange(-amount) .SetCorporation(this) .SetInvolvedCorporation(target).Build()); var targetWallet = new CorporationWallet(target); targetWallet.Balance += amount; target.LogTransaction(TransactionLogEvent.Builder() .SetTransactionType(TransactionType.corporationTransfer_from) .SetCreditBalance(targetWallet.Balance) .SetCreditChange(amount) .SetCorporation(target) .SetInvolvedCorporation(this).Build()); }
public void TransferItems(Trade hisTrade, Container sourceContainer, Container targetContainer) { var tradeItems = GetItems(); foreach (var tradeItem in tradeItems) { var item = sourceContainer.GetItemOrThrow(tradeItem.itemEid); item.Quantity.ThrowIfNotEqual(tradeItem.ItemInfo.Quantity, ErrorCodes.ItemQuantityMismatch); } sourceContainer.RelocateItems(owner, hisTrade.owner, tradeItems.Select(i => i.itemEid), targetContainer); var outEBuilder = TransactionLogEvent.Builder().SetTransactionType(TransactionType.TradeItemOut).SetCharacter(owner).SetInvolvedCharacter(hisTrade.owner); var inEBuilder = TransactionLogEvent.Builder().SetTransactionType(TransactionType.TradeItemIn).SetCharacter(hisTrade.owner).SetInvolvedCharacter(owner); foreach (var tradeItem in tradeItems) { outEBuilder.SetItem(tradeItem.ItemInfo.Definition, tradeItem.ItemInfo.Quantity); owner.LogTransaction(outEBuilder); inEBuilder.SetItem(tradeItem.ItemInfo.Definition, tradeItem.ItemInfo.Quantity); hisTrade.owner.LogTransaction(inEBuilder); } TransferCredit(); }
private void TransferCredit() { if (Credit <= 0.0) { return; } var ownerWallet = _characterWalletFactory(owner, TransactionType.TradeSpent); ownerWallet.Balance -= Credit; owner.LogTransaction(TransactionLogEvent.Builder() .SetTransactionType(TransactionType.TradeSpent) .SetCreditBalance(ownerWallet.Balance) .SetCreditChange(-Credit) .SetCharacter(owner) .SetInvolvedCharacter(trader).Build()); var traderWallet = _characterWalletFactory(trader, TransactionType.TradeGained); traderWallet.Balance += Credit; trader.LogTransaction(TransactionLogEvent.Builder() .SetTransactionType(TransactionType.TradeGained) .SetCreditBalance(traderWallet.Balance) .SetCreditChange(Credit) .SetCharacter(trader) .SetInvolvedCharacter(owner).Build()); }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var containerName = request.Data.GetOrDefault <string>(k.name); var targetCharacter = Character.Get(request.Data.GetOrDefault <int>(k.characterID)); var targetContainerEid = request.Data.GetOrDefault <long>(k.container); var publicContainer = character.GetPublicContainerWithItems(); var sourceContainer = publicContainer.GetItems(true).OfType <Container>().FirstOrDefault(container => ContainerFinder(containerName, container)).ThrowIfNull(ErrorCodes.ContainerNotFound); var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.AddContainerContent).SetCharacter(character); var items = sourceContainer.GetItems().ToArray(); foreach (var item in items) { b.SetItem(item); character.LogTransaction(b); } var targetContainer = Container.GetOrThrow(targetContainerEid); sourceContainer.RelocateItems(character, targetCharacter, items, targetContainer); sourceContainer.Save(); targetContainer.Save(); Message.Builder.FromRequest(request).WithOk().Send(); scope.Complete(); } }
public static ErrorCodes UpdateUsedComponents(IEnumerable <ProductionLiveComponent> usedComponents, Container container, Character character, TransactionType transactionType) { var ec = ErrorCodes.NoError; foreach (var component in usedComponents) { var componentItem = container.GetItem(component.eid, true); if (componentItem == null) { ec = ErrorCodes.ItemNotFound; return(ec); } var logQuantity = componentItem.Quantity; if (component.resultQuantity == 0) { Entity.Repository.Delete(componentItem); } else { logQuantity = componentItem.Quantity - component.resultQuantity; componentItem.Quantity = component.resultQuantity; } var b = TransactionLogEvent.Builder().SetTransactionType(transactionType).SetCharacter(character).SetItem(componentItem.Definition, logQuantity); character.LogTransaction(b); } return(ec); }
protected virtual void RelocateItem(Character character, long issuerEid, Item item, Container targetContainer) { //user can't move it) item.ED.AttributeFlags.NonRelocatable.ThrowIfTrue(ErrorCodes.ItemNotRelocatable); //add to container // ebbol a kontenerbol kikerult,ha sikerul a targetbe pakolni! targetContainer.AddItem(item, issuerEid, true); //item left his set or a new item added to the his set if (IsPersonalContainer != targetContainer.IsPersonalContainer) { var b = TransactionLogEvent.Builder(); if (IsPersonalContainer) { b.SetTransactionType(TransactionType.ItemDonate).SetContainer(targetContainer); } else { b.SetTransactionType(TransactionType.ItemObtain).SetContainer(this); } character.LogTransaction(b); } //corp hangar and folder hierarchy check, other things if needed. if (IsLogSkipped(targetContainer)) { return; } targetContainer.AddLogEntry(character, ContainerAccess.Add, item.Definition, item.Quantity); AddLogEntry(character, ContainerAccess.Remove, item.Definition, item.Quantity); }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var account = _accountRepository.Get(request.Session.AccountId).ThrowIfNull(ErrorCodes.AccountNotFound); var id = request.Data.GetOrDefault <int>(k.ID); var character = request.Session.Character; character.IsDocked.ThrowIfFalse(ErrorCodes.CharacterHasToBeDocked); var redeemableItem = RedeemableItemInfo.LoadRedeemableItemById(id, account); var container = character.GetPublicContainerWithItems(); foreach (var item in redeemableItem.CreateItems()) { item.Owner = character.Eid; try { if (item is RedeemableItem redeemable) { // ha instant akkor itt kell aktivalni if (redeemable.ED.AttributeFlags.InstantActivate) { redeemable.Activate(account, character); continue; } } container.AddItem(item, true); } finally { var b = TransactionLogEvent.Builder() .SetTransactionType(TransactionType.ItemRedeem) .SetCharacter(character) .SetContainer(container) .SetItem(item); character.LogTransaction(b); } } _accountRepository.Update(account); container.Save(); redeemableItem.SetRedeemed(character); Transaction.Current.OnCommited(() => { var result = _goodiePackHandler.GetMyRedeemableItems(account); result.Add(k.container, container.ToDictionary()); Message.Builder.FromRequest(request).WithData(result).Send(); }); scope.Complete(); } }
private IDictionary <string, object> EndCalibrationProgramForge(ProductionInProgress productionInProgress) { Logger.Info("Calibration program forge finished: " + productionInProgress); var sourceCPRGEid = productionInProgress.ReservedEids[0]; var targetCPRGEid = productionInProgress.ReservedEids[1]; var sourceCPRG = (CalibrationProgram)Repository.LoadOrThrow(sourceCPRGEid); var targetCPRG = (CalibrationProgram)Repository.LoadOrThrow(targetCPRGEid); //delete the used items var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.CPRGForgeDeleted).SetCharacter(productionInProgress.character); foreach (var item in productionInProgress.GetReservedItems()) { b.SetItem(item); productionInProgress.character.LogTransaction(b.Build()); Repository.Delete(item); } //pick the output defintion--------------------------------------------------- var outputDefinition = productionInProgress.resultDefinition; //load container var container = (PublicContainer)Container.GetOrThrow(PublicContainerEid); container.ReloadItems(productionInProgress.character); var resultItem = (CalibrationProgram)Factory.CreateWithRandomEID(outputDefinition); resultItem.Owner = productionInProgress.character.Eid; resultItem.Save(); int materialEfficiencyPoints; int timeEfficiencyPoints; CalculateResultingPoints(sourceCPRG, targetCPRG, productionInProgress.character, out materialEfficiencyPoints, out timeEfficiencyPoints); resultItem.MaterialEfficiencyPoints = materialEfficiencyPoints; resultItem.TimeEfficiencyPoints = timeEfficiencyPoints; //add to public container container.AddItem(resultItem, false); container.Save(); productionInProgress.character.WriteItemTransactionLog(TransactionType.PrototypeCreated, resultItem); //get list in order to return Logger.Info("EndCPGForge created an item: " + resultItem + " production:" + productionInProgress); var replyDict = new Dictionary <string, object> { { k.result, resultItem.ToDictionary() }, }; return(replyDict); }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var baseEID = request.Data.GetOrDefault <long>(k.baseEID); var character = request.Session.Character; character.IsDocked.ThrowIfFalse(ErrorCodes.CharacterHasToBeDocked); var dockingBase = character.GetCurrentDockingBase(); if (dockingBase.Eid != baseEID) { throw new PerpetuumException(ErrorCodes.FacilityOutOfReach); } var corporation = character.GetPrivateCorporationOrThrow(); var role = corporation.GetMemberRole(character); role.IsAnyRole(CorporationRole.CEO, CorporationRole.HangarOperator, CorporationRole.DeputyCEO).ThrowIfFalse(ErrorCodes.InsufficientPrivileges); if (!role.IsAnyRole(CorporationRole.CEO)) { _corporationManager.IsInJoinOrLeave(character).ThrowIfError(); } var mainHangar = dockingBase.GetPublicCorporationHangarStorage(); var rentInfo = mainHangar.GetCorporationHangarRentInfo(); var wallet = new CorporationWallet(corporation); wallet.Balance -= rentInfo.price; var b = TransactionLogEvent.Builder() .SetCorporation(corporation) .SetTransactionType(TransactionType.hangarRent) .SetCreditBalance(wallet.Balance) .SetCreditChange(-rentInfo.price); corporation.LogTransaction(b); var corporateHangar = CorporateHangar.Create(); corporateHangar.Owner = corporation.Eid; mainHangar.AddChild(corporateHangar); //set lease start time corporateHangar.LeaseStart = DateTime.Now; corporateHangar.LeaseEnd = DateTime.Now + rentInfo.period; corporateHangar.IsLeaseExpired = false; corporateHangar.SetLogging(true, character); //set logging on by default mainHangar.Save(); dockingBase.AddCentralBank(TransactionType.hangarRent, rentInfo.price); Message.Builder.FromRequest(request).WithData(corporateHangar.ToDictionary()).Send(); scope.Complete(); } }
protected static void LogTransaction(Player player, Item deployableItem) { var b = TransactionLogEvent.Builder() .SetTransactionType(TransactionType.ItemDeploy) .SetCharacter(player.Character) .SetItem(deployableItem); player.Character.LogTransaction(b); }
private static void LogOpen(Character character, Container container, LotteryItem lotteryItem) { var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.LotteryOpen) .SetCharacter(character) .SetContainer(container) .SetItem(lotteryItem); character.LogTransaction(b); }
private static void LogRandomItemCreated(Character character, Container container, Item randomItem) { var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.LotteryRandomItemCreated) .SetCharacter(character) .SetContainer(container) .SetItem(randomItem); character.LogTransaction(b); }
public void RepairItems(Character character, IEnumerable <long> targetEiDs, Container sourceContainer, bool useCorporationWallet) { var wallet = character.GetWallet(useCorporationWallet, TransactionType.ProductionMultiItemRepair); var b = TransactionLogEvent.Builder() .SetCharacter(character) .SetTransactionType(TransactionType.ProductionMultiItemRepair); var corpWallet = wallet as CorporationWallet; if (corpWallet != null) { b.SetCorporation(corpWallet.Corporation); } var sumPrice = 0.0; foreach (var item in sourceContainer.SelectDamagedItems(targetEiDs).ToArray()) { try { var price = GetRepairPrice(character, item); wallet.Balance -= price; b.SetCreditBalance(wallet.Balance).SetCreditChange(-price).SetItem(item); if (corpWallet != null) { corpWallet.Corporation.LogTransaction(b); } else { character.LogTransaction(b); } item.Repair(); //ha nem robot akkor csomagoljuk be if (item.ED.AttributeFlags.Repackable && !item.ED.CategoryFlags.IsCategory(CategoryFlags.cf_robots)) { item.IsRepackaged = true; } sumPrice += price; } catch (PerpetuumException gex) { character.SendItemErrorMessage(Commands.ProductionRepair, gex.error, item); } } GetDockingBase().AddCentralBank(TransactionType.ProductionMultiItemRepair, sumPrice); sourceContainer.Save(); }
public void InsuranceBuy(Character character, Robot robot, ref int currentInsurances, int maxInsurances, int insuranceDays, ref Corporation corporation) { robot.ED.ThrowIfEqual(Robot.NoobBotEntityDefault, ErrorCodes.DefinitionNotSupported); robot.IsSingleAndUnpacked.ThrowIfFalse(ErrorCodes.RobotMustbeSingleAndNonRepacked); robot.Initialize(character); robot.CheckOwnerCharacterAndCorporationAndThrowIfFailed(character); corporation = character.GetCorporation(); long?corporationEid = character.CorporationEid; var useCorporationWallet = false; var endDate = DateTime.Now.AddDays(insuranceDays); var insurance = _insuranceHelper.GetInsurance(robot.Eid); _insuranceHelper.GetConditions(character, robot, insurance, (long)corporationEid, insuranceDays, maxInsurances, currentInsurances, ref endDate, ref useCorporationWallet).ThrowIfError(); var wallet = character.GetWalletWithAccessCheck(useCorporationWallet, TransactionType.InsuranceFee); double insuranceFee, payOut; GetInsurancePrice(robot, out insuranceFee, out payOut).ThrowIfError(); wallet.Balance -= insuranceFee; var b = TransactionLogEvent.Builder() .SetCharacter(character) .SetTransactionType(TransactionType.InsuranceFee) .SetCreditBalance(wallet.Balance) .SetCreditChange(-insuranceFee) .SetItem(robot); var corpWallet = wallet as CorporationWallet; if (corpWallet != null) { b.SetCorporation(corpWallet.Corporation); corporation.LogTransaction(b); } else { character.LogTransaction(b); } if (!useCorporationWallet) { corporationEid = null; } InsuranceHelper.AddInsurance(character, robot.Eid, endDate, InsuranceType.robotInsurance, corporationEid, payOut).ThrowIfError(); character.GetCurrentDockingBase().AddCentralBank(TransactionType.InsuranceFee, insuranceFee); currentInsurances++; }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var hangarEID = request.Data.GetOrDefault <long>(k.eid); var corporation = character.GetCorporation(); var corporateHangar = corporation.GetHangar(hangarEID, character, ContainerAccess.LogList); var hangarStorage = corporateHangar.GetHangarStorage(); var rentInfo = hangarStorage.GetCorporationHangarRentInfo(); var wallet = new CorporationWallet(corporation); wallet.Balance -= rentInfo.price; var b = TransactionLogEvent.Builder().SetCorporation(corporation).SetTransactionType(TransactionType.hangarRent).SetCreditBalance(wallet.Balance).SetCreditChange(-rentInfo.price); corporation.LogTransaction(b); if (corporateHangar.IsLeaseExpired) { corporateHangar.LeaseStart = DateTime.Now; corporateHangar.LeaseEnd = DateTime.Now + rentInfo.period; } else { corporateHangar.LeaseStart += rentInfo.period; corporateHangar.LeaseEnd += rentInfo.period; } corporateHangar.IsLeaseExpired = false; corporateHangar.Save(); hangarStorage.GetParentDockingBase().AddCentralBank(TransactionType.hangarRent, rentInfo.price); var result = new Dictionary <string, object> { { k.eid, hangarEID }, { k.name, corporateHangar.Name }, { k.price, rentInfo.price }, { k.rentPeriod, (int)rentInfo.period.TotalDays }, { k.leaseStart, corporateHangar.LeaseStart }, { k.leaseEnd, corporateHangar.LeaseEnd }, { k.leaseExpired, 0 } }; Message.Builder.FromRequest(request).WithData(result).Send(); scope.Complete(); } }
public void SubtractFromWallet(Character character, TransactionType transactionType, double amount) { var wallet = _walletFactory(character, transactionType); wallet.Balance -= amount; var b = TransactionLogEvent.Builder() .SetTransactionType(transactionType) .SetCreditBalance(wallet.Balance) .SetCreditChange(-amount) .SetCharacter(character); character.LogTransaction(b); }
public Item Open(Container targetContainer, Character character) { var randomLoot = _loots.RandomElement(); var randomItem = (Item)Factory.CreateWithRandomEID(randomLoot.definition); randomItem.Owner = character.Eid; randomItem.Quantity = FastRandom.NextInt(randomLoot.quantity); targetContainer.AddItem(randomItem, false); character.LogTransaction(TransactionLogEvent.Builder().SetTransactionType(TransactionType.GiftOpen).SetCharacter(character).SetContainer(targetContainer).SetItem(this)); character.LogTransaction(TransactionLogEvent.Builder().SetTransactionType(TransactionType.GiftRandomItemCreated).SetCharacter(character).SetContainer(targetContainer).SetItem(randomItem)); return(randomItem); }
public void AddToWallet(Character character, TransactionType transactionType, double amount) { var wallet = _walletFactory(character, transactionType); wallet.Balance += amount; var b = TransactionLogEvent.Builder() .SetTransactionType(transactionType) .SetCreditBalance(wallet.Balance) .SetCreditChange(amount) .SetCharacter(character); character.LogTransaction(b); _centralBank.SubAmount(amount, transactionType); }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var amount = request.Data.GetOrDefault <long>(k.amount); if (amount <= 0) { return; } character.IsInTraining().ThrowIfTrue(ErrorCodes.TrainingCharacterInvolved); character.IsPrivilegedTransactionsAllowed().ThrowIfError(); Corporation corporation = character.GetPrivateCorporationOrThrow(); corporation.IsActive.ThrowIfFalse(ErrorCodes.CorporationNotExists); var ceo = corporation.CEO; if (ceo != character) { _corporationManager.IsJoinPeriodExpired(character, corporation.Eid).ThrowIfFalse(ErrorCodes.corporationTransactionsFrozen); } var characterWallet = _characterWalletFactory(character, TransactionType.characterDonate); characterWallet.Balance -= amount; var builder = TransactionLogEvent.Builder() .SetCharacter(character) .SetTransactionType(TransactionType.characterDonate) .SetCreditBalance(characterWallet.Balance) .SetCreditChange(-amount) .SetCorporation(corporation); character.LogTransaction(builder); var corporationWallet = new CorporationWallet(corporation); corporationWallet.Balance += amount; builder.SetCreditBalance(corporationWallet.Balance) .SetCreditChange(amount); corporation.LogTransaction(builder); scope.Complete(); } }
/// <summary> /// This function is called periodically and pays the owned base's income to a corporation /// </summary> private static void DoSiegeCorporationSharePayOut() { using (var scope = Db.CreateTransaction()) { try { var timeBehind = DateTime.Now.AddHours(-5); //real var records = Db.Query().CommandText("select corporationeid,amount from ownerincome where lastflush < @dayBehind") .SetParameter("@dayBehind", timeBehind) .Execute() .Select(r => new { corporation = Corporation.GetOrThrow(r.GetValue <long>(0)), amount = r.GetValue <double>(1) }) .Where(r => r.amount > 0.0); foreach (var record in records) { var corporation = record.corporation; var wallet = new CorporationWallet(corporation); wallet.Balance += record.amount; corporation.LogTransaction(TransactionLogEvent.Builder() .SetCorporation(corporation) .SetTransactionType(TransactionType.BaseIncome) .SetCreditBalance(wallet.Balance) .SetCreditChange(record.amount)); Db.Query().CommandText("update ownerincome set amount=0,lastflush=@now where corporationeid=@corpEID") .SetParameter("@now", DateTime.Now) .SetParameter("@corpEID", corporation.Eid) .ExecuteNonQuery(); Logger.Info("owner income added to corp: " + corporation.Eid + " amount: " + record.amount); } scope.Complete(); } catch (Exception ex) { Logger.Exception(ex); } } }
private IDictionary <string, object> EndPrototype(ProductionInProgress productionInProgress) { Logger.Info("Prototype finished: " + productionInProgress); //delete the used items foreach (var item in productionInProgress.GetReservedItems()) { var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.PrototypeDeleted).SetCharacter(productionInProgress.character).SetItem(item); productionInProgress.character.LogTransaction(b); Repository.Delete(item); } //pick the output defintion--------------------------------------------------- var outputDefinition = productionInProgress.resultDefinition; //load container var container = (PublicContainer)Container.GetOrThrow(PublicContainerEid); container.ReloadItems(productionInProgress.character); var outputDefault = EntityDefault.Get(outputDefinition).ThrowIfEqual(EntityDefault.None, ErrorCodes.DefinitionNotSupported); //create item var resultItem = container.CreateAndAddItem(outputDefinition, false, item => { item.Owner = productionInProgress.character.Eid; item.Quantity = outputDefault.Quantity * productionInProgress.amountOfCycles; }); container.Save(); productionInProgress.character.WriteItemTransactionLog(TransactionType.PrototypeCreated, resultItem); //get list in order to return Logger.Info("EndPrototype created an item: " + resultItem + " production:" + productionInProgress); var replyDict = new Dictionary <string, object> { { k.result, resultItem.BaseInfoToDictionary() }, }; ProductionProcessor.EnqueueProductionMissionTarget(MissionTargetType.prototype, productionInProgress.character, MyMissionLocationId(), productionInProgress.resultDefinition); return(replyDict); }
private void PayBackBuyOrder() { var submitter = Character.GetByEid(submitterEID); //use corporation wallet based on the order and not on the current corp of the character PrivateCorporation corporation = null; if (forMembersOf != null) { corporation = PrivateCorporation.Get((long)forMembersOf); } IWallet <double> wallet; if (corporation != null && useCorporationWallet) { wallet = new CorporationWallet(corporation); } else { wallet = submitter.GetWallet(false, TransactionType.buyOrderPayBack); } wallet.Balance += FullPrice; var b = TransactionLogEvent.Builder() .SetTransactionType(TransactionType.buyOrderPayBack) .SetCreditBalance(wallet.Balance) .SetCreditChange(FullPrice) .SetCharacter(submitter) .SetItem(itemDefinition, quantity); var corpWallet = wallet as CorporationWallet; if (corpWallet != null) { b.SetCorporation(corpWallet.Corporation); corpWallet.Corporation.LogTransaction(b); } else { submitter.LogTransaction(b); } _centralBank.SubAmount(FullPrice, TransactionType.MarketTax); }
public void PayOutToSeller(Character seller, bool useSellerCorporationWallet, int definition, double price, int quantity, TransactionType transactionType, bool affectAverage, bool forCorporation) { var taxRate = forCorporation ? 1.0 : GetMarketTaxRate(seller); var resultPrice = price * quantity * taxRate; var sellerWallet = seller.GetWallet(useSellerCorporationWallet, transactionType); sellerWallet.Balance += resultPrice; var b = TransactionLogEvent.Builder() .SetCharacter(seller) .SetTransactionType(transactionType) .SetCreditBalance(sellerWallet.Balance) .SetCreditChange(resultPrice) .SetItem(definition, quantity); var corpWallet = sellerWallet as CorporationWallet; if (corpWallet != null) { b.SetCorporation(corpWallet.Corporation); corpWallet.Corporation.LogTransaction(b); } else { seller.LogTransaction(b); } if (affectAverage) { //itt playernek fizetunk ki _marketHandler.InsertAveragePrice(this, definition, price * quantity, quantity); } if (forCorporation) { return; } var tax = price * quantity * (1 - taxRate); var dockingBase = GetDockingBase(); dockingBase.AddCentralBank(TransactionType.MarketTax, tax); }
public void CashInMarketFee(Character character, bool useCorporationWallet, double pricePerPiece) { var wallet = character.GetWalletWithAccessCheck(useCorporationWallet, TransactionType.marketFee); wallet.Balance -= pricePerPiece; var b = TransactionLogEvent.Builder().SetCharacter(character).SetTransactionType(TransactionType.marketFee).SetCreditBalance(wallet.Balance).SetCreditChange(-pricePerPiece); if (wallet is CorporationWallet corpWallet) { b.SetCorporation(corpWallet.Corporation); corpWallet.Corporation.LogTransaction(b); } else { character.LogTransaction(b); } }
public void TransferCredit(Character source, Character target, long amount) { source.IsInTraining().ThrowIfTrue(ErrorCodes.TrainingCharacterInvolved); target.IsInTraining().ThrowIfTrue(ErrorCodes.TrainingCharacterInvolved); target.IsActive.ThrowIfFalse(ErrorCodes.CharacterDeleted); //attempt to send money to a privileged character if (target.AccessLevel.IsAnyPrivilegeSet()) { //source majer? if (!source.AccessLevel.IsAnyPrivilegeSet()) { //source nem majer //target majer, de mennyire? target.CheckPrivilegedTransactionsAndThrowIfFailed(); } } //if gm is the source - transactions are controlled source.CheckPrivilegedTransactionsAndThrowIfFailed(); var sourceWallet = _walletFactory(source, TransactionType.characterTransfer_to); sourceWallet.Balance -= amount; source.LogTransaction(TransactionLogEvent.Builder() .SetTransactionType(TransactionType.characterTransfer_to) .SetCreditBalance(sourceWallet.Balance) .SetCreditChange(-amount) .SetCharacter(source) .SetInvolvedCharacter(target)); var targetWallet = _walletFactory(target, TransactionType.characterTransfer_from); targetWallet.Balance += amount; source.LogTransaction(TransactionLogEvent.Builder() .SetTransactionType(TransactionType.characterTransfer_from) .SetCreditBalance(targetWallet.Balance) .SetCreditChange(amount) .SetCharacter(target) .SetInvolvedCharacter(source)); }
public void Write(IZone zone, Player player, Unit killer) { if (killer != null) { if (!(killer is Player)) { _logger.Log(new NpcDeathLogEvent { zone = zone, player = player, killer = killer }); } } var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.PlayerDeath).SetCharacter(player.Character).SetItem(player); player.Character.LogTransaction(b); }
public static void CashInCreditForDocument(int price, Character character, TransactionType transactionType, bool useCorporationWallet = false) { var wallet = character.GetWalletWithAccessCheck(useCorporationWallet, transactionType, CorporationRole.editPBS); wallet.Balance -= price; var b = TransactionLogEvent.Builder().SetCharacter(character).SetTransactionType(transactionType).SetCreditBalance(wallet.Balance).SetCreditChange(-price); var corpWallet = wallet as CorporationWallet; if (corpWallet != null) { b.SetCorporation(corpWallet.Corporation); corpWallet.Corporation.LogTransaction(b); } else { character.LogTransaction(b); } }