Beispiel #1
0
        public void ShouldNotMergeIfEarlierEventWasntTerminatedByFiltering(TerminationState earlierEventTerminatedAs)
        {
            GivenEventsMeetMergeConditions();
            _event.TerminatedState = earlierEventTerminatedAs;

            Assert.IsFalse(_strategy.AreMergable(_event, _subsequentEvent));
        }
Beispiel #2
0
    public void ResetGame(int width, int height, int virusHeight, int virusCount)
    {
        this.width       = width;
        this.height      = height;
        this.virusCount  = virusCount;
        this.virusHeight = virusHeight;

        gameState        = new GameState(width, height);
        spawnRow         = height - 1;
        spawnCol         = width / 2 - 1;
        terminationState = TerminationState.ONGOING;

        SpawnViruses(virusCount, virusHeight);
        StartTurn();

        OnGameReset?.Invoke();
    }
Beispiel #3
0
 private static IDEEvent CompletionEvent(TerminationState ts, IName name)
 {
     return(new CompletionEvent
     {
         // this is invalid but Ok for this test!
         ActiveDocument = Names.Document(Guid.NewGuid() + " "),
         TerminatedState = ts,
         Selections =
         {
             new ProposalSelection
             {
                 Proposal = new Proposal
                 {
                     Name = name
                 }
             }
         }
     });
 }
Beispiel #4
0
    void StartTurn()
    {
        playerCanPlay = true;
        if (gameState.IsOccupied(spawnRow, spawnCol) || gameState.IsOccupied(spawnRow, spawnCol + 1))
        {
            terminationState = TerminationState.LOSS;
            playerCanPlay    = false;
            OnGameEnd?.Invoke();
            return;
        }
        Color primaryColor   = (Color)Random.Range(0, 3);
        Color secondaryColor = (Color)Random.Range(0, 3);

        if (singleColorPillsOnly)
        {
            secondaryColor = primaryColor;
        }
        gameState.SpawnPill(spawnRow, spawnCol, primaryColor, secondaryColor);
        currentPillRow = spawnRow;
        currentPillCol = spawnCol;
    }
Beispiel #5
0
 public void Wait()
 {
     if (playerCanPlay && gameState.CanMoveDown(currentPillRow, currentPillCol))
     {
         --currentPillRow;
     }
     else
     {
         EndTurn();
     }
     if (!gameState.UpdateState())
     {
         if (gameState.GetVirusCount() == 0)
         {
             terminationState = TerminationState.WIN;
             OnGameEnd?.Invoke();
             return;
         }
         StartTurn();
     }
 }
Beispiel #6
0
        public void OnlyReadsAppliedEventsWithMethods()
        {
            const TerminationState applied   = TerminationState.Applied;
            const TerminationState cancelled = TerminationState.Cancelled;

            var x = Names.General("x");
            var m = Names.Method("[T,P] [T,P].M()");

            var appliedAndMethod = CompletionEvent(applied, m);

            AddFile(
                "a.zip",
                OtherEvent(),
                CompletionEvent(applied, x),
                CompletionEvent(cancelled, m),
                appliedAndMethod);

            var expected = Lists.NewList(appliedAndMethod);
            var actual   = _sut.FindAppliedCompletionEvents("a.zip");

            CollectionAssert.AreEquivalent(expected, actual);
        }