public void InsuranceBuy(Character character, IEnumerable <long> robotEids) { //auto clean InsuranceHelper.CleanUpInsurances(); var currentInsurances = InsuranceHelper.CountInsurances(character); var maxInsurances = RealMaxSlotsPerCharacter(character); var insuranceDays = GetInsuranceDays(character); Corporation usedCorporation = null; foreach (var robot in robotEids.Select(RobotHelper.LoadRobotOrThrow)) { try { InsuranceBuy(character, robot, ref currentInsurances, maxInsurances, insuranceDays, ref usedCorporation); } catch (PerpetuumException gex) { character.SendItemErrorMessage(Commands.ProductionInsuranceBuy, gex.error, robot); } } usedCorporation?.SendInsuranceList(); }
public void HandleRequest(IRequest request) { using (var scope = Db.CreateTransaction()) { var character = request.Session.Character; var facilityEid = request.Data.GetOrDefault <long>(k.facility); var targetEids = request.Data.GetOrDefault <long[]>(k.target); _productionManager.GetFacilityAndCheckDocking(facilityEid, character, out InsuraceFacility insuraceFacility); insuraceFacility.InsuranceBuy(character, targetEids); var list = InsuranceHelper.InsuranceList(character); var result = new Dictionary <string, object> { { k.insurance, list } }; if (list.Count > 0) { Message.Builder.FromRequest(request).WithData(result).Send(); } else { Message.Builder.FromRequest(request).WithEmpty().Send(); } scope.Complete(); } }
public void HandleRequest(IRequest request) { InsuranceHelper.LoadInsurancePrices(); var result = InsuranceHelper.GetInsuranceState(); Message.Builder.FromRequest(request).WithData(result).Send(); }
public static void CheckAllowedTypesForAddAndThrowIfFailed(Item item) { item.ThrowIfType <Container>(ErrorCodes.ContainersAreNotSupportedTryCreatingACorporateFolder); if (item is Robot robot) { robot.IsSelected.ThrowIfTrue(ErrorCodes.RobotMustBeDeselected); InsuranceHelper.IsPrivateInsured(robot.Eid).ThrowIfTrue(ErrorCodes.OperationNotAllowedOnInsuredItem); } }
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 ProductionProcessor(IProductionDataAccess productionDataAccess, IProductionInProgressRepository pipRepository, ProductionDescription.Factory productionDescFactory, IEntityServices entityServices, InsuranceHelper insuranceHelper, MissionProcessor missionProcessor) { _productionDataAccess = productionDataAccess; _pipRepository = pipRepository; _productionDescFactory = productionDescFactory; _entityServices = entityServices; _insuranceHelper = insuranceHelper; _missionProcessor = missionProcessor; }
public void CleanUp(Character character) { //reset extensions character.ResetAllExtensions(); //reset credit character.Credit = 0; //reset sparks _sparkHelper.ResetSparks(character); //remove scanresults var repo = new MineralScanResultRepository(character); repo.DeleteAll(); //remove insurance InsuranceHelper.RemoveAll(character); //remove market orders _marketHelper.RemoveAll(character); Db.Query().CommandText("delete charactertransactions where characterid=@characterID").SetParameter("@characterID", character.Id).ExecuteNonQuery(); Db.Query().CommandText("delete productionlog where characterid=@characterID").SetParameter("@characterID", character.Id).ExecuteNonQuery(); Db.Query().CommandText("delete techtreeunlockednodes where owner=@eid").SetParameter("@eid", character.Eid).ExecuteNonQuery(); Db.Query().CommandText("delete techtreelog where character=@characterID").SetParameter("@characterID", character.Id).ExecuteNonQuery(); Db.Query().CommandText("delete techtreepoints where owner=@eid").SetParameter("@eid", character.Eid).ExecuteNonQuery(); character.HomeBaseEid = null; //delete all items Db.Query().CommandText("delete entities where owner=@rootEid") .SetParameter("@rootEid", character.Eid) .ExecuteNonQuery(); Transaction.Current.OnCommited(() => { //stop productions ProductionAbort(character); //stop all missions MissionForceAbort(character); }); //do/finish character wizard }
public void Visit(Robot robot) { robot.IsDamaged.ThrowIfTrue(ErrorCodes.RobotHasToBeRepaired); robot.IsSelected.ThrowIfTrue(ErrorCodes.RobotMustBeDeselected); InsuranceHelper.IsInsured(robot.Eid).ThrowIfTrue(ErrorCodes.ItemIsInsuredOperationFails); robot.VisitRobotComponents(this); robot.VisitRobotInventory(this); foreach (var component in robot.Components) { Entity.Repository.Delete(component); } PackItem(robot); }
public void SendInsuranceList() { var corpInfo = InsuranceHelper.GetCorporationInsurances(Eid); var affectedMembers = GetMembersWithAnyRoles(CorporationRole.CEO, CorporationRole.DeputyCEO, CorporationRole.Accountant).Select(r => r.character).ToArray(); if (corpInfo.Count > 0) { Message.Builder.SetCommand(Commands.ProductionCorporationInsuranceList).WithData(corpInfo).ToCharacters(affectedMembers).Send(); } else { var emptyDict = new Dictionary <string, object> { { k.state, k.empty } }; Message.Builder.SetCommand(Commands.ProductionCorporationInsuranceList).WithData(emptyDict).ToCharacters(affectedMembers).Send(); } }
public ErrorCodes InsuranceDelete(Character character, long targetEid) { //auto clean InsuranceHelper.CleanUpInsurances(); var item = Item.GetOrThrow(targetEid); var insurance = _insuranceHelper.GetInsurance(targetEid); if (insurance == null) { return(ErrorCodes.NoError); } if (insurance.corporationEid != null) { var corporation = character.GetCorporation(); var role = corporation.GetMemberRole(character); //ha nem az issuer akarja torolni if (insurance.character != character) { //akkor torolhetio a CEO, dpCEO if (!role.IsAnyRole(CorporationRole.DeputyCEO, CorporationRole.CEO, CorporationRole.Accountant)) { return(ErrorCodes.InsufficientPrivileges); } } } else { //le lehet torolni ha // - nalad van // - te kototted if (!((item.Owner == character.Eid) || (insurance.character == character))) { return(ErrorCodes.AccessDenied); } } _insuranceHelper.DeleteAndInform(insurance, item.Eid); return(ErrorCodes.NoError); }
public void HandleRequest(IRequest request) { var character = request.Session.Character; var targetEid = request.Data.GetOrDefault <long>(k.target); _productionProcessor.InsuranceDelete(character, targetEid).ThrowIfError(); var list = InsuranceHelper.InsuranceList(character); var result = new Dictionary <string, object> { { k.insurance, list } }; if (list.Count > 0) { Message.Builder.FromRequest(request).WithData(result).Send(); } else { Message.Builder.FromRequest(request).WithEmpty().Send(); } }
protected override void OnMemberRemoved(Character member) { base.OnMemberRemoved(member); //clean up insurances var deletedInsurances = InsuranceHelper.CleanUpOnCorporationLeave(member, Eid); InsuranceHelper.SendEmptyCorporationInsuranceList(member); //remove market orders CancelAllCorporationOrders(member); //last member leaving if (Members.Length <= 0) { //set the corp inactive IsActive = false; CorporationManager.DeleteYellowPages(Eid); //... do other corp closing cleanup Transaction.Current.OnCommited(() => { ZoneManager.Value.Zones.ForEach(z => z.UpdateCorporation(CorporationCommand.Close, new Dictionary <string, object> { { k.corporationEID, Eid } })); }); } else { if (deletedInsurances > 0) { //refresh insurance list SendInsuranceList(); } } }
public ReprocessSessionMember(InsuranceHelper insuranceHelper) { _insuranceHelper = insuranceHelper; }
public void HandleRequest(IRequest request) { Message.Builder.FromRequest(request) .WithData(InsuranceHelper.GetInsuranceState()) .Send(); }
public void HandleRequest(IRequest request) { var character = request.Session.Character; InsuranceHelper.SendInsuranceListToCharacter(character); }
//ennek mindenkepp vegig kell futnia private void HandlePlayerDead(IZone zone, Unit killer) { using (var scope = Db.CreateTransaction()) { EnlistTransaction(); try { killer = zone.ToPlayerOrGetOwnerPlayer(killer) ?? killer; SaveCombatLog(zone, killer); var character = Character; var dockingBase = character.GetHomeBaseOrCurrentBase(); dockingBase.DockIn(character, NormalUndockDelay, ZoneExitType.Died); PlayerDeathLogger.Log.Write(zone, this, killer); //pay out insurance if needed var wasInsured = InsuranceHelper.CheckInsuranceOnDeath(Eid, Definition); if (!Session.AccessLevel.IsAdminOrGm()) { var robotInventory = GetContainer(); Debug.Assert(robotInventory != null); var lootItems = new List <LootItem>(); // minden fittelt modul foreach (var module in Modules.Where(m => LootHelper.Roll())) { lootItems.Add(LootItemBuilder.Create(module).AsDamaged().Build()); var activeModule = module as ActiveModule; var ammo = activeModule?.GetAmmo(); if (ammo != null) { if (LootHelper.Roll()) { lootItems.Add(LootItemBuilder.Create(ammo).Build()); } } // szedjuk le a robotrol module.Parent = robotInventory.Eid; //in case the container is full //toroljuk is le, nem kell ez sehova mar Repository.Delete(module); } foreach (var item in robotInventory.GetItems(true).Where(i => i is VolumeWrapperContainer)) { //Transport assignments var wrapper = item as VolumeWrapperContainer; if (wrapper == null) { continue; } lootItems.AddRange(wrapper.GetLootItems()); wrapper.SetAllowDelete(); Repository.Delete(wrapper); } // elkerunk minden itemet a kontenerbol es valogatunk belole 50% szerint foreach (var item in robotInventory.GetItems().Where(i => LootHelper.Roll() && !i.ED.AttributeFlags.NonStackable)) { var qtyMod = FastRandom.NextDouble(); item.Quantity = (int)(item.Quantity * qtyMod); if (item.Quantity > 0) { lootItems.Add(LootItemBuilder.Create(item.Definition).SetQuantity(item.Quantity).SetRepackaged(item.ED.AttributeFlags.Repackable).Build()); } else { robotInventory.RemoveItemOrThrow(item); //toroljuk is le, nem kell ez mar Repository.Delete(item); } } if (lootItems.Count > 0) { var lootContainer = LootContainer.Create().AddLoot(lootItems).BuildAndAddToZone(zone, CurrentPosition); if (lootContainer != null) { var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.PutLoot).SetCharacter(character).SetContainer(lootContainer.Eid); foreach (var lootItem in lootItems) { b.SetItem(lootItem.ItemInfo.Definition, lootItem.ItemInfo.Quantity); Character.LogTransaction(b); } } } var killedByPlayer = (killer != null && killer.IsPlayer()); Trashcan.Get().MoveToTrash(this, Session.DisconnectTime, wasInsured, killedByPlayer, Session.InactiveTime); character.NextAvailableRobotRequestTime = DateTime.Now.AddMinutes(killedByPlayer ? ARKHE_REQUEST_TIMER_MINUTES_PVP : ARKHE_REQUEST_TIMER_MINUTES_NPC); Robot activeRobot = null; if (!killedByPlayer) { activeRobot = dockingBase.CreateStarterRobotForCharacter(character); if (activeRobot != null) { Transaction.Current.OnCommited(() => { var starterRobotInfo = new Dictionary <string, object> { { k.baseEID, Eid }, { k.robotEID, activeRobot.Eid } }; Message.Builder.SetCommand(Commands.StarterRobotCreated).WithData(starterRobotInfo).ToCharacter(character).Send(); }); } } character.SetActiveRobot(activeRobot); } else { // mert rendesek vagyunk this.Repair(); // csak az adminok miatt kell var container = dockingBase.GetPublicContainer(); container.AddItem(this, false); } this.Save(); scope.Complete(); } catch (Exception ex) { Logger.Exception(ex); } } }
public ErrorCodes GetInsurancePrice(Item item, out double insuranceFee, out double payOut) { insuranceFee = 0; payOut = 0; return(InsuranceHelper.GetInsurancePrice(item.Definition, ref insuranceFee, ref payOut)); }
public InsuraceFacility(InsuranceHelper insuranceHelper) { _insuranceHelper = insuranceHelper; }
public ErrorCodes InsuranceQuery(Character character, IEnumerable <long> targetEids, out Dictionary <string, object> result) { var ec = ErrorCodes.NoError; result = new Dictionary <string, object>(); var corporationEid = character.CorporationEid; var insuranceDays = GetInsuranceDays(character); var maxInsurances = RealMaxSlotsPerCharacter(character); var currentInsurances = InsuranceHelper.CountInsurances(character); var counter = 0; foreach (var eid in targetEids) { var useCorporationWallet = false; var insurance = _insuranceHelper.GetInsurance(eid); var endDate = DateTime.Now.AddDays(insuranceDays); var item = Item.GetOrThrow(eid); var robot = item as Robot; if (robot == null) { ec = ErrorCodes.InsuranceAllowedForRobotsOnly; continue; } if (!robot.IsSingleAndUnpacked) { ec = ErrorCodes.RobotMustbeSingleAndNonRepacked; continue; } double price, payOut; if ((ec = GetInsurancePrice(robot, out price, out payOut)) != ErrorCodes.NoError) { continue; } var oneRobot = new Dictionary <string, object> { { k.price, price }, { k.payOut, payOut }, { k.eid, robot.Eid }, }; if ((ec = _insuranceHelper.GetConditions(character, robot, insurance, corporationEid, insuranceDays, maxInsurances, currentInsurances, ref endDate, ref useCorporationWallet)) != ErrorCodes.NoError) { continue; } oneRobot.Add(k.endTime, endDate); //ez lesz ha befizet ra if (insurance != null) { oneRobot.Add(k.current, insurance.endDate); //ez a mostani, mert ez mar biztositva van } oneRobot.Add(k.useCorporationWallet, useCorporationWallet); result.Add("i" + counter++, (object)oneRobot); } if (targetEids.Count() == 1) { return(ec); } return(ErrorCodes.NoError); }
public override void OnDeleteFromDb() { InsuranceHelper.DeleteAndInform(this); base.OnDeleteFromDb(); }