Example #1
0
        private void ProcessSpecial(PlayerObject player, NPCPage page)
        {
            List <UserItem> allGoods = new List <UserItem>();

            switch (page.Key.ToUpper())
            {
            case BuyKey:
                for (int i = 0; i < Goods.Count; i++)
                {
                    player.CheckItem(Goods[i]);
                }

                player.Enqueue(new S.NPCGoods {
                    List = Goods, Rate = PriceRate(player), Type = PanelType.Buy
                });
                break;

            case SellKey:
                player.Enqueue(new S.NPCSell());
                break;

            case BuySellKey:
                for (int i = 0; i < Goods.Count; i++)
                {
                    player.CheckItem(Goods[i]);
                }

                player.Enqueue(new S.NPCGoods {
                    List = Goods, Rate = PriceRate(player), Type = PanelType.Buy
                });
                player.Enqueue(new S.NPCSell());
                break;

            case RepairKey:
                player.Enqueue(new S.NPCRepair {
                    Rate = PriceRate(player)
                });
                break;

            case SRepairKey:
                player.Enqueue(new S.NPCSRepair {
                    Rate = PriceRate(player)
                });
                break;

            case CraftKey:
                for (int i = 0; i < CraftGoods.Count; i++)
                {
                    player.CheckItemInfo(CraftGoods[i].Item.Info);
                }

                player.Enqueue(new S.NPCGoods {
                    List = (from x in CraftGoods where x.CanCraft(player) select x.Item).ToList(), Rate = PriceRate(player), Type = PanelType.Craft
                });
                break;

            case RefineKey:
                if (player.Info.CurrentRefine != null)
                {
                    player.ReceiveChat("You're already refining an item.", ChatType.System);
                    player.Enqueue(new S.NPCRefine {
                        Rate = (Settings.RefineCost), Refining = true
                    });
                    break;
                }
                else
                {
                    player.Enqueue(new S.NPCRefine {
                        Rate = (Settings.RefineCost), Refining = false
                    });
                }
                break;

            case RefineCheckKey:
                player.Enqueue(new S.NPCCheckRefine());
                break;

            case RefineCollectKey:
                player.CollectRefine();
                break;

            case ReplaceWedRingKey:
                player.Enqueue(new S.NPCReplaceWedRing {
                    Rate = Settings.ReplaceWedRingCost
                });
                break;

            case StorageKey:
                player.SendStorage();
                player.Enqueue(new S.NPCStorage());
                break;

            case BuyBackKey:
            {
                var callingNPC = NPCObject.Get(player.NPCObjectID);

                if (callingNPC != null)
                {
                    if (!callingNPC.BuyBack.ContainsKey(player.Name))
                    {
                        callingNPC.BuyBack[player.Name] = new List <UserItem>();
                    }

                    for (int i = 0; i < callingNPC.BuyBack[player.Name].Count; i++)
                    {
                        player.CheckItem(callingNPC.BuyBack[player.Name][i]);
                    }

                    player.Enqueue(new S.NPCGoods {
                            List = callingNPC.BuyBack[player.Name], Rate = PriceRate(player), Type = PanelType.Buy
                        });
                }
            }
            break;

            case BuyUsedKey:
            {
                var callingNPC = NPCObject.Get(player.NPCObjectID);

                if (callingNPC != null)
                {
                    for (int i = 0; i < callingNPC.UsedGoods.Count; i++)
                    {
                        player.CheckItem(callingNPC.UsedGoods[i]);
                    }

                    player.Enqueue(new S.NPCGoods {
                            List = callingNPC.UsedGoods, Rate = PriceRate(player), Type = PanelType.Buy
                        });
                }
            }
            break;

            case ConsignKey:
                player.Enqueue(new S.NPCConsign());
                break;

            case MarketKey:
                player.UserMatch = false;
                player.GetMarket(string.Empty, ItemType.Nothing);
                break;

            case GuildCreateKey:
                if (player.Info.Level < Settings.Guild_RequiredLevel)
                {
                    player.ReceiveChat(String.Format("You have to be at least level {0} to create a guild.", Settings.Guild_RequiredLevel), ChatType.System);
                }
                else if (player.MyGuild == null)
                {
                    player.CanCreateGuild = true;
                    player.Enqueue(new S.GuildNameRequest());
                }
                else
                {
                    player.ReceiveChat("You are already part of a guild.", ChatType.System);
                }
                break;

            case RequestWarKey:
                if (player.MyGuild != null)
                {
                    if (player.MyGuildRank != player.MyGuild.Ranks[0])
                    {
                        player.ReceiveChat("You must be the leader to request a war.", ChatType.System);
                        return;
                    }
                    player.Enqueue(new S.GuildRequestWar());
                }
                else
                {
                    player.ReceiveChat(GameLanguage.NotInGuild, ChatType.System);
                }
                break;

            case SendParcelKey:
                player.Enqueue(new S.MailSendRequest());
                break;

            case CollectParcelKey:

                sbyte result = 0;

                if (player.GetMailAwaitingCollectionAmount() < 1)
                {
                    result = -1;
                }
                else
                {
                    foreach (var mail in player.Info.Mail)
                    {
                        if (mail.Parcel)
                        {
                            mail.Collected = true;
                        }
                    }
                }
                player.Enqueue(new S.ParcelCollected {
                    Result = result
                });
                player.GetMail();
                break;

            case AwakeningKey:
                player.Enqueue(new S.NPCAwakening());
                break;

            case DisassembleKey:
                player.Enqueue(new S.NPCDisassemble());
                break;

            case DowngradeKey:
                player.Enqueue(new S.NPCDowngrade());
                break;

            case ResetKey:
                player.Enqueue(new S.NPCReset());
                break;

            case PearlBuyKey:
                for (int i = 0; i < Goods.Count; i++)
                {
                    player.CheckItem(Goods[i]);
                }

                player.Enqueue(new S.NPCPearlGoods {
                    List = Goods, Rate = PriceRate(player)
                });
                break;
            }
        }
Example #2
0
        private void ProcessSpecial(PlayerObject player, NPCPage page)
        {
            List<UserItem> allGoods = new List<UserItem>();

            switch (page.Key.ToUpper())
            {
                case BuyKey:
                    for (int i = 0; i < Goods.Count; i++)
                        player.CheckItem(Goods[i]);

                    player.Enqueue(new S.NPCGoods { List = Goods, Rate = Info.PriceRate });
                    break;
                case SellKey:
                    player.Enqueue(new S.NPCSell());
                    break;
                case BuySellKey:
                    for (int i = 0; i < Goods.Count; i++)
                        player.CheckItem(Goods[i]);

                    player.Enqueue(new S.NPCGoods { List = Goods, Rate = Info.PriceRate });
                    player.Enqueue(new S.NPCSell());
                    break;
                case RepairKey:
                    player.Enqueue(new S.NPCRepair { Rate = Info.PriceRate });
                    break;
                case SRepairKey:
                    player.Enqueue(new S.NPCSRepair { Rate = Info.PriceRate });
                    break;
                case RefineKey:
                    if (player.Info.CurrentRefine != null)
                    {
                        player.ReceiveChat("You're already refining an item.", ChatType.System);
                        player.Enqueue(new S.NPCRefine { Rate = (Settings.RefineCost), Refining = true });
                        break;
                    }
                    else
                        player.Enqueue(new S.NPCRefine { Rate = (Settings.RefineCost), Refining = false });
                    break;
                case RefineCheckKey:
                    player.Enqueue(new S.NPCCheckRefine());
                    break;
                case RefineCollectKey:
                    player.CollectRefine();
                    break;
                case ReplaceWedRingKey:
                    player.Enqueue(new S.NPCReplaceWedRing { Rate = Settings.ReplaceWedRingCost });
                    break;
                case StorageKey:
                    player.SendStorage();
                    player.Enqueue(new S.NPCStorage());
                    break;
                case BuyBackKey:
                    if (!BuyBack.ContainsKey(player.Name)) BuyBack[player.Name] = new List<UserItem>();

                    for (int i = 0; i < BuyBack[player.Name].Count; i++)
                    {
                        player.CheckItem(BuyBack[player.Name][i]);
                    }

                    player.Enqueue(new S.NPCGoods { List = BuyBack[player.Name], Rate = Info.PriceRate });
                    break;
                case BuyUsedKey:
                    for (int i = 0; i < UsedGoods.Count; i++)
                        player.CheckItem(UsedGoods[i]);

                    player.Enqueue(new S.NPCGoods { List = UsedGoods, Rate = Info.PriceRate });
                    break;
                case ConsignKey:
                    player.Enqueue(new S.NPCConsign());
                    break;
                case MarketKey:
                    player.UserMatch = false;
                    player.GetMarket(string.Empty, ItemType.Nothing);
                    break;
                case ConsignmentsKey:
                    player.UserMatch = true;
                    player.GetMarket(string.Empty, ItemType.Nothing);
                    break;
                case GuildCreateKey:
                    if (player.Info.Level < Settings.Guild_RequiredLevel)
                    {
                        player.ReceiveChat(String.Format("You have to be at least level {0} to create a guild.", Settings.Guild_RequiredLevel), ChatType.System);
                    }
                    if (player.MyGuild == null)
                    {
                        player.CanCreateGuild = true;
                        player.Enqueue(new S.GuildNameRequest());
                    }
                    else
                        player.ReceiveChat("You are already part of a guild.", ChatType.System);
                    break;
                case RequestWarKey:
                    if (player.MyGuild != null)
                    {
                        if (player.MyGuildRank != player.MyGuild.Ranks[0])
                        {
                            player.ReceiveChat("You must be the leader to request a war.", ChatType.System);
                            return;
                        }
                        player.Enqueue(new S.GuildRequestWar());
                    }
                    else
                    {
                        player.ReceiveChat("You are not in a guild.", ChatType.System);
                    }
                    break;
                case SendParcelKey:
                    player.Enqueue(new S.MailSendRequest());
                    break;
                case CollectParcelKey:

                    sbyte result = 0;

                    if (player.GetMailAwaitingCollectionAmount() < 1)
                    {
                        result = -1;
                    }
                    else
                    {
                        foreach (var mail in player.Info.Mail)
                        {
                            if (mail.Parcel) mail.Collected = true;
                        }
                    }
                    player.Enqueue(new S.ParcelCollected { Result = result });
                    player.GetMail();
                    break;
                case AwakeningKey:
                    player.Enqueue(new S.NPCAwakening());
                    break;
                case DisassembleKey:
                    player.Enqueue(new S.NPCDisassemble());
                    break;
                case DowngradeKey:
                    player.Enqueue(new S.NPCDowngrade());
                    break;
                case ResetKey:
                    player.Enqueue(new S.NPCReset());
                    break;
                case PearlBuyKey:
                    for (int i = 0; i < Goods.Count; i++)
                        player.CheckItem(Goods[i]);

                    player.Enqueue(new S.NPCPearlGoods { List = Goods, Rate = Info.PriceRate });
                    break;
            }
        }