What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Compare two values...more information inside.

  • Thread starter Thread starter weischbier
  • Start date Start date
W

weischbier

Guest
So, I managed to get a list loaded into a datagridview.
Not to hard but challenging.
Now I want it to compare the numbers within this list with our currenttargets id which is uint.

here's my code:
Code:
//Import them
private void ImportIDs()
        {
            try
            {
                StreamReader s = new StreamReader(Path.Combine(Logging.ApplicationPath, string.Format(@"CustomClasses\Necrophilia - Advanced\Weischbier.Manager\Settings\BossIDs.ini")));
                String str;
                while ((str = s.ReadLine()) != null)
                {
                    Logger.WriteDebug("Importing Bosses by Id: " + str);
                    List.BossIdList.Add(new BossIDs(Convert.ToUInt32(str)));
                }
                s.Close();
            }
            catch (Exception e)
            {
                Logger.Write(Color.Red, "Unable to read BossIDs.ini. Please read the Debug for more information.");
                Logger.WriteDebug(e.Message);
            }
        }


public static System.ComponentModel.BindingList<BossIDs> BossIdList;

public class BossIDs
    {
        private uint blabla;
        public BossIDs(uint listItem)
        {
            ListItem = listItem;
        }


        public uint ListItem
        {
            get { return blabla; }
            set { blabla = value; }
        }
    }

//Compare them
public static bool IsBoss(this WoWUnit unit)
        {
            foreach (BossIDs b in List.BossIdList)
            {
                if (b != null && b.ListItem.Equals(StyxWoW.Me.CurrentTarget))
                    return true;
            }
            return false;
        }

Now, C# throws no errors with this and its loading everything fine.
But it returns false everytime.
For the record I only added this 31146 id to the file. It's the Raiders Dummy.

Any thoughts on this? I'm at the end with my coding skills...

greetz

Weischbier
 
I'm on my mac, so I don't have VS open, but off the top of my head, I'd say it's something like this:
PHP:
public static bool IsBoss(this WoWUnit unit)
        {
            foreach (BossIDs b in List.BossIdList)
            {
                if (b != null && b.ListItem == StyxWoW.Me.CurrentTarget.Entry)
                    return true;
            }
            return false;
        }
 
Code:
        public static bool IsBoss(WoWUnit unit)
        {
            return BossIdList.Contains(unit.Entry);
        }
A shorter way to do it.
 
I'm on my mac, so I don't have VS open, but off the top of my head, I'd say it's something like this:
PHP:
public static bool IsBoss(this WoWUnit unit)
        {
            foreach (BossIDs b in List.BossIdList)
            {
                if (b != null && b.ListItem == StyxWoW.Me.CurrentTarget.Entry)
                    return true;
            }
            return false;
        }

I tried it and it didn't work,
But thanks :)

Code:
        public static bool IsBoss(WoWUnit unit)
        {
            return BossIdList.Contains(unit.Entry);
        }
A shorter way to do it.

That was the first way I did it and did not work.
But thanks :)

greetz

Weischbier
 
what type is 'StyxWoW.Me.CurrentTarget' ?

does it work if you try it with
Code:
if (b != null && b.ListItem.Equals(31146))
 
dont read in directly from the txt file or whatever your reading in, read it into a list, then use that list as, to do a Foreach and check.
 
Back
Top