示例#1
0
文件: Quest.cs 项目: dcmorse/phial
 public Quest(FreeStrategy strategy, int shadowHuntAllocated, ILogger log)
 {
     FreeStrategy        = strategy;
     ShadowHuntAllocated = shadowHuntAllocated;
     HuntBag             = new HuntBag();
     Log = log;
 }
示例#2
0
        static void RunOne(FreeStrategy strategy)
        {
            var logger = new ConsoleLogger();
            var q      = new Quest(strategy, 1, logger);

            q.FromRivendell();
            logger.Log(q.ToString());
        }
示例#3
0
文件: Quest.cs 项目: dcmorse/phial
        private (int, bool) ApplyGuidePowers(int tileValue, bool reveal, Tile tile)
        {
            List <Companion> separatedCompanions;

            (tileValue, reveal, separatedCompanions) = FreeStrategy.CalculateGuidePowers(tileValue, reveal, tile, this);
            if (separatedCompanions.Count > 0)
            {
                SeparateCompanions(separatedCompanions);
            }
            return(tileValue, reveal);
        }
示例#4
0
文件: Quest.cs 项目: dcmorse/phial
        void RevealFellowshipOutsideMordorAndResolveStrongholdTiles()
        {
            int ntiles = RevealFellowshipOutsideMordor();

            for (; ntiles > 0; ntiles--)
            {
                var tile = HuntBag.DrawTile();
                Log.Log($"    stronghold tile {tile}");
                FreeStrategy.Hunt(tile.Value(0), false, tile, this);
            }
        }
示例#5
0
文件: Quest.cs 项目: dcmorse/phial
        public Quest MordorTrack()
        {
            for (; ; Turns++)
            {
                // int eyes = ShadowHuntAllocated + D6.CountHits(ShadowRolled, 6);
                ShadowActionDiceRoll shadowDice = new ShadowActionDiceRoll(7 + Minions, ShadowHuntAllocated);
                bool movedOrHidThisTurn         = false;
                var  freeDice    = new FreeActionDiceRoll(FreeActionDiceCount);
                int  freeHuntBox = 0;

                Log.Log($"Turn {Turns}: {shadowDice.Eyes} eyes, {freeDice}");

                while (freeDice.CharacterOrWills > 0 || StriderCanHide(freeDice))
                {
                    if (StriderCanHide(freeDice))
                    {
                        Revealed = false;
                        Log.Log($"  Strider hide");
                        freeDice.SpendMostUselessDie();
                    }
                    else if (Revealed)
                    {
                        Revealed = false;
                        Log.Log($"  hide");
                        freeDice.SpendCharacterOrWill();
                    }
                    else
                    {
                        var tile      = HuntBag.DrawTile();
                        int huntValue = tile.Value(shadowDice.Eyes + freeHuntBox);
                        Log.Log($"  from step {MordorTrackStep} {tile} = {huntValue}");
                        FreeStrategy.Hunt(huntValue, tile.Reveal(), tile, this);
                        if (!tile.Stop())
                        {
                            MordorTrackStep++;
                        }
                        freeHuntBox++;
                        Log.Log($"    corruption {Corruption}, {shadowDice.Eyes} eyes");
                        freeDice.SpendCharacterOrWill();
                        if (IsOver())
                        {
                            return(this);
                        }
                    }
                    movedOrHidThisTurn = true;
                }
                if (!movedOrHidThisTurn)
                {
                    Corruption++;
                    Log.Log("  lazy hobbit corruption");
                }
            }
        }
示例#6
0
文件: Trials.cs 项目: dcmorse/phial
        public Trials(FreeStrategy strategy)
        {
            var logger = new NullLogger();

            for (var i = 0; i < TrialCount; i++)
            {
                var q = new Quest(strategy, 1, logger).FromRivendell();
                if (q.IsCorrupted())
                {
                    SARVs.Increment(q.Turns);
                }
                else if (q.IsRingDestroyed())
                {
                    FPRVs.Increment(q.Turns);
                }
                else
                {
                    Debug.Assert(false, "This game isn't finished. Why?");
                }
            }
        }
示例#7
0
文件: Quest.cs 项目: dcmorse/phial
        public Quest FromRivendell()
        {
            for (Turns = 1; ; Turns++)
            {
                if (AtTheGatesOfMordor())
                {
                    EnterMordor();
                    return(MordorTrack());
                }
                ShadowActionDiceRoll shadowDice = new ShadowActionDiceRoll(7 + Minions, ShadowHuntAllocated);
                int freeHuntBoxDiceCount        = 0;
                var freeDice = new FreeActionDiceRoll(FreeActionDiceCount);
                Log.Log($"Turn {Turns}: {shadowDice.Eyes} eyes, {freeDice}");

                while (freeDice.CharacterOrWills > 0 || StriderCanHide(freeDice))
                {
                    if (PromoteGandalfIfAble(freeDice))
                    {
                        // do nothing
                    }
                    else if (StriderCanHide(freeDice))
                    {
                        Revealed = false;
                        Log.Log($"  Strider hide");
                        freeDice.SpendMostUselessDie();
                    }
                    else if (Revealed)
                    {
                        Revealed = false;
                        Log.Log($"  hide");
                        freeDice.SpendCharacterOrWill();
                    }
                    else if (AtTheGatesOfMordor())
                    {
                        EnterMordor();
                        return(MordorTrack());
                    }
                    else
                    {
                        int hits = D6.CountHits(shadowDice.Eyes, 6 - freeHuntBoxDiceCount);
                        if (hits > 0)
                        {
                            var  tile        = HuntBag.DrawTile();
                            int  huntValue   = tile.Value(hits);
                            bool wasRevealed = Revealed;
                            Log.Log($"  walk {EffectiveDistanceFromRivendell + 1} {Pluralize("step", EffectiveDistanceFromRivendell + 1)} from Rivendell  - {hits} {Pluralize("hit", hits)} - {tile}");
                            FreeStrategy.Hunt(huntValue, tile.Reveal(), tile, this);
                            ++Progress;
                            bool freshlyRevealed = (!wasRevealed) && Revealed;
                            if (freshlyRevealed)
                            {
                                RevealFellowshipOutsideMordorAndResolveStrongholdTiles();
                            }
                            ++freeHuntBoxDiceCount;
                            Log.Log($"    corruption {Corruption}, {shadowDice.Eyes} eyes");
                        }
                        else
                        {
                            Progress++;
                            Log.Log($"  walk {EffectiveDistanceFromRivendell} {Pluralize("step", EffectiveDistanceFromRivendell)} from Rivendell");
                        }
                        freeDice.SpendCharacterOrWill();
                    }
                    if (IsOver())
                    {
                        return(this);
                    }
                }
            }
        }