Exemplo n.º 1
0
 public bool NextTask()
 {
     m_pond.Task = m_tasks.GetNextTask(m_pond.Task);
     m_selectedPad = '\0';
     m_hopStack = new HopStack();
     UpdateGameState();
     return true;
 }
Exemplo n.º 2
0
 public bool SetTask(int taskNumber)
 {
     if (!m_tasks.IsValidTask(taskNumber))
         return false;
     Task task = m_tasks.GetTask(taskNumber);
     if (m_pond.Task != task)
     {
         m_pond.Task = task;
         m_selectedPad = '\0';
         m_hopStack = new HopStack();
         UpdateGameState();
     }
     return true;
 }
Exemplo n.º 3
0
        public void HopStackTest()
        {
            HopStack hs = new HopStack();
            Assert.IsFalse(hs.HasUndo());
            Assert.IsFalse(hs.HasRedo());

            hs.Push(new Hop('A', 'C'));
            Assert.IsTrue(hs.HasUndo());
            Assert.IsFalse(hs.HasRedo());

            hs.Push(new Hop('C', 'M'));
            Assert.IsTrue(hs.HasUndo());
            Assert.IsFalse(hs.HasRedo());

            Hop h = hs.Undo();
            Assert.IsNotNull(h);
            Assert.IsTrue(h.StartPad == 'C' && h.EndPad == 'M');
            Assert.IsTrue(hs.HasUndo());
            Assert.IsTrue(hs.HasRedo());

            h = hs.Undo();
            Assert.IsNotNull(h);
            Assert.IsTrue(h.StartPad == 'A' && h.EndPad == 'C');
            Assert.IsFalse(hs.HasUndo());
            Assert.IsTrue(hs.HasRedo());

            h = hs.Redo();
            Assert.IsNotNull(h);
            Assert.IsTrue(h.StartPad == 'A' && h.EndPad == 'C');
            Assert.IsTrue(hs.HasUndo());
            Assert.IsTrue(hs.HasRedo());

            h = hs.Redo();
            Assert.IsNotNull(h);
            Assert.IsTrue(h.StartPad == 'C' && h.EndPad == 'M');
            Assert.IsTrue(hs.HasUndo());
            Assert.IsFalse(hs.HasRedo());

            h = hs.Undo();
            Assert.IsNotNull(h);
            Assert.IsTrue(h.StartPad == 'C' && h.EndPad == 'M');
            Assert.IsTrue(hs.HasUndo());
            Assert.IsTrue(hs.HasRedo());

            hs.Push(new Hop('C', 'G'));
            Assert.IsTrue(hs.HasUndo());
            Assert.IsFalse(hs.HasRedo());

            h = hs.Undo();
            Assert.IsNotNull(h);
            Assert.IsTrue(h.StartPad == 'C' && h.EndPad == 'G');
            Assert.IsTrue(hs.HasUndo());
            Assert.IsTrue(hs.HasRedo());

            h = hs.Undo();
            Assert.IsNotNull(h);
            Assert.IsTrue(h.StartPad == 'A' && h.EndPad == 'C');
            Assert.IsFalse(hs.HasUndo());
            Assert.IsTrue(hs.HasRedo());

            hs.Push(new Hop('A', 'K'));
            Assert.IsTrue(hs.HasUndo());
            Assert.IsFalse(hs.HasRedo());
        }