Beispiel #1
0
 public DonEntry(DonEnum don, ClasseType classe, int giveatlevel, bool choosen)
 {
     //  mValue = 1;
     mChoosen     = choosen;
     mDon         = don;
     mClasse      = classe;
     mGiveAtLevel = giveatlevel;
 }
Beispiel #2
0
 public static BaseDon getDon(DonEnum don)
 {
     if (BaseDon.DonBank.ContainsKey(don.ToString().ToLower()))
     {
         return(BaseDon.DonBank[don.ToString().ToLower()]);
     }
     else
     {
         return(null);
     }
 }
Beispiel #3
0
 public bool hasDon(DonEnum don)
 {
     lock (mDons)
     {
         foreach (DonEntry entry in mDons)
         {
             if (entry.Don == don)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #4
0
        /*   public ICollection Dons
         * {
         *     get
         *     {
         *         return mDons.Keys;
         *     }
         * }*/

        public int getDonNiveau(DonEnum don)
        {
            int count = 0;

            lock (mDons)
            {
                foreach (DonEntry entry in mDons)
                {
                    if (entry.Don == don)
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
Beispiel #5
0
 private void addDonChoix(int x, int y, DonEnum don, bool dispo)
 {
     if (mDonView == don)
     {
         AddImage(x + 10, y, 2153);
     }
     else if (dispo)
     {
         AddButton(x + 10, y, 2151, 2152, (int)don + 100, GumpButtonType.Reply, 0);
     }
     else
     {
         AddButton(x + 10, y, 2472, 2473, (int)don + 100, GumpButtonType.Reply, 0);
     }
     AddLabel(x + 45, y, ColorText, BaseDon.getDonName(don));
 }
Beispiel #6
0
        public static string getDonName(DonEnum don)
        {
            string dname = "";

            if (BaseDon.DonBank.ContainsKey(don.ToString().ToLower()))
            {
                dname = BaseDon.DonBank[don.ToString().ToLower()].Name;
            }
            else
            {
                dname = don.ToString();
            }

            if (don == DonEnum.DonSupClasse)
            {
                dname = "Don à choisir";
            }
            return(dname);
        }
Beispiel #7
0
 public BaseDon(DonEnum type, string name, bool canUse)
 {
     mDType  = type;
     mName   = name;
     mCanUse = canUse;
 }
Beispiel #8
0
        public GumpDons(NubiaPlayer _owner, NubiaPlayer _viewer)
            : base("Dons de " + _owner.Name, 640, 480)
        {
            m_owner  = _owner;
            m_viewer = _viewer;

            int y     = YBase;
            int x     = XBase;
            int line  = 0;
            int scale = 110;
            int decal = 30;

            int col      = 0;
            int coldecal = 310;

            int limit = 8;

            if (m_owner.Dons == null)
            {
                return;
            }

            int page = 1;


            AddPage(page);

            int nbrPage = (int)Math.Truncate((double)m_owner.Dons.DonsEntrys.Count - 1 / 8.0);

            //int dsup = 0;

            /* for (int i = -1; i < (int)ClasseType.Maximum; i++)
             * {
             *
             *   if (m_owner.DonCredits.ContainsKey((ClasseType)i))
             *   {
             *       if (m_owner.DonCredits[(ClasseType)i] > 0)
             *       {
             *           dsup += m_owner.DonCredits[(ClasseType)i];
             *       }
             *   }
             *
             * }*/
            /*  if (dsup > 0)
             * {
             *    AddButtonPageSuivante(x, y, 10);
             *    AddLabel(x + 50, y, ColorTextGreen, "Choisir un nouveau don");
             *    AddLabel(x + 200, y, ColorTextGray, "( " + dsup + " don" + (dsup > 1 ? "" : "s") + " à choisir )");
             * }*/
            if (nbrPage > 0)
            {
                //AddButton(x+500, y, 4014, 4015, 5, GumpButtonType.Page, page - 1);

                AddButton(x + 550, y, 4005, 4006, 6, GumpButtonType.Page, page + 1);
            }
            List <DonEnum> display = new List <DonEnum>();

            Console.WriteLine("Nombre de dons au total: " + m_owner.Dons.DonsEntrys.Count);
            for (int e = 0; e < m_owner.Dons.DonsEntrys.Count; e++)
            {
                DonEntry entry   = m_owner.Dons.DonsEntrys[e];
                DonEnum  donEnum = entry.Don;
                bool     canView = true;
                if (display.Contains(donEnum) && donEnum != DonEnum.DonSupClasse)
                {
                    canView = false;
                }
                if (entry.Don == DonEnum.DonSupClasse && entry.Choosen)
                {
                    canView = false;
                }
                // Console.WriteLine("Don: " + donEnum.ToString());
                if (canView)
                {
                    display.Add(donEnum);
                    BaseDon don = BaseDon.getDon(donEnum);
                    //  Console.WriteLine("Don entry: " + entry);
                    //   Console.WriteLine("Don: " + don);
                    int ly = y + line * scale + 30;
                    int lx = x + col * coldecal;


                    AddBackground(lx, ly, 300, 50, 9400);
                    AddLabel(lx + 5, ly + 2, ColorTextYellow, BaseDon.getDonName(donEnum));


                    int cd = 200;
                    if (entry.Classe > ClasseType.Roublard)
                    {
                        cd -= 55;
                    }
                    AddLabel(lx + 5 + cd, ly + 2, ColorTextLight, (entry.Classe == ClasseType.None ? "Général" : Classe.GetNameClasse(entry.Classe)));
                    AddLabel(lx + 5 + 250, ly + 2, ColorText, "Niv " + entry.GiveAtLevel.ToString());

                    AddBackground(lx, ly + 25, 300, 80, 9200);



                    if (entry.Don == DonEnum.DonSupClasse && !entry.Choosen)
                    {
                        //AddImage(lx + 10, ly + 40, 2277);
                        AddButton(lx + 10, ly + 40, 2277, 2277, (int)e + 100, GumpButtonType.Reply, 0);
                        String desc = "<BASEFONT COLOR=#EE0000>Choississez votre don en cliquant sur l'icone</BASEFONT>";

                        AddHtml(lx + 60, ly + 35, 235, 60, desc, true, true);
                    }
                    else if (don != null)
                    {
                        AddImage(lx + 10, ly + 40, don.Icone);
                        if (m_owner.Dons.getDonNiveau(donEnum) > 1)
                        {
                            AddLabel(lx + 10, ly + 80, ColorTextYellow, "Rang:" + m_owner.Dons.getDonNiveau(donEnum));
                        }
                        String desc = don.Description;
                        if (don.CanUse)
                        {
                            desc += "<br>(Utilisation: .don " + don.ToString() + ")";
                        }
                        AddHtml(lx + 60, ly + 35, 235, 60, desc, true, true);
                    }

                    line++;

                    if (line >= 4)
                    {
                        col++;
                        line = 0;
                    }
                    if (col > 1)
                    {
                        col  = 0;
                        line = 0;
                        page++;
                        AddPage(page);
                        AddButton(x + 500, y, 4014, 4015, 5, GumpButtonType.Page, page - 1);
                        if (nbrPage > page)
                        {
                            AddButton(x + 550, y, 4005, 4006, 6, GumpButtonType.Page, page + 1);
                        }
                    }
                }
            }
        }
Beispiel #9
0
        public void ComputeDons()
        {
            if (mOwner == null)
            {
                return;
            }

            // Console.WriteLine("COMPUTE DON DE " + mOwner.Name);
            List <DonEntry> toAdd = new List <DonEntry>();

            //DOns Hors classes
            for (int n = 0; n <= mOwner.Niveau; n += 3)
            {
                bool has = false;
                foreach (DonEntry entry in mDons)
                {
                    if (entry.Classe == ClasseType.None && entry.GiveAtLevel == n)
                    {
                        has = true;
                    }
                }
                if (!has)
                {
                    toAdd.Add(new DonEntry(DonEnum.DonSupClasse, ClasseType.None, n, false));
                }
            }

            foreach (Classe c in mOwner.GetClasses())
            {
                for (int n = 1; n <= c.Niveau; n++)
                {
                    for (int d = 0; d < c.DonClasse[n].Length; d++)
                    {
                        // Console.WriteLine("Classe {0} niveau {1} don {2} ", c, n, d);
                        if (c.DonClasse[n][d] == null)
                        {
                            continue;
                        }

                        DonEnum don = c.DonClasse[n][d];
                        //  Console.WriteLine("Don = " + don.ToString());
                        if (don == DonEnum.DonSupClasse)
                        {
                            bool has = false;
                            foreach (DonEntry entry in mDons)
                            {
                                if (entry.Classe == c.CType && entry.GiveAtLevel == n)
                                {
                                    has = true;
                                }
                            }
                            if (!has)
                            {
                                toAdd.Add(new DonEntry(DonEnum.DonSupClasse, c.CType, n, false));
                            }
                        }
                        else
                        {
                            bool has = false;
                            foreach (DonEntry entry in mDons)
                            {
                                if (entry.Classe == c.CType && entry.GiveAtLevel == n && entry.Don == don)
                                {
                                    has = true;
                                }
                            }
                            if (!has)
                            {
                                toAdd.Add(new DonEntry(don, c.CType, n, false));
                            }
                        }
                    }
                }

                foreach (DonEntry entry in toAdd)
                {
                    mDons.Add(entry);
                }
                toAdd.Clear();
            }
        }
Beispiel #10
0
        public GumpNewDonChoix(NubiaPlayer _owner, ClasseType c, int niveauClasse, DonEnum donView, int page)
            : base("Dons de " + _owner.Name, 640, 480)
        {
            m_owner  = _owner;
            mDonView = donView;
            m_classe = c;
            m_niveau = niveauClasse;
            m_page   = page;

            int y     = YBase;
            int x     = XBase;
            int line  = 4;
            int scale = 25;
            int decal = 10;

            int col      = 0;
            int coldecal = 310;

            int limit = 16;

            if (m_owner.Dons == null)
            {
                return;
            }



            List <BaseDon> donDispo = new List <BaseDon> ();

            int nbrPage = BaseDon.DonBank.Values.Count / (limit * 2);

            if (page > 0)
            {
                AddButton(x + 500, y, 4014, 4015, 5, GumpButtonType.Reply, page - 1);
            }
            if (page < nbrPage)
            {
                AddButton(x + 550, y, 4005, 4006, 6, GumpButtonType.Reply, page + 1);
            }

            if (mDonView != DonEnum.DonSupClasse)
            {
                AddBackground(x, y, 300, 50, 9400);
                AddLabel(x + 5, y + 2, ColorTextYellow, BaseDon.getDonName(mDonView));


                int cd = 200;
                if (m_classe > ClasseType.Roublard)
                {
                    cd -= 55;
                }
                AddLabel(x + 5 + cd, y + 2, ColorTextLight, (m_classe == ClasseType.None ? "Général" : Classe.GetNameClasse(m_classe)));
                AddLabel(x + 5 + 250, y + 2, ColorText, "Niv " + m_niveau.ToString());

                AddBackground(x, y + 25, 300, 80, 9200);
                BaseDon don = BaseDon.getDon(mDonView);

                if (don != null)
                {
                    AddImage(x + 10, y + 40, don.Icone);
                    //  AddLabel(x + 10, y + 80, ColorTextYellow, "Rang:" + m_owner.Dons.getDonNiveau(don));
                    String desc = don.Description;
                    if (don.CanUse)
                    {
                        desc += "<br>(Utilisation: .don " + don.ToString() + ")";
                    }
                    AddHtml(x + 60, y + 35, 235, 60, desc, true, true);

                    if (don.hasConditions(m_owner))
                    {
                        AddButtonPageSuivante(x + coldecal, y, 9);
                        AddLabel(x + coldecal + 60, y, ColorTextYellow, "Apprendre ce don");
                    }
                }
            }


            if (c == ClasseType.None)
            {
                BaseDon[] donArray = new BaseDon[BaseDon.DonBank.Values.Count];
                BaseDon.DonBank.Values.CopyTo(donArray, 0);
                int mini  = page * limit * 2;
                int count = 0;
                for (int b = 0; b < donArray.Length; b++)
                {
                    BaseDon don = donArray[b];
                    if ((int)don.DType >= 1000 && !(m_owner.hasDon(don.DType) && don.AchatMax <= 1))
                    {
                        count++;
                        if (count < mini)
                        {
                            continue;
                        }
                        if (donDispo.Count < limit * 2)
                        {
                            donDispo.Add(don);
                        }
                        else
                        {
                            break;
                        }
                    }

                    /*  if (donDispo.Count > limit * 2)
                     *    break;*/
                }

                foreach (BaseDon d in donDispo)
                {
                    if (d != null)
                    {
                        addDonChoix(x + col * coldecal, decal + y + line * scale, d.DType, d.hasConditions(m_owner));
                        if (line > limit)
                        {
                            line = 0;
                            col++;
                            if (col >= 2)
                            {
                                break;
                            }
                        }
                        line++;
                    }
                }
            }
            else
            {
                DonEnum[] enumlist = m_owner.getClasse(m_classe).getCustomDon(m_owner, m_niveau);
                BaseDon[] donArray = new BaseDon[enumlist.Length];


                int mini  = page * limit * 2;
                int count = 0;
                for (int b = 0; b < enumlist.Length; b++)
                {
                    BaseDon don = BaseDon.getDon(enumlist[b]);
                    if (don == null)
                    {
                        continue;
                    }

                    if ((int)don.DType >= 1000 && !(m_owner.hasDon(don.DType) && don.AchatMax <= 1))
                    {
                        count++;
                        if (count < mini)
                        {
                            continue;
                        }
                        if (donDispo.Count < limit * 2)
                        {
                            donDispo.Add(don);
                        }
                        else
                        {
                            break;
                        }


                        count++;
                    }

                    /*  if (donDispo.Count > limit * 2)
                     *    break;*/
                }

                foreach (BaseDon d in donDispo)
                {
                    if (d != null)
                    {
                        addDonChoix(x + col * coldecal, decal + y + line * scale, d.DType, d.hasConditions(m_owner));
                        if (line > limit)
                        {
                            line = 0;
                            col++;
                            if (col >= 2)
                            {
                                break;
                            }
                        }
                        line++;
                    }
                }
            }
        }