コード例 #1
0
        internal TMSkillInfo getAtRank(int count)
        {
            if (count < 0)
            {
                return(null);
            }

            IEnumerator ie  = MasterHash.GetEnumerator();
            TMSkillInfo inf = null;

            while (count > -1)
            {
                ie.MoveNext();
                inf = (TMSkillInfo)((KeyValuePair <string, TMSkillInfo>)ie.Current).Value;
                if (inf.SkillEnable)
                {
                    count--;
                }
            }
            return(inf);
        }
コード例 #2
0
        private void QuickMethod()
        {
            Mobile m = Mobile;

            IEnumerator <KeyValuePair <string, SkillProfile> > ie = Profile.subProfiles.GetEnumerator();

            while (ie.MoveNext())
            {
                IEnumerator <KeyValuePair <string, TMSkillInfo> > ie2 = ie.Current.Value.MasterHash.GetEnumerator();
                while (ie2.MoveNext())
                {
                    TMSkillInfo tsi = ie2.Current.Value;
                    if (m.Skills.Total + (tsi.SkillValue * tsi.SkillWeight) <= totalAllowedPoints)
                    {
                        m.Skills[tsi.SkillID].Base = tsi.SkillValue;
                    }
                }
            }
            m.Str = Profile.StrVal;
            m.Dex = Profile.DexVal;
            m.Int = Profile.IntVal;
        }
コード例 #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;
            Dictionary <string, TMUsedInfo> selected = new Dictionary <string, TMUsedInfo>();

            if (info.ButtonID == 1)
            {
                bool man   = Profile.Manual;
                int  page  = 1;
                int  count = 0;
                int  csid  = (1000 * page) + (count % (Skin.NumPerPage - 1));
                if (man)
                {
                    while (count != Profile.MasterHash.Count)
                    {
                        string relaytext = "";
                        try
                        {
                            TextRelay relay = info.GetTextEntry(csid);
                            relaytext = relay.Text;
                        }
                        catch (Exception ex)
                        {
                            SkillSettings.DoTell2("Manual gathering problems: " + ex);
                        }
                        if (relaytext != "")
                        {
                            int value = -1;
                            try { value = Int32.Parse(relaytext); }
                            catch (Exception ex) { SkillSettings.DoTell2("Error on parse manual: " + ex); }
                            TMSkillInfo skinf = Profile.getAtRank(count);
                            if (skinf.SkillEnable)
                            {
                                TMUsedInfo inf = new TMUsedInfo(skinf.SkillName, value * skinf.SkillWeight, skinf.SkillWeight, skinf.SkillCap, skinf.SkillID);
                                selected.Add(skinf.SkillName, inf);
                            }
                        }
                        if (count % Skin.NumPerPage == 0 && count != 0)
                        {
                            page++;
                        }
                        count++;
                        csid = 3000 + count;
                    }
                }
                else
                {
                    while (count != Profile.MasterHash.Count)                      //Make sure all text entries have a 0 in them.
                    {
                        if (info.IsSwitched(csid))
                        {
                            TMSkillInfo skinf = Profile.getAtRank(count);
                            TMUsedInfo  inf   = new TMUsedInfo(skinf.SkillName, skinf.SkillWeight * skinf.SkillValue, skinf.SkillWeight, skinf.SkillCap, skinf.SkillID);
                            selected.Add(skinf.SkillName, inf);
                        }
                        if ((count + 1) % Skin.NumPerPage == 0)
                        {
                            page++;
                        }
                        count++;
                        csid = 1000 + count;
                    }
                }
            }
            else
            {
                return;
            }
            bool resend = Session.addSkill("" + Profile.ProfileName, selected);

            if (resend)
            {
                from.SendGump(Page.Clone());
                from.SendGump(new TMAlertGump(Session.CurrentErrorMessage));
            }
        }
コード例 #4
0
        public void GetGumpCode(TMQueryPage page)
        {
            Page = page;
            SkillSettings.DoTell("GetGumpCode, Skill Gump.");
            if (Profile == null)
            {
                try
                {
                    Dictionary <string, object> h = (Dictionary <string, object>)Page.GetValueSet();
                    Profile = (SkillProfile)h["Profile"];
                    Skin    = (TMSS4Skin)h["Skin"];
                    Session = (TMSkillSession)h["Session"];
                }
                catch (Exception e)
                {
                    SkillSettings.DoTell("Error when generating skill gump: " + e);
                    return;
                }
            }
            if (Profile == null)
            {
                SkillSettings.DoTell("Profile is still null. Cannot continue."); return;
            }
            if (!Profile.SkillEnable)
            {
                SkillSettings.DoTell("Skills not enabled on this profile.");
                return;
            }
            this.Dragable = false;
            Page.BaseSkinByType(this);
            Page.AddTitle("Skill Gump for " + Profile.ProfileName + ": ", "Control", this);
            if (Profile.IconID > 0)
            {
                SkillSettings.DoTell("Adding Icon: " + Profile.IconID);
                Page.AddIcon(Profile.IconID, "Control", this);
            }
            this.AddLabel(35, Skin.GetCoord("Control", "H") - 40, Skin.HighlightText, "Profile Maximum: " + Profile.SkillPoints + " pts");
            ButtonInfo inf2 = Skin.ButtonInfo["SessionAddButton"];

            SkillSettings.DoTell("Inf2: X: " + inf2.X + " Y: " + inf2.Y + " W: " + inf2.W + " H: " + inf2.H + " BG: " + inf2.bgID + " TX: " + inf2.text);
            Page.AddSuperButton(inf2.X, Page.Y + inf2.Y, inf2.H, inf2.W, inf2.bgID, Skin.ListUnderButtonN, Skin.ListUnderButtonP, Skin.AddLabel, GumpButtonType.Reply, 1, 0, this);
            IEnumerator ie = Profile.MasterHash.GetEnumerator();
            GumpList    l  = new GumpList(this, "details", this.Skin);

            l.numperpage = 8;
            l.AddColumn("Skill Name");
            l.AddColumn("Skill Value");
            l.AddColumn("Weight");
            l.AddColumn("Select");
            l.SetColumnCount(4);
            l.ChangeColumnWidth(0, 200);
            l.X            = Skin.SelectStartX;
            l.Y            = Skin.SelectStartY;
            l.ShowDividers = true;
            int colcount = 3;             // at least columns for title, value, and checkbox.

            if (Profile.CapEnable)
            {
                colcount++;
            }
            if (Profile.WeightEnable)
            {
                colcount++;
            }
            l.SetColumnCount(colcount);
            int checkID = 0;

            if (!Profile.Manual)
            {
                checkID = 1000;
            }
            else
            {
                checkID = 3000;
            }
            Dictionary <string, TMUsedInfo> selitem = Session.HasSelectedItems(Profile.ProfileName);

            SkillSettings.DoTell(" Selitem debug: " + selitem.Count + " Profile: " + Profile.ProfileName + " TSP: " + Session.totalSelectedPoints);
            IEnumerator selitemie = selitem.GetEnumerator();

            while (selitemie.MoveNext())
            {
                SkillSettings.DoTell(" - " + ((KeyValuePair <string, TMUsedInfo>)selitemie.Current).Value.SkillName + " Value: " + ((KeyValuePair <string, TMUsedInfo>)selitemie.Current).Value.SkillValue);
            }
            while (ie.MoveNext())
            {
                TMSkillInfo inf = (TMSkillInfo)((KeyValuePair <string, TMSkillInfo>)ie.Current).Value;

                /*
                 * if (y % sk.NumPerPage == 0)
                 * {Page.SetupPage(thisProfile.ProfileName, y == 0, thisProfile.MasterHash.Count - y < sk.NumPerPage ? true : false, page); page++;}
                 * Page.AddEntryCheck( 0, y%sk.NumPerPage, sk.SelectUp, sk.SelectDn, false, (1000 * page) + (y % sk.NumPerPage), ""+inf.SkillName, ""+inf.SkillWeight, ""+inf.SkillValue );
                 * y++;*/
                GumpListEntry e = new GumpListEntry(0, 0, l, Skin.EntryDefaultWidth, Skin.EntryDefaultHeight);

                e.AddColumn(inf.SkillName);
                e.AddColumn("" + inf.SkillValue);
                if (Profile.CapEnable)
                {
                    e.AddColumn("" + inf.SkillCap);
                }
                if (Profile.WeightEnable)
                {
                    e.AddColumn("" + inf.SkillWeight);
                }
                if (!Profile.Manual)
                {
                    e.AddColumn(new GumpCheck(-2, 0, Skin.EntryDefaultCheckUp, Skin.EntryDefaultCheckDn, selitem.ContainsKey(inf.SkillName), checkID));
                }
                else
                {
                    e.AddColumn(new GumpTextEntry(0, 0, 30, Skin.EntryDefaultHeight, Skin.NormalText, checkID, ""));
                }

                checkID++;
                l.Add(e);
            }
            l.CommitList();
            Session.Mobile.SendGump(this);
        }
コード例 #5
0
        public static void writeFile(SkillProfile profile, bool naming)
        {
            string middle;

            if (naming)
            {
                middle = "" + profile.ProfileName + " [Original]";
            }
            else
            {
                middle = "" + profile.ProfileName;
            }

            if (!Directory.Exists("TMSS/SkillProfiles/Information"))
            {
                Directory.CreateDirectory("TMSS/SkillProfiles/Information/");
            }

            string path = "TMSS/SkillProfiles/Information/" + profile.ProfileName + ".txt";

            try
            {
                using (FileStream stream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    StreamWriter sw = new StreamWriter(stream);

                    sw.WriteLine("This is the output for " + profile.ProfileName + " on " + DateTime.Now);

                    if (naming)
                    {
                        sw.WriteLine("This was generated at the creation of the profile.");
                    }

                    sw.WriteLine("\n\nGeneral: ");
                    sw.WriteLine("\t-Manual: " + profile.Manual);
                    sw.WriteLine("\t-Stat Force: " + profile.StatForce);
                    sw.WriteLine("\t-Stats Enabled: " + profile.StatEnable);
                    sw.WriteLine("\t-Stat Sum: " + profile.StatSum);
                    sw.WriteLine("\t-Strength: " + profile.StrVal);
                    sw.WriteLine("\t-Dexterity: " + profile.DexVal);
                    sw.WriteLine("\t-Intelligence: " + profile.IntVal);
                    sw.WriteLine("\t-Skill Force: " + profile.SkillForce);
                    sw.WriteLine("\t-Name: " + profile.ProfileName);
                    sw.WriteLine("\t-Num Allowed Skills: " + profile.SkillPoints);
                    sw.WriteLine("\t-Skill Sum: " + profile.SkillPoints);
                    sw.WriteLine("\t-Skill Sum: " + profile.IsKeyed);
                    sw.WriteLine("\t-Skill Sum: " + profile.IsGumped);
                    sw.WriteLine("\n\nEnabled Skills & Skill Values: ");
                    sw.WriteLine("\n\n");
                    //sw.WriteLine("Index: " +  " Name: " + SkillInfo.Table[0].Name + " Is: " +   " And its Max Value is: " );
                    IEnumerator ie = profile.MasterHash.GetEnumerator();
                    int         i  = 0;
                    while (ie.MoveNext())
                    {
                        TMSkillInfo info = ((KeyValuePair <string, TMSkillInfo>)ie.Current).Value;
                        sw.WriteLine("\tIndex: " + i + " Name: " + info.SkillName + " is " + info.SkillEnable + ", with Max of: " + info.SkillValue + ", Cap of " + info.SkillCap + ", and Weight of " + info.SkillWeight);
                        i++;
                    }

                    sw.Close();
                    stream.Close();
                }
            }
            catch (Exception e)
            {
                SkillSettings.DoTell("Error while attempting to write out profile information: " + e);
            }
        }
コード例 #6
0
        //This is used when a new profile is selected for an item, in order to load up the profile.
        //It is only used if the profile is not already loaded into the SkillProfiles array above.
        public static int SkillProfileLoader(string name, bool which)
        {
            if (Profiles.ContainsKey(name))
            {
                return(((SkillProfile)Profiles[name]).ID);
            }
            try
            {
                SkillProfile profile;
                string       path = "";
                if (which == false)
                {
                    path = "TMSS/SkillProfiles/" + name + ".skx";
                }
                else
                {
                    path = "TMSS/SkillProfiles/" + name;
                }
                if (!File.Exists(path))
                {
                    SkillSettings.DoTell("File Does Not Exist: " + path); return(0);
                }

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreWhitespace = true;
                XmlReader reader = XmlReader.Create(path, settings);
                reader.ReadToFollowing("TMSkillProfile");
                int    count    = 0;
                string realname = reader.GetAttribute(0);
                //reader.ReadStartElement("TMSkillProfile");
                profile = new SkillProfile(realname);

                reader.ReadToFollowing("Stats");
                profile.StatEnable = reader.GetAttribute(0) == "True" ? true : false;
                profile.StatForce  = reader.GetAttribute(1) == "True" ? true : false;
                profile.StatSum    = Int32.Parse(reader.GetAttribute(2));
                profile.StrVal     = Int32.Parse(reader.GetAttribute(3));
                profile.DexVal     = Int32.Parse(reader.GetAttribute(4));
                profile.DexVal     = Int32.Parse(reader.GetAttribute(5));

                reader.ReadToFollowing("Gumps");
                profile.Manual   = reader.GetAttribute(0) == "True" ? true : false;
                profile.IsGumped = reader.GetAttribute(1) == "True" ? true : false;
                profile.IconID   = Int32.Parse(reader.GetAttribute(2));

                reader.ReadToFollowing("Skills");
                profile.SkillEnable = reader.GetAttribute(0) == "True" ? true : false;
                profile.SkillPoints = Int32.Parse(reader.GetAttribute(1));
                SkillSettings.DoTell("Profile - " + profile.ProfileName + " has points at " + profile.SkillPoints);
                profile.SkillForce   = reader.GetAttribute(2) == "True" ? true : false;
                profile.IsKeyed      = reader.GetAttribute(3) == "True" ? true : false;
                profile.CapEnable    = reader.GetAttribute(4) == "True" ? true : false;
                profile.CapSum       = Int32.Parse(reader.GetAttribute(5));
                profile.WeightEnable = reader.GetAttribute(6) == "True" ? true : false;
                count = Int32.Parse(reader.GetAttribute(7));
                reader.ReadToFollowing("SkillInfo");
                while (count > 0)
                {
                    TMSkillInfo inf = new TMSkillInfo(reader);
                    profile.MasterHash.Add(inf.SkillName, inf);
                    count--;
                }
                reader.Close();
                int ret = AddNewProfile(profile);
                writeFile(profile, false);
                return(ret);
            }
            catch (Exception e)
            { SkillSettings.DoTell("Error while loading Skill Profile. This is a Level 1 I/O error. Please report." + e); return(-1); }
        }
コード例 #7
0
		//This is used when a new profile is selected for an item, in order to load up the profile.
		//It is only used if the profile is not already loaded into the SkillProfiles array above.
		public static int SkillProfileLoader(string name, bool which)
		{			
			if (Profiles.ContainsKey(name))
				return ((SkillProfile)Profiles[name]).ID;
			try
			{
				SkillProfile profile;
				string path = "";
				if (which == false)
					path = "TMSS/SkillProfiles/" + name + ".skx";
				else
					path = "TMSS/SkillProfiles/" + name;
				if (!File.Exists(path))
				{ SkillSettings.DoTell("File Does Not Exist: " + path);	return 0; }				
				
				XmlReaderSettings settings = new XmlReaderSettings();
				settings.IgnoreWhitespace = true;
				XmlReader reader = XmlReader.Create(path, settings);
				reader.ReadToFollowing("TMSkillProfile");
				int count = 0;
				string realname = reader.GetAttribute(0);
				//reader.ReadStartElement("TMSkillProfile");				
				profile = new SkillProfile(realname);
				
				reader.ReadToFollowing("Stats");
				profile.StatEnable = reader.GetAttribute(0) == "True" ? true : false;
				profile.StatForce = reader.GetAttribute(1) == "True" ? true : false;
				profile.StatSum = Int32.Parse(reader.GetAttribute(2));
				profile.StrVal = Int32.Parse(reader.GetAttribute(3) );
				profile.DexVal = Int32.Parse(reader.GetAttribute(4) );
				profile.DexVal = Int32.Parse(reader.GetAttribute(5) );

				reader.ReadToFollowing("Gumps");				
				profile.Manual = reader.GetAttribute(0) == "True" ? true : false;
				profile.IsGumped = reader.GetAttribute(1) == "True" ? true : false;
				profile.IconID = Int32.Parse(reader.GetAttribute(2) );

				reader.ReadToFollowing("Skills");
				profile.SkillEnable = reader.GetAttribute(0) == "True" ? true : false;
				profile.SkillPoints = Int32.Parse(reader.GetAttribute(1));
				SkillSettings.DoTell("Profile - "+profile.ProfileName+" has points at "+profile.SkillPoints );
				profile.SkillForce = reader.GetAttribute(2) == "True" ? true : false;
				profile.IsKeyed = reader.GetAttribute(3) == "True" ? true : false;
				profile.CapEnable = reader.GetAttribute(4) == "True" ? true : false;
				profile.CapSum = Int32.Parse(reader.GetAttribute(5));
				profile.WeightEnable = reader.GetAttribute(6) == "True" ? true : false;
				count = Int32.Parse(reader.GetAttribute(7) );
				reader.ReadToFollowing("SkillInfo");		
				while (count > 0)
				{
					TMSkillInfo inf = new TMSkillInfo( reader );
					profile.MasterHash.Add( inf.SkillName, inf );
					count--;
				}
				reader.Close();								
				int ret = AddNewProfile(profile);
				writeFile(profile, false);
				return ret;
			}
			catch (Exception e)
			{ SkillSettings.DoTell("Error while loading Skill Profile. This is a Level 1 I/O error. Please report." + e); return -1; }
		}