예제 #1
0
        private static List <PA_TreatDisease> FindAvailable_TreatDisease_Actions(
            PD_Game game
            )
        {
            int currentPlayer = game.GQ_CurrentPlayer();

            bool currentPlayerIsMedic = game.GQ_CurrentPlayer_Role() == PD_Player_Roles.Medic;

            if (currentPlayerIsMedic)
            {
                return(new List <PA_TreatDisease>());
            }

            var        currentPlayerLocation     = game.GQ_PlayerLocation(currentPlayer);
            List <int> infectionCubesTypesOnCity =
                game.GQ_InfectionCubeTypes_OnCity(currentPlayerLocation);

            List <PA_TreatDisease> availableTreatDiseaseActions = new List <PA_TreatDisease>();

            foreach (var type in infectionCubesTypesOnCity)
            {
                var action = new PA_TreatDisease(currentPlayer, currentPlayerLocation, type);
                availableTreatDiseaseActions.Add(action);
            }

            return(availableTreatDiseaseActions);
        }
        public override List <PD_MacroAction> FilterMacros(PD_Game game, PD_AI_PathFinder pathFinder, List <PD_MacroAction> allMacros)
        {
#if DEBUG
            if (game.GQ_IsInState_ApplyingMainPlayerActions() == false)
            {
                throw new System.Exception("wrong state.");
            }
#endif

            var allTreatMacros_ExecutableNow = allMacros.FindAll(
                x =>
                x.Is_TypeOf_TreatDisease_Any()
                &&
                x.Is_ExecutableNow()
                );

            if (allTreatMacros_ExecutableNow.Count == 0)
            {
                return(new List <PD_MacroAction>());
            }

            List <PD_MacroAction> noNegativeEffect_TreatMacros = new List <PD_MacroAction>();
            foreach (var macro in allTreatMacros_ExecutableNow)
            {
                double value =
                    PD_AI_CardEvaluation_Utilities
                    .Calculate_ListOfPlayerActions_Effect_On_Percent_AbilityToCureDiseases(
                        game,
                        macro.Actions_Executable_Now,
                        true
                        );
                if (value == 0)
                {
                    noNegativeEffect_TreatMacros.Add(macro);
                }
            }

            if (noNegativeEffect_TreatMacros.Count == 0)
            {
                return(new List <PD_MacroAction>());
            }

            List <PD_MacroAction> treatMacros_ofCities_InfectedWith_RequestedNumCubes = new List <PD_MacroAction>();
            foreach (var macro in noNegativeEffect_TreatMacros)
            {
                if (
                    macro.MacroAction_Type == PD_MacroAction_Type.TreatDisease_Macro
                    )
                {
                    PA_TreatDisease treatAction = (PA_TreatDisease)macro.Find_LastCommand();
                    int             destination = treatAction.CityToTreatDiseaseAt;
                    int             treatType   = treatAction.TypeOfDiseaseToTreat;
                    int             numCubesThisTypeOnThatCity =
                        game.GQ_Num_InfectionCubes_OfType_OnCity(
                            destination,
                            treatType
                            );
                    if (numCubesThisTypeOnThatCity >= MinSameCubes)
                    {
                        treatMacros_ofCities_InfectedWith_RequestedNumCubes.Add(macro);
                    }
                }
                else if (
                    macro.MacroAction_Type == PD_MacroAction_Type.TreatDisease_Medic_Macro
                    )
                {
                    PA_TreatDisease_Medic treatAction = (PA_TreatDisease_Medic)macro.Find_LastCommand();
                    int destination = treatAction.CityToTreatDiseaseAt;
                    int treatType   = treatAction.TypeOfDiseaseToTreat;
                    int numCubesThisTypeOnThatCity =
                        game.GQ_Num_InfectionCubes_OfType_OnCity(
                            destination,
                            treatType
                            );
                    if (numCubesThisTypeOnThatCity >= MinSameCubes)
                    {
                        treatMacros_ofCities_InfectedWith_RequestedNumCubes.Add(macro);
                    }
                }
                else if (
                    macro.MacroAction_Type == PD_MacroAction_Type.AutoTreatDisease_Medic_Macro
                    )
                {
                    int destination = macro.Find_Destination();
                    int treatType   = game.GQ_City_InfectionType(destination);
                    int numCubesThisTypeOnThatCity =
                        game.GQ_Num_InfectionCubes_OfType_OnCity(
                            destination,
                            treatType
                            );
                    if (numCubesThisTypeOnThatCity >= MinSameCubes)
                    {
                        treatMacros_ofCities_InfectedWith_RequestedNumCubes.Add(macro);
                    }
                }
            }

            if (treatMacros_ofCities_InfectedWith_RequestedNumCubes.Count > 0)
            {
                return(treatMacros_ofCities_InfectedWith_RequestedNumCubes);
            }
            else
            {
                return(new List <PD_MacroAction>());
            }
        }