コード例 #1
0
        public override bool FilterAdminCommand(Character character, CommandHandling.CommandArgs command)
        {
            switch (command.Command)
            {
            case "omok":

                OnStart(character, GameKindEnum.Omok);
                return(true);

            case "senduser":
                // Arg: <charname> <portalname>
                if (command.Count == 2)
                {
                    var charName   = command[0].Value;
                    var portalName = command[1].Value;

                    if (Portals.TryGetValue(portalName, out Portal portal))
                    {
                        var c = FindUser(charName);
                        if (c != null)
                        {
                            c.ChangeMap(ID, portal);
                        }
                    }
                }
                return(true);

            case "reset":
                // Do map reset....
                return(true);

            case "matchtable":
            {
                SendAvatarInfo(character);

                var p = new Packet(ServerMessages.TOURNAMENT_MATCH_TABLE);
                // This one is nasty. We cannot write lots of data at once.
                for (var i = 0; i < SLOTS; i++)
                {
                    for (var j = 0; j < 6; j++)
                    {
                        p.WriteInt(character.ID);
                    }
                }
                var round = CurrentRound;
                if (round >= 100)
                {
                    round -= 100;
                }
                p.WriteByte((byte)round);
                character.SendPacket(p);
                return(true);
            }



            case "prize":
                // Arg: <itemid1> <itemid2>
                // TODO add validation
                if (command.Count == 2)
                {
                    PrizeSet = true;
                    var p = new Packet(ServerMessages.TOURNAMENT_SET_PRIZE);
                    ItemID[0] = command[0].GetInt32();
                    ItemID[1] = command[1].GetInt32();

                    p.WriteBool(true);
                    p.WriteByte(1);
                    p.WriteInt(ItemID[0]);
                    p.WriteInt(ItemID[1]);
                    SendPacket(p);

                    // For the user himself
                    p = new Packet(ServerMessages.TOURNAMENT_SET_PRIZE);
                    p.WriteBool(true);
                    p.WriteByte(0);
                    character.SendPacket(p);
                }
                return(true);

            case "giveprize":
                // Arg: <itemid> <portalname>
                if (command.Count == 2)
                {
                    var itemid     = command[0].GetInt32();
                    var portalName = command[1].Value;

                    if (Portals.TryGetValue(portalName, out Portal portal))
                    {
                        var item = BaseItem.CreateFromItemID(itemid);
                        item.GiveStats(ItemVariation.None);
                        var reward = Reward.Create(item);

                        // Drops through floor with X + 50 on pt 2
                        DropPool.Create(
                            reward,
                            0,
                            0,
                            DropType.Normal,
                            0,
                            new Pos((short)(portal.X + 40), portal.Y),
                            portal.X + 40,
                            0,
                            false,
                            0,
                            true,     // Yes, by pet??!?
                            false
                            );
                    }
                }
                return(true);
            }
            return(false);
        }