public PartnerekViewModel()
        {
            PartnerHelper partnerhelper = new PartnerHelper();

            Partnerek          = partnerhelper.GetPartners();
            SearchablePartners = new BindableCollection <Partner>(Partnerek);
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Developer"/> class.
 /// </summary>
 /// <param name="service">
 /// The service.
 /// </param>
 /// <param name="partnerService">
 /// The partner Service.
 /// </param>
 /// <param name="prefix">
 /// The prefix.
 /// </param>
 /// <param name="httpClient">
 /// The http Client.
 /// </param>
 /// <param name="limits">
 /// The limits.
 /// </param>
 public Developer(TimerService service, PartnerService partnerService, PartnerHelper pHelper, IDocumentStore store, PrefixService prefix, HttpClient httpClient, TranslateLimitsNew limits, DBLApiService dblApi)
 {
     timerService   = service;
     prefixService  = prefix;
     PartnerService = partnerService;
     docStore       = store;
     client         = httpClient;
     Limits         = limits;
     PartnerHelper  = pHelper;
     DblApi         = dblApi;
 }
Exemple #3
0
        private void GetPartners()
        {
            BindableCollection <Partner> temp = new BindableCollection <Partner>();
            PartnerHelper helper = new PartnerHelper();

            foreach (Partner partner in helper.GetPartners())
            {
                temp.Add(partner);
            }
            Partnerek = temp;
        }
        public BevetelezesekViewModel()
        {
            PartnerHelper partnerHelper = new PartnerHelper();

            Partnerek = partnerHelper.GetPartners();

            Ruhak = new BindableCollection <Munkaruha>();
            if (Partnerek.Count > 0)
            {
                SelectedPartner = Partnerek[0];
            }
        }
        public void Save()
        {
            PartnerHelper partnerHelper = new PartnerHelper();

            if (partnerHelper.ModifyPartner(Partner))
            {
                TryClose(true);
            }
            else
            {
                TryClose(false);
            }
        }
        public void AddPartner()
        {
            var windowmanager = new WindowManager();
            var window        = new AddAndModifyPartnerViewModel();
            var result        = windowmanager.ShowDialog(window, null, null);

            if (result == true)
            {
                PartnerHelper partnerhelper = new PartnerHelper();
                Partnerek          = partnerhelper.GetPartners();
                SearchablePartners = new BindableCollection <Partner>(Partnerek);
                MessageBox.Show("Partner hozzáadva");
            }
        }
 public void DoubleClickPartnerList()
 {
     if (SelectedPartner != null)
     {
         var windowmanager = new WindowManager();
         var window        = new ModifyPartnerViewModel(SelectedPartner);
         var result        = windowmanager.ShowDialog(window, null, null);
         if (result == true)
         {
             PartnerHelper partnerhelper = new PartnerHelper();
             Partnerek          = partnerhelper.GetPartners();
             SearchablePartners = new BindableCollection <Partner>(Partnerek);
             MessageBox.Show("Partner módosítva.");
         }
     }
 }
 public void RemovePartner()
 {
     if (SelectedPartner != null)
     {
         var result = MessageBox.Show(string.Format("Valóban törölni szeretné a következő partnert: {0} ?", SelectedPartner.Name), "Partner törlése", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             var partnerhelper = new PartnerHelper();
             if (partnerhelper.DeletePartner(SelectedPartner.Id))
             {
                 Partnerek          = partnerhelper.GetPartners();
                 SearchablePartners = new BindableCollection <Partner>(Partnerek);
                 MessageBox.Show("Partner törölve.");
             }
             else
             {
                 MessageBox.Show("Sikertelen törlés. Amíg van olyan cikk kiadva akinél ez a partner szerepel nem lehet törölni!");
             }
         }
     }
 }
Exemple #9
0
        public void SaveAction()
        {
            if (NewName == null || NewName == string.Empty)
            {
                return;
            }
            PartnerHelper helper = new PartnerHelper();

            if (helper.AddPartner(
                    new Partner()
            {
                Name = NewName
            }
                    ))
            {
                TryClose(true);
            }
            else
            {
                TryClose(false);
            }
        }
Exemple #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TimerService"/> class.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="partnerService">
        /// The partner Service.
        /// </param>
        /// <param name="pHelper">
        /// The p Helper.
        /// </param>
        /// <param name="provider">
        /// The provider.
        /// </param>
        public TimerService(DiscordShardedClient client, PartnerService partnerService, PartnerHelper pHelper, BirthdayService bService, DatabaseObject config, IServiceProvider provider)
        {
            partnerHelper   = pHelper;
            PartnerService  = partnerService;
            Provider        = provider;
            ShardedClient   = client;
            BirthdayService = bService;

            timer = new Timer(
                async _ =>
            {
                try
                {
                    if (config.RunPartner)
                    {
                        var t = Task.Run(PartnerAsync);
                    }

                    if (config.RunBirthday)
                    {
                        var b = Task.Run(BirthdayAsync);
                    }
                }
                catch (Exception e)
                {
                    LogHandler.LogMessage("Partner Error:\n" + $"{e}", LogSeverity.Error);
                }

                GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                GC.WaitForPendingFinalizers();

                LastFireTime = DateTime.UtcNow;
            },
                null,
                TimeSpan.Zero,
                TimeSpan.FromMinutes(FirePeriod));
        }
Exemple #11
0
 public Tests(PartnerService pService, PartnerHelper pHelper)
 {
     _Partner     = pService;
     _PartnerHelp = pHelper;
 }
Exemple #12
0
 public Partner(PrefixService prefixService, PartnerService partnerService, PartnerHelper partnerHelper)
 {
     PrefixService  = prefixService;
     PartnerService = partnerService;
     PartnerHelp    = partnerHelper;
 }
Exemple #13
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            default:
                bool delay = false;
                if (Option == 255)
                {
                    delay  = true;
                    Option = 0;
                }
                Mate mate = null;
                if (Option != 0)
                {
                    mate = session.Character.Mates.Find(s => s.MateType == MateType.Partner && s.PetId == Option - 1);
                    if (mate == null || mate.IsTemporalMate)
                    {
                        return;
                    }
                }
                short         slot      = inv.Slot;
                InventoryType equipment = InventoryType.Wear;
                if (Option > 0)
                {
                    equipment = (InventoryType)(12 + Option);
                }

                InventoryType itemToWearType = inv.Type;

                if (inv == null)
                {
                    return;
                }
                if (ItemValidTime > 0 && !inv.IsBound)
                {
                    inv.ItemDeleteTime = DateTime.Now.AddSeconds(ItemValidTime);
                }
                else if (!inv.IsBound && ItemType == ItemType.Jewelery && new int[] { 3951, 3952, 3953, 3954, 3955, 7427 }.Contains(EffectValue))
                {
                    inv.ItemDeleteTime = DateTime.Now.AddSeconds(3600);
                }
                if (!inv.IsBound)
                {
                    switch (inv.Item.Effect)
                    {
                    case 790:         // Tarot
                    case 932:         // Attack amulet
                    case 933:         // defense amulet
                        inv.BoundCharacterId = session.Character.CharacterId;
                        break;
                    }

                    if (!delay && ((EquipmentSlot == EquipmentType.Fairy && (MaxElementRate == 70 || MaxElementRate == 80)) || EquipmentSlot == EquipmentType.CostumeHat || EquipmentSlot == EquipmentType.CostumeSuit || EquipmentSlot == EquipmentType.WeaponSkin))
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)itemToWearType}^{slot}^1 {Language.Instance.GetMessageFromKey("ASK_BIND")}");
                        return;
                    }
                    if (delay)
                    {
                        inv.BoundCharacterId = session.Character.CharacterId;
                    }
                }

                double timeSpanSinceLastSpUsage = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp;

                if (EquipmentSlot == EquipmentType.Sp && inv.Rare == -2)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0));
                    return;
                }

                if (Option == 0)
                {
                    if (EquipmentSlot == EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Specialist) != null)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0));
                        return;
                    }

                    if ((ItemType != ItemType.Weapon &&
                         ItemType != ItemType.Armor &&
                         ItemType != ItemType.Fashion &&
                         ItemType != ItemType.Jewelery &&
                         ItemType != ItemType.Specialist) ||
                        LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) ||
                        (ItemType != ItemType.Jewelery && EquipmentSlot != EquipmentType.Boots && EquipmentSlot != EquipmentType.Gloves && ((Class >> (byte)session.Character.Class) & 1) != 1))
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }

                    if (session.Character.UseSp)
                    {
                        if (session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, equipment) is ItemInstance sp && sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0));
                            return;
                        }
                    }

                    if (ItemType == ItemType.Weapon || ItemType == ItemType.Armor)
                    {
                        if (inv.BoundCharacterId.HasValue && inv.BoundCharacterId.Value != session.Character.CharacterId)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                            return;
                        }
                    }

                    if (session.Character.UseSp && EquipmentSlot == EquipmentType.Sp)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10));
                        return;
                    }

                    if (session.Character.JobLevel < LevelJobMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10));
                        return;
                    }
                }
                else if (mate != null)
                {
                    if (inv.Item.EquipmentSlot == EquipmentType.MainWeapon || inv.Item.EquipmentSlot == EquipmentType.SecondaryWeapon || inv.Item.EquipmentSlot == EquipmentType.Armor)
                    {
                        switch (mate.Monster.AttackClass)
                        {
                        case 0:
                            if (inv.ItemVNum != 990 && inv.ItemVNum != 997)
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                                return;
                            }
                            break;

                        case 1:
                            if (inv.ItemVNum != 991 && inv.ItemVNum != 996)
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                                return;
                            }
                            break;

                        case 2:
                            if (inv.ItemVNum != 992 && inv.ItemVNum != 995)
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                                return;
                            }
                            break;
                        }
                    }

                    if (mate.Level < LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }

                    Item partnerEquipment = ServerManager.GetItem(inv.ItemVNum);

                    bool isBadEquipment = false;

                    switch (partnerEquipment.EquipmentSlot)
                    {
                    case EquipmentType.MainWeapon:
                    {
                        if (partnerEquipment.ItemSubType != 12)
                        {
                            isBadEquipment = true;
                        }
                        else
                        {
                            mate.WeaponInstance = inv;
                        }
                    }
                    break;

                    case EquipmentType.Armor:
                    {
                        if (partnerEquipment.ItemSubType != 4)
                        {
                            isBadEquipment = true;
                        }
                        else
                        {
                            mate.ArmorInstance = inv;
                        }
                    }
                    break;

                    case EquipmentType.Gloves:
                    {
                        mate.GlovesInstance = inv;
                    }
                    break;

                    case EquipmentType.Boots:
                    {
                        mate.BootsInstance = inv;
                    }
                    break;

                    case EquipmentType.Sp:
                    {
                        if (mate.IsUsingSp)
                        {
                            return;
                        }

                        if (partnerEquipment.ItemSubType != 4 ||
                            !PartnerHelper.CanWearSp(mate.NpcMonsterVNum, inv.ItemVNum))
                        {
                            isBadEquipment = true;
                        }
                        else
                        {
                            if (!mate.CanUseSp())
                            {
                                int spRemainingCooldown = mate.GetSpRemainingCooldown();
                                session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("STAY_TIME"), spRemainingCooldown), 11));
                                session.SendPacket($"psd {spRemainingCooldown}");
                                return;
                            }

                            mate.Sp = new PartnerSp(inv);
                        }
                    }
                    break;
                    }

                    if (isBadEquipment)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }
                }

                ItemInstance currentlyEquippedItem = session.Character.Inventory.LoadBySlotAndType((short)EquipmentSlot, equipment);

                if (currentlyEquippedItem == null)
                {
                    // move from equipment to wear
                    session.Character.Inventory.MoveInInventory(inv.Slot, itemToWearType, equipment);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInventoryRemove(itemToWearType, slot));
                }
                else
                {
                    Logger.LogUserEvent("EQUIPMENT_TAKEOFF", session.GenerateIdentity(), $"IIId: {currentlyEquippedItem.Id} ItemVnum: {currentlyEquippedItem.ItemVNum} Upgrade: {currentlyEquippedItem.Upgrade} Rare: {currentlyEquippedItem.Rare}");

                    // move from wear to equipment and back
                    session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, equipment, itemToWearType, inv.Slot);
                    session.SendPacket(currentlyEquippedItem.GenerateInventoryAdd());
                    session.Character.EquipmentBCards.RemoveAll(o => o.ItemVNum == currentlyEquippedItem.ItemVNum);
                }

                Logger.LogUserEvent("EQUIPMENT_WEAR", session.GenerateIdentity(), $"IIId: {inv.Id} ItemVnum: {inv.ItemVNum} Upgrade: {inv.Upgrade} Rare: {inv.Rare}");

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequiredItems?.Any(obj => obj?.VNum == VNum) == true)?.Copy();
                if (raid?.DailyEntries > 0)
                {
                    var entries = raid.DailyEntries - session.Character.GeneralLogs.CountLinq(s => s.LogType == "InstanceEntry" && short.Parse(s.LogData) == raid.Id && s.Timestamp.Date == DateTime.Today);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("INSTANCE_ENTRIES"), entries), 10));
                }

                if (mate == null)
                {
                    session.Character.EquipmentBCards.AddRange(inv.Item.BCards);

                    switch (inv.Item.ItemType)
                    {
                    case ItemType.Armor:
                        session.Character.ShellEffectArmor.Clear();

                        foreach (ShellEffectDTO dto in inv.ShellEffects)
                        {
                            session.Character.ShellEffectArmor.Add(dto);
                        }
                        break;

                    case ItemType.Weapon:
                        switch (inv.Item.EquipmentSlot)
                        {
                        case EquipmentType.MainWeapon:
                            session.Character.ShellEffectMain.Clear();

                            foreach (ShellEffectDTO dto in inv.ShellEffects)
                            {
                                session.Character.ShellEffectMain.Add(dto);
                            }
                            break;

                        case EquipmentType.SecondaryWeapon:
                            session.Character.ShellEffectSecondary.Clear();

                            foreach (ShellEffectDTO dto in inv.ShellEffects)
                            {
                                session.Character.ShellEffectSecondary.Add(dto);
                            }
                            break;
                        }
                        break;
                    }
                }
                else
                {
                    mate.BattleEntity.BCards.AddRange(inv.Item.BCards);
                }

                if (Option == 0)
                {
                    session.SendPackets(session.Character.GenerateStatChar());
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());

                    if (EquipmentSlot == EquipmentType.Fairy)
                    {
                        ItemInstance fairy = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Fairy, equipment);
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXPData(fairy.ElementRate + fairy.Item.ElementRate)), 10));
                    }

                    if (EquipmentSlot == EquipmentType.Amulet)
                    {
                        session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 39));
                        inv.BoundCharacterId = session.Character.CharacterId;
                        if (inv.ItemDeleteTime > DateTime.Now || inv.DurabilityPoint > 0)
                        {
                            session.Character.AddBuff(new Buff(62, session.Character.Level), session.Character.BattleEntity);
                        }
                    }
                }
                else if (mate != null)
                {
                    session.SendPacket(mate.GenerateScPacket());
                }
                break;
            }
        }