~zanneth/SolitaireOracle

74793a8838014f30ec48df7c7d7be583531c2bba — zanneth 1 year, 3 months ago 1edcc9b master
Implement functions to solve game
M InjectedManagedAssembly/GameState.cs => InjectedManagedAssembly/GameState.cs +5 -0
@@ 74,6 74,11 @@ namespace SolitaireOracle
            }
        }

        public void SolveGame(int fortuneCardValue = 0)
        {
            InternalBoardState.SolveByDeletingTableauCards(fortuneCardValue);
        }

        private IList ScreenStack
        {
            get

M InjectedManagedAssembly/InternalBoardState.cs => InjectedManagedAssembly/InternalBoardState.cs +26 -2
@@ 35,7 35,7 @@ namespace SolitaireOracle
            }
        }

        private Suit CardSuit
        public Suit CardSuit
        {
            get
            {


@@ 44,13 44,19 @@ namespace SolitaireOracle
            }
        }

        private int CardValue
        public int CardValue
        {
            get
            {
                FieldInfo field = _type.GetField("#=qGa_rTwBFoHeQRSVVfaUd_Q==", BindingFlags.Public | BindingFlags.Instance);
                return (int)field.GetValue(_internalState);
            }

            set
            {
                FieldInfo field = _type.GetField("#=qGa_rTwBFoHeQRSVVfaUd_Q==", BindingFlags.Public | BindingFlags.Instance);
                field.SetValue(_internalState, value);
            }
        }
    }



@@ 67,6 73,24 @@ namespace SolitaireOracle
            _itemType = itemType;
        }

        public void SolveByDeletingTableauCards(int fortuneCardValue = 0)
        {
            // Create an array of empty cells.
            Array cells = Array.CreateInstance(_itemType, 11);
            for (int i = 0; i < 11; ++i)
            {
                cells.SetValue(Activator.CreateInstance(_itemType), i);
            }

            // Overwrite the tableau cell items with the empty cell items.
            FieldInfo tableauField = _boardType.GetField("#=qzsOQ0cf1yO$i8Y9aA3nQSA==", BindingFlags.Public | BindingFlags.Instance);
            tableauField.SetValue(_internalState, cells);

            // In order to influence the fortune card, change the card value of the final major foundation cell.
            InternalSolitaireItem finalMajorCell = FinalMajorFoundationCell;
            finalMajorCell.CardValue = fortuneCardValue;
        }

        public List<InternalSolitaireItem> TableauCells
        {
            get

M InjectedManagedAssembly/Main.cs => InjectedManagedAssembly/Main.cs +4 -0
@@ 75,9 75,13 @@ namespace SolitaireOracle
                {
                    Console.WriteLine("<nothing in free cell>");
                }

                // Uncomment to solve game.
                // gameState.SolveGame();
            }
            catch (MilanScreenNotVisibleException e)
            {

                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }