Пример #1
0
        private static int FindAlchemyResult(EntityList ingredients, EntityList ready, ref bool refExact)
        {
            for (int i = 1; i < dbRecipes.Length; i++)
            {
                RecipeRec recipe = dbRecipes[i];

                int t_cnt  = AuxUtils.GetTokensCount(recipe.Ingredients, "+");
                int finded = 0;
                ready.Clear();

                for (int t = 1; t <= t_cnt; t++)
                {
                    string tok = AuxUtils.GetToken(recipe.Ingredients, "+", (sbyte)t);
                    char   f   = tok[0];
                    if (f != '_' && f != '!')
                    {
                        f = '?';
                    }
                    else
                    {
                        tok = tok.Substring(1, tok.Length - 1);
                    }

                    if (f == '_')
                    {
                        Item       item = (Item)ingredients.FindByCLSID(GlobalVars.iid_DeadBody);
                        NWCreature db   = (NWCreature)item.Contents.GetItem(0);
                        if (db.Entry.Sign.CompareTo(tok) == 0)
                        {
                            finded++;
                            ready.Add(item);
                        }
                    }
                    else
                    {
                        int  id   = GlobalVars.nwrDB.FindEntryBySign(tok).GUID;
                        Item item = (Item)ingredients.FindByCLSID(id);
                        if (item != null && (f == '?' || (f == '!' && item.State == ItemState.is_Blessed)))
                        {
                            finded++;
                            ready.Add(item);
                        }
                    }
                }

                if (finded >= t_cnt)
                {
                    refExact = (finded == t_cnt);
                    return(i);
                }
            }

            refExact = false;
            return(-1);
        }
Пример #2
0
        public string GetNounDeclension(Number number, Case ncase)
        {
            string result = "";

            try {
                if (!string.IsNullOrEmpty(Morphology))
                {
                    string word = AuxUtils.GetToken(Morphology, "[]", 1);
                    if (AuxUtils.GetTokensCount(Morphology, "[]") == 1)
                    {
                        result = word;
                    }
                    else
                    {
                        string sfx = AuxUtils.GetToken(Morphology, "[]", 2);

                        int    sf_idx = ((int)(number) - 1) * 6 + (int)(ncase);
                        string sf     = AuxUtils.GetToken(sfx, ",", sf_idx);

                        if (sf.CompareTo("") == 0)
                        {
                            result = word;
                        }
                        else
                        {
                            if (sf[0] != '-')
                            {
                                result = sf;
                            }
                            else
                            {
                                sf     = sf.Substring(1);
                                result = word + sf;
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Write("BaseEntry.getNounDeclension(): " + ex.Message);
                throw ex;
            }

            return(result);
        }
 private void DoCommand(string cmd)
 {
     try {
         int    tokCount = (int)AuxUtils.GetTokensCount(cmd, " ");
         string token    = AuxUtils.GetToken(cmd, " ", 1).ToLower();
         Player player   = GlobalVars.nwrGame.Player;
         if (token.Equals("name_gen"))
         {
             for (int i = 1; i <= 10; i++)
             {
                 AddMessage(GlobalVars.nwrGame.NameLib.GenerateName("ru", Gender.gMale, NamesLib.NameGen_RndSlabs));
             }
         }
         else
         {
             if (token.Equals("test"))
             {
                 player.Body = new HumanBody(player);
             }
             else
             {
                 if (token.Equals("suicide"))
                 {
                     player.Death("Suicide", null);
                 }
                 else
                 {
                     if (token.Equals("set_fury"))
                     {
                         GlobalVars.Debug_Fury = !GlobalVars.Debug_Fury;
                         string temp = GlobalVars.Debug_Fury ? "yes" : "no";
                         AddMessage(">> (fury = " + temp + ")");
                     }
                     else
                     {
                         if (token.Equals("transform"))
                         {
                             if (tokCount == 1)
                             {
                                 throw new Exception(BaseLocale.GetStr(RS.rs_NoValue));
                             }
                             string    temp  = AuxUtils.GetToken(cmd, " ", 2);
                             DataEntry entry = GlobalVars.nwrDB.FindEntryBySign(temp);
                             if (entry != null)
                             {
                                 EffectExt ext = new EffectExt();
                                 ext.SetParam(EffectParams.ep_MonsterID, entry.GUID);
                                 player.UseEffect(EffectID.eid_Transformation, null, InvokeMode.im_ItSelf, ext);
                             }
                         }
                         else
                         {
                             if (token.Equals("add_monster"))
                             {
                                 if (tokCount == 1)
                                 {
                                     throw new Exception(BaseLocale.GetStr(RS.rs_NoValue));
                                 }
                                 string temp = AuxUtils.GetToken(cmd, " ", 2);
                                 int    tx;
                                 int    ty;
                                 if (tokCount == 4)
                                 {
                                     tx = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 3));
                                     ty = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 4));
                                 }
                                 else
                                 {
                                     tx = -1;
                                     ty = -1;
                                 }
                                 DataEntry entry = GlobalVars.nwrDB.FindEntryBySign(temp);
                                 if (entry != null)
                                 {
                                     GlobalVars.nwrGame.AddCreatureEx(player.LayerID, player.Field.X, player.Field.Y, tx, ty, entry.GUID);
                                 }
                             }
                             else
                             {
                                 if (token.Equals("kill_all"))
                                 {
                                     NWField fld = player.CurrentField;
                                     for (int i = fld.Creatures.Count - 1; i >= 0; i--)
                                     {
                                         NWCreature cr = fld.Creatures.GetItem(i);
                                         if (!cr.IsPlayer && !cr.Mercenary)
                                         {
                                             cr.Death("", null);
                                         }
                                     }
                                 }
                                 else
                                 {
                                     if (token.Equals("show_goals"))
                                     {
                                         ShowGoals();
                                     }
                                     else
                                     {
                                         if (token.Equals("set_divinity"))
                                         {
                                             GlobalVars.Debug_Divinity = !GlobalVars.Debug_Divinity;
                                             string temp;
                                             if (GlobalVars.Debug_Divinity)
                                             {
                                                 temp = "yes";
                                             }
                                             else
                                             {
                                                 temp = "no";
                                             }
                                             AddMessage(">> (divinity = " + temp + ")");
                                         }
                                         else
                                         {
                                             if (token.Equals("set_freeze"))
                                             {
                                                 GlobalVars.Debug_Freeze = !GlobalVars.Debug_Freeze;
                                                 string temp;
                                                 if (GlobalVars.Debug_Freeze)
                                                 {
                                                     temp = "yes";
                                                 }
                                                 else
                                                 {
                                                     temp = "no";
                                                 }
                                                 AddMessage(">> (freeze = " + temp + ")");
                                             }
                                             else
                                             {
                                                 if (token.Equals("set_morality"))
                                                 {
                                                     if (tokCount == 1)
                                                     {
                                                         throw new Exception(BaseLocale.GetStr(RS.rs_NoValue));
                                                     }
                                                     int dummy = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 2));
                                                     player.Morality = (sbyte)dummy;
                                                     AddMessage(">> (Player.Morality = " + Convert.ToString(dummy) + ")");
                                                 }
                                                 else
                                                 {
                                                     if (token.Equals("takeitem"))
                                                     {
                                                         if (tokCount == 1)
                                                         {
                                                             throw new Exception(BaseLocale.GetStr(RS.rs_NoName));
                                                         }
                                                         if (tokCount == 2)
                                                         {
                                                             throw new Exception(BaseLocale.GetStr(RS.rs_NoCount));
                                                         }
                                                         token = AuxUtils.GetToken(cmd, " ", 2);
                                                         int dummy = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 3));
                                                         TakePlayerItem(player, token, dummy);
                                                     }
                                                     else
                                                     {
                                                         AddMessage(BaseLocale.GetStr(RS.rs_CommandUnknown));
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } catch (Exception ex) {
         AddMessage(BaseLocale.GetStr(RS.rs_CommandUnknown));
         AddMessage(ex.Message);
     }
 }