Example #1
0
        public bool IsShipInSector(GenericShip anotherShip, ArcType arcType)
        {
            GenericArc  arc     = Arcs.First(n => n.ArcType == arcType);
            ShotInfoArc arcInfo = new ShotInfoArc(HostShip, anotherShip, arc);

            return(arcInfo.IsShotAvailable);
        }
Example #2
0
        public int RangeToShipBySector(GenericShip anotherShip, ArcType arcType)
        {
            GenericArc  arc     = Arcs.First(n => n.ArcType == arcType);
            ShotInfoArc arcInfo = new ShotInfoArc(HostShip, anotherShip, arc);

            return(arcInfo.Range);
        }
Example #3
0
        private bool IsPossibleRedirectTarget(GenericShip ship)
        {
            bool result = false;

            if (ship.ShipId == HostShip.ShipId)
            {
                return(false);
            }

            DistanceInfo distInfo = new DistanceInfo(HostShip, ship);

            if (distInfo.Range > 1)
            {
                return(false);
            }

            foreach (GenericArc arc in Combat.Attacker.ArcsInfo.Arcs)
            {
                ShotInfoArc shotInfoArcDefender = new ShotInfoArc(Combat.Attacker, HostShip, arc);
                if (shotInfoArcDefender.InArc && shotInfoArcDefender.IsShotAvailable)
                {
                    ShotInfoArc shotInfoArcRedirect = new ShotInfoArc(Combat.Attacker, ship, arc);
                    if (shotInfoArcRedirect.InArc && shotInfoArcDefender.IsShotAvailable)
                    {
                        return(true);
                    }
                }
            }

            return(result);
        }
Example #4
0
        private void GetShipsInAllArcDirections()
        {
            ArcMobile temporaryArc = new ArcMobile(Selection.ThisShip.ShipBase);

            Selection.ThisShip.ArcInfo.Arcs.Add(temporaryArc);

            EnemiesInArcHolder = new Dictionary <ArcFacing, List <GenericShip> >();

            foreach (var arc in ArcFacings)
            {
                EnemiesInArcHolder.Add(arc, new List <GenericShip>());

                foreach (GenericShip enemyShip in Roster.GetPlayer(Roster.AnotherPlayer(Selection.ThisShip.Owner.PlayerNo)).Ships.Values)
                {
                    temporaryArc.Facing = arc;

                    if (Selection.ThisShip.ShipsBumped.Contains(enemyShip))
                    {
                        continue;
                    }
                    if (Selection.ThisShip.ShipBaseArcsType == BaseArcsType.ArcMobileDual && (arc == ArcFacing.Right || arc == ArcFacing.Rear))
                    {
                        continue;
                    }

                    ShotInfoArc arcShotInfo = new ShotInfoArc(Selection.ThisShip, enemyShip, temporaryArc);
                    if (arcShotInfo.InArc && arcShotInfo.Range < 4)
                    {
                        EnemiesInArcHolder[arc].Add(enemyShip);
                    }
                    else if (Selection.ThisShip.ShipBaseArcsType == BaseArcsType.ArcMobile) // With primary firing arc
                    {
                        ShotInfoArc arcPrimaryShotInfo = new ShotInfoArc(Selection.ThisShip, enemyShip, Selection.ThisShip.ArcInfo.GetArc <ArcPrimary>());
                        if (arcPrimaryShotInfo.InArc && arcPrimaryShotInfo.Range < 4)
                        {
                            EnemiesInArcHolder[arc].Add(enemyShip);
                        }
                    }
                    else if (Selection.ThisShip.ShipBaseArcsType == BaseArcsType.ArcMobileDual)
                    {
                        temporaryArc.Facing = DualPointerArcs[arc];
                        ShotInfoArc secondArcShotInfo = new ShotInfoArc(Selection.ThisShip, enemyShip, temporaryArc);
                        if (secondArcShotInfo.InArc && secondArcShotInfo.Range < 4)
                        {
                            EnemiesInArcHolder[arc].Add(enemyShip);
                        }
                    }
                }
            }

            Selection.ThisShip.ArcInfo.Arcs.Remove(temporaryArc);
        }
Example #5
0
        public bool IsShipInSector(GenericShip anotherShip, ArcType arcType)
        {
            GenericArc  arc     = Arcs.First(n => n.ArcType == arcType);
            ShotInfoArc arcInfo = new ShotInfoArc(HostShip, anotherShip, arc);

            bool result = arcInfo.IsShotAvailable;

            if (arcType == ArcType.Bullseye)
            {
                HostShip.CallOnBullseyeArcCheck(anotherShip, ref result);
            }

            return(result);
        }
Example #6
0
        private int GetDiceCount()
        {
            List <GenericShip> shipsInAttackArc = new List <GenericShip>();

            foreach (GenericShip ship in Roster.AllShips.Values)
            {
                ShotInfoArc inArcCheck = new ShotInfoArc(HostShip, ship, Combat.ArcForShot);
                if (inArcCheck.InArc)
                {
                    shipsInAttackArc.Add(ship);
                }
            }

            return(shipsInAttackArc.Count);
        }
Example #7
0
        private bool HasTargetForWeapons(List <GenericArc> arcs)
        {
            foreach (GenericArc arc in arcs)
            {
                foreach (GenericShip enemyShip in HostShip.Owner.EnemyShips.Values)
                {
                    ShotInfoArc shotInfoArc = new ShotInfoArc(HostShip, enemyShip, arc);
                    if (shotInfoArc.IsShotAvailable)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #8
0
        private bool IsAvailable()
        {
            int shipsInAttackArc = 0;

            foreach (GenericShip ship in Roster.AllShips.Values)
            {
                ShotInfoArc shotInfoArc = new ShotInfoArc(HostShip, ship, Combat.ArcForShot);
                if (shotInfoArc.InArc)
                {
                    shipsInAttackArc++;
                }
            }

            return(Combat.AttackStep == CombatStep.Attack &&
                   shipsInAttackArc == 1 &&
                   Combat.DiceRollAttack.HasResult(DieSide.Focus));
        }
Example #9
0
        protected virtual bool CheckInArcRequirements(GenericShip ship)
        {
            foreach (GenericArc arc in Combat.Attacker.ArcsInfo.Arcs)
            {
                ShotInfoArc shotInfoArcDefender = new ShotInfoArc(Combat.Attacker, HostShip, arc);
                if (shotInfoArcDefender.InArc && shotInfoArcDefender.IsShotAvailable)
                {
                    ShotInfoArc shotInfoArcRedirect = new ShotInfoArc(Combat.Attacker, ship, arc);
                    if (shotInfoArcRedirect.InArc && shotInfoArcDefender.IsShotAvailable)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #10
0
 private static string ArcRangeInfoToText(ShotInfoArc info)
 {
     if (info.InArc)
     {
         if (info.Range < 4)
         {
             return(info.Range.ToString());
         }
         else
         {
             return("Beyond range 3");
         }
     }
     else
     {
         return("Not in arc");
     }
 }
Example #11
0
        public Dictionary <ArcFacing, List <GenericShip> > GetEnemiesInAllSectors()
        {
            Dictionary <ArcFacing, List <GenericShip> > EnemiesInAllSectors = new Dictionary <ArcFacing, List <GenericShip> >();

            foreach (GenericArc sector in Sectors)
            {
                EnemiesInAllSectors.Add(sector.Facing, new List <GenericShip>());
                foreach (GenericShip enemyShip in HostShip.Owner.AnotherPlayer.Ships.Values)
                {
                    ShotInfoArc sectorInfo = new ShotInfoArc(HostShip, enemyShip, sector);
                    if (sectorInfo.InArc && sectorInfo.Range != 0)
                    {
                        EnemiesInAllSectors[sector.Facing].Add(enemyShip);
                    }
                }
            }

            return(EnemiesInAllSectors);
        }
Example #12
0
        public int RangeToShipBySector(GenericShip anotherShip, ArcType arcType)
        {
            ShotInfoArc arcInfo = GetSectorInfo(anotherShip, arcType);

            if (arcInfo != null)
            {
                bool result = arcInfo.IsShotAvailable;
                if (arcType == ArcType.Bullseye)
                {
                    HostShip.CallOnBullseyeArcCheck(anotherShip, ref result);
                }

                return(result ? arcInfo.Range : int.MaxValue);
            }
            else
            {
                return(int.MaxValue);
            }
        }
Example #13
0
        public bool IsShipInSector(GenericShip anotherShip, ArcType arcType)
        {
            ShotInfoArc arcInfo = GetSectorInfo(anotherShip, arcType);

            if (arcInfo != null)
            {
                bool result = arcInfo.IsShotAvailable;
                if (arcType == ArcType.Bullseye)
                {
                    HostShip.CallOnBullseyeArcCheck(anotherShip, ref result);
                }

                return(result);
            }
            else
            {
                return(false);
            }
        }
Example #14
0
        private bool IsAvailable()
        {
            bool result = false;

            if (Combat.AttackStep == CombatStep.Defence && Combat.Attacker.Owner.PlayerNo != HostShip.Owner.PlayerNo)
            {
                ShotInfoArc arcInfo = new ShotInfoArc(
                    HostShip,
                    Combat.Attacker,
                    HostShip.SectorsInfo.Arcs.First(n => n.Facing == Arcs.ArcFacing.Front)
                    );

                if (arcInfo.Range <= 1)
                {
                    result = true;
                }
            }

            return(result);
        }