Beispiel #1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            mModelType = (ArmorModelType)reader.ReadInt();
            mArtisan   = reader.ReadMobile();

            int rescount = reader.ReadInt();

            mNubiaQuality   = (NubiaQualityEnum)reader.ReadInt();
            mTRessourceList = new List <NubiaRessource>();
            for (int i = 0; i < rescount; i++)
            {
                mTRessourceList.Add((NubiaRessource)reader.ReadInt());
            }
        }
Beispiel #2
0
        public static string getQualityName(NubiaQualityEnum q)
        {
            switch (q)
            {
            case NubiaQualityEnum.Mauvaise: return("Mauvaise facture");

            case NubiaQualityEnum.Normale: return(string.Empty);

            case NubiaQualityEnum.Bonne: return("Bonne facture");

            case NubiaQualityEnum.Excellente: return("Excellente facture");

            case NubiaQualityEnum.Maitre: return("Facture de maitre");
            }
            return(string.Empty);
        }
Beispiel #3
0
        public void AfterCraft(NubiaQualityEnum quality)
        {
            mNubiaQuality = quality;
            for (int i = 0; i < mTRessourceList.Count; i++)
            {
                NubiaRessource     res   = mTRessourceList[i];
                NubiaInfoRessource infos =
                    NubiaInfoRessource.GetInfoRessource(res);
                mArBoost = Math.Max(mArBoost, infos.GlobalAR);
                mHitsMax = Math.Max((int)(50.0 * infos.Durabilite), mHitsMax);
                mHits    = mHitsMax;
            }
            switch (mNubiaQuality)
            {
            case NubiaQualityEnum.Mauvaise: mArBoost--; break;

            case NubiaQualityEnum.Bonne: mHitsMax += 20; break;

            case NubiaQualityEnum.Excellente: mArBoost++; mHitsMax += 40; break;

            case NubiaQualityEnum.Maitre: mArBoost++; mHitsMax += 60; break;
            }
        }
        public void TryCraft(NubiaPlayer crafter, BaseToolNubia tool, CraftEntry entry)
        {
            if (entry == null || crafter == null || tool == null)
            {
                Console.WriteLine("WARNING: Null dans TryCraft ou index invalid");
                return;
            }
            Item newitem = null;

            if (entry.MinValue > crafter.Competences[mComp].getPureMaitrise())
            {
                crafter.SendMessage("Vous n'êtes pas encore assez doué pour ça...");
                return;
            }


            if (crafter.Backpack == null)
            {
                crafter.SendMessage("vous n'avez pas de sac à dos");
                return;
            }



            bool      allressource   = false;
            ArrayList ressourceslist = new ArrayList();

            for (int r = 0; r < entry.Ressource.Length; r++)
            {
                Type type       = entry.Ressource[r].RType;
                int  nbr        = entry.Ressource[r].Number;
                int  nbrTrouve  = 0;
                int  nbrConsume = 0;

                bool badselect = false;
                if (type == typeof(BaseMetal) && nbr > 0)
                {
                    if (tool.Metal != null)
                    {
                        type = tool.Metal.GetType();
                    }
                    else
                    {
                        crafter.SendMessage(2118, "Vous devez selectionner le Métal");
                        badselect = true;
                    }
                }
                else if (type == typeof(BaseCuir) && nbr > 0)
                {
                    if (tool.Cuir != null)
                    {
                        type = tool.Cuir.GetType();
                    }
                    else
                    {
                        crafter.SendMessage(2118, "Vous devez selectionner le Cuir");
                        badselect = true;
                    }
                }
                else if (type == typeof(BaseBois) && nbr > 0)
                {
                    if (tool.Bois != null)
                    {
                        type = tool.Bois.GetType();
                    }
                    else
                    {
                        crafter.SendMessage(2118, "Vous devez selectionner le Bois");
                        badselect = true;
                    }
                }
                else if (type == typeof(BaseOs) && nbr > 0)
                {
                    if (tool.Os != null)
                    {
                        type = tool.Os.GetType();
                    }
                    else
                    {
                        crafter.SendMessage(2118, "Vous devez selectionner les Os");
                        badselect = true;
                    }
                }
                else if (type == typeof(BaseTissu) && nbr > 0)
                {
                    if (tool.Tissu != null)
                    {
                        type = tool.Tissu.GetType();
                    }
                    else
                    {
                        crafter.SendMessage(2118, "Vous devez selectionner le Tissu");
                        badselect = true;
                    }
                }
                if (badselect)
                {
                    return;
                }


                bool          resIsNotRaffine = false;
                Item          notRaffineRes   = null;
                BaseRessource itAdd           = null;
                foreach (Item ritem in crafter.Backpack.Items)
                {
                    Console.WriteLine("Ritem=" + ritem + " :: type=" + type);
                    if (ritem.GetType().IsSubclassOf(type) || ritem.GetType() == type)
                    {
                        ConstructorInfo rtor = ritem.GetType().GetConstructor(Type.EmptyTypes);
                        Object          robj = rtor.Invoke(null);
                        //itAdd = robj as Item;
                        Console.WriteLine("Same Type");
                        if (ritem is BaseRessource)
                        {
                            Console.WriteLine(((BaseRessource)ritem).isRaffine);
                            if (!((BaseRessource)ritem).isRaffine)
                            {
                                resIsNotRaffine = true;
                                notRaffineRes   = ritem;
                                continue;
                            }
                            else
                            {
                                itAdd = ritem as BaseRessource;
                            }
                        }
                        if (ritem.Amount == 1)
                        {
                            //ritem.Delete();
                            nbrTrouve++;
                        }
                        else if (ritem.Amount < nbr - nbrTrouve)
                        {
                            nbrTrouve += ritem.Amount;
                            //ritem.Delete();
                        }
                        else
                        {
                            nbrTrouve = nbr;
                            //ritem.Amount -= nbr-nbrTrouve;
                        }
                    }
                    if (nbr - nbrTrouve <= 0)
                    {
                        break;
                    }
                }
                if (itAdd != null)
                {
                    ressourceslist.Add(itAdd);
                }
                if (nbrTrouve < nbr)
                {
                    if (resIsNotRaffine)
                    {
                        crafter.SendMessage(2118, "Vous devez raffiner votre {0} avant tout", notRaffineRes.Name);
                    }
                    else
                    {
                        crafter.SendMessage("Il vous manque des matériaux...");
                    }
                    allressource = false;
                }
                else
                {
                    allressource = true;

                    /*Type[] types = new Type[ressourceslist.ToArray().Length];
                     * for(int t = 0; t < types.Length; t++)
                     *  types[t] = ((Item)ressourceslist[t]).GetType();
                     * int[] quatitys = new int[entry.Ressource.Length];
                     * for(int q = 0; q < quatitys.Length; q++)
                     *  quatitys[q] = entry.Ressource[q].Number;*/
                }
                if (!allressource)
                {
                    return;
                }
            }

            int rollResult = crafter.Competences[mComp].intRoll();

            //crafter.Competences.wait(1);
            if (rollResult > entry.Diff)
            {
                newitem = null;

                Console.WriteLine("Craft réussi");

                crafter.GiveXP(50);

                try
                {
                    ConstructorInfo constructor = entry.ToCraft.GetConstructor(Type.EmptyTypes);
                    if (constructor != null)
                    {
                        Object obj = constructor.Invoke(null);
                        newitem = obj as Item;
                    }
                    else
                    {
                        Console.WriteLine("constructor null dans trycraft");
                    }
                }
                catch (Exception ex) {
                    Console.WriteLine("TryCraft: " + ex.Message);
                    return;
                }

                if (newitem == null)
                {
                    Console.WriteLine("ERROR: newitem == null dans TryCraft");
                    return;
                }
                crafter.SendMessage("Vous reussissez votre création!!");
                if (newitem is INubiaCraftable)
                {
                    Console.WriteLine("Attribution de parametre INubiaCraftable");
                    INubiaCraftable nubitem = newitem as INubiaCraftable;

                    NubiaQualityEnum quality = NubiaQualityEnum.Normale;

                    int delta = rollResult - entry.Diff;
                    if (delta < 5)
                    {
                        quality = NubiaQualityEnum.Mauvaise;
                    }
                    else if (delta >= 30)
                    {
                        quality = NubiaQualityEnum.Maitre;
                    }
                    else if (delta >= 20)
                    {
                        quality = NubiaQualityEnum.Excellente;
                    }
                    else if (delta >= 10)
                    {
                        quality = NubiaQualityEnum.Bonne;
                    }

                    Console.WriteLine("Quality: " + quality);
                    Console.WriteLine("DELTA = " + delta);

                    nubitem.Artisan = crafter;
                    nubitem.TRessourceList.Clear();
                    bool colored = false;
                    for (int i = 0; i < ressourceslist.Count; i++)
                    {
                        //   Console.WriteLine("Ressources: " + ressourceslist[i].ToString());
                        if (ressourceslist[i] is BaseRessource)
                        {
                            BaseRessource res = ressourceslist[i] as BaseRessource;
                            if (!colored && res.Infos != null)
                            {
                                newitem.Hue = res.Infos.Hue;
                                colored     = true;
                            }
                            Console.WriteLine("Ressource enregistrée: " + res.Ressource.ToString());
                            // nubitem.AddRessource((NubiaRessource)res.Ressource);
                            nubitem.TRessourceList.Add(res.Ressource);
                        }
                    }
                    Console.WriteLine("After Craft");
                    nubitem.AfterCraft(quality);
                    //   nubitem.ComputeRessourceBonus();
                }
                if (newitem != null && crafter.Backpack != null)
                {
                    crafter.Backpack.AddItem(newitem);
                }
                else if (newitem != null)
                {
                    newitem.MoveToWorld(crafter.Location, crafter.Map);
                }
            }
            else
            {
                crafter.SendMessage("Vous n'arrivez a rien, de la matière première à été perdue");
            }

            Console.WriteLine("Consume Quantity:  ");
            for (int r2 = 0; r2 < entry.Ressource.Length; r2++)
            {
                Type type2 = entry.Ressource[r2].RType;
                int  nbr2  = entry.Ressource[r2].Number;
                CraftSystemNubia.ConsumeQuantity(crafter.Backpack, type2, nbr2, tool);
            }
            Console.Write("Ok !");
        }