예제 #1
0
        public void TestPutAllLMap()
        {
            Map <Object, Object> ht  = new HashMap <Object, Object>();
            Map <Object, Object> amt = new AMT();

            ht.Put("this", "that");
            amt.PutAll(ht);
            Assert.AreEqual(amt, ht, "Should be equal");
        }
예제 #2
0
파일: TreeList.cs 프로젝트: atomaszz/gelios
        public void FillTreeFromList(ref TListNode AListNode)
        {
            TTreeStackItem     Item;
            TAltInfoItem       AltInfoItem;
            TAlternateTreeList AT;
            TNodeMain          Node;
            TTreeListTFS       Tfs;
            TMainTreeList      AMT;
            TMainTreeList      MNew;
            TTreeListItem      LI;

            Init(0);
            Item = f_Stack.GetLevel();
            while (Item != null)
            {
                AMT = FindByLevel(f_TreeList, Item.Level);
                if (AMT != null)
                {
                    AListNode.LoadInfoForAlternate(ref f_AltInfo, Item.Level);
                    for (int i = 0; i <= f_AltInfo.ItemCount - 1; i++)
                    {
                        AltInfoItem        = f_AltInfo.GetItem(i);
                        AT                 = new TAlternateTreeList();
                        AT.MainAlternative = AltInfoItem.Main;
                        AT.NodeStart       = AltInfoItem.NodeStart;
                        AT.NodeEnd         = AltInfoItem.NodeEnd;
                        AT.ID              = AltInfoItem.ID;
                        AT.Num             = AltInfoItem.Num;
                        Node               = AListNode.SearchFirstNodeToAlternate(AltInfoItem.ID, AltInfoItem.Num, Item.Level);
                        while (Node != null)
                        {
                            Tfs = new TTreeListTFS(Node.WorkShape);
                            AT.AddToAlternate(Tfs);
                            for (int j = 0; j <= Tfs.ItemCount - 1; j++)
                            {
                                LI = Tfs.GetTreeTFEItem(j);
                                f_Stack.AddToStack(LI.BaseShape.ID);
                                if (AListNode.IsContainsChildShape(LI.BaseShape.ID))
                                {
                                    if (LI.MainNode == null)
                                    {
                                        MNew        = new TMainTreeList();
                                        MNew.Level  = LI.BaseShape.ID;
                                        LI.MainNode = MNew;
                                    }
                                }
                            }
                            Node = AListNode.SearchNextNodeToAlternate(AltInfoItem.ID, AltInfoItem.Num, Node);
                        }
                        AMT.AddToTree(AT);
                    }
                }
                Item.Fixed = true;
                Item       = f_Stack.GetLevel();
            }
        }
예제 #3
0
        public void TestGet()
        {
            AbstractMap <Object, Object> map = new AMT();

            Assert.IsNull(map.Get("key"));
            Assert.IsNull(map.Get(null));

            map.Put("k", "v");
            map.Put("key", null);
            map.Put(null, "value");

            Assert.AreEqual("v", map.Get("k"));
            Assert.IsNull(map.Get("key"));
            Assert.AreEqual("value", map.Get(null));
        }
예제 #4
0
        public void TestContainValue()
        {
            AbstractMap <Object, Object> map = new AMT();

            Assert.IsFalse(map.ContainsValue("v"));
            Assert.IsFalse(map.ContainsValue(null));

            map.Put("k", "v");
            map.Put("key", null);
            map.Put(null, "value");

            Assert.IsTrue(map.ContainsValue("v"));
            Assert.IsTrue(map.ContainsValue("value"));
            Assert.IsTrue(map.ContainsValue(null));
        }
예제 #5
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            switch (info.ButtonID)
            {
            case 0:
            {
                break;
            }

                #region Guide Pages
            case 1001:
            {
                string text = info.TextEntries[0].Text;
                int    PR   = Convert.ToInt32(text);
                if (REVR != null)
                {
                    REVR.Price = PR;
                    from.SendMessage("Price set..");
                }
                SendGump(from, PAGE.TicketLimit, REVR);
                break;
            }

            case 1002:
            {
                string days    = info.TextEntries[0].Text;
                string hours   = info.TextEntries[1].Text;
                string minutes = info.TextEntries[2].Text;

                int d, h, m;
                try
                {
                    d = Convert.ToInt32(days);
                    h = Convert.ToInt32(hours);
                    m = Convert.ToInt32(minutes);
                }
                catch
                {
                    from.SendMessage(38, "You did not enter a valid number, please try again. Numbers must be actual numbers, no letters or characters will work.");
                    SendGump(from, PAGE.Date, REVR);
                    return;
                }

                DateTime dt = DateTime.UtcNow;
                dt = dt.AddDays(d);
                dt = dt.AddHours(h);
                dt = dt.AddMinutes(m);

                REVR.Expiration = dt;
                from.SendMessage("Expiration: " + REVR.Date_String);
                from.SendMessage(38, "Please select an item.");
                from.Target = new RevTarget(REVR);
                break;
            }

            case 1003:
            {
                string text = info.TextEntries[0].Text;
                int    PR   = Convert.ToInt32(text);
                if (REVR != null)
                {
                    REVR.TicketLimit = PR;
                    from.SendMessage("Ticket limit set..");
                }
                SendGump(from, PAGE.Date, REVR);
                break;
            }

                #endregion
                #region Edit Pages
            case 2001:
            {
                string text = info.TextEntries[0].Text;
                int    PR   = Convert.ToInt32(text);
                if (REVR != null)
                {
                    REVR.Price = PR;
                    from.SendMessage("Price set..");
                }
                SendGump(from, PAGE.Props, REVR);
                break;
            }

            case 2002:
            {
                string days = info.TextEntries[0].Text;
                string hours = info.TextEntries[1].Text;
                string minutes = info.TextEntries[2].Text;
                int    d, h, m;
                try
                {
                    d = Convert.ToInt32(days);
                    h = Convert.ToInt32(hours);
                    m = Convert.ToInt32(minutes);
                }
                catch
                {
                    from.SendMessage(38, "You did not enter a valid number, please try again. Numbers must be actual numbers, no letters or characters will work.");
                    SendGump(from, PAGE.EditDate, REVR);
                    return;
                }

                DateTime dt = DateTime.UtcNow;
                dt = dt.AddDays(d);
                dt = dt.AddHours(h);
                dt = dt.AddMinutes(m);

                REVR.Expiration = dt;
                from.SendMessage("Expiration: " + REVR.Date_String);
                SendGump(from, PAGE.Props, REVR);
                break;
            }

            case 2003:
            {
                from.SendMessage(38, "Please select an item.");
                from.Target = new RevTarget(REVR);
                break;
            }

            case 2004:
            {
                SendGump(from, PAGE.PlayerScreen, REVR);
                break;
            }

            case 2005:
            {
                string text = info.TextEntries[0].Text;
                int    PR   = Convert.ToInt32(text);
                if (REVR != null)
                {
                    REVR.TicketLimit = PR;
                    from.SendMessage("Ticket Limit set..");
                }
                SendGump(from, PAGE.Props, REVR);
                break;
            }

                #endregion
                #region Player Pages
            case 4001:
            {
                string text = info.TextEntries[0].Text;
                int    AMT, Tickets = Contestant.GetTickets(REVR.NewContestants, from);
                try { AMT = Convert.ToInt32(text); }
                catch { AMT = 1; }

                if (AMT > 0)
                {
                    if (Tickets >= REVR.TicketLimit)
                    {
                        from.SendMessage(SETTINGS.LabelHue, SETTINGS.Limit);
                        break;
                    }

                    if (Tickets + AMT > REVR.TicketLimit)
                    {
                        AMT = REVR.TicketLimit - Tickets;
                    }


                    int Cost = AMT * REVR.Price;
                    if (from.Backpack.ConsumeTotal(typeof(Gold), Cost) || from.BankBox.ConsumeTotal(typeof(Gold), Cost))
                    {
                        bool CU = false;
                        foreach (Contestant c in REVR.NewContestants)
                        {
                            if (from == c.Player)
                            {
                                c.Tickets += AMT;
                                CU         = true;
                                break;
                            }
                        }

                        if (!CU)
                        {
                            REVR.NewContestants.Add(new Contestant(from, AMT));
                        }

                        from.SendMessage(SETTINGS.LabelHue, string.Format(SETTINGS.Purchase, AMT.ToString()));
                        REVR.InvalidateProperties();
                    }
                    else
                    {
                        from.SendMessage(SETTINGS.LabelHue, string.Format(SETTINGS.Not_Enough_Gold, Cost.ToString(), AMT.ToString()));
                    }
                }
                break;
            }

            case 4002:
            {
                SendGump(from, PAGE.PlayerScreen, REVR);
                break;
            }

                #endregion
                #region EditSend
            case 5001:
            {
                SendGump(from, PAGE.EditPrice, REVR);
                break;
            }

            case 5002:
            {
                SendGump(from, PAGE.EditDate, REVR);
                break;
            }

            case 5003:
            {
                REVR.Expiration = DateTime.UtcNow.Subtract(TimeSpan.FromDays(1));
                REVR.Expire();
                break;
            }

            case 5004:
            {
                SendGump(from, PAGE.EditTicketLimit, REVR);
                break;
            }
                #endregion
            }
        }
예제 #6
0
 public AMTSet(AMT parent)
 {
     this.parent = parent;
 }
예제 #7
0
 public AMTSetIterator(AMT parent)
 {
     this.parent = parent;
 }
예제 #8
0
 public AMTEntry(int index, AMT parent) : base(null, null)
 {
     this.v = parent.values.Get(index);
     this.k = parent.keys.Get(index);
 }