Example #1
0
        ////////////////

        public override void Action(CommandCaller caller, string input, string[] args)
        {
            var mymod = (IntrinsicsMod)this.mod;

            if (!mymod.Config.DebugModeCheat)
            {
                caller.Reply("Cheat mode not active. See configs.", Color.Red);
                return;
            }

            if (Main.netMode == 1)
            {
                LogHelpers.Warn("Not supposed to run on client.");
                return;
            }

            if (Main.netMode == 2 && caller.CommandType != CommandType.Console)
            {
                bool hasPriv = UserHelpers.HasBasicServerPrivilege(caller.Player);

                if (!hasPriv)
                {
                    caller.Reply("Access denied.", Color.Red);
                    return;
                }
            }

            if (args.Length < 1)
            {
                caller.Reply("Insufficient arguments.", Color.Red);
                return;
            }

            if (args[0].Length == 0 || args[0][0] != '\"')
            {
                caller.Reply("Invalid first item name: " + args[0], Color.Red);
                return;
            }

            IList <Item> items = new List <Item>();

            int    argNextIdx = 0;
            string itemKey;

            while (CommandsHelpers.GetQuotedStringFromArgsAt(args, argNextIdx, out argNextIdx, out itemKey))
            {
                int itemId;

                if (!ItemAttributeHelpers.DisplayNamesToIds.ContainsKey(itemKey))
                {
                    itemId = ItemID.TypeFromUniqueKey(itemKey);

                    if (itemId == 0)
                    {
                        caller.Reply("Invalid item name: " + itemKey, Color.Red);
                        return;
                    }
                }
                else
                {
                    itemId = ItemAttributeHelpers.DisplayNamesToIds[itemKey];
                }

                var item = new Item();
                item.SetDefaults(itemId);

                items.Add(item);
            }

            IEnumerable <string> itemNames = items.Select(i => ItemID.GetUniqueKey(i.type));                   //TODO GetProperUniqueId

            if (ImpartmentContractItem.Create(Main.LocalPlayer, Main.LocalPlayer.Center, new HashSet <string>(itemNames)) != -1)
            {
                caller.Reply("Created Impartment Contract.", Color.Lime);
            }
            else
            {
                caller.Reply("Could not create Impartment Contract.", Color.Red);
            }
        }
Example #2
0
        public static int CreateContract(Player player, params Item[] items)
        {
            IEnumerable <string> itemNames = items.Select(i => ItemID.GetUniqueKey(i.type));                  //TODO GetProperUniqueId

            return(ImpartmentContractItem.Create(player, player.Center, new HashSet <string>(itemNames)));
        }