Exemplo n.º 1
0
 private void SpendBlankForEffect(DieSide side)
 {
     Combat.DiceRollAttack.RemoveType(side);
     DefenderSuffersDamage();
 }
Exemplo n.º 2
0
 private void SpendDieForRemoveShieldEffect(DieSide side)
 {
     DecisionSubPhase.ConfirmDecisionNoCallback();
     Combat.DiceRollAttack.RemoveType(side);
     DefenderSuffersDamage();
 }
Exemplo n.º 3
0
 private void SpendDieForExposeDamageCardEffect(DieSide side)
 {
     DecisionSubPhase.ConfirmDecisionNoCallback();
     Combat.DiceRollAttack.RemoveType(side);
     DefenderExposesDamageCard();
 }
Exemplo n.º 4
0
 private void DontUseEmperorPalpatine()
 {
     PalpatineDieChoice = DieSide.Unknown;
     Messages.ShowInfo("Emperor Palpatine was not used");
 }
Exemplo n.º 5
0
 public void SetSide(DieSide side)
 {
     Side = side;
 }
Exemplo n.º 6
0
 public void ChangeWorstResultTo(DieSide newSide)
 {
     ChangeDice(WorstResult, newSide, true);
     UpdateDiceCompareHelperPrediction();
 }
Exemplo n.º 7
0
 private void CancelResultAndFinish(DieSide dieSide)
 {
     Combat.DiceRollAttack.RemoveType(dieSide);
     Phases.CurrentSubPhase.CallBack();
     Phases.CurrentSubPhase.Resume();
 }
Exemplo n.º 8
0
        /// <summary>
        /// Adds available dice modification
        /// </summary>
        protected void AddDiceModification(
            string name,
            Func <bool> isAvailable,
            Func <int> aiPriority,
            DiceModificationType modificationType,
            Func <int> getCount,
            List <DieSide> sidesCanBeSelected = null,
            DieSide sideCanBeChangedTo        = DieSide.Unknown,
            DiceModificationTimingType timing = DiceModificationTimingType.Normal,
            bool isGlobal = false,
            Action <Action <bool> > payAbilityCost = null,
            Action payAbilityPostCost = null,
            bool isTrueReroll         = true,
            bool isForcedFullReroll   = false,
            bool isForcedModification = false
            )
        {
            if (sidesCanBeSelected == null)
            {
                sidesCanBeSelected = new List <DieSide>()
                {
                    DieSide.Blank, DieSide.Focus, DieSide.Success, DieSide.Crit
                }
            }
            ;

            GenericShip.EventHandlerShip DiceModification = (ship) =>
            {
                CustomDiceModification diceModification = new CustomDiceModification()
                {
                    Name = name,
                    DiceModificationName   = name,
                    ImageUrl               = HostImageUrl,
                    DiceModificationTiming = timing,
                    HostShip               = HostShip,
                    Source = HostUpgrade,
                    CheckDiceModificationAvailable     = isAvailable,
                    GenerateDiceModificationAiPriority = aiPriority,
                    IsForced           = isForcedModification,
                    DoDiceModification = (Action callback) =>
                    {
                        if (payAbilityCost == null)
                        {
                            payAbilityCost = payCallback => payCallback(true);
                        }

                        payAbilityCost(success =>
                        {
                            if (success)
                            {
                                GenericDiceModification(
                                    delegate
                                {
                                    if (payAbilityPostCost != null)
                                    {
                                        payAbilityPostCost();
                                    }
                                    callback();
                                },
                                    modificationType,
                                    getCount,
                                    sidesCanBeSelected,
                                    sideCanBeChangedTo,
                                    timing,
                                    isTrueReroll,
                                    isForcedFullReroll,
                                    isForcedModification
                                    );
                            }
                            else
                            {
                                callback();
                            }
                        });
                    },
                    IsReroll = modificationType == DiceModificationType.Reroll,
                };

                if (!isGlobal)
                {
                    ship.AddAvailableDiceModificationOwn(diceModification);
                }
                else
                {
                    ship.AddAvailableDiceModification(diceModification, HostShip);
                }
            };

            if (!isGlobal)
            {
                switch (timing)
                {
                case DiceModificationTimingType.AfterRolled:
                    HostShip.OnGenerateDiceModificationsAfterRolled += DiceModification;
                    DiceModificationRemovers.Add(() => HostShip.OnGenerateDiceModificationsAfterRolled -= DiceModification);
                    break;

                case DiceModificationTimingType.Normal:
                    HostShip.OnGenerateDiceModifications += DiceModification;
                    DiceModificationRemovers.Add(() => HostShip.OnGenerateDiceModifications -= DiceModification);
                    break;

                case DiceModificationTimingType.Opposite:
                    HostShip.OnGenerateDiceModificationsOpposite += DiceModification;
                    DiceModificationRemovers.Add(() => HostShip.OnGenerateDiceModificationsOpposite -= DiceModification);
                    break;

                case DiceModificationTimingType.CompareResults:
                    HostShip.OnGenerateDiceModificationsCompareResults += DiceModification;
                    DiceModificationRemovers.Add(() => HostShip.OnGenerateDiceModificationsCompareResults -= DiceModification);
                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (timing)
                {
                case DiceModificationTimingType.AfterRolled:
                    GenericShip.OnGenerateDiceModificationsAfterRolledGlobal += DiceModification;
                    DiceModificationRemovers.Add(() => GenericShip.OnGenerateDiceModificationsAfterRolledGlobal -= DiceModification);
                    break;

                case DiceModificationTimingType.Normal:
                    GenericShip.OnGenerateDiceModificationsGlobal += DiceModification;
                    DiceModificationRemovers.Add(() => GenericShip.OnGenerateDiceModificationsGlobal -= DiceModification);
                    break;

                case DiceModificationTimingType.Opposite:
                    GenericShip.OnGenerateDiceModificationsOppositeGlobal += DiceModification;
                    DiceModificationRemovers.Add(() => GenericShip.OnGenerateDiceModificationsOppositeGlobal -= DiceModification);
                    break;

                case DiceModificationTimingType.CompareResults:
                    GenericShip.OnGenerateDiceModificationsCompareResultsGlobal += DiceModification;
                    DiceModificationRemovers.Add(() => GenericShip.OnGenerateDiceModificationsCompareResultsGlobal -= DiceModification);
                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 9
0
        private void DiceModificationChange(Action callback, Func <int> getCount, List <DieSide> sidesCanBeSelected, DieSide newSide)
        {
            //TODO: Change to select dice manager

            DieSide oldSide = DieSide.Unknown;

            foreach (DieSide side in sidesCanBeSelected)
            {
                if (DiceRoll.CurrentDiceRoll.HasResult(side))
                {
                    oldSide = side;
                    break;
                }
            }

            if (oldSide != DieSide.Unknown)
            {
                Combat.CurrentDiceRoll.Change(oldSide, newSide, getCount());
                callback();
            }
            else
            {
                callback();
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// Adds available dice modification
 /// </summary>
 protected void AddDiceModification(string name, Func <bool> isAvailable, Func <int> aiPriority, DiceModificationType modificationType, int count, List <DieSide> sidesCanBeSelected = null, DieSide sideCanBeChangedTo = DieSide.Unknown, DiceModificationTimingType timing = DiceModificationTimingType.Normal, bool isGlobal = false, Action <Action <bool> > payAbilityCost = null, Action payAbilityPostCost = null, bool isTrueReroll = true)
 {
     AddDiceModification(
         name,
         isAvailable,
         aiPriority,
         modificationType,
         delegate { return(count); },
         sidesCanBeSelected,
         sideCanBeChangedTo,
         timing,
         isGlobal,
         payAbilityCost,
         payAbilityPostCost,
         isTrueReroll
         );
 }
Exemplo n.º 11
0
        private void GenericDiceModification(Action callback, DiceModificationType modificationType, Func <int> getCount, List <DieSide> sidesCanBeSelected, DieSide newSide, DiceModificationTimingType timing, bool isTrueReroll = true)
        {
            switch (modificationType)
            {
            case DiceModificationType.Reroll:
                DiceModificationReroll(callback, getCount, sidesCanBeSelected, timing, isTrueReroll);
                break;

            case DiceModificationType.Change:
                DiceModificationChange(callback, getCount, sidesCanBeSelected, newSide);
                break;

            case DiceModificationType.Cancel:
                DiceModificationCancel(callback, sidesCanBeSelected, timing);
                break;

            case DiceModificationType.Add:
                DiceModificationAdd(callback, getCount, newSide);
                break;

            default:
                break;
            }
        }
Exemplo n.º 12
0
 private void ModifyDice(DieSide oldDieSide, DieSide newDieSide, int count)
 {
     DiceRoll.CurrentDiceRoll.Change(oldDieSide, newDieSide, count);
 }
 public Die(DieSide side, bool is_selected = false)
 {
     Side     = side;
     Selected = is_selected;
 }
Exemplo n.º 14
0
 public void ChangeOne(DieSide oldSide, DieSide newSide, bool cannotBeRerolled = false)
 {
     ChangeDice(oldSide, newSide, true, cannotBeRerolled);
     UpdateDiceCompareHelperPrediction();
 }
Exemplo n.º 15
0
 private void Skip()
 {
     NamedResult = DieSide.Unknown;
 }
Exemplo n.º 16
0
 public void ChangeAll(DieSide oldSide, DieSide newSide)
 {
     ChangeDice(oldSide, newSide, false);
     UpdateDiceCompareHelperPrediction();
 }
Exemplo n.º 17
0
 public bool HasResult(DieSide side)
 {
     return(DiceList.Any(n => n.Side == side));
 }
Exemplo n.º 18
0
    public DieSide FindDieToChange(DieSide destinationSide)
    {
        if (DiceList.Count <= 0)
        {
            Messages.ShowErrorToHuman("No dice in this roll to change.");
            return(DieSide.Unknown);
        }

        if (destinationSide != DieSide.Blank)
        {
            if (Blanks > 0)
            {
                return(DieSide.Blank);
            }
            if (Focuses > 0)
            {
                return(DieSide.Focus);
            }
            if (Successes > 0)
            {
                return(DieSide.Success);
            }
            if (CriticalSuccesses > 0)
            {
                return(DieSide.Crit);
            }
        }
        else
        {   // Asking for blanks. We could put a switch case here to account for different CheckType situations.
            // This currently handles CheckType == Check well, which is I think where most people would ask for a blank.
            if (Type == DiceKind.Attack)
            {
                if (CriticalSuccesses > 0)
                {
                    return(DieSide.Crit);
                }
                if (Successes > 0)
                {
                    return(DieSide.Success);
                }
                if (Focuses > 0)
                {
                    return(DieSide.Focus);
                }
                if (Blanks > 0)
                {
                    return(DieSide.Blank);
                }
            }
            else
            {
                if (Focuses > 0)
                {
                    return(DieSide.Focus);
                }
                if (Successes > 0)
                {
                    return(DieSide.Success);
                }
                if (Blanks > 0)
                {
                    return(DieSide.Blank);
                }
            }
        }
        return(DieSide.Unknown); // We never should get here
    }
Exemplo n.º 19
0
 public void ChangeAll(DieSide oldSide, DieSide newSide, bool cannotBeRerolled = false, bool cannotBeModified = false)
 {
     ChangeDice(oldSide, newSide, false, cannotBeRerolled, cannotBeModified);
     UpdateDiceCompareHelperPrediction();
 }
Exemplo n.º 20
0
 private void DontUseEmperorPalpatine(object sender, System.EventArgs e)
 {
     PalpatineDieChoice = DieSide.Unknown;
     Messages.ShowInfo("Emperor Palpatine not used");
     DecisionSubPhase.ConfirmDecision();
 }