Beispiel #1
0
        private static void ProcessExchangeMountParkRequest(WorldClient Client, string Packet)
        {
            MountPark MP = Client.Character.inMountPark;

            if (MP != null)
            {
                char c = Packet[2];
                Packet = Packet.Substring(3);
                int guid = -1;
                try
                {
                    guid = int.Parse(Packet);
                }
                catch (Exception e)
                {
                };
                switch (c)
                {
                case 'C':    //Parcho => Etable (Stocker)
                    if (guid == -1 || !Client.Character.InventoryCache.hasItemGuid(guid))
                    {
                        return;
                    }
                    InventoryItemModel obj = Client.Character.InventoryCache.GetItem(guid);

                    //on prend la DD demandée
                    int   DDid = -1;
                    Mount DD   = null;
                    if (obj.GetStats().HasEffect(EffectEnum.MountOwner))
                    {
                        DDid = obj.GetStats().GetEffect(EffectEnum.MountOwner).Items;
                        DD   = MountTable.getMount(DDid);
                    }
                    //FIXME mettre return au if pour ne pas créer des nouvelles dindes
                    if (DD == null)
                    {
                        int color = StaticMountTable.getMountColorByParchoTemplate(obj.TemplateID);
                        if (color < 1)
                        {
                            return;
                        }
                        DD = new Mount(color);
                    }
                    DD.Intialize();

                    //On enleve l'Item du Monde et du Perso
                    Client.Character.InventoryCache.remove(guid);
                    InventoryItemTable.removeItem(guid);
                    //on ajoute la dinde a l'étable
                    Client.Account.Data.Mounts.Add(DD.ID, DD);
                    Client.Account.Data.Save();

                    //On envoie les Packet
                    Client.Send(new ObjectRemoveMessage(obj.ID));
                    Client.Send(new ExchangeEndMessage('+', DD.parse()));
                    break;

                case 'c':    //Etable => Parcho(Echanger)
                    Mount DD1 = MountTable.getMount(guid);
                    //S'il n'a pas la dinde
                    if (!Client.Account.Data.Mounts.ContainsKey(DD1.ID) || DD1 == null)
                    {
                        return;
                    }
                    //on retire la dinde de l'étable
                    Client.Account.Data.Mounts.Remove(DD1.ID);

                    GenericStats Stat = new GenericStats();
                    Stat.AddItem(EffectEnum.MountOwner, DD1.ID);
                    Stat.AddSpecialEffect(EffectEnum.MountOwnerName, Client.Character.Name);
                    Stat.AddSpecialEffect(EffectEnum.MountName, DD1.Name);

                    var item = InventoryItemTable.TryCreateItem(StaticMountTable.getMountScroll(DD1.get_color()).ID, Client.Character, 1, -1, Stat.ToItemStats());

                    Client.Send(new ExchangeEndMessage('-', DD1.ID + ""));
                    Stat = null;
                    break;

                case 'g':    //Equiper
                    Mount DD3 = MountTable.getMount(guid);
                    //S'il n'a pas la dinde
                    if (DD3 == null || !Client.Account.Data.Mounts.ContainsKey(DD3.ID) || Client.Character.Mount != null)
                    {
                        return;
                    }
                    DD3.Intialize();
                    Client.Account.Data.Mounts.Remove(DD3.ID);
                    Client.Account.Data.Save();
                    Client.Character.Mount = DD3;

                    //Packets
                    Client.Send(new CharacterRideEventMessage("+", DD3));
                    Client.Send(new ExchangeEndMessage('-', DD3.ID + ""));
                    Client.Send(new CharacterMountXpGive(Client.Character.MountXPGive));
                    break;

                case 'p':    //Equipé => Stocker
                    //Si c'est la dinde équipé
                    if (Client.Character.Mount != null ? Client.Character.Mount.ID == guid : false)
                    {
                        //Si le perso est sur la monture on le fait descendre
                        if (Client.Character.isOnMount())
                        {
                            Client.Character.toogleOnMount();
                        }
                        //Si ca n'a pas réussie, on s'arrete là (Items dans le sac ?)
                        if (Client.Character.isOnMount())
                        {
                            return;
                        }

                        Mount DD2 = Client.Character.Mount;
                        DD2.Intialize();
                        Client.Account.Data.Mounts.Add(DD2.ID, DD2);
                        Client.Account.Data.Save();
                        Client.Character.Mount = null;

                        //Packets
                        Client.Send(new ExchangeEndMessage('+', DD2.parse()));
                        Client.Send(new CharacterRideEventMessage("-", null));
                        Client.Send(new CharacterMountXpGive(Client.Character.MountXPGive));
                    }
                    else    //Sinon...
                    {
                    }
                    break;
                }
            }
            else
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }
        }