Exemplo n.º 1
0
    private static void HandleUpdateCatalysts(GameSession session, PacketReader packet)
    {
        long itemUid     = packet.ReadLong();
        bool addCatalyst = packet.ReadBool();

        if (!session.Player.Inventory.HasItem(itemUid) && !session.Player.Inventory.ItemIsEquipped(itemUid))
        {
            return;
        }

        ItemEnchant itemEnchant = session.Player.ItemEnchant;

        if (itemEnchant is null)
        {
            return;
        }

        if (!itemEnchant.UpdateAdditionalCatalysts(itemUid, addCatalyst))
        {
            EnchantHelper.ExcessCatalystError(session, itemEnchant);
            return;
        }

        session.Send(ItemEnchantPacket.UpdateCharges(itemEnchant));
    }
Exemplo n.º 2
0
    private void CreateNewStats(Item item)
    {
        Constants          = new();
        Statics            = new();
        Randoms            = new();
        Enchants           = new();
        LimitBreakEnchants = new();
        GemSockets         = new();
        if (item.Rarity is 0 or > 6)
        {
            return;
        }

        int   optionId          = ItemMetadataStorage.GetOptionMetadata(item.Id).OptionId;
        float optionLevelFactor = ItemMetadataStorage.GetOptionMetadata(item.Id).OptionLevelFactor;

        ConstantStats.GetStats(item, optionId, optionLevelFactor, out Dictionary <StatAttribute, ItemStat> constantStats);
        Constants = constantStats;
        StaticStats.GetStats(item, optionId, optionLevelFactor, out Dictionary <StatAttribute, ItemStat> staticStats);
        Statics = staticStats;
        RandomStats.GetStats(item, out Dictionary <StatAttribute, ItemStat> randomStats);
        Randoms = randomStats;
        if (item.EnchantLevel > 0)
        {
            Enchants = EnchantHelper.GetEnchantStats(item.EnchantLevel, item.Type, item.Level);
        }
        GetGemSockets(item, optionLevelFactor);
    }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Make the external spelling dictionary conform as closely as possible to the spelling
        /// status recorded in the Wordforms. We try to keep these in sync, but when we first
        /// create an external spelling dictionary we need to make it match, and even later, on
        /// restoring a backup or when a user on another computer changed the database, we may
        /// need to re-synchronize. The best we can do is to Add all the words we know are
        /// correct and remove all the others we know about at all; it's possible that a
        /// wordform that was previously correct and is now deleted will be thought correct by
        /// the dictionary. In the case of a major language, of course, it's also possible that
        /// words that were never in our inventory at all will be marked correct. This is the
        /// best we know how to do.
        ///
        /// We also force there to be an external spelling dictionary for the default vernacular WS;
        /// others are updated only if they already exist.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public static void ConformSpellingDictToWordforms(FdoCache cache)
        {
            // Force a dictionary to exist for the default vernacular writing system.
            IFdoServiceLocator servloc = cache.ServiceLocator;
            var lgwsFactory            = servloc.GetInstance <ILgWritingSystemFactory>();

            using (EnchantHelper.EnsureDictionary(cache.DefaultVernWs, lgwsFactory))
            {
            }

            // Make all existing spelling dictionaries give as nearly as possible the right answers.
            foreach (IWritingSystem wsObj in cache.ServiceLocator.WritingSystems.VernacularWritingSystems)
            {
                int ws = wsObj.Handle;
                using (var dict = EnchantHelper.GetDictionary(ws, lgwsFactory))
                {
                    if (dict == null)
                    {
                        continue;
                    }
                    // we only force one to exist for the default, others might not have one.
                    foreach (IWfiWordform wf in servloc.GetInstance <IWfiWordformRepository>().AllInstances())
                    {
                        string wordform = wf.Form.get_String(ws).Text;
                        if (!string.IsNullOrEmpty(wordform))
                        {
                            EnchantHelper.SetSpellingStatus(wordform,
                                                            wf.SpellingStatus == (int)SpellingStatusStates.correct, dict);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Copies the spelling override files from the restore location to the place where
 /// Enchant expects to fnd them.
 /// REVIEW: Should this be a move instead of a copy?
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void CopySpellingOverrideFilesFromBackupToEnchant()
 {
     foreach (var file in Directory.GetFiles(m_restoreSettings.SpellingDictionariesPath))
     {
         EnchantHelper.AddReplaceSpellingOverrideFile(file);
     }
 }
Exemplo n.º 5
0
        public override bool TakeAction()
        {
            MosaicInfo mosaicInfo = new ShareCacheStruct <MosaicInfo>().FindKey(postion);

            if (mosaicInfo != null)
            {
                notchColor = mosaicInfo.MosaicColor;
            }
            var package     = UserEnchant.Get(ContextUser.UserID);
            var itemPackage = UserItemPackage.Get(ContextUser.UserID);

            if (package == null || itemPackage == null)
            {
                return(false);
            }

            UserItemInfo userItem = itemPackage.ItemPackage.Find(m => m.UserItemID == userItemID);

            if (userItem != null)
            {
                int openPostion = EnchantHelper.EnchantOpenGridNum(userItem.ItemLv);
                if (postion > openPostion)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1213_GridNumNotEnough;
                    return(false);
                }
                var userEnchantInfo = package.EnchantPackage.Find(m => m.UserItemID == userItemID && m.Position == postion);
                if (userEnchantInfo != null)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1259_EnchantOpenGridFull;
                    return(false);
                }
                List <UserEnchantInfo> enchantList = new List <UserEnchantInfo>();
                var enchantInfoArray = package.EnchantPackage.FindAll(m => string.IsNullOrEmpty(m.UserItemID));

                foreach (var info in enchantInfoArray)
                {
                    EnchantInfo enchantInfo = new ShareCacheStruct <EnchantInfo>().FindKey(info.EnchantID);
                    if (enchantInfo != null && EnchantHelper.IsMosaicColor(postion, enchantInfo.ColorType))
                    {
                        enchantList.Add(info);
                    }
                }
                if (enchantList.Count == 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1261_EnchantEquipmentNotEnough;
                    return(false);
                }
                enchantArray = enchantList.GetPaging(pageIndex, pageSize, out PageCount).ToArray();
            }
            return(true);
        }
Exemplo n.º 6
0
    private static void HandleOpheliaEnchant(GameSession session, PacketReader packet)
    {
        long itemUid = packet.ReadLong();

        IInventory inventory = session.Player.Inventory;
        Item       item      = inventory.GetFromInventoryOrEquipped(itemUid);

        if (item is null)
        {
            return;
        }

        ItemEnchant itemEnchantStats = session.Player.ItemEnchant;

        if (itemEnchantStats.Level != item.EnchantLevel && itemEnchantStats.ItemUid != item.Uid)
        {
            itemEnchantStats = GetEnchantInfo(item, EnchantType.Ophelia);
        }

        // Check if player has enough ingredients
        if (!EnchantHelper.PlayerHasIngredients(itemEnchantStats, inventory) || !EnchantHelper.PlayerHasRequiredCatalysts(itemEnchantStats))
        {
            session.Send(ItemEnchantPacket.Notice((short)ItemEnchantError.NotEnoughMaterials));
            EnchantHelper.TalkError(session, itemEnchantStats);
            return;
        }

        foreach (EnchantIngredient ingredient in itemEnchantStats.Ingredients)
        {
            inventory.ConsumeByTag(session, ingredient.Tag.ToString(), ingredient.Amount);
        }

        foreach (long catalystUids in itemEnchantStats.CatalystItemUids)
        {
            inventory.ConsumeItem(session, catalystUids, 1);
        }

        Random random       = Random.Shared;
        double randomResult = random.NextDouble();

        if (itemEnchantStats.Rates.TotalSuccessRate() < (float)(randomResult * 100))
        {
            FailEnchant(session, itemEnchantStats, item);
            itemEnchantStats.Success = false;
            return;
        }

        // Enchant success
        itemEnchantStats.Success = true;
        itemEnchantStats.Level++;
        SetEnchantStats(session, itemEnchantStats, item);
    }
Exemplo n.º 7
0
    private static void HandlePeachyEnchant(GameSession session, PacketReader packet)
    {
        long itemUid = packet.ReadLong();

        IInventory inventory = session.Player.Inventory;
        Item       item      = inventory.GetFromInventoryOrEquipped(itemUid);

        if (item is null)
        {
            return;
        }

        ItemEnchant itemEnchantStats = session.Player.ItemEnchant;

        if (itemEnchantStats.Level != item.EnchantLevel && itemEnchantStats.ItemUid != item.Uid)
        {
            itemEnchantStats = GetEnchantInfo(item, EnchantType.Peachy);
        }

        // Check if player has enough ingredients
        if (!EnchantHelper.PlayerHasIngredients(itemEnchantStats, inventory) || !EnchantHelper.PlayerHasRequiredCatalysts(itemEnchantStats))
        {
            session.Send(ItemEnchantPacket.Notice((short)ItemEnchantError.NotEnoughMaterials));
            EnchantHelper.TalkError(session, itemEnchantStats);
            return;
        }

        foreach (EnchantIngredient ingredient in itemEnchantStats.Ingredients)
        {
            inventory.ConsumeByTag(session, ingredient.Tag.ToString(), ingredient.Amount);
        }

        foreach (long catalystUids in itemEnchantStats.CatalystItemUids)
        {
            inventory.ConsumeItem(session, catalystUids, 1);
        }

        int neededEnchants = GetNeededEnchantExp(item.EnchantLevel);
        int expGained      = (int)Math.Ceiling((double)(10000 / neededEnchants));

        item.EnchantExp += expGained;
        if (item.EnchantExp >= 10000)
        {
            item.EnchantExp = 0;
            SetEnchantStats(session, itemEnchantStats, item);
        }

        itemEnchantStats.Success = true;
        itemEnchantStats.Level++;
        itemEnchantStats.CatalystItemUids.Clear();
        session.Send(ItemEnchantPacket.UpdateExp(item));
    }
Exemplo n.º 8
0
        private IEnumerable <String> GetSpellingDictionaryFilesList()
        {
            var enchantDictionaryFiles = new HashSet <String>();
            var enchantDictionaryList  = EnchantHelper.GetEnchantDictionaryList();

            var wsManager = m_cache.ServiceLocator.WritingSystemManager;

            foreach (IWritingSystem ws in wsManager.LocalWritingSystems)
            {
                var spellCheckingDictionary = ws.SpellCheckingId;
                if (string.IsNullOrEmpty(spellCheckingDictionary) || spellCheckingDictionary == "<None>")
                {
                    continue;                     // no spelling dictionary for WS
                }
                foreach (var languageId in enchantDictionaryList)
                {
                    if (languageId.StartsWith(spellCheckingDictionary) || spellCheckingDictionary.StartsWith(languageId))
                    {
                        if (EnchantHelper.OverrideSpellingsExist(languageId))
                        {
                            var dictionaryPath = EnchantHelper.GetOverrideDictionaryPath(languageId);
                            if (!String.IsNullOrEmpty(dictionaryPath))
                            {
                                enchantDictionaryFiles.Add(dictionaryPath);
                            }
                            //Also include the other file which we think is for spellings the user is excluding
                            //but which are in the main enchant dictionary file for this language.
                            //At this point in time July 2010 FieldWorks does not add anything to this file but
                            //we are backing it up anyway in case FW does in the future make changes to this file
                            //or if the user manually edits this file.
                            var excludedSpellingsFile = Path.ChangeExtension(dictionaryPath, ".exc");
                            if (!String.IsNullOrEmpty(excludedSpellingsFile) && File.Exists(excludedSpellingsFile))
                            {
                                enchantDictionaryFiles.Add(excludedSpellingsFile);
                            }
                        }
                    }
                }
            }
            //Now that we have the list of Enchant files
            if (!Directory.Exists(m_settings.SpellingDictionariesPath))
            {
                Directory.CreateDirectory(m_settings.SpellingDictionariesPath);
            }
            else
            {
                RemoveAllFilesFromFolder(m_settings.SpellingDictionariesPath);
            }
            CopyAllFilesToFolder(enchantDictionaryFiles, m_settings.SpellingDictionariesPath);
            return(AllFilesInADirectory(m_settings.SpellingDictionariesPath));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Enable the spelling tool always. Correct the property value if need be to match whether
        /// we are actually showing vernacular spelling.
        /// </summary>
        /// <param name="commandObject"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public virtual bool OnDisplayUseVernSpellingDictionary(object commandObject,
                                                               ref UIItemDisplayProperties display)
        {
            CheckDisposed();

            display.Enabled = display.Visible = Cache != null;
            bool checking = EnchantHelper.DictionaryExists(Cache.DefaultVernWs, Cache.LanguageWritingSystemFactoryAccessor);

            // Make sure the property value is consistent. It can get off, e.g., if the value FLEx remembers from its
            // last run is not consistent with what TE stored in the database.
            m_mediator.PropertyTable.SetProperty("UseVernSpellingDictionary", checking);
            display.Checked = checking;
            return(true);            //we've handled this
        }
Exemplo n.º 10
0
        /// <summary>
        /// Ensure that there is a spell-checking dictionary for this writing system. If there is not
        /// already, create one. Then return it (whether new or not).
        /// </summary>
        /// <returns></returns>
        public Enchant.Dictionary EnsureDictionary()
        {
            // This undoes the effect of disabling it by setting the spelling dictionary name to <None>.
            ILgWritingSystemFactory wsf      = m_cache.LanguageWritingSystemFactoryAccessor;
            IWritingSystem          wsEngine = wsf.get_EngineOrNull(Hvo);

            if (String.IsNullOrEmpty(wsEngine.SpellCheckDictionary) || wsEngine.SpellCheckDictionary == "<None>")
            {
                wsEngine.SpellCheckDictionary = wsEngine.IcuLocale;
            }

            int ws = m_cache.DefaultVernWs;

            return(EnchantHelper.EnsureDictionary(ws, ICULocale, wsf));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 合成附魔符
        /// </summary>
        /// <param name="_userEntID1"></param>
        /// <param name="_userEntID2"></param>
        /// <param name="entExp"></param>
        private void UpdateEnchant(string _userEntID1, string _userEntID2, int entExp)
        {
            var             package = UserEnchant.Get(Uid);
            UserEnchantInfo uEInfo1 = package.EnchantPackage.Find(m => m.UserEnchantID == _userEntID1);
            UserEnchantInfo uEInfo2 = package.EnchantPackage.Find(m => m.UserEnchantID == _userEntID2);

            if (uEInfo1 != null && uEInfo2 != null)
            {
                int experience = MathUtils.Addition(uEInfo2.CurrExprience, entExp);
                uEInfo1.CurrExprience = MathUtils.Addition(uEInfo1.CurrExprience, experience);
                package.SaveEnchant(uEInfo1);
                EnchantHelper.CheckEnchantEscalate(ContextUser.UserID, _userEntID1);
                package.RemoveEnchant(uEInfo2);
            }
        }
Exemplo n.º 12
0
        public override bool TakeAction()
        {
            GameUser user     = null;
            string   puUserID = string.Empty;

            if (!string.IsNullOrEmpty(toUserID))
            {
                puUserID = toUserID;
                user     = UserCacheGlobal.LoadOffline(toUserID);
            }
            else
            {
                puUserID = ContextUser.UserID;
                user     = new GameDataCacheSet <GameUser>().FindKey(ContextUser.UserID);
                UserFunction userFunction = new GameDataCacheSet <UserFunction>().FindKey(ContextUser.UserID,
                                                                                          FunctionEnum.Enchant);
                if (userFunction != null)
                {
                    EnchantHelper.EnchantFunctionOpen(ContextUser);
                }
                else
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_NoFun;
                    return(false);
                }
            }
            generalArray = new GameDataCacheSet <UserGeneral>().FindAll(puUserID, m => m.GeneralStatus == GeneralStatus.DuiWuZhong && m.GeneralType != GeneralType.Soul).ToArray();
            if (user != null)
            {
                goldNum = user.GoldNum;
                if (user.UserExtend != null)
                {
                    enchantPackNum = user.UserExtend.EnchantGridNum;
                    moShiNum       = user.UserExtend.MoJingNum;
                }
            }
            package = UserEnchant.Get(puUserID);
            if (package != null && string.IsNullOrEmpty(toUserID))
            {
                var enchantsArray = package.EnchantPackage.FindAll(m => string.IsNullOrEmpty(m.UserItemID));
                enchantPackageArray = enchantsArray.GetPaging(pageIndex, pageSize, out pageCount).ToArray();
            }
            mosaicList = new ConfigCacheSet <MosaicInfo>().FindAll().ToArray();
            return(true);
        }
Exemplo n.º 13
0
 public override void BuildPacket()
 {
     PushIntoStack(PageCount);
     PushIntoStack(enchantArray.Length);
     foreach (var enchant in enchantArray)
     {
         EnchantInfo enchantInfo = new ShareCacheStruct <EnchantInfo>().FindKey(enchant.EnchantID);
         abilityNum = EnchantHelper.EnchantAbilityStr(enchant.EnchantID, enchant.EnchantLv);
         DataStruct dsItem = new DataStruct();
         dsItem.PushIntoStack(enchant.UserEnchantID.ToNotNullString());
         dsItem.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.EnchantName.ToNotNullString());
         dsItem.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.HeadID.ToNotNullString());
         dsItem.PushIntoStack((short)enchant.EnchantLv);
         dsItem.PushIntoStack(enchantInfo == null ? (short)0 : (short)enchantInfo.ColorType);
         dsItem.PushIntoStack(enchantInfo == null ? (short)0 : (short)enchantInfo.AbilityType);
         dsItem.PushIntoStack(abilityNum.ToNotNullString());
         PushIntoStack(dsItem);
     }
 }
Exemplo n.º 14
0
        public override bool TakeAction()
        {
            if (ContextUser.UserExtend != null && latticeNum > ContextUser.UserExtend.EnchantGridNum)
            {
                int openGold   = EnchantHelper.EnchantOpenGoldNum(latticeNum, ContextUser.UserExtend.EnchantGridNum);
                int subGridNum = MathUtils.Subtraction(latticeNum, ContextUser.UserExtend.EnchantGridNum);
                if (ops == 1)
                {
                    ErrorCode = ops;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1260_UseGoldOpenPackage, openGold, subGridNum);
                    return(false);
                }
                else if (ops == 2)
                {
                    if (ContextUser.GoldNum >= openGold)
                    {
                        ErrorCode = ops;
                        int goldNum = ContextUser.GoldNum;
                        ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, openGold);
                        ContextUser.UserExtend.UpdateNotify(obj =>
                        {
                            ContextUser.UserExtend.EnchantGridNum = (short)latticeNum;
                            return(true);
                        });

                        UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 8, latticeNum, subGridNum, openGold, ContextUser.GoldNum, goldNum);
                    }
                    else
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                        return(false);
                    }
                }
                else
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Implemented to reset spell-checking everywhere when the spelling status of a wordform changes.
 /// </summary>
 public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
 {
     if (tag == WfiWordformTags.kflidSpellingStatus)
     {
         RestartSpellChecking();
         // This keeps the spelling dictionary in sync with the WFI.
         // Arguably this should be done in FDO. However the spelling dictionary is used to
         // keep the UI showing squiggles, so it's also arguable that it is a UI function.
         // In any case it's easier to do it in PropChanged (which also fires in Undo/Redo)
         // than in a data-change method which does not.
         var    wf   = m_wordformRepos.GetObject(hvo);
         string text = wf.Form.VernacularDefaultWritingSystem.Text;
         if (!string.IsNullOrEmpty(text))
         {
             EnchantHelper.SetSpellingStatus(text, m_cache.DefaultVernWs,
                                             m_cache.LanguageWritingSystemFactoryAccessor,
                                             wf.SpellingStatus == (int)SpellingStatusStates.correct);
         }
     }
 }
Exemplo n.º 16
0
        public override bool TakeAction()
        {
            string puUserID;

            if (string.IsNullOrEmpty(toUserID))
            {
                puUserID = ContextUser.UserID;
            }
            else
            {
                puUserID = toUserID;
                UserCacheGlobal.LoadOffline(puUserID);
            }
            UserGeneral general = new PersonalCacheStruct <UserGeneral>().FindKey(puUserID, generalID);

            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            generalName = general.GeneralName;
            careerID    = general.CareerID;
            var          package  = UserEnchant.Get(puUserID);
            UserItemInfo useritem = EnchantHelper.GetGeneralWeapon(general.UserID, general.GeneralID);

            if (useritem != null)
            {
                userItemID = useritem.UserItemID;
                ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(useritem.ItemID);
                if (itemInfo != null)
                {
                    itemName = itemInfo.ItemName;
                    headID   = itemInfo.HeadID;
                }
                openNum      = EnchantHelper.EnchantOpenGridNum(useritem.ItemLv);
                enchantArray = package.EnchantPackage.FindAll(m => m.UserItemID == useritem.UserItemID).ToArray();
            }

            return(true);
        }
Exemplo n.º 17
0
    private static ItemEnchant GetEnchantInfo(Item item, EnchantType type)
    {
        ItemEnchant itemEnchantStats        = new(type, item.Uid, item.EnchantLevel);
        Script      script                  = ScriptLoader.GetScript("Functions/calcEnchantValues");
        DynValue    successRateScriptResult = script.RunFunction("calcEnchantRates", item.EnchantLevel + 1);
        DynValue    ingredientsResult       = script.RunFunction("calcEnchantIngredients", item.EnchantLevel + 1, item.Rarity, (int)item.Type, item.Level);

        itemEnchantStats.Rates.BaseSuccessRate = (float)successRateScriptResult.Tuple[0].Number;
        itemEnchantStats.Rates.CatalystRate    = (float)successRateScriptResult.Tuple[1].Number;
        itemEnchantStats.PityCharges           = (int)successRateScriptResult.Tuple[2].Number;
        itemEnchantStats.Rates.ChargesRate     = (float)successRateScriptResult.Tuple[3].Number;

        itemEnchantStats.CatalystAmountRequired = (int)ingredientsResult.Tuple[0].Number;
        for (int i = 1; i < ingredientsResult.Tuple.Length; i += 2)
        {
            EnchantIngredient ingredient = new((ItemStringTag)Enum.Parse(typeof(ItemStringTag), ingredientsResult.Tuple[i].String), (int)ingredientsResult.Tuple[i + 1].Number);
            itemEnchantStats.Ingredients.Add(ingredient);
        }

        itemEnchantStats.Stats = EnchantHelper.GetEnchantStats(item.EnchantLevel + 1, item.Type, item.Level);
        return(itemEnchantStats);
    }
Exemplo n.º 18
0
        public override bool TakeAction()
        {
            var package = UserEnchant.Get(ContextUser.UserID);

            if (package != null)
            {
                userEnchant = package.EnchantPackage.Find(m => m.UserEnchantID == userEnchantID);
                if (userEnchant != null)
                {
                    matureNum   = (decimal)userEnchant.MaxMature / GameConfigSet.MaxEnchantMature;
                    maxMature   = CombatHelper.EnchantFinalNum(userEnchant);
                    enchantInfo = new ConfigCacheSet <EnchantInfo>().FindKey(userEnchant.EnchantID);
                    EnchantLvInfo enchantLvInfo = new ConfigCacheSet <EnchantLvInfo>().FindKey(userEnchant.EnchantID,
                                                                                               userEnchant.EnchantLv);
                    if (enchantLvInfo != null)
                    {
                        abilityNum = TrumpHelper.GetTransformData(enchantLvInfo.Num);
                    }
                }
            }
            enchantList = EnchantHelper.EnchantCultureList();
            return(true);
        }
Exemplo n.º 19
0
        protected override void Read(PacketStream stream)
        {
            var actionType  = (ActionType)stream.ReadInt32();
            var slotEquip   = (byte)(stream.ReadInt32() & 0xFF);
            var slotReagent = (byte)(stream.ReadInt32() & 0xFF);
            var slotCash    = (byte)(stream.ReadInt32() & 0xFF);

            switch (actionType)
            {
            case ActionType.Reinforcement:
                EnchantHelper.Reinforcement(Connection, slotEquip, slotReagent, slotCash);
                break;

            case ActionType.Enchant:
                break;

            case ActionType.LevelDown:
                break;

            case ActionType.Craft:
                break;

            case ActionType.Dismantle:
                break;

            case ActionType.PranCostumeEnchant:
                break;

            case ActionType.StoneRefinement:
                break;

            case ActionType.StoneEnchant:
                break;
            }

            Log.Warn("ActionType: {0}", actionType);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 附魔符ID=等级=数量
        /// </summary>
        /// <param name="list"></param>
        /// <param name="userID"></param>
        private static void PutEnchant(string[] list, string userID)
        {
            var package = UserEnchant.Get(userID);

            foreach (string enchant in list)
            {
                if (string.IsNullOrEmpty(enchant))
                {
                    continue;
                }
                string[] crystalList = enchant.Split(new char[] { '=' });

                int   enchantID  = crystalList.Length > 0 ? Convert.ToInt32(crystalList[0]) : 0;
                short enchantLv  = crystalList.Length > 1 ? Convert.ToInt16(crystalList[1]) : (short)0;
                int   enchantNum = crystalList.Length > 2 ? Convert.ToInt32(crystalList[2]) : 0;

                EnchantInfo enchantInfo   = new ShareCacheStruct <EnchantInfo>().FindKey(enchantID);
                var         enchantLvInfo = new ShareCacheStruct <EnchantLvInfo>().FindKey(enchantID, enchantLv);
                if (enchantInfo != null && package != null && enchantLvInfo != null)
                {
                    for (int i = 0; i < enchantNum; i++)
                    {
                        UserEnchantInfo userenchant = EnchantHelper.GetUserEnchantInfo(enchantID, enchantLv);
                        if (userenchant != null)
                        {
                            UserLogHelper.AppenEnchantLog(userID, 2, userenchant, new CacheList <SynthesisInfo>());
                            package.SaveEnchant(userenchant);
                        }
                    }
                }
                else
                {
                    new Base.BaseLog().SaveLog("领取附魔符异常", new Exception(string.Format("userID:{3},enchantID:{0},enchantNum:{1},enchantLv:{2}", enchantID, enchantNum, enchantLv, userID)));
                }
            }
        }
Exemplo n.º 21
0
        public override bool TakeAction()
        {
            if (ContextUser.UserStatus == UserStatus.CountryCombat)
            {
                CountryCombat countryCombat = new CountryCombat(ContextUser);
                if (countryCombat.GameActive != null && countryCombat.GameActive.RefreshStatus() == CombatStatus.Combat)
                {
                    countryCombat.Exit();
                }
            }

            if (ContextUser.EnergyNum <= 0 && ContextUser.SurplusEnergy <= 0)
            {
                ErrorCode = 3;
                ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            //if (_ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID))
            //{
            //    ErrorCode = 1;
            //    ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood;
            //    return false;
            //}
            //if (_ops != 1 && UserItemHelper.CheckItemOut(ContextUser, ItemStatus.BeiBao))
            //{
            //    ErrorCode = 1;
            //    ErrorInfo = LanguageManager.GetLang().St_User_BeiBaoMsg;
            //    return false;
            //}

            UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血

            plotInfo = new ShareCacheStruct <PlotInfo>().FindKey(plotID);

            if (plotInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().LoadDataError;
                return(false);
            }
            int challengeNum = PlotHelper.GetPlotChallengeNum(UserId.ToString(), plotInfo.PlotID);

            if (plotInfo.PlotType == PlotType.Elite && challengeNum >= plotInfo.ChallengeNum)
            {
                ErrorCode = 4;
                ErrorInfo = LanguageManager.GetLang().St4002_IsPlotEliteNotChallengeNum;
                return(false);
            }

            if ((challengeNum >= plotInfo.ChallengeNum && ContextUser.VipLv < 3))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4002_NotChallengeNum;
                return(false);
            }

            int num = challengeNum;
            int challengeDefSoldNum    = ConfigEnvSet.GetInt("UserPlot.ChallengeDefSoldNum");
            int challengeDoubleSoldNum = ConfigEnvSet.GetInt("UserPlot.ChallengeDoubleSoldNum");

            if (_ops != 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID))
            {
                ErrorCode = 1;
                _plotNum  = challengeDefSoldNum;
                return(false);
            }
            else
            {
                if (_ops != 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID) == false)
                {
                    int openNum = num - plotInfo.ChallengeNum + 1;
                    _plotNum = challengeDoubleSoldNum * openNum + challengeDefSoldNum;
                }
            }

            if (_ops != 1 && num >= plotInfo.ChallengeNum)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4002_IsPlotNum, _plotNum);
                return(false);
            }
            if (_ops == 1 && num >= plotInfo.ChallengeNum)
            {
                if (ContextUser.GoldNum < _plotNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                ContextUser.UseGold = MathUtils.Subtraction(ContextUser.UseGold, _plotNum);
            }
            if (_ops == 1 && num >= plotInfo.ChallengeNum && PlotHelper.GetPlotIsOne(UserId.ToString(), plotInfo.PlotID) == false)
            {
                int openNum = num - plotInfo.ChallengeNum + 1;
                _plotNum = challengeDoubleSoldNum * openNum + challengeDefSoldNum;;
                if (ContextUser.GoldNum < _plotNum)
                {
                    ErrorCode = 2;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, _plotNum);
            }
            if (_ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull;
                return(false);
            }
            //var cacheSetUserPlot = new PersonalCacheStruct<UserPlotPackage>();
            //var userPlotPack = cacheSetUserPlot.FindKey(ContextUser.UserID);
            //var userPlot = userPlotPack != null ? userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null;
            var userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, plotID);

            if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum)
            {
                if (plotInfo.PlotType == PlotType.Elite)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed;
                    return(false);
                }
                else if (plotInfo.PlotType == PlotType.HeroPlot)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum;
                    return(false);
                }
            }
            npcList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            //if (ContextUser.EnergyNum < (npcList.Count * PlotInfo.BattleEnergyNum))
            //{
            //    ErrorCode = 3;
            //    ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
            //    return false;
            //}
            ContextUser.InPlotDate = DateTime.Now;
            //if (ContextUser.UserExtend == null || ContextUser.UserExtend.PlotStatusID == 0 || ContextUser.UserExtend.MercenarySeq == 0)
            //{
            //    ContextUser.TempEnergyNum = PlotInfo.BattleEnergyNum;
            //    //ContextUser.RemoveEnergyNum(PlotInfo.BattleEnergyNum);
            //}
            //ContextUser.Update();
            if (ContextUser.UserExtend != null && ContextUser.UserExtend.PlotStatusID <= 0)
            {
                ContextUser.UserExtend.UpdateNotify(obj =>
                {
                    ContextUser.UserExtend.PlotStatusID = plotID;
                    ContextUser.UserExtend.PlotNpcID    = -1;
                    ContextUser.UserExtend.MercenarySeq = 1;
                    ContextUser.UserExtend.IsBoss       = false;
                    return(true);
                });
            }

            _isOverCombat             = userPlot != null && userPlot.PlotStatus == PlotStatus.Completed;
            ContextUser.TempEnergyNum = PlotInfo.BattleEnergyNum;
            return(true);
        }
Exemplo n.º 22
0
    public override void Handle(GameSession session, PacketReader packet)
    {
        EnchantScrollMode mode = (EnchantScrollMode)packet.ReadByte();

        long scrollUid = packet.ReadLong();
        long equipUid  = packet.ReadLong();

        Player player = session.Player;

        if (!player.Inventory.HasItem(equipUid) && !player.Inventory.HasItem(scrollUid))
        {
            session.Send(EnchantScrollPacket.UseScroll((short)EnchantScrollError.ItemsNoLongerValid));
            return;
        }

        Item scroll = player.Inventory.GetByUid(scrollUid);
        Item equip  = player.Inventory.GetByUid(equipUid);

        EnchantScrollMetadata metadata = EnchantScrollMetadataStorage.GetMetadata(scroll.Function.Id);

        if (metadata is null)
        {
            return;
        }

        if (!metadata.Rarities.Contains(equip.Rarity))
        {
            session.Send(EnchantScrollPacket.UseScroll((short)EnchantScrollError.CannotBeEnchantedDueToRarity));
            return;
        }

        if (metadata.MinLevel > equip.Level || metadata.MaxLevel < equip.Level)
        {
            session.Send(EnchantScrollPacket.UseScroll((short)EnchantScrollError.InsufficientItemLevel));
            return;
        }

        if (!metadata.ItemTypes.Contains(equip.Type))
        {
            session.Send(EnchantScrollPacket.UseScroll((short)EnchantScrollError.IneligibleItem));
            return;
        }

        if (equip.EnchantLevel >= metadata.EnchantLevels.Last())
        {
            session.Send(EnchantScrollPacket.UseScroll((short)EnchantScrollError.GearCannotBeEnchanted));
            return;
        }

        int enchantLevelIndex = Random.Shared.Next(metadata.EnchantLevels.Count);
        Dictionary <StatAttribute, ItemStat> enchantStats = EnchantHelper.GetEnchantStats(metadata.EnchantLevels[enchantLevelIndex], equip.Type, equip.Level);

        switch (mode)
        {
        case EnchantScrollMode.AddItem:
            session.Send(EnchantScrollPacket.AddItem(equipUid, enchantStats));
            break;

        case EnchantScrollMode.UseScroll:
            HandleUseScroll(session, equip, scroll, enchantStats, metadata.EnchantLevels[enchantLevelIndex], metadata.Id);
            break;

        default:
            LogUnknownMode(mode);
            break;
        }
    }
Exemplo n.º 23
0
        public override bool TakeAction()
        {
            UserItemInfo useritem    = null;
            var          itemPackage = UserItemPackage.Get(ContextUser.UserID);
            var          package     = UserEnchant.Get(ContextUser.UserID);

            if (itemPackage == null || package == null)
            {
                return(false);
            }
            useritem = itemPackage.ItemPackage.Find(m => !m.IsRemove && m.UserItemID == userItemID);
            if (ops == 0)
            {
                int currNum = package.EnchantPackage.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count;
                if (currNum >= ContextUser.UserExtend.EnchantGridNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1259_EnchantGridNumFull;
                    return(false);
                }
                var uEnchantInfo = package.EnchantPackage.Find(m => m.UserEnchantID == userEnchantID);
                if (uEnchantInfo != null && !string.IsNullOrEmpty(uEnchantInfo.UserItemID))
                {
                    useritem = itemPackage.ItemPackage.Find(m => !m.IsRemove && m.UserItemID == uEnchantInfo.UserItemID);
                    uEnchantInfo.Position   = 0;
                    uEnchantInfo.UserItemID = string.Empty;
                    package.SaveEnchant(uEnchantInfo);
                    if (useritem != null && useritem.ItemStatus.Equals(ItemStatus.YongBing))
                    {
                        var userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(Uid, useritem.GeneralID);
                        if (userGeneral != null)
                        {
                            userGeneral.RefreshMaxLife();
                        }
                    }
                }
            }
            else if (ops == 1)
            {
                if (useritem == null || useritem.Equparts != EquParts.WuQi)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1259_UserItemNotWuQi;
                    return(false);
                }
                int openGridNum = EnchantHelper.EnchantOpenGridNum(useritem.ItemLv);
                if (potion > openGridNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1213_GridNumNotEnough;
                    return(false);
                }
                var userEnchantArray = package.EnchantPackage.FindAll(m => m.UserItemID == userItemID);
                if (userEnchantArray.Count >= openGridNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1213_OpenNumNotEnough;
                    return(false);
                }
                foreach (var info in userEnchantArray)
                {
                    if (info.Position == potion)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1259_EnchantOpenGridFull;
                        return(false);
                    }
                }
                var uEnchantInfo = package.EnchantPackage.Find(m => m.UserEnchantID == userEnchantID);
                if (uEnchantInfo != null && string.IsNullOrEmpty(uEnchantInfo.UserItemID))
                {
                    uEnchantInfo.Position   = (short)potion;
                    uEnchantInfo.UserItemID = userItemID;
                    package.SaveEnchant(uEnchantInfo);
                    var userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(Uid, useritem.GeneralID);
                    if (userGeneral != null)
                    {
                        userGeneral.RefreshMaxLife();
                    }
                }
            }
            return(true);
        }
Exemplo n.º 24
0
        public override void BuildPacket()
        {
            PushIntoStack(enchantPackNum);
            PushIntoStack(moShiNum);
            PushIntoStack(goldNum);
            PushIntoStack(generalArray.Length);
            foreach (var general in generalArray)
            {
                UserEnchantInfo[] enchantGeneralArray = new UserEnchantInfo[0];
                UserItemInfo      useritem            = EnchantHelper.GetGeneralWeapon(general.UserID, general.GeneralID);
                ItemBaseInfo      itemInfo            = null;
                if (useritem != null)
                {
                    itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(useritem.ItemID);
                    openNum  = EnchantHelper.EnchantOpenGridNum(useritem.ItemLv);
                    if (package != null)
                    {
                        enchantGeneralArray = package.EnchantPackage.FindAll(m => m.UserItemID == useritem.UserItemID).ToArray();
                    }
                }
                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack(general.GeneralID);
                dsItem.PushIntoStack(general.GeneralName.ToNotNullString());
                dsItem.PushIntoStack((short)general.CareerID);
                dsItem.PushIntoStack(useritem == null ? string.Empty : useritem.UserItemID.ToNotNullString());
                dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemName.ToNotNullString());
                dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.HeadID.ToNotNullString());
                dsItem.PushIntoStack((short)openNum);
                dsItem.PushIntoStack(enchantGeneralArray.Length);
                foreach (var enchant in enchantGeneralArray)
                {
                    EnchantInfo enchantInfo = new ConfigCacheSet <EnchantInfo>().FindKey(enchant.EnchantID);
                    DataStruct  dsItem1     = new DataStruct();
                    dsItem1.PushIntoStack((short)enchant.Position);
                    dsItem1.PushIntoStack(enchant.UserEnchantID.ToNotNullString());
                    dsItem1.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.EnchantName.ToNotNullString());
                    dsItem1.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.HeadID.ToNotNullString());
                    dsItem1.PushIntoStack((short)enchant.EnchantLv);
                    dsItem1.PushIntoStack(enchantInfo == null ? (short)0 : (short)enchantInfo.ColorType);
                    dsItem.PushIntoStack(dsItem1);
                }

                PushIntoStack(dsItem);
            }
            this.PushIntoStack(pageCount);
            this.PushIntoStack(enchantPackageArray.Length);
            foreach (var enchant in enchantPackageArray)
            {
                EnchantInfo enchantInfo = new ConfigCacheSet <EnchantInfo>().FindKey(enchant.EnchantID);
                DataStruct  dsItem      = new DataStruct();
                dsItem.PushIntoStack(enchant.UserEnchantID.ToNotNullString());
                dsItem.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.EnchantName.ToNotNullString());
                dsItem.PushIntoStack(enchantInfo == null ? string.Empty : enchantInfo.HeadID.ToNotNullString());
                dsItem.PushIntoStack((short)enchant.EnchantLv);
                dsItem.PushIntoStack(enchantInfo == null ? (short)0 : (short)enchantInfo.ColorType);
                PushIntoStack(dsItem);
            }
            this.PushIntoStack(mosaicList.Length);
            foreach (var mosaic in mosaicList)
            {
                DataStruct dsItem = new DataStruct();
                dsItem.PushIntoStack((short)mosaic.Position);
                dsItem.PushIntoStack(mosaic.MosaicColor.ToNotNullString());
                dsItem.PushIntoStack((short)mosaic.DemandLv);

                this.PushIntoStack(dsItem);
            }
        }
Exemplo n.º 25
0
        public ICollection <SpellCorrectMenuItem> GetSuggestions(Point mousePos,
                                                                 SimpleRootSite rootsite, out int hvoObj, out int tag, out int wsAlt, out int wsText,
                                                                 out string word, out Dictionary dict, out bool nonSpellingError)
        {
            hvoObj           = tag = wsAlt = wsText = 0;   // make compiler happy for early returns
            word             = null;
            dict             = null;
            nonSpellingError = true;

            IVwRootBox rootb = rootsite != null ? rootsite.RootBox : null;

            if (rootb == null)
            {
                return(null);
            }

            // Get a selection at the indicated point.
            IVwSelection sel = rootsite.GetSelectionAtPoint(mousePos, false);

            // Get the selected word and verify that it is a single run within a single
            // editable string.
            if (sel != null)
            {
                sel = sel.GrowToWord();
            }
            if (sel == null || !sel.IsRange || sel.SelType != VwSelType.kstText || !SelectionHelper.IsEditable(sel))
            {
                return(null);
            }
            ITsString tss;
            bool      fAssocPrev;
            int       ichAnchor;

            sel.TextSelInfo(false, out tss, out ichAnchor, out fAssocPrev, out hvoObj, out tag, out wsAlt);
            int ichEnd, hvoObjE, tagE, wsE;

            sel.TextSelInfo(true, out tss, out ichEnd, out fAssocPrev, out hvoObjE, out tagE, out wsE);
            if (hvoObj != hvoObjE || tag != tagE || wsAlt != wsE)
            {
                return(null);
            }

            int ichMin = Math.Min(ichEnd, ichAnchor);
            int ichLim = Math.Max(ichEnd, ichAnchor);

            ILgWritingSystemFactory wsf = rootsite.RootBox.DataAccess.WritingSystemFactory;

            // May need to enlarge the word beyond what GrowToWord does, if there is adjacent wordforming material.
            int ichMinAdjust = AdjustWordBoundary(wsf, tss, ichMin, -1, 0) + 1;             // further expanded start of word.
            int ichLimAdjust = AdjustWordBoundary(wsf, tss, ichLim - 1, 1, tss.Length);     // further expanded lim of word.
            // From the ends we can strip stuff with different spell-checking properties.
            IVwStylesheet styles     = rootsite.RootBox.Stylesheet;
            int           spellProps = SpellCheckProps(tss, ichMin, styles);

            while (ichMinAdjust < ichMin && SpellCheckProps(tss, ichMinAdjust, styles) != spellProps)
            {
                ichMinAdjust++;
            }
            while (ichLimAdjust > ichLim && SpellCheckProps(tss, ichLimAdjust - 1, styles) != spellProps)
            {
                ichLimAdjust--;
            }
            ichMin = ichMinAdjust;
            ichLim = ichLimAdjust;

            ITsStrFactory tsf = TsStrFactoryClass.Create();

            // Now we have the specific range we will check. Get the actual string.
            ITsStrBldr bldr = tss.GetBldr();

            if (ichLim < bldr.Length)
            {
                bldr.ReplaceTsString(ichLim, bldr.Length, null);
            }
            if (ichMin > 0)
            {
                bldr.ReplaceTsString(0, ichMin, null);
            }
            ITsString tssWord = bldr.GetString();

            // See whether we need the special blue underline, which is used mainly for adjacent words in different writing systems.
            List <int> wss = TsStringUtils.GetWritingSystems(tssWord);

            if (wss.Count > 1)
            {
                return(MakeWssSuggestions(tssWord, wss, rootb, hvoObj, tag, wsAlt, ichMin, ichLim));
            }
            ITsString keepOrcs;             // holds any ORCs we found in the original word that we need to keep rather than reporting.
            IList <SpellCorrectMenuItem> result = MakeEmbeddedNscSuggestion(ref tssWord, styles, rootb,
                                                                            hvoObj, tag, wsAlt, ichMin, ichLim, out keepOrcs);

            if (result.Count > 0)
            {
                return(result);
            }

            // Determine whether it is a spelling problem.
            wsText = TsStringUtils.GetWsOfRun(tssWord, 0);
            dict   = EnchantHelper.GetDictionary(wsText, wsf);
            if (dict == null)
            {
                return(null);
            }
            word = tssWord.get_NormalizedForm(FwNormalizationMode.knmNFC).Text;
            if (word == null)
            {
                return(null);                // don't think this can happen, but...
            }
            if (dict.Check(word))
            {
                return(null);                // not mis-spelled.
            }
            // Get suggestions. Make sure to return an empty collection rather than null, even if no suggestions,
            // to indicate an error.
            ICollection <string> suggestions = dict.Suggest(word);

            foreach (string suggest in suggestions)
            {
                ITsString replacement = tsf.MakeStringRgch(suggest, suggest.Length, wsText);
                if (keepOrcs != null)
                {
                    ITsStrBldr bldrRep = keepOrcs.GetBldr();
                    bldrRep.ReplaceTsString(0, 0, replacement);
                    replacement = bldrRep.GetString();
                }
                result.Add(new SpellCorrectMenuItem(rootb, hvoObj, tag, wsAlt, ichMin, ichLim, suggest,
                                                    replacement));
            }
            nonSpellingError = false;             // it IS a spelling problem.
            return(result);
        }
Exemplo n.º 26
0
 public bool Undo()
 {
     EnchantHelper.SetSpellingStatus(m_word, m_wsText, m_rootb.DataAccess.WritingSystemFactory, false);
     m_rootb.PropChanged(m_hvoObj, m_tag, m_wsAlt, 1, 1);
     return(true);
 }
Exemplo n.º 27
0
        public override bool TakeAction()
        {
            var cacheEnvSet = new ConfigCacheSet <ConfigEnvSet>();
            var envset      = cacheEnvSet.FindKey("CombatMaxBout");

            if (envset != null)
            {
            }
            PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(PlotNpcID);

            if (npcInfo == null)
            {
                return(false);
            }
            PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID);

            if (plotInfo == null)
            {
                return(false);
            }
            //判断是否有下一关
            int nextLayerNum  = MathUtils.Addition(ContextUser.UserExtend.LayerNum, 1);
            int nextHurdleNum = MathUtils.Addition(ContextUser.UserExtend.HurdleNum, 1);

            if ((UserHelper.IsLastLayer(plotInfo) || !IsGotoNextLayer(nextLayerNum)))
            {
                if (UserHelper.IsKill(ContextUser, npcInfo.PlotID))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnableLayerNum;
                    return(false);
                }
            }

            if (ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood;
                return(false);
            }
            //原因:灵件背包满时未提示
            if (ops != 1 && UserHelper.IsSpareGridNum(ContextUser, 0))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St_User_SpareBeiBaoMsg;
                return(false);
            }

            if (ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID))
            {
                ErrorCode = 1;
                ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull;
                return(false);
            }

            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return(false);
            }
            if (ContextUser.UseMagicID == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic;
                return(false);
            }
            if (new GameDataCacheSet <UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty;
                return(false);
            }
            //PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID);
            if (IsPlotOut(npcInfo))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnable;
                return(false);
            }

            UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血

            //触发战斗
            ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID);

            if (plotCombater == null)
            {
                return(false);
            }
            var cacheSet = new GameDataCacheSet <UserPlotCombat>();

            userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
            if (userPlotCombat == null)
            {
                userPlotCombat = new UserPlotCombat()
                {
                    UserID    = ContextUser.UserID,
                    PlotNpcID = PlotNpcID
                };
                cacheSet.Add(userPlotCombat, GameEnvironment.CacheUserPeriod);
                userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID);
            }
            userPlotCombat.PlotID     = npcInfo.PlotID;
            userPlotCombat.CombatDate = DateTime.Now;
            userPlotCombat.IsWin      = plotCombater.Doing();
            if (!userPlotCombat.IsWin)
            {
                userPlotCombat.OverNum += 1;
            }
            combatProcessList             = (CombatProcessContainer)plotCombater.GetProcessResult();
            userPlotCombat.GeneralNum     = combatProcessList.AttackList.Count;
            userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList());

            if (userPlotCombat.IsWin)
            {
                int honourNum = 0;
                PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, 0, out honourNum);
                prizeItems     = PlotHelper.GetKalpaPlotMonsterItems(Uid, npcInfo.PlotID, npcInfo.PlotNpcID);
                universalArray = GetUniversalList().ToArray();
                if (plotInfo.PlotType == PlotType.Kalpa)
                {
                    KalpaDailyRestrain(npcInfo);
                    if (ContextUser.UserExtend == null)
                    {
                        ContextUser.UserExtend = new GameUserExtend();
                    }

                    PlotInfo[] plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == ContextUser.UserExtend.LayerNum && m.PlotSeqNo == nextHurdleNum && m.PlotType == PlotType.Kalpa).ToArray();
                    if (plotInfoList.Length > 0)
                    {
                        int layerNum  = ContextUser.UserExtend.LayerNum;
                        int hurdleNum = ContextUser.UserExtend.HurdleNum;

                        if (CheckHurdleNum(ContextUser.UserID, layerNum, hurdleNum))
                        {
                            ContextUser.UserExtend.UpdateNotify(obj =>
                            {
                                ContextUser.UserExtend.HurdleNum = nextHurdleNum;
                                return(true);
                            });
                            //ContextUser.Update();
                            PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID);
                        }
                    }
                    else if (IsGotoNextLayer(nextLayerNum))
                    {
                        //判断是否能到下一层
                        plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == nextLayerNum && m.PlotType == PlotType.Kalpa).ToArray();
                        if (plotInfoList.Length > 0)
                        {
                            ContextUser.UserExtend.UpdateNotify(obj =>
                            {
                                ContextUser.UserExtend.LayerNum  = nextLayerNum;
                                ContextUser.UserExtend.HurdleNum = 1;
                                return(true);
                            });
                            //ContextUser.Update();
                            PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID);
                        }
                    }
                }
            }


            //日志
            UserCombatLog log = new UserCombatLog();

            log.CombatLogID   = Guid.NewGuid().ToString();
            log.UserID        = userPlotCombat.UserID;
            log.CityID        = ContextUser.CityID;
            log.PlotID        = userPlotCombat.PlotID;
            log.NpcID         = userPlotCombat.PlotNpcID;
            log.CombatType    = CombatType.Kalpa;
            log.HostileUser   = string.Empty;
            log.IsWin         = userPlotCombat.IsWin;
            log.CombatProcess = JsonUtils.Serialize(combatProcessList);
            log.PrizeItem     = prizeItems;
            log.CreateDate    = DateTime.Now;
            var sender = DataSyncManager.GetDataSender();

            sender.Send(log);

            UserHelper.GetGeneralLife(ContextUser.UserID);

            return(true);
        }
Exemplo n.º 28
0
        public override bool Matches(SIL.FieldWorks.Common.COMInterfaces.ITsString arg)
        {
            var dict = EnchantHelper.GetDictionary(m_ws, WritingSystemFactory);

            return(new SpellCheckMethod(arg, dict, m_ws, WritingSystemFactory.get_CharPropEngine(m_ws)).Run());
        }
Exemplo n.º 29
0
        public override bool TakeAction()
        {
            var package = UserEnchant.Get(ContextUser.UserID);

            if (package != null)
            {
                var userEnchant = package.EnchantPackage.Find(m => m.UserEnchantID == userEnchantID);
                if (userEnchant != null)
                {
                    if (userEnchant.MaxMature >= GameConfigSet.MaxEnchantMature)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St1258_OutMaxEnchantMature;
                        return(false);
                    }
                    List <EnchantCulTure> culTuresList   = EnchantHelper.EnchantCultureList();
                    EnchantCulTure        enchantCulTure = culTuresList.Find(m => m.CultureType == cultureType);
                    if (enchantCulTure != null)
                    {
                        if (cultureType == EnchantCultureType.Ordinary)
                        {
                            if (ContextUser.UserExtend == null || ContextUser.UserExtend.MoJingNum < enchantCulTure.MoJingNum)
                            {
                                ErrorCode = LanguageManager.GetLang().ErrorCode;
                                ErrorInfo = LanguageManager.GetLang().St1258_MagicCrystalNotEnough;
                                return(false);
                            }
                        }
                        else
                        {
                            if (ContextUser.GoldNum < enchantCulTure.GoldNum)
                            {
                                ErrorCode = LanguageManager.GetLang().ErrorCode;
                                ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                                return(false);
                            }
                        }
                        string content = string.Empty;
                        if (RandomUtils.IsHit(enchantCulTure.SuccessNum))
                        {
                            if (cultureType == EnchantCultureType.Ordinary)
                            {
                                ContextUser.UserExtend.MoJingNum = MathUtils.Subtraction(ContextUser.UserExtend.MoJingNum, enchantCulTure.MoJingNum);
                                content = string.Format(LanguageManager.GetLang().St1258_ConsumeMagicCrystalUpEnhance, enchantCulTure.MoJingNum, enchantCulTure.UpMature);
                            }
                            else
                            {
                                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, enchantCulTure.GoldNum);
                                content             = string.Format(LanguageManager.GetLang().St1258_ConsumeGoldNumUpEnhance, enchantCulTure.GoldNum, enchantCulTure.UpMature);
                            }
                            short maxMatureNum = MathUtils.Addition(userEnchant.MaxMature, enchantCulTure.UpMature, (short)GameConfigSet.MaxEnchantMature);
                            userEnchant.UpdateNotify(obj =>
                            {
                                userEnchant.MaxMature = maxMatureNum;
                                return(true);
                            });
                            UserLogHelper.AppenEnchantLog(ContextUser.UserID, 3, userEnchant, new CacheList <SynthesisInfo>());
                        }
                        else
                        {
                            if (cultureType == EnchantCultureType.Ordinary)
                            {
                                ContextUser.UserExtend.MoJingNum = MathUtils.Subtraction(ContextUser.UserExtend.MoJingNum, enchantCulTure.MoJingNum);
                                content = string.Format(LanguageManager.GetLang().St1258_EnhanceCultureFailedMagicCrystal, enchantCulTure.MoJingNum);
                            }
                            else
                            {
                                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, enchantCulTure.GoldNum);
                                content             = string.Format(LanguageManager.GetLang().St1258_EnhanceCultureFailedGold, enchantCulTure.GoldNum);
                            }
                        }
                        ErrorCode = 0;
                        ErrorInfo = content;
                    }
                }
            }
            return(true);
        }