Esempio n. 1
0
    public void PushPopDrop()
    {
        var r = new DropStack <char>();

        r.IsEmpty.AssertIsTrue();
        r.Count.AssertEquals(0);

        r = r.Push('a');
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(1);
        r.Peek.AssertEquals('a');

        r = r.Push('b').Push('c');
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(3);
        r.Peek.AssertEquals('c');

        r = r.Pop();
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(2);
        r.Peek.AssertEquals('b');

        r = r.Drop();
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(1);
        r.Peek.AssertEquals('b');

        r = r.Drop();
        r.IsEmpty.AssertIsTrue();
        r.Count.AssertEquals(0);
    }
Esempio n. 2
0
    public void PushPopDrop()
    {
        var r = new DropStack<char>();
        r.IsEmpty.AssertIsTrue();
        r.Count.AssertEquals(0);

        r = r.Push('a');
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(1);
        r.Peek.AssertEquals('a');

        r = r.Push('b').Push('c');
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(3);
        r.Peek.AssertEquals('c');

        r = r.Pop();
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(2);
        r.Peek.AssertEquals('b');

        r = r.Drop();
        r.IsEmpty.AssertIsFalse();
        r.Count.AssertEquals(1);
        r.Peek.AssertEquals('b');

        r = r.Drop();
        r.IsEmpty.AssertIsTrue();
        r.Count.AssertEquals(0);
    }
Esempio n. 3
0
 public void KeepOnly()
 {
     var r = new DropStack<char>().Push('a').Push('b').Push('c').Push('d').KeepOnly(2);
     r.Count.AssertEquals(2);
     r.Peek.AssertEquals('d');
     r.Pop().Peek.AssertEquals('c');
 }
 public GuessColorpagina()
 {
     this.InitializeComponent();
     dt.Tick    += Dt_Tick;
     dt.Interval = TimeSpan.FromSeconds(1);
     _dropStack  = new DropStack(_deck.DrawCard());
 }
Esempio n. 5
0
    public void KeepOnly()
    {
        var r = new DropStack <char>().Push('a').Push('b').Push('c').Push('d').KeepOnly(2);

        r.Count.AssertEquals(2);
        r.Peek.AssertEquals('d');
        r.Pop().Peek.AssertEquals('c');
    }
        private void ShowPlayer()
        {
            _dropstack = new DropStack(_deck.DrawCard());
            card       = _deck.DrawCard();

            imgDropstackOldCard.Source  = _dropstack.GetTopCard().Image;
            imgDropstackOldCard2.Source = card.Image;
        }
Esempio n. 7
0
        protected override bool ProcessKeyPressed(AsciiKey key)
        {
            switch (key.Key)
            {
            case Keys.U:
                UseItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.E:
                EquipItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.Z:
                EquipHoldableItemLeft?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.X:
                EquipHoldableItemRight?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.T:
                TakeOffItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.D:
                DropItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.A:
                DropStack?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.C:
                CheckScroll?.Invoke(this, EventArgs.Empty);
                return(true);
            }
            return(base.ProcessKeyPressed(key));
        }
Esempio n. 8
0
        private void InitializeControls()
        {
            checkScrollButton = new StandardButton(20)
            {
                Position = new Point(Width - 30, 40),
                Text     = "[C] Check Scroll"
            };
            checkScrollButton.Click += (sender, args) => CheckScroll?.Invoke(this, EventArgs.Empty);
            Add(checkScrollButton);

            useItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[U] Use"
            };
            useItemButton.Click += (sender, args) => UseItem?.Invoke(this, EventArgs.Empty);
            Add(useItemButton);

            equipItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[E] Equip"
            };
            equipItemButton.Click += (sender, args) => EquipItem?.Invoke(this, EventArgs.Empty);
            Add(equipItemButton);

            equipLeftHoldableButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[Z] Equip Left"
            };
            equipLeftHoldableButton.Click += (sender, args) => EquipHoldableItemLeft?.Invoke(this, EventArgs.Empty);
            Add(equipLeftHoldableButton);

            equipRightHoldableButton = new StandardButton(20)
            {
                Position = new Point(Width - 31, 40),
                Text     = "[X] Equip Right"
            };
            equipRightHoldableButton.Click += (sender, args) => EquipHoldableItemRight?.Invoke(this, EventArgs.Empty);
            Add(equipRightHoldableButton);

            takeOffItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 40),
                Text     = "[T] Take Off"
            };
            takeOffItemButton.Click += (sender, args) => TakeOffItem?.Invoke(this, EventArgs.Empty);
            Add(takeOffItemButton);

            dropItemButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 43),
                Text     = "[D] Drop"
            };
            dropItemButton.Click += (sender, args) => DropItem?.Invoke(this, EventArgs.Empty);
            Add(dropItemButton);

            dropAllItemsButton = new StandardButton(20)
            {
                Position = new Point(Width - 52, 46),
                Text     = "[A] Drop All"
            };
            dropAllItemsButton.Click += (sender, args) => DropStack?.Invoke(this, EventArgs.Empty);
            Add(dropAllItemsButton);
        }