Exemplo n.º 1
0
        public bool IsShotAvailable(GenericShip targetShip)
        {
            bool result = true;

            int minRange = WeaponInfo.MinRange;
            int maxRange = WeaponInfo.MaxRange;

            HostShip.CallUpdateWeaponRange(this, ref minRange, ref maxRange, targetShip);

            ShotInfo shotInfo = new ShotInfo(HostShip, targetShip, this);

            if (!shotInfo.IsShotAvailable)
            {
                return(false);
            }

            if (shotInfo.Range < minRange)
            {
                return(false);
            }
            if (shotInfo.Range > maxRange)
            {
                return(false);
            }

            return(result);
        }
        public virtual bool IsShotAvailable(GenericShip targetShip)
        {
            bool result = true;

            int MinRangeUpdated = WeaponInfo.MinRange;
            int MaxRangeUpdated = WeaponInfo.MaxRange;

            HostShip.CallUpdateWeaponRange(this, ref MinRangeUpdated, ref MaxRangeUpdated);

            if (!State.IsFaceup)
            {
                return(false);
            }

            if (State.UsesCharges && State.Charges == 0)
            {
                return(false);
            }

            ShotInfo shotInfo = new ShotInfo(HostShip, targetShip, this);
            int      range    = shotInfo.Range;

            if (!shotInfo.IsShotAvailable)
            {
                return(false);
            }

            if (range < MinRangeUpdated)
            {
                return(false);
            }
            if (range > MaxRangeUpdated)
            {
                return(false);
            }

            if (!AreTokenRequirementsMet(targetShip))
            {
                return(false);
            }

            return(result);
        }
Exemplo n.º 3
0
        public virtual bool IsShotAvailable(GenericShip targetShip)
        {
            bool result = true;

            int MinRangeUpdated = WeaponInfo.MinRange;
            int MaxRangeUpdated = WeaponInfo.MaxRange;

            HostShip.CallUpdateWeaponRange(this, ref MinRangeUpdated, ref MaxRangeUpdated);

            if (!State.IsFaceup)
            {
                return(false);
            }

            if (State.UsesCharges && State.Charges == 0)
            {
                return(false);
            }

            ShotInfo shotInfo = new ShotInfo(HostShip, targetShip, this);
            int      range    = shotInfo.Range;

            if (!shotInfo.IsShotAvailable)
            {
                return(false);
            }

            if (range < MinRangeUpdated)
            {
                return(false);
            }
            if (range > MaxRangeUpdated)
            {
                return(false);
            }

            Type tokenRequirement = HostShip.GetWeaponAttackRequirement(this, isSilent: true);

            if (tokenRequirement == typeof(BlueTargetLockToken))
            {
                List <GenericToken> waysToPay = new List <GenericToken>();

                List <char>  letters         = ActionsHolder.GetTargetLocksLetterPairs(HostShip, targetShip);
                GenericToken targetLockToken = HostShip.Tokens.GetToken(typeof(BlueTargetLockToken), letters.FirstOrDefault());
                if (targetLockToken != null)
                {
                    waysToPay.Add(targetLockToken);
                }

                HostShip.CallOnGenerateAvailableAttackPaymentList(waysToPay);

                if (waysToPay.Count == 0)
                {
                    return(false);
                }
            }
            else if (tokenRequirement != null)
            {
                if (!HostShip.Tokens.HasToken(tokenRequirement))
                {
                    return(false);
                }
            }

            return(result);
        }