示例#1
0
        private static void PromoteSkill(Person p, SkillType st, ref int xp, int max)
        {
            Skill sk = p.Skills.GetByType(st);

            if (sk.Level < max)
            {
                Skill base_sk = p.Skills.GetByType(st.BasedOn);

                int promote = 0;
                while (true)
                {
                    promote = Math.Min(xp, max - sk.Level);
                    if (base_sk != null && base_sk.Level < sk.Level + promote)
                    {
                        PromoteSkill(p, base_sk.Type, ref xp, base_sk.Level + 1);
                    }
                    else
                    {
                        break;
                    }
                }

                sk.Level += promote;
                xp       -= promote;
            }

            // Add skills based on this, if maximum level reached
            if (sk.Level >= 100)
            {
                foreach (SkillType st2 in SkillType.List)
                {
                    if (st2.BasedOn != st || p.Skills.GetByType(st2) != null)
                    {
                        continue;
                    }
                    p.AddSkill(st2);
                }
            }
        }
示例#2
0
        public void ShowSkill(SkillType st, bool force)
        {
            if (!SkillsToShow.Contains(st) && (force || !ShownSkills.Contains(st)))
            {
                SkillsToShow.Add(st);

                /*
                 *      // Production
                 *      foreach (ItemType it in ItemType.List)
                 *              if (it.ProduceSkill != null && it.ProduceSkill.Type == st)
                 *                      ShowItem(it);
                 *
                 *      // Installation
                 *      foreach (ItemType it in ItemType.List)
                 *              if (it.InstallSkill != null && it.InstallSkill.Type == st)
                 *              {
                 *                      ShowItem(it);
                 *                      foreach (BuildingType bt in BuildingType.List.Values)
                 *                              if (bt.Materials.Count > 0 && bt.Materials[0].Type == it)
                 *                                      ShowBuilding(bt);
                 *              }
                 */
            }
        }
示例#3
0
        private static bool CanPromoteSkill(Person p, SkillType st)
        {
            if (p.Man.NoLearn)
            {
                return(false);
            }

            // Add prerequisite skills if none
            Skill sk = p.Skills.GetByType(st);

            if (sk != null)
            {
                return(true);
            }
            else if (st.BasedOn != null && CanPromoteSkill(p, st.BasedOn))
            {
                p.Skills.Add(new Skill(st));
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        public static void LoadData(string filename)
        {
            XmlDocument doc = LoadXmlDocument(filename);

            NameGenerator.Init((XmlElement)doc.SelectSingleNode("data/names"));

            // Terrain
            foreach (XmlElement el in doc.SelectNodes("/data/terrain/entry"))
            {
                new Terrain(el.GetAttribute("name"));
            }

            // Weather
            foreach (XmlElement el in doc.SelectNodes("/data/weather/entry"))
            {
                new Weather(el.GetAttribute("name"));
            }

            // Item
            foreach (XmlElement el in doc.SelectNodes("/data/item/entry"))
            {
                new ItemType(el.GetAttribute("name"));
            }

            // Skill
            foreach (XmlElement el in doc.SelectNodes("/data/skill/entry"))
            {
                new SkillType(el.GetAttribute("name"));
            }

            // Months
            foreach (XmlElement el in doc.SelectNodes("/data/month/entry"))
            {
                Month m = new Month();
                m.NameEn      = el.GetAttribute("name-en");
                m.NameRu      = el.GetAttribute("name-ru");
                m.Weather     = Weather.Get(el.GetAttribute("weather"));
                m.Temperature = Convert.ToInt32(el.GetAttribute("temperature"));
            }

            // Building
            foreach (XmlElement el in doc.SelectNodes("/data/building/entry"))
            {
                BuildingType t = new BuildingType(el.GetAttribute("name"));
                t.FullNameEn   = el.GetAttribute("name-en");
                t.FullNameRu   = el.GetAttribute("name-ru");
                t.Speed        = LoadInteger(el, "speed");
                t.DriveTerrain = Terrain.Get(el.GetAttribute("drive-terrain"));
                t.Capacity     = LoadInteger(el, "capacity");
                t.Defence      = LoadInteger(el, "defence");
                t.HP           = LoadInteger(el, "hp");
                t.Radiation    = LoadInteger(el, "radiation");
                t.Temperature  = LoadInteger(el, "temperature");
                t.NoBuild      = (el.GetAttribute("nobuild") == "True");

                t.MaintainSkill = LoadSkill(el, "maintain-skill");
                t.DriveSkill    = LoadSkill(el, "drive-skill");
                foreach (XmlElement elItem in el.SelectNodes("material"))
                {
                    t.Materials.Add(LoadItem(elItem));
                }
                foreach (XmlElement elItem in el.SelectNodes("optional"))
                {
                    t.OptionalMaterials.Add(LoadItem(elItem));
                }
                t.Fuel     = ItemType.Get(el.GetAttribute("fuel"));
                t.Resource = LoadItem(el, "resource");
            }

            // Terrain - full
            foreach (XmlElement el in doc.SelectNodes("/data/terrain/entry"))
            {
                Terrain t = Terrain.Get(el.GetAttribute("name"));
                t.FullNameEn = el.GetAttribute("name-en");
                t.FullNameRu = el.GetAttribute("name-ru");
                t.MP         = LoadInteger(el, "mp");
                if (el.GetAttribute("walking") != "")
                {
                    t.Walking = Convert.ToBoolean(el.GetAttribute("walking"));
                }
                if (el.GetAttribute("vehicles") != "")
                {
                    t.Vehicles = Convert.ToBoolean(el.GetAttribute("vehicles"));
                }
                if (el.GetAttribute("ships") != "")
                {
                    t.Ships = Convert.ToBoolean(el.GetAttribute("ships"));
                }
                foreach (XmlElement elMonster in el.SelectNodes("monster"))
                {
                    t.Monsters.Add(ItemType.Get(elMonster.GetAttribute("type")),
                                   Convert.ToInt32(elMonster.GetAttribute("chance")));
                }
            }

            // Weather - full
            foreach (XmlElement el in doc.SelectNodes("/data/weather/entry"))
            {
                Weather t = Weather.Get(el.GetAttribute("name"));
                t.FullNameEn = el.GetAttribute("name-en");
                t.FullNameRu = el.GetAttribute("name-ru");
                LoadInteger(ref t.Radiation, el.GetAttribute("radiation"));
            }

            // Skills - full
            foreach (XmlElement el in doc.SelectNodes("/data/skill/entry"))
            {
                SkillType t = SkillType.Get(el.GetAttribute("name"));
                t.FullNameEn    = el.GetAttribute("name-en");
                t.FullNameRu    = el.GetAttribute("name-ru");
                t.DescriptionEn = el.GetAttribute("description-en");
                t.DescriptionRu = el.GetAttribute("description-ru");
                t.BasedOn       = SkillType.Get(el.GetAttribute("based-on"));
                LoadInteger(ref t.DefaultLevel, el.GetAttribute("default-level"));
            }

            // Items - fill
            foreach (XmlElement el in doc.SelectNodes("/data/item/entry"))
            {
                ItemType t = ItemType.Get(el.GetAttribute("name"));
                t.FullNameEn1 = el.GetAttribute("name-en1");
                t.FullNameEn2 = el.GetAttribute("name-en2");
                t.FullNameRu0 = el.GetAttribute("name-ru0");
                t.FullNameRu1 = el.GetAttribute("name-ru1");
                t.FullNameRu2 = el.GetAttribute("name-ru2");

                t.IsMan     = (el.GetAttribute("is-man") == "True");
                t.IsWeapon  = (el.GetAttribute("is-weapon") == "True");
                t.IsArmor   = (el.GetAttribute("is-armor") == "True");
                t.IsMonster = (el.GetAttribute("is-monster") == "True");

                if (el.GetAttribute("nogive") != "")
                {
                    t.NoGive = Convert.ToBoolean(el.GetAttribute("nogive"));
                }
                LoadInteger(ref t.Weight, el.GetAttribute("weight"));
                t.Capacity[(int)Movement.Walk] = LoadInteger(el, "capacity-walk");
                t.Capacity[(int)Movement.Ride] = LoadInteger(el, "capacity-ride");
                t.InstallSkill     = LoadSkill(el, "install-skill");
                t.Rations          = LoadInteger(el, "rations");
                t.Dead             = ItemType.Get(el.GetAttribute("dead"));
                t.DecomposeChance  = LoadInteger(el, "decompose-chance");
                t.OwnerRadiation   = LoadInteger(el, "owner-radiation");
                t.RegionRadiation  = LoadInteger(el, "region-radiation");
                t.OwnerTemperature = LoadInteger(el, "owner-temperature");
                LoadInteger(ref t.TemperatureFrom, el.GetAttribute("temperature-from"));
                LoadInteger(ref t.TemperatureEffect, el.GetAttribute("temperature-effect"));
                t.Burn = (el.GetAttribute("burn") == "True");
                LoadItems(t.Drops, el.SelectNodes("drop"));

                // Production
                t.ProduceSkill    = LoadSkill(el, "produce-skill");
                t.ProduceBuilding = BuildingType.Get(el.GetAttribute("produce-inside"));
                if (el.GetAttribute("production-rate") != "")
                {
                    t.ProductionRate = LoadInteger(el, "production-rate");
                }
                t.ProduceFrom1 = LoadItem(el, "produce-from1");
                t.ProduceFrom2 = LoadItem(el, "produce-from2");
                t.ProduceAs    = ItemType.Get(el.GetAttribute("produce-as"));

                // Mutation
                if (el.GetAttribute("radiation-effect") != "")
                {
                    t.RadiationEffect = LoadInteger(el, "radiation-effect");
                }
                if (el.GetAttribute("radiation-from") != "")
                {
                    t.RadiationFrom = LoadInteger(el, "radiation-from");
                }
                if (el.GetAttribute("radiation-to") != "")
                {
                    t.RadiationTo = LoadInteger(el, "radiation-to");
                }
                t.MutatePercent = LoadInteger(el, "mutate-percent");
                t.MutateTo      = ItemType.Get(el.GetAttribute("mutate-to"));

                // Man
                foreach (XmlElement elFood in el.SelectNodes("food"))
                {
                    ItemType it = ItemType.Get(elFood.GetAttribute("name"));
                    t.Food.Add(it);
                }
                t.Medicine      = ItemType.Get(el.GetAttribute("medicine"));
                t.Baby          = ItemType.Get(el.GetAttribute("baby"));
                t.BabyFrom      = ItemType.Get(el.GetAttribute("baby-from"));
                t.BabyTimer     = LoadInteger(el, "baby-timer");
                t.MaxHireAmount = LoadInteger(el, "max-hire-amount");
                t.NoLearn       = (el.GetAttribute("nolearn") == "True");

                // Monster
                LoadSkills(t.Skills, el.SelectNodes("skill"));
                LoadInteger(ref t.Aggression, el.GetAttribute("aggression"));
                LoadInteger(ref t.PackSize, el.GetAttribute("pack-size"));

                // Baby
                foreach (XmlElement elGrowTo in el.SelectNodes("grow-to"))
                {
                    t.GrowTo.Add(ItemType.Get(elGrowTo.GetAttribute("name")));
                }

                // Weapon
                t.WeaponSkill = SkillType.Get(el.GetAttribute("weapon-skill"));
                if (el.GetAttribute("ranged") != "")
                {
                    t.Ranged = Convert.ToBoolean(el.GetAttribute("ranged"));
                }
                if (el.GetAttribute("heavy") != "")
                {
                    t.Heavy = Convert.ToBoolean(el.GetAttribute("ranged"));
                }
                if (el.GetAttribute("anti-tank") != "")
                {
                    t.AntiTank = Convert.ToBoolean(el.GetAttribute("anti-tank"));
                }
                if (el.GetAttribute("explosive") != "")
                {
                    t.Explosive = Convert.ToBoolean(el.GetAttribute("explosive"));
                }
                if (el.GetAttribute("ammo") != "")
                {
                    t.Ammo = ItemType.Get(el.GetAttribute("ammo"));
                }
                if (el.GetAttribute("case") != "")
                {
                    t.Case = ItemType.Get(el.GetAttribute("case"));
                }
                LoadInteger(ref t.ToWound, el.GetAttribute("wound-chance"));
                LoadInteger(ref t.HitModifier, el.GetAttribute("hit-modifier"));
                LoadInteger(ref t.ArmorModifier, el.GetAttribute("armor-modifier"));
                LoadInteger(ref t.Attacks, el.GetAttribute("attacks"));
                LoadInteger(ref t.Targets, el.GetAttribute("targets"));
                LoadInteger(ref t.Lethality, el.GetAttribute("lethality"));
                LoadInteger(ref t.HP, el.GetAttribute("hp"));

                // Armor
                t.ArmorSave = LoadInteger(el, "armor-save");
            }

            // Chosen
            LoadSkills(ChosenSkills, doc.SelectNodes("data/chosen/skill"));
            LoadItems(ChosenItems, doc.SelectNodes("data/chosen/item"));
        }
示例#5
0
        public static void LoadGame(string folder)
        {
            // Create predefined factions
            XmlDocument doc = LoadXmlDocument(Path.Combine(folder, "gamein.xml"));

            // Factions
            foreach (XmlElement elFaction in doc.SelectNodes("/game/faction"))
            {
                int     num = Convert.ToInt32(elFaction.GetAttribute("num"));
                Faction f   = new Faction(num);
                f.Name     = elFaction.GetAttribute("name");
                f.Password = elFaction.GetAttribute("password");
                f.Email    = elFaction.GetAttribute("email");
                if (elFaction.HasAttribute("default-attitude"))
                {
                    f.DefaultAttitude = (Attitude)Convert.ToInt32(elFaction.GetAttribute("default-attitude"));
                }
                if (elFaction.GetAttribute("text-report") != "")
                {
                    f.Options.TextReport = Convert.ToBoolean(elFaction.GetAttribute("text-report"));
                }
                if (elFaction.GetAttribute("xml-report") != "")
                {
                    f.Options.XmlReport = Convert.ToBoolean(elFaction.GetAttribute("xml-report"));
                }
                if (elFaction.GetAttribute("lang") == "ru")
                {
                    f.Options.Lang = Lang.Ru;
                }

                foreach (XmlElement el in elFaction.SelectNodes("shown-item"))
                {
                    f.ShownItems.Add(ItemType.Get(el.GetAttribute("name")));
                }
                foreach (XmlElement el in elFaction.SelectNodes("shown-skill"))
                {
                    f.ShownSkills.Add(SkillType.Get(el.GetAttribute("name")));
                }
                foreach (XmlElement el in elFaction.SelectNodes("shown-building"))
                {
                    f.ShownBuildings.Add(BuildingType.Get(el.GetAttribute("name")));
                }

                // Attitudes
                foreach (XmlElement elAttitude in elFaction.SelectNodes("attitude"))
                {
                    Attitude a    = (Attitude)Convert.ToInt32(elAttitude.GetAttribute("level"));
                    int      fnum = Convert.ToInt32(elAttitude.GetAttribute("faction"));
                    f.Attitudes.Add(fnum, a);
                }
            }

            // Map
            XmlElement elMap = (XmlElement)doc.SelectSingleNode("/game/map");

            Map.SetDimensions(Convert.ToInt32(elMap.GetAttribute("width")),
                              Convert.ToInt32(elMap.GetAttribute("height")));
            LoadInteger(ref Map.Turn, doc.DocumentElement.GetAttribute("turn"));
            Map.Turn++;

            // Regions
            foreach (XmlElement elRegion in elMap.SelectNodes("region"))
            {
                int    x = Convert.ToInt32(elRegion.GetAttribute("x"));
                int    y = Convert.ToInt32(elRegion.GetAttribute("y"));
                Region r = Map.Region(x, y);
                r.Terrain    = Terrain.Get(elRegion.GetAttribute("terrain"));
                r.Name       = elRegion.GetAttribute("name");
                r._radiation = Convert.ToInt32(elRegion.GetAttribute("radiation"));

                // Items
                LoadItems(r.Resources, elRegion.SelectNodes("resource"));
                LoadItems(r.Junk, elRegion.SelectNodes("junk"));

                // Buildings
                foreach (XmlElement elBuilding in elRegion.SelectNodes("building"))
                {
                    BuildingType t   = BuildingType.Get(elBuilding.GetAttribute("type"));
                    int          num = Convert.ToInt32(elBuilding.GetAttribute("num"));
                    Building     b   = new Building(t, r, num);
                    b.Name = elBuilding.GetAttribute("name");
                    if (elBuilding.HasAttribute("description"))
                    {
                        b.Description = elBuilding.GetAttribute("description");
                    }
                    LoadItems(b.Installed, elBuilding.SelectNodes("installed"));
                }

                // Persons
                foreach (XmlElement elPerson in elRegion.SelectNodes("person"))
                {
                    int     num = Convert.ToInt32(elPerson.GetAttribute("num"));
                    Faction f;
                    if (elPerson.HasAttribute("faction"))
                    {
                        f = Faction.Get(Convert.ToInt32(elPerson.GetAttribute("faction")));
                    }
                    else
                    {
                        f = Faction.Get(Constants.NPCFactionNum);
                    }
                    Person p = new Person(f, r, num);
                    p.Name = elPerson.GetAttribute("name");
                    if (elPerson.HasAttribute("description"))
                    {
                        p.Description = elPerson.GetAttribute("description");
                    }
                    p.Insanity    = LoadInteger(elPerson, "insanity");
                    p.BabyTimer   = LoadInteger(elPerson, "baby-timer");
                    p.FatherSkill = SkillType.Get(elPerson.GetAttribute("father-skill"));
                    p.FatherName  = elPerson.GetAttribute("father-name");
                    p.Chosen      = (elPerson.GetAttribute("chosen") == "True");
                    p.Patrolling  = (elPerson.GetAttribute("patrolling") == "True");
                    p.Avoiding    = (elPerson.GetAttribute("avoiding") == "True");
                    LoadInteger(ref p.Age, elPerson.GetAttribute("age"));
                    if (elPerson.GetAttribute("building") != "")
                    {
                        p.Building = r.Buildings.GetByNumber(Convert.ToInt32(elPerson.GetAttribute("building")));
                    }
                    if (elPerson.GetAttribute("leader") != "")
                    {
                        p.Leader = r.Persons.GetByNumber(Convert.ToInt32(elPerson.GetAttribute("leader")));
                    }

                    XmlElement elTrade = (XmlElement)elPerson.SelectSingleNode("trade");
                    if (elTrade != null)
                    {
                        p.TradeOrder            = new TradeOrder();
                        p.TradeOrder.PersonNum  = LoadInteger(elTrade, "with");
                        p.TradeOrder.BuyWhat    = ItemType.Get(elTrade.SelectSingleNode("buy/@type").Value);
                        p.TradeOrder.BuyAmount  = LoadInteger((XmlElement)elTrade.SelectSingleNode("buy"), "amount");
                        p.TradeOrder.SellWhat   = ItemType.Get(elTrade.SelectSingleNode("sell/@type").Value);
                        p.TradeOrder.SellAmount = LoadInteger((XmlElement)elTrade.SelectSingleNode("sell"), "amount");
                    }

                    LoadItems(p.Items, elPerson.SelectNodes("item"));
                    LoadSkills(p.Skills, elPerson.SelectNodes("skill"));

                    foreach (XmlElement el in elPerson.SelectNodes("consume"))
                    {
                        p.Consume.Add(ItemType.Get(el.GetAttribute("type")));
                    }
                    foreach (XmlElement el in elPerson.SelectNodes("burn"))
                    {
                        p.Burn.Add(ItemType.Get(el.GetAttribute("type")));
                    }
                    foreach (XmlElement el in elPerson.SelectNodes("equipment"))
                    {
                        p.Equipment.Add(ItemType.Get(el.GetAttribute("type")));
                    }
                }
            }
        }
示例#6
0
 public void ShowSkill(SkillType st)
 {
     ShowSkill(st, false);
 }
示例#7
0
 public void PromoteSkill(SkillType st)
 {
     PromoteSkill(st, false);
 }
示例#8
0
        private static void ShowSkillType(SkillType st)
        {
            if (faction.ShownSkills.Contains(st) && !faction.SkillsToShow.Contains(st))
            {
                return;
            }

            XmlElement elSkills = (XmlElement)doc.DocumentElement.SelectSingleNode("skills");
            XmlElement el       = (XmlElement)elSkills.SelectSingleNode(
                String.Format("skill[@id='{0}']", st.Name));

            if (el != null)
            {
                return;
            }
            el = doc.CreateElement("skill");
            elSkills.AppendChild(el);
            el.SetAttribute("id", st.Name);

            if (faction.Options.Lang == Lang.En)
            {
                el.SetAttribute("name", st.FullNameEn);
            }
            else
            {
                el.SetAttribute("name", st.FullNameRu);
            }

            if (!faction.SkillsToShow.Contains(st))
            {
                return;
            }

            el.SetAttribute("full", "True");

            if (faction.Options.Lang == Lang.En)
            {
                el.SetAttribute("description", st.DescriptionEn);
            }
            else
            {
                el.SetAttribute("description", st.DescriptionRu);
            }
            if (st.BasedOn != null)
            {
                AddSkillAttribute(el, st.BasedOn, "based-on");
            }
            if (st.Special)
            {
                el.SetAttribute("special", "True");
            }

            foreach (ItemType it in ItemType.List)
            {
                if (it.ProduceSkill != null && it.ProduceSkill.Type == st)
                {
                    AddItemType(el, it, "produce");
                }
            }

            foreach (ItemType it in ItemType.List)
            {
                if (it.InstallSkill != null && it.InstallSkill.Type == st)
                {
                    AddItemType(el, it, "install");
                }
            }

            foreach (ItemType it in ItemType.List)
            {
                if (it.InstallSkill != null && it.InstallSkill.Type == st)
                {
                    foreach (BuildingType bt in BuildingType.List)
                    {
                        if (!bt.NoBuild && bt.Materials.Count > 0 && bt.Materials[0].Type == it)
                        {
                            AddBuildingType(el, bt, "build");
                        }
                    }
                }
            }

            foreach (BuildingType bt in BuildingType.List)
            {
                if (bt.DriveSkill != null && bt.DriveSkill.Type == st)
                {
                    AddBuildingType(el, bt, "drive");
                }
            }
        }
示例#9
0
 private static void AddSkillAttribute(XmlElement el, SkillType st, string nodeName)
 {
     el.SetAttribute(nodeName, st.Name);
     ShowSkillType(st);
 }
示例#10
0
        public static void WriteSkillReport(SkillType st)
        {
            string s = st.ToString(lng) + " :";

            if (lng == Lang.En)
            {
                if (st.DescriptionEn != "")
                {
                    s += " " + st.DescriptionEn;
                }

                if (st.BasedOn != null)
                {
                    s += " This skill requires " + st.BasedOn.FullNameEn +
                         " [" + st.BasedOn.Name + "] to study.";
                }

                if (st.Special)
                {
                    s += " This is a special skill,";
                    if (st.BasedOn == null)
                    {
                        s += " it can't be learned by other persons.";
                    }
                    else
                    {
                        s += " a person can learn it only from team leader.";
                    }
                }

                // Production
                ItemTypeList products = new ItemTypeList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.ProduceSkill != null && it.ProduceSkill.Type == st)
                    {
                        products.Add(it);
                    }
                }
                if (products.Count > 0)
                {
                    s += " A person with this skill may PRODUCE " +
                         products.ToString(lng);
                }

                // Installation
                ItemTypeList installs = new ItemTypeList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.InstallSkill != null && it.InstallSkill.Type == st)
                    {
                        installs.Add(it);
                    }
                }
                if (installs.Count > 0)
                {
                    s += " A person with this skill can INSTALL and UNINSTALL " +
                         installs.ToString(lng);
                }

                // Building
                BuildingTypeList buildings = new BuildingTypeList();
                foreach (ItemType it in installs)
                {
                    foreach (BuildingType bt in BuildingType.List)
                    {
                        if (!bt.NoBuild && bt.Materials.Count > 0 && bt.Materials[0].Type == it)
                        {
                            buildings.Add(bt);
                        }
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " It allows to BUILD: " + buildings.ToString(lng);
                }

                // Driving
                buildings.Clear();
                foreach (BuildingType bt in BuildingType.List)
                {
                    if (bt.DriveSkill != null && bt.DriveSkill.Type == st)
                    {
                        buildings.Add(bt);
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " A person with this skill can DRIVE " + buildings.ToString(Lang.En);
                }
            }
            else
            {
                if (st.DescriptionRu != "")
                {
                    s += " " + st.DescriptionRu;
                }

                if (st.BasedOn != null)
                {
                    s += " Для изучения необходим навык " +
                         st.BasedOn.ToString(lng) + ".";
                }

                if (st.Special)
                {
                    s += " Это специальный навык,";
                    if (st.BasedOn == null)
                    {
                        s += " другие персонажи не могут получить его.";
                    }
                    else
                    {
                        s += " который можно получить только под руководством бригадира.";
                    }
                }

                // Production
                ItemTypeList products = new ItemTypeList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.ProduceSkill != null && it.ProduceSkill.Type == st)
                    {
                        products.Add(it);
                    }
                }
                if (products.Count > 0)
                {
                    s += " Навык позволяет производить предметы: " +
                         products.ToString(lng);
                }

                // Installation
                ItemTypeList installs = new ItemTypeList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.InstallSkill != null && it.InstallSkill.Type == st)
                    {
                        installs.Add(it);
                    }
                }
                if (installs.Count > 0)
                {
                    s += " Навык позволяет монтировать и демонтировать предметы: " +
                         installs.ToString(lng);
                }

                // Building
                BuildingTypeList buildings = new BuildingTypeList();
                foreach (ItemType it in installs)
                {
                    foreach (BuildingType bt in BuildingType.List)
                    {
                        if (!bt.NoBuild && bt.Materials.Count > 0 && bt.Materials[0].Type == it)
                        {
                            buildings.Add(bt);
                        }
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " С его помощью могут быть построены: " + buildings.ToString(lng);
                }

                // Driving
                buildings.Clear();
                foreach (BuildingType bt in BuildingType.List)
                {
                    if (bt.DriveSkill != null && bt.DriveSkill.Type == st)
                    {
                        buildings.Add(bt);
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " Навык позволяет водить машины: " +
                         buildings.ToString(lng);
                }
            }

            Write(s);
            Write("");
        }
示例#11
0
        public static void Load(string folder)
        {
            if (folder == "")
            {
                folder = Directory.GetCurrentDirectory();
            }
            DirectoryInfo di = new DirectoryInfo(folder);

            foreach (FileInfo fi in di.GetFiles("request.*"))
            {
                TextReader tr = new StreamReader(fi.FullName, Encoding.GetEncoding(1251));

                string email        = "";
                string faction_name = "Faction";
                string gender       = "MAN";
                string chosen_name  = "";
                string special      = "";
                Lang   lng          = Lang.En;
                bool   body         = false;

                while (true)
                {
                    string s = tr.ReadLine();
                    if (s == null)
                    {
                        break;
                    }
                    if (s.Trim() == "")
                    {
                        body = true;
                    }

                    if (s.IndexOf(":") == -1)
                    {
                        continue;
                    }
                    string name = s.Substring(0, s.IndexOf(":")).ToLower();
                    string val  = s.Substring(s.IndexOf(":") + 2);

                    if (name == "from")
                    {
                        email = val;
                    }

                    if (!body)
                    {
                        continue;
                    }

                    if (name == "faction")
                    {
                        faction_name = MyStrings.GetValidString(val);
                    }
                    if (name == "chosen" && val.ToLower() == "woman")
                    {
                        gender = "WOMA";
                    }
                    if (name == "name")
                    {
                        chosen_name = MyStrings.GetValidString(val);
                    }
                    if (name == "language" && val.ToLower() == "ru")
                    {
                        lng = Lang.Ru;
                    }
                    if (name == "skill")
                    {
                        special = val;
                    }
                }
                tr.Close();

                if (email != "")
                {
                    // Create new faction
                    Faction f = new Faction();
                    f.Email        = email;
                    f.Name         = faction_name;
                    f.Options.Lang = lng;
                    for (int i = 0; i < 6; i++)
                    {
                        f.Password += (Char)('a' + Constants.Random('z' - 'a'));
                    }

                    // Select region with less faction players and monsters and more wanderers
                    Region r        = Map.Regions[Constants.Random(Map.Regions.Count)];
                    int    unwanted = 0;
                    int    wanted   = 0;
                    foreach (Person p in r.Persons)
                    {
                        if (!p.Faction.IsNPC || p.Man.IsMonster)
                        {
                            unwanted++;
                        }
                        else
                        {
                            wanted++;
                        }
                    }

                    int j     = Map.Regions.IndexOf(r);
                    int start = j;
                    while (true)
                    {
                        j++;
                        if (j >= Map.Regions.Count)
                        {
                            j = 0;
                        }
                        if (j == start)
                        {
                            break;
                        }
                        Region r2 = Map.Regions[j];
                        if (r2._radiation >= 90 || r2.Radiation >= 90 || !r2.Terrain.Walking)
                        {
                            continue;
                        }
                        int unwanted2 = 0;
                        int wanted2   = 0;
                        foreach (Person p in r2.Persons)
                        {
                            if (!p.Faction.IsNPC || p.Man.IsMonster || p.Insanity >= Constants.DangerousInsanity)
                            {
                                unwanted2++;
                            }
                            else
                            {
                                wanted2++;
                            }
                        }

                        if (unwanted2 < unwanted ||
                            (unwanted2 == unwanted && wanted2 > wanted))
                        {
                            r        = r2;
                            unwanted = unwanted2;
                            wanted   = wanted2;
                        }
                    }

                    if (r._radiation >= 90 || !r.Terrain.Walking)
                    {
                        throw new Exception("What region you picked you?");
                    }

                    // Create Chosen One
                    Person chosen = new Person(f, r);
                    chosen.Chosen = true;
                    if (chosen_name != "")
                    {
                        chosen.Name = chosen_name;
                    }
                    else
                    {
                        chosen.Name = NameGenerator.Name(gender);
                    }
                    chosen.Avoiding = true;

                    chosen.AddItems(ItemType.Get(gender), 1);
                    foreach (Item itm in DataFile.ChosenItems)
                    {
                        chosen.AddItems(itm.Type, itm.Amount);
                    }
                    foreach (Skill sk in DataFile.ChosenSkills)
                    {
                        chosen.AddSkill(sk.Type).Level = sk.Level;
                    }

                    // Special skill
                    if (special != "")
                    {
                        SkillType spec = SkillType.GetByAnyName(special);
                        if (spec != null)
                        {
                            Skill spec_skill = DataFile.ChosenSpecial.GetByType(spec);
                            if (spec_skill != null)
                            {
                                chosen.AddSkill(spec_skill.Type).Level = spec_skill.Level;
                            }
                        }
                    }

                    // Show all buildable objects
                    foreach (Skill sk in chosen.Skills)
                    {
                        foreach (BuildingType bt in BuildingType.List)
                        {
                            if (!bt.NoBuild && bt.Materials.Count > 0 &&
                                bt.Materials[0].Type.InstallSkill.Type == sk.Type)
                            {
                                f.ShowBuilding(bt);
                            }
                        }
                    }

                    Console.WriteLine("..Faction created for " + email);
                }
            }
        }
示例#12
0
        public static void WriteSkillReport(SkillType st)
        {
            string s = st.ToString(lng) + " :";

            if (lng == Lang.En)
            {
                if (st.DescriptionEn != "")
                {
                    s += " " + st.DescriptionEn;
                }

                if (st.BasedOn != null)
                {
                    s += " This skill requires " + st.BasedOn.FullNameEn +
                         " [" + st.BasedOn.Name + "] to study.";
                }

                // Production
                ItemTypeArrayList products = new ItemTypeArrayList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.ProduceSkill != null && it.ProduceSkill.Type == st)
                    {
                        products.Add(it);
                    }
                }
                if (products.Count > 0)
                {
                    s += " A person with this skill may PRODUCE " +
                         products.ToString(lng);
                }

                // Installation
                ItemTypeArrayList installs = new ItemTypeArrayList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.InstallSkill != null && it.InstallSkill.Type == st)
                    {
                        installs.Add(it);
                    }
                }
                if (installs.Count > 0)
                {
                    s += " A person with this skill can INSTALL and UNINSTALL " +
                         installs.ToString(lng);
                }

                // Building
                BuildingTypeArrayList buildings = new BuildingTypeArrayList();
                foreach (ItemType it in installs)
                {
                    foreach (BuildingType bt in BuildingType.List)
                    {
                        if (!bt.NoBuild && bt.Materials.Count > 0 && bt.Materials[0].Type == it)
                        {
                            buildings.Add(bt);
                        }
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " It allows to BUILD: " + buildings.ToString(lng);
                }

                // Driving
                buildings.Clear();
                foreach (BuildingType bt in BuildingType.List)
                {
                    if (bt.DriveSkill != null && bt.DriveSkill.Type == st)
                    {
                        buildings.Add(bt);
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " A person with this skill can DRIVE " + buildings.ToString(Lang.En);
                }
            }
            else
            {
                if (st.DescriptionRu != "")
                {
                    s += " " + st.DescriptionRu;
                }

                if (st.BasedOn != null)
                {
                    s += " Для изучения необходим навык " +
                         st.BasedOn.ToString(lng) + ".";
                }

                // Production
                ItemTypeArrayList products = new ItemTypeArrayList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.ProduceSkill != null && it.ProduceSkill.Type == st)
                    {
                        products.Add(it);
                    }
                }
                if (products.Count > 0)
                {
                    s += " Навык позволяет производить предметы: " +
                         products.ToString(lng);
                }

                // Installation
                ItemTypeArrayList installs = new ItemTypeArrayList();
                foreach (ItemType it in ItemType.List)
                {
                    if (it.InstallSkill != null && it.InstallSkill.Type == st)
                    {
                        installs.Add(it);
                    }
                }
                if (installs.Count > 0)
                {
                    s += " Навык позволяет монтировать и демонтировать предметы: " +
                         installs.ToString(lng);
                }

                // Building
                BuildingTypeArrayList buildings = new BuildingTypeArrayList();
                foreach (ItemType it in installs)
                {
                    foreach (BuildingType bt in BuildingType.List)
                    {
                        if (!bt.NoBuild && bt.Materials.Count > 0 && bt.Materials[0].Type == it)
                        {
                            buildings.Add(bt);
                        }
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " С его помощью могут быть построены: " + buildings.ToString(lng);
                }

                // Driving
                buildings.Clear();
                foreach (BuildingType bt in BuildingType.List)
                {
                    if (bt.DriveSkill != null && bt.DriveSkill.Type == st)
                    {
                        buildings.Add(bt);
                    }
                }
                if (buildings.Count > 0)
                {
                    s += " Навык позволяет водить машины: " +
                         buildings.ToString(lng);
                }
            }

            Write(s);
            Write("");
        }
示例#13
0
 public int Add(SkillType item)
 {
     return(base.Add(item));
 }