예제 #1
0
        private bool PosValidate(List <Coord> atkRange)
        {
            bool enmyInRange = false;

            Unit unit = Oponent.GetUnitAt(Target);

            foreach (Coord cell in atkRange)
            {
                if (unit.InUnit(cell))
                {
                    enmyInRange = true;
                    break;
                }
            }

            if (!enmyInRange)
            {
                ErrorMsg = NO_ENEMIES;
                return(false);
            }
            else if (!atkRange.Contains(Target))
            {
                ErrorMsg = OUT_OF_RANGE;
                return(false);
            }
            return(true);
        }
예제 #2
0
        protected override bool Validate()
        {
            bool valid = true;

            if (!Coord.IsValid(AllyPos) || !Coord.IsValid(Target))
            {
                ErrorMsg = INVALID_POS;
                valid    = false;
            }
            else if (Oponent == null)
            {
                ErrorMsg = NO_OPONENT;
                valid    = false;
            }
            else if (CurPlayer == null)
            {
                ErrorMsg = PLAYER;
                valid    = false;
            }
            else if (Boards == null)
            {
                ErrorMsg = NO_BOARDS;
                valid    = false;
            }
            else
            {
                APawn allyPawn = CurPlayer.GetPawnAt(AllyPos);
                if (allyPawn is ABasicPawn)
                {
                    ABasicPawn allyAttackerPawn = CurPlayer.GetPawnAt(AllyPos) as ABasicPawn;
                    if (allyPawn == null)
                    {
                        ErrorMsg = NO_PAWN;
                        valid    = false;
                    }
                    else if (Oponent.GetUnitAt(Target) == null)
                    {
                        ErrorMsg = NO_PAWN;
                        valid    = false;
                    }
                }
                else
                {
                    valid = false;
                }
            }
            return(valid);
        }
예제 #3
0
        public override double Value()
        {
            double total = 10;

            if (Oponent.GetUnitAt(Target) is CulturalCenter)
            {
                total += 1.0;
            }
            double remainingHealth = Oponent.GetUnitAt(Target).CurrLife / Oponent.GetUnitAt(Target).TotalLife;

            if (remainingHealth < 0.5)
            {
                total += 3.0;
            }
            if (Coord.Distance(Target, CurPlayer.GetCultCenter().Position) < BoardConsts.MAX_COL / 2)
            {
                total += 1 + 100 / Coord.Distance(Target, CurPlayer.GetCultCenter().Position);
            }
            return(total);
        }
예제 #4
0
        public override bool Execute(bool isSimulation = false)
        {
            bool valid = false;

            if (Validate())
            {
                ABasicPawn   allyPawn = (ABasicPawn)CurPlayer.GetPawnAt(AllyPos);
                Dijkstra     didi     = new Dijkstra(Boards.GetBoard(), AllyPos, allyPawn.AtkRange);
                List <Coord> atkRange = didi.GetValidPaths(Command.ATTACK);
                if (PosValidate(atkRange))
                {
                    valid = true;
                    Unit enemyUnit = Oponent.GetUnitAt(Target);
                    int  damage    = allyPawn.Atk - enemyUnit.Def;
                    if (damage > 0)
                    {
                        HitMsg             = String.Format("{0} HAVE DEALT {1} DAMAGE!", allyPawn.Culture, damage);
                        enemyUnit.CurrLife = enemyUnit.CurrLife - damage;
                        if (enemyUnit.CurrLife <= 0)
                        {
                            Oponent.RemoveUnitAt(Target, Boards);
                            HitMsg += " ENEMY KILLED!!";
                        }
                    }
                    else
                    {
                        HitMsg = BLOCK;
                    }
                }
            }
            //if (!isSimulation) {
            //    UserUtils.PrintSucess((valid) ? (HitMsg) : (ErrorMsg));
            //    Console.ReadLine();
            //}
            return(valid);
        }