示例#1
0
        // Function from file: stack.dm
        public bool building_checks(StackRecipe R = null, double?multiplier = null)
        {
            if ((this.get_amount() ?? 0) < (R.req_amount ?? 0) * (multiplier ?? 0))
            {
                if ((R.req_amount ?? 0) * (multiplier ?? 0) > 1)
                {
                    Task13.User.WriteMsg(new Txt("<span class='warning'>You haven't got enough ").item(this).str(" to build ").the((R.req_amount ?? 0) * (multiplier ?? 0)).item().str(" ").item(R.title).s().str("!</span>").ToString());
                }
                else
                {
                    Task13.User.WriteMsg(new Txt("<span class='warning'>You haven't got enough ").item(this).str(" to build ").the(R.title).item().str("!</span>").ToString());
                }
                return(false);
            }

            if (R.one_per_turf == true && Lang13.Bool(Lang13.FindIn(R.result_type, Task13.User.loc)))
            {
                Task13.User.WriteMsg("<span class='warning'>There is another " + R.title + " here!</span>");
                return(false);
            }

            if (R.on_floor == true && !(Task13.User.loc is Tile_Simulated_Floor))
            {
                Task13.User.WriteMsg(new Txt("<span class='warning'>").The(R.title).item().str(" must be constructed on the floor!</span>").ToString());
                return(false);
            }
            return(true);
        }
示例#2
0
        // Function from file: stack.dm
        public override dynamic interact(dynamic user = null, bool?flag1 = null)
        {
            string      t1             = null;
            int?        i              = null;
            StackRecipe R              = null;
            int         max_multiplier = 0;
            dynamic     title          = null;
            bool        can_build      = false;
            ByTable     multipliers    = null;
            dynamic     n              = null;


            if (!(this.recipes != null))
            {
                return(null);
            }

            if (!(this != null) || (this.get_amount() ?? 0) <= 0)
            {
                Interface13.Browse(user, null, "window=stack");
            }
            ((Mob)user).set_machine(this);
            t1 = "<HTML><HEAD><title>Constructions from " + this + "</title></HEAD><body><TT>Amount Left: " + this.get_amount() + "<br>";
            i  = null;
            i  = 1;

            while ((i ?? 0) <= this.recipes.len)
            {
                R = this.recipes[i];

                if (R == null)
                {
                    t1 += "<hr>";
                }
                else
                {
                    if ((i ?? 0) > 1 && !(this.recipes[(i ?? 0) - 1] == null))
                    {
                        t1 += "<br>";
                    }
                    max_multiplier = Num13.Floor((this.get_amount() ?? 0) / (R.req_amount ?? 0));
                    title          = null;
                    can_build      = true;
                    can_build      = can_build && max_multiplier > 0;

                    if ((R.res_amount ?? 0) > 1)
                    {
                        title += new Txt().item(R.res_amount).str("x ").item(R.title).s().ToString();
                    }
                    else
                    {
                        title += "" + R.title;
                    }
                    title += new Txt(" (").item(R.req_amount).str(" ").item(this.singular_name).s().str(")").ToString();

                    if (can_build)
                    {
                        t1 += new Txt("<A href='?src=").Ref(this).str(";make=").item(i).str(";multiplier=1'>").item(title).str("</A>  ").ToString();
                    }
                    else
                    {
                        t1 += "" + title;
                        i++;
                        continue;
                    }

                    if ((R.max_res_amount ?? 0) > 1 && max_multiplier > 1)
                    {
                        max_multiplier = Num13.MinInt(max_multiplier, Num13.Floor((R.max_res_amount ?? 0) / (R.res_amount ?? 0)));
                        t1            += " |";
                        multipliers    = new ByTable(new object [] { 5, 10, 25 });

                        foreach (dynamic _a in Lang13.Enumerate(multipliers))
                        {
                            n = _a;


                            if (max_multiplier >= Convert.ToDouble(n))
                            {
                                t1 += new Txt(" <A href='?src=").Ref(this).str(";make=").item(i).str(";multiplier=").item(n).str("'>").item(n * R.res_amount).str("x</A>").ToString();
                            }
                        }

                        if (!multipliers.Contains(max_multiplier))
                        {
                            t1 += new Txt(" <A href='?src=").Ref(this).str(";make=").item(i).str(";multiplier=").item(max_multiplier).str("'>").item(max_multiplier * (R.res_amount ?? 0)).str("x</A>").ToString();
                        }
                    }
                }
                i++;
            }
            t1 += "</TT></body></HTML>";
            Interface13.Browse(user, t1, "window=stack");
            GlobalFuncs.onclose(user, "stack");
            return(null);
        }
示例#3
0
        // Function from file: stack.dm
        public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null)
        {
            StackRecipe R          = null;
            double?     multiplier = null;
            dynamic     O          = null;
            dynamic     new_item   = null;
            Obj_Item    I          = null;

            base.Topic(href, href_list, (object)(hsrc));

            if (Task13.User.restrained() || Task13.User.stat != 0 || Task13.User.get_active_hand() != this)
            {
                return(null);
            }

            if (Lang13.Bool(href_list["make"]))
            {
                if ((this.get_amount() ?? 0) < 1)
                {
                    GlobalFuncs.qdel(this);
                }
                R          = this.recipes[String13.ParseNumber(href_list["make"])];
                multiplier = String13.ParseNumber(href_list["multiplier"]);

                if (!Lang13.Bool(multiplier) || (multiplier ?? 0) <= 0)
                {
                    return(null);
                }

                if (!this.building_checks(R, multiplier))
                {
                    return(null);
                }

                if (Lang13.Bool(R.time))
                {
                    Task13.User.visible_message("<span class='notice'>" + Task13.User + " starts building " + R.title + ".</span>", "<span class='notice'>You start building " + R.title + "...</span>");

                    if (!GlobalFuncs.do_after(Task13.User, R.time, null, Task13.User))
                    {
                        return(null);
                    }

                    if (!this.building_checks(R, multiplier))
                    {
                        return(null);
                    }
                }
                O     = Lang13.Call(R.result_type, Task13.User.loc);
                O.dir = Task13.User.dir;
                this.use((R.req_amount ?? 0) * (multiplier ?? 0));

                if ((R.max_res_amount ?? 0) > 1)
                {
                    new_item        = O;
                    new_item.amount = (R.res_amount ?? 0) * (multiplier ?? 0);

                    if (Convert.ToDouble(new_item.amount) <= 0)
                    {
                        return(null);
                    }
                }

                if (O is Obj_Item)
                {
                    Task13.User.put_in_hands(O);
                }
                ((Ent_Static)O).add_fingerprint(Task13.User);

                if (O is Obj_Item_Weapon_Storage)
                {
                    foreach (dynamic _a in Lang13.Enumerate(O, typeof(Obj_Item)))
                    {
                        I = _a;

                        GlobalFuncs.qdel(I);
                    }
                }
            }

            if (this != null && Task13.User.machine == this)
            {
                Task13.Schedule(0, (Task13.Closure)(() => {
                    this.interact(Task13.User);
                    return;

                    return;
                }));
            }
            return(null);
        }