コード例 #1
0
ファイル: Merchant.cs プロジェクト: pboutell/amud-server
        private void buyItem(string search, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            Item item = items.getItemByName(search);

            if (item != null)
            {
                int sellPrice = item.value * 2;
                if (player.gold > sellPrice)
                {
                    player.items.addToInventory(item);
                    gold += sellPrice;
                    player.gold -= sellPrice;
                    buffer.AppendFormat("\r\n%BYou purchase %W{0} %Bfor %Y{1} %Bgold.", item.description, sellPrice);
                    say("Thank you for your business.");
                    player.client.send(buffer.ToString());
                }
                else
                {
                    say("Please, don't waste my time. Come back when you have some coin.");
                }
            }
            else
            {
                say("I apologize, I am fresh out of " + search);
            }
        }
コード例 #2
0
ファイル: EquipmentCom.cs プロジェクト: pboutell/amud-server
        private void doDrop(string[] args, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            if (args.Length == 1)
            {
                player.client.send("Drop what?");
            }
            else
            {
                Item item = player.items.getItemByName(args[1].TrimEnd('\r', '\n'));

                if (item != null)
                {
                    player.items.removeFromInventory(item);
                    player.room.addItem(item);
                    buffer.AppendFormat("You drop a {0} onto the ground.", item.description);
                    player.client.send(buffer.ToString());
                }
                else
                {
                    player.client.send("I can't find that item.");
                }
            }
        }
コード例 #3
0
ファイル: CombatCom.cs プロジェクト: pboutell/amud-server
        private void doKill(string[] args, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            if (args.Length == 1)
            {
                player.client.send("Kill whom?");
                return;
            }

            Character target = player.room.getCharacterByName(args[1]);

            if (target == player)
            {
                buffer.AppendLine("\r\nYou kill yourself!");
                buffer.AppendLine("Do you want your possessions identified?");
            }
            else if (target != null)
            {
                buffer.AppendFormat("You attack {0} with all your might!", target.name);
                player.combat.target = target;
                player.combat.isFighting = true;
            }
            else
            {
                buffer.AppendLine("I do not see anybody by that name here.");
            }

            player.client.send(buffer.ToString());
        }
コード例 #4
0
ファイル: BuilderCom.cs プロジェクト: pboutell/amud-server
        //TODO: Clean this up
        private void doCreate(string[] args, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            if (args.Length == 1)
            {
                player.parser.parse("create --help");
                return;
            }

            if (args[1] == "mob")
            {
                player.client.send("I don't know how to create mob yet.");
            }
            else if (args[1] == "item")
            {
                if (args.ElementAtOrDefault(2) != null)
                {
                    if (args[2].Length > 10)
                    {
                        player.client.send("please select a shorter name.");
                        return;
                    }

                    Item newItem = new Item(args[2].TrimEnd('\r', '\n'), "", 5, "none", 1);
                    player.items.addToInventory(newItem);
                    buffer.AppendFormat("{0} creates a {1} out of thin air!", player.name, newItem.name);
                    player.room.sendToRoom(buffer.ToString());
                }
            }
            else
            {
                player.parser.parse("create --help");
            }
        }
コード例 #5
0
ファイル: EquipmentCom.cs プロジェクト: pboutell/amud-server
        private void doPickup(string[] args, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            if (args.Length == 1)
            {
                player.client.send("Pickup what?");
            }
            else
            {
                Item item = player.room.getItemByName(args[1].TrimEnd('\r', '\n'));

                if (item != null)
                {
                    buffer.AppendFormat("You pick up {0}, off the ground.", item.description);
                    player.client.send(buffer.ToString());
                    player.room.removeItem(item);
                    player.items.addToInventory(item);
                }
                else
                {
                    player.client.send("I don't see that anywhere.");
                }
            }
        }
コード例 #6
0
ファイル: MiscCom.cs プロジェクト: pboutell/amud-server
 private void doTime(string[] args, Player player)
 {
     StringBuilder buffer = new StringBuilder();
     buffer.AppendFormat("\r\n%c{0}\r\n%C{1}\r\n",
                         player.world.worldTime.ToShortTimeString(),
                         player.world.worldTime.ToLongDateString());
     player.client.send(buffer.ToString());
 }
コード例 #7
0
ファイル: MiscCom.cs プロジェクト: pboutell/amud-server
 private void doLook(string[] args, Player player)
 {
     if (args.Length > 1)
     {
         lookAt(player, args[1]);
     }
     else
     {
         lookAll(player);
     }
 }
コード例 #8
0
ファイル: MiscCom.cs プロジェクト: pboutell/amud-server
        private void doHelp(string[] args, Player player)
        {
            Commands commands = new Commands();
            StringBuilder buffer = new StringBuilder();

            buffer.AppendLine("Available Commands:\r\n");
            foreach (Command c in commands.all)
            {
                buffer.AppendFormat("    [ {0,12} ] {1}\r\n", c.name, c.description);
            }
            player.client.send(buffer.ToString());
        }
コード例 #9
0
ファイル: MiscCom.cs プロジェクト: pboutell/amud-server
        private void lookAll(Player player)
        {
            StringBuilder buffer = new StringBuilder();

            buffer.AppendFormat("%W{0}\r\n{1}\r\n%w{2}\r\n%R{3}\r\n%B{4}\r\n%M{5}",
                                 player.room.name,
                                 player.room.exitsToString(),
                                 player.room.description,
                                 player.room.NPCsToString(),
                                 player.room.itemsToString(),
                                 player.room.playersToString(player));

            player.client.send(buffer.ToString().TrimEnd('\r', '\n'));
        }
コード例 #10
0
        private void doChat(string[] args, Player player)
        {
            StringBuilder text = new StringBuilder();

            if (args.Length == 0)
            {
                player.client.send("chat what?\r\n");
            }

            foreach (string s in args.Skip(1))
            {
                text.Append(s);
                text.Append(" ");
            }

            player.client.sendToAll("%W[%Cchat %y" + player.name + "%w:%W]%x \"" + text.ToString().Trim() + "%x.\"\r\n");
        }
コード例 #11
0
        private void doSay(string[] args, Player player)
        {
            StringBuilder text = new StringBuilder();

            if (args.Length == 0)
            {
                player.client.send("say what?\r\n");
            }

            foreach (string s in args.Skip(1))
            {
                text.Append(s);
                text.Append(" ");
            }

            player.client.send("%Byou say \"%W" + text.ToString().Trim() + ".%B\"%x\r\n");
            player.room.sendToRestRoom("\n%B" + player.name + " says \"%W" + text.ToString().Trim() + ".%B\"%x\r\n", player);
        }
コード例 #12
0
ファイル: MovementCom.cs プロジェクト: pboutell/amud-server
        private void doWalk(string[] args, Player player)
        {
            Movement movement = new Movement();

            if (player.combat.isFighting)
            {
                player.client.send("Not while fighting!");
                return;
            }

            if (movement.walk(Direction.shortDirectionToInt(args[0].TrimEnd('\r', '\n')), player))
            {
                player.parser.parse("look");
            }
            else
            {
                player.client.send("You can't go that way!");
            }
        }
コード例 #13
0
ファイル: BuilderCom.cs プロジェクト: pboutell/amud-server
        private void doClone(string[] args, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            if (args.Length == 1)
            {
                player.parser.parse("clone --help");
                return;
            }

            if (args[1] == "mob")
            {
                if (args.ElementAtOrDefault(2) != null)
                {
                    NPC clone = player.world.findNPC(args[2].TrimEnd('\r', '\n'));
                    if (clone != null)
                    {
                        buffer.AppendFormat("{0} creates {1} out of thin air!", player.name, clone.description);
                        player.room.addNPC(clone);
                        player.world.mobs.Add(clone);
                        player.room.sendToRoom(buffer.ToString());
                    }
                    else
                    {
                        player.client.send("I dont know how to clone that mob!");
                    }
                }
                else
                {
                    player.client.send("Clone which mob?");
                }
            }
            else if (args[1] == "item")
            {
                player.client.send("I don't know how to clone items yet.");
            }
            else
            {
                player.parser.parse("clone --help");
            }
        }
コード例 #14
0
ファイル: EquipmentCom.cs プロジェクト: pboutell/amud-server
        private void doRemove(string[] args, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            if (args.Length == 1)
            {
                player.client.send("Remove what?");
            }
            else
            {
                Item item = player.items.removeFromEquipped(args[1].TrimEnd('\r', '\n'));

                if (item != null)
                {
                    buffer.AppendFormat("Removed {0} from {1}.", item.description, item.wearLocation);
                    player.client.send(buffer.ToString());
                }
                else
                {
                    player.client.send("I don't know how to remove that.");
                }
            }
        }
コード例 #15
0
ファイル: Movement.cs プロジェクト: pboutell/amud-server
        public bool walk(int direction, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            if (player.room.hasExit(direction))
            {
                player.room.removePlayer(player);
                buffer.AppendFormat("\r\n{0} exits the room to the {1}.\r\n",
                                    player.name, Direction.directionToName(direction));
                player.room.sendToRestRoom(buffer.ToString(), player);

                buffer.Clear();
                player.room.exits[direction].addPlayer(player);
                buffer.AppendFormat("\r\n{0} has entered the room from the {1}.\r\n",
                                    player.name, Direction.directionToName(Direction.oppositeExit(direction)));
                player.room.sendToRestRoom(buffer.ToString(), player);
                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #16
0
ファイル: Merchant.cs プロジェクト: pboutell/amud-server
        public override bool shop(string[] args, Player player)
        {
            if (args.Length > 1)
            {
                if (args[1].TrimEnd('\r', '\n') == "buy")
                {
                    if (args.ElementAtOrDefault(2) != null)
                    {
                        buyItem(args[2].TrimEnd('\r', '\n'), player);
                    }
                    else
                    {
                        say("What would you like to purchase?");
                        player.client.send(listBuy());
                    }
                }
                else if (args[1].TrimEnd('\r', '\n') == "sell")
                {
                    if (args.ElementAtOrDefault(2) != null)
                    {
                        sellItem(args[2].TrimEnd('\r', '\n'), player);
                    }
                    else
                    {
                        say("I can give you these prices for your stuff.");
                        player.client.send(listSell(player));
                    }
                }
            }
            else
            {
                say("Hello! please have a look at my merchandise.");
                player.client.send(listBuy());
            }

            return true;
        }
コード例 #17
0
ファイル: MiscCom.cs プロジェクト: pboutell/amud-server
        private void lookAt(Player player, string what)
        {
            StringBuilder buffer = new StringBuilder();

            Character c = player.room.getCharacterByName(what);
            if (c != null)
            {
                buffer.AppendFormat("You look at {0}.\r\n{1}\r\n\n{2}",
                                    c.name,
                                    c.description,
                                    c.items.equippedToString());
            }

            Item item = player.room.getItemByName(what);
            if (item != null)
            {
                buffer.AppendFormat("\r\nYou look at {0}.\r\n{1}\r\n", item.name, item.description);
            }

            if (buffer.ToString().Length < 1)
                player.client.send("You do not see that here!");
            else
                player.client.send(buffer.ToString());
        }
コード例 #18
0
ファイル: Merchant.cs プロジェクト: pboutell/amud-server
        private void sellItem(string search, Player player)
        {
            StringBuilder buffer = new StringBuilder();

            Item item = player.items.getItemByName(search);

            if (item != null)
            {
                if (gold > item.value)
                {
                    player.items.removeFromInventory(item);
                    items.addToInventory(item);
                    player.gold += item.value;
                    gold -= item.value;
                    buffer.AppendFormat("\r\n%BYou sell %W{0} to {1}, %Bfor %Y{2} %Bgold.", item.description, name, item.value);
                    say("Thank you for your business.");
                    player.client.send(buffer.ToString());
                }
                else
                {
                    say("I can't purchase that at the moment, I'm a little short.");
                }
            }
            else
            {
                player.client.send("I can't find that item");
            }
        }
コード例 #19
0
ファイル: Merchant.cs プロジェクト: pboutell/amud-server
        private string listSell(Player player)
        {
            StringBuilder buffer = new StringBuilder();
            int x = 1;

            buffer.AppendLine("\r\n%YYou can sell:");
            foreach (Item i in player.items.inventory)
            {
                buffer.AppendFormat("\r\n\t%B{0}%W) %w{1,3}%Yg %W[ %w{2,8}%W ]  %B{3}%x",
                                    x++,
                                    i.value,
                                    i.name,
                                    i.description);
            }

            return buffer.ToString();
        }
コード例 #20
0
ファイル: MiscCom.cs プロジェクト: pboutell/amud-server
 private void doQuit(string[] args, Player player)
 {
     player.client.sendToRest(player.name + " has left the game!");
     player.client.send("thank you, come again!");
     player.client.disconnect();
 }
コード例 #21
0
ファイル: NPC.cs プロジェクト: pboutell/amud-server
 public virtual bool shop(string[] args, Player player)
 {
     return false;
 }
コード例 #22
0
ファイル: Room.cs プロジェクト: pboutell/amud-server
 public void addPlayer(Player player)
 {
     players.Add(player);
     characters.Add(player);
     player.room = this;
 }
コード例 #23
0
ファイル: Room.cs プロジェクト: pboutell/amud-server
        public void sendToRestRoom(string message, Player player)
        {
            for (int x = 0; x < players.Count; x++)
            {
                Player p = players.ElementAtOrDefault(x);

                if (p != null && p != player)
                    p.client.send(message);
            }
        }
コード例 #24
0
ファイル: Room.cs プロジェクト: pboutell/amud-server
 public void removePlayer(Player player)
 {
     characters.Remove(player);
     players.Remove(player);
 }
コード例 #25
0
ファイル: Room.cs プロジェクト: pboutell/amud-server
        public string playersToString(Player player)
        {
            StringBuilder buffer = new StringBuilder();

            foreach (Player p in players)
            {
                if (p != player)
                {
                    if (p != null && !p.client.isPlaying)
                    {
                        buffer.Append("%w( %rdisconnected%w )%x ");
                    }
                    buffer.AppendFormat("{0} is standing here.\r\n", p.name);
                }
            }

            return buffer.ToString().TrimEnd('\r', '\n');
        }
コード例 #26
0
ファイル: Room.cs プロジェクト: pboutell/amud-server
        public void findShop(string[] args, Player player)
        {
            bool result = false;

            foreach (NPC n in npcs)
            {
                result = n.shop(args, player);
                if (result)
                    break;
            }

            if (!result)
            {
                player.client.send("There is no merchant around.");
            }
        }
コード例 #27
0
ファイル: MiscCom.cs プロジェクト: pboutell/amud-server
 private void doShop(string[] args, Player player)
 {
     player.room.findShop(args, player);
 }
コード例 #28
0
ファイル: EquipmentCom.cs プロジェクト: pboutell/amud-server
        private void doWear(string[] args, Player player)
        {
            if (args.Length == 1)
            {
                player.client.send("Wear what?");
            }
            else
            {
                Item item = player.items.getItemByName(args[1].TrimEnd('\r', '\n'));

                if (item != null)
                {
                    if (player.items.addToEquipped(item.wearLocation, item))
                    {
                        player.client.send("You equip " + item.description + ".");
                    }
                    else
                    {
                        player.client.send("You can't wear that there!");
                    }
                }
            }
        }
コード例 #29
0
ファイル: BuilderCom.cs プロジェクト: pboutell/amud-server
        private void doDig(string[] args, Player player)
        {
            if (args.Length == 1)
            {
                player.parser.parse("dig --help");
                return;
            }

            int direction = Direction.directionToNumber(args[1]);

            if (direction >= 0 && direction < 4)
            {
                if (!player.world.newExit(direction, player.room))
                {
                    player.client.send("Can't dig that way!");
                }
                else
                {
                    player.client.send("Dug " + args[1]);
                }
            }
            else
            {
                player.client.send("I don't know how to dig that direction!");
            }
        }
コード例 #30
0
ファイル: Command.cs プロジェクト: pboutell/amud-server
 public void dispatch(string[] args, Player player)
 {
     this.method.Invoke(args, player);
 }