Esempio n. 1
0
 public void Advance()
 {
     _currentRavage  = _currentBuild;
     _currentBuild   = _currentExplore;
     _currentExplore = null;
     SendAdvanceData();
 }
Esempio n. 2
0
        public void BuildAndRavage_BecomesTwoBuilds()
        {
            List <string> invaderLog = new List <string>();

            // Given: Going to Ravage / Build in Jungle
            var(user, ctx) = TestSpirit.SetupGame(PowerCard.For <CallToTrade>(), (gs) => {
                var jungleCard  = new InvaderCard(Terrain.Jungle);
                gs.InvaderDeck  = InvaderDeck.BuildTestDeck(jungleCard, jungleCard, jungleCard, jungleCard);
                gs.NewLogEntry += (s) => invaderLog.Add(s.Msg());
            });

            // Given: advance to 2nd round where we have a ravage
            user.DoesNothingForARound();
            invaderLog.Clear();

            // Given: a space that IS-RAVAGE AND BUILD
            var spaceCtx = ctx.AllSpaces
                           .Select(ctx.Target)
                           .Last(s => s.MatchesRavageCard && s.MatchesBuildCard);        // last stays away from city and ocean

            invaderLog.Add("Selected target:" + spaceCtx.Space.Label);

            //  And: it has 3 explorers (in case dahan attacks during ravage, would still 1 left over
            Given_HasOnly3Explorers(spaceCtx);
            Given_Has2Dahan(spaceCtx);
            Given_NoSuroundingTowns(spaceCtx);
            Given_NoSuroundingDahan(spaceCtx);

            When_GrowsBuysAndActivatesCard(user, spaceCtx);

            spaceCtx.Tokens.InvaderSummary().ShouldBe("1C@3,1T@2,4E@1");
        }
Esempio n. 3
0
        static public InvaderDeck MountainThenAllSands()
        {
            var sand = new InvaderCard(Terrain.Sand);

            return(InvaderDeck.BuildTestDeck(
                       new InvaderCard(Terrain.Mountain),            // initial explorer in mountains
                       sand, sand, sand, sand, sand
                       ));
        }
Esempio n. 4
0
        public void Explore()
        {
            if (InvaderDeck.IsEmpty)
            {
                SendGameEndData();
                GameLost?.Invoke();
                return;
            }

            _currentExplore = InvaderDeck.Dequeue();
            SendExploreData();
        }
Esempio n. 5
0
        public void StopsAllInvaderActions()
        {
            List <string> invaderLog = new List <string>();

            var(user, ctx) = TestSpirit.SetupGame(PowerCard.For <IndomitableClaim>(), (gs) => {
                var jungleCard  = new InvaderCard(Terrain.Jungle);
                gs.InvaderDeck  = InvaderDeck.BuildTestDeck(jungleCard, jungleCard, jungleCard, jungleCard);
                gs.NewLogEntry += (s) => invaderLog.Add(s.Msg());
            });

            // Given: there a ravage card
            user.Grows();
            user.IsDoneBuyingCards();
            invaderLog.Clear();

            // and: there is a space that IS-RAVAGE AND BUILD (aka: Jungle - see above)
            var spaceCtx = ctx.AllSpaces
                           .Select(ctx.Target)
                           .Last(s => s.MatchesRavageCard && s.MatchesBuildCard);        // last stays away from city and ocean

            invaderLog.Add("Selected target:" + spaceCtx.Space.Label);

            // And: we have a presence in that land
            ctx.Self.Presence.PlaceOn(spaceCtx.Space, spaceCtx.GameState);

            //  And: it has 3 explorers
            spaceCtx.Tokens.InitDefault(Invader.Explorer, 3);
            spaceCtx.Tokens.InitDefault(Invader.Town, 0);
            spaceCtx.Tokens.InitDefault(Invader.City, 0);               // if we had to advance cards, might have buit a city
            spaceCtx.Tokens.InvaderSummary().ShouldBe("3E@1", "Unable to init to 3 exploreres.");
            //  And 2 dahan
            spaceCtx.Dahan.Init(2);

            // When: grows and purchases card
            user.Grows();
            user.PlaysCard(IndomitableClaim.Name);

            //  And: has enough elements to trigger the bonus
            ctx.Self.Elements[Element.Sun]   = 2;
            ctx.Self.Elements[Element.Earth] = 3;

            //  When: Activates Card
            user.SelectsFastAction(IndomitableClaim.Name);
            user.TargetsLand_IgnoreOptions(spaceCtx.Space.Label);
            user.PullsPresenceFromTrack(ctx.Self.Presence.Energy.RevealOptions.Single());

            // Then: nothing changed
            spaceCtx.Tokens.InvaderSummary().ShouldBe("3E@1", "should be same that we started with");

            // Make sure that we actually executed the Ravage Build / Explore Bit
            invaderLog.Count(s => s.Contains("Exploring")).ShouldBeGreaterThan(0);
        }
        private static void AppendInvaderCard(Board board, InvaderCard invaderCard, StringBuilder builder)
        {
            if (invaderCard == null)
            {
                builder.Append("00000000");
                return;
            }

            for (var i = 0; i < 8; i++)
            {
                var land = board.GetLandTypeById(i);
                builder.Append(invaderCard.Lands.Contains(land) || (i < 3 && invaderCard.Lands.Contains(Land.Coastal)) ? "1" : "0");
            }
        }
        public void Send(Board board, InvaderCard explore, InvaderCard build, InvaderCard ravage)
        {
            var builder = new StringBuilder();

            builder.Append("LED:");
            AppendInvaderCard(board, ravage, builder);
            AppendInvaderCard(board, explore, builder);
            AppendInvaderCard(board, build, builder);
            AppendEscalation(explore, builder);

            var str = builder.ToString();

            _deviceCommunication.Send(str);
        }
Esempio n. 8
0
        public Quarantine_Tests()
        {
            var powerCard = PowerCard.For <CallToTend>();

            var(userLocal, ctxLocal) = TestSpirit.SetupGame(powerCard, gs => {
                gs.NewLogEntry += (s) => { if (s is InvaderActionEntry)
                                           {
                                               log.Enqueue(s.Msg());
                                           }
                };
                gs.InvaderDeck = InvaderDeck.BuildTestDeck(
                    new InvaderCard(Terrain.Sand),                     // not on coast
                    InvaderCard.Stage2Costal(),
                    new InvaderCard(Terrain.Jungle)
                    );
            });
            user = userLocal;
            ctx  = ctxLocal;
            log.Clear();             // skip over initial Explorer setup
        }
Esempio n. 9
0
        /// <summary> Replaces all Invader Cards with null-cards that don't ravage/build/explore</summary>
        static public void DisableInvaderDeck(this GameState gs)
        {
            var nullCard = new InvaderCard(Terrain.None);

            gs.InvaderDeck = InvaderDeck.BuildTestDeck(new byte[12].Select(_ => nullCard).ToArray());
        }
 private void AppendEscalation(InvaderCard explore, StringBuilder builder)
 {
     builder.Append((explore != null && explore.Escalation) ? "1" : "0");
 }