コード例 #1
0
        protected virtual void SystemInit()
        {
            Console.WriteLine("SystemInit Called!");
            //Actors.registerSheet("core",ActorSheetType);
            Globals.CONFIG.Actor.entityClass = typeof(ActorGlue);
            dynamic sheetOptions = new RawJSObject();

            sheetOptions.makeDefault = true;
            Actors.registerSheet("dnd5e", typeof(ActorSheetGlue), sheetOptions);
            //Items.registerSheet("dnd5e", SimpleItemSheet, { makeDefault: true});
        }
コード例 #2
0
        private void DoStatRoll(string statname)
        {
            Console.WriteLine("doing roll");
            dynamic data     = getData().data;
            dynamic stat     = data.stats[statname];
            string  rollstr  = stat.d8.toString() + "d8";
            float   modifier = stat.plus - stat.damage;

            if (modifier > 0)
            {
                rollstr = rollstr + "+" + modifier.ToString();
            }
            else if (modifier < 0)
            {
                rollstr = rollstr + modifier.ToString();
            }
            Console.WriteLine("rolling " + rollstr);
            dynamic opts = new RawJSObject();

            opts.flavor = "Makes a(n) " + statname + " roll...";

            new Roll(rollstr, null).toMessage(null, opts);
        }
コード例 #3
0
        public override void ActivateListeners(jQuery htmlObject)
        {
            // Activate tabs
            jQuery  tabs = htmlObject.Find(".tabs");
            dynamic opts = new RawJSObject();

            opts.initial  = _sheetTab;
            opts.callback = (ClickCallback)ClickTabSelect;
            new FVTTBridge.Bindings.Tabs(tabs, opts);

            //
            // Everything below here is only needed if the sheet is editable
            if (!Options.editable)
            {
                return;
            }

            // Update Inventory Item

            htmlObject.Find(".item-edit").Click(ev => {
                jQuery li = jQuery.Select(ev.CurrentTarget).Parents(".item");
                Item item = Actor.getOwnedItem(li.Data("itemId"));
                //item.render(true);
            });


            // Delete Inventory Item
            htmlObject.Find(".item-delete").Click(ev => {
                jQuery li = jQuery.Select(ev.CurrentTarget).Parents(".item");
                Actor.deleteOwnedItem(li.Data("itemId"), null);
                li.SlideUp(200, () => Render(false));
            });
            // hook stat roll buttons
            htmlObject.Find(".roll_stat_button").Click(ev =>
            {
                Element button = ev.CurrentTarget;
                DoStatRoll(button.GetAttribute("data-statname"));
            });


            htmlObject.Find(".roll_skill_button").Click(ev => {
                Element button = ev.CurrentTarget;
                DoSkillRoll(button.GetAttribute("data-skillname"));
            });

            // Clear skill pulldown
            htmlObject.Find("#skill_pulldown").Click(ev =>
            {
                htmlObject.Find(ev.CurrentTarget).Val("");
            });

            HTMLCollection clear_pulldowns = Document.GetElementsByClassName("clear_pulldown");

            foreach (Element el in clear_pulldowns)
            {
                el.AddEventListener("click", ev => { htmlObject.Find(ev.CurrentTarget.ToString()).Val(""); }, false);
            }

            htmlObject.Find("#add_skill_button").Click(ev =>
            {
                jQuery skillname = htmlObject.Find("#skill_pulldown");
                Console.WriteLine("add skill " + skillname.Val());
                DoAddSkill(skillname.Val());
            });

            htmlObject.Find("#roll_button").Click(ev =>
            {
                Console.WriteLine("show roll dialog");
                htmlObject.Find("#roll_dialog").Show();
            });

            HTMLCollection action_buttons = Document.GetElementsByClassName("action_button");

            foreach (Element el in action_buttons)
            {
                el.AddEventListener("click", ev =>
                {
                    Element button = (Element)ev.CurrentTarget;
                    DoItemAction(button.GetAttribute("data-itemkey"),
                                 button.GetAttribute("data-actionkey"));
                });
            }
        }