Exemplo n.º 1
0
 public bool RemoveEffect(IEffect effect)
 {
     lock ( SyncRoot )
     {
         return(Slots.Any(item => item.RemoveEffect(effect)));
     }
 }
Exemplo n.º 2
0
 public bool Contains(IEffect effect)
 {
     lock ( SyncRoot )
     {
         return(Slots.Any(item => item.Contains(effect)));
     }
 }
Exemplo n.º 3
0
        private async Task <DialogTurnResult> PromptForVehiclePlateNumberConfirmationStepAsync(WaterfallStepContext step, CancellationToken cancellationToken)
        {
            var state = await _stateAccessor.GetAsync(step.Context, cancellationToken : cancellationToken);

            if (!Slots.Any(s => s.StartTime == state.StartDate?.Hour) && step.Result is FoundChoice choice)
            {
                state.StartDate = state.SlotChoices[choice.Index];
                await _stateAccessor.SetAsync(step.Context, state, cancellationToken);
            }

            // Check last settings
            if (string.IsNullOrEmpty(state.VehiclePlateNumber) &&
                !string.IsNullOrEmpty(state.LastSettings?.VehiclePlateNumber))
            {
                state.VehiclePlateNumber = state.LastSettings.VehiclePlateNumber;
            }

            // Check whether we don't know the vehicle plate number.
            if (string.IsNullOrEmpty(state.VehiclePlateNumber))
            {
                return(await step.NextAsync(cancellationToken : cancellationToken));
            }

            return(await step.PromptAsync(
                       VehiclePlateNumberConfirmationPromptName,
                       new PromptOptions
            {
                Prompt = MessageFactory.Text($"I have {state.VehiclePlateNumber} as your plate number, is that correct?"),
            },
                       cancellationToken));
        }
Exemplo n.º 4
0
 public bool AddEffect(IEffect effect)
 {
     lock ( SyncRoot )
     {
         return(Slots.Any(item => item.SetEffect(effect)));
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// 移除一张卡牌
        /// </summary>
        /// <param name="card">要移除的卡牌</param>
        /// <returns>是否移除成功</returns>
        public bool RemoveCard(TCard card)
        {
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }

            lock ( SyncRoot )
            {
                return(Slots.Any(item => card.Equals(item.Card) && item.RemoveCard()));
            }
        }
Exemplo n.º 6
0
        public String GetSummary(bool includeProfile, bool includeWargear)
        {
            StringBuilder sbSummary  = new StringBuilder();
            string        helpString = Name + " [+" + CommandPoints + " CP] [" + CurrentPowerlevel + " Powerlvl, " + CurrentPoints + " Pkt.]";


            sbSummary.AppendLine(new String('.', helpString.Length));
            sbSummary.AppendLine(helpString);
            sbSummary.AppendLine(new String('.', helpString.Length));

            #region quick summary <number> <slot>
            if (Slots != null && Slots.Any())
            {
                foreach (Slot slot in Slots)
                {
                    if (slot.CreatedUnits != null && slot.CreatedUnits.Any())
                    {
                        int numberOfEntries = 0;
                        foreach (Unit unit in slot.CreatedUnits)
                        {
                            numberOfEntries += 1;
                        }

                        sbSummary.AppendLine(numberOfEntries + " " + slot.BattleRole.Name);
                    }
                }
            }
            #endregion

            sbSummary.AppendLine();

            if (Slots != null && Slots.Any())
            {
                foreach (Slot slot in Slots)
                {
                    if (slot.CreatedUnits != null && slot.CreatedUnits.Any())
                    {
                        String slotHeadline = "[" + slot.BattleRole.Name.ToUpper() + "]";
                        sbSummary.AppendLine(slotHeadline);
                        sbSummary.AppendLine(new String('=', slotHeadline.Length));
                        foreach (Unit unit in slot.CreatedUnits)
                        {
                            sbSummary.AppendLine(unit.GetSummary(includeProfile, includeWargear));
                        }
                    }
                }
            }

            return(sbSummary.ToString());
        }
Exemplo n.º 7
0
        protected override void InstantiationFinished()
        {
            base.InstantiationFinished();
            var gnrl = AlphaClient.Instance.GetRoot <GeneralVM>();

            Instruments = gnrl.DerivativeVMs;
            Slots       = CreateObservableCollection(m_slots);

            CollectionViewSource.GetDefaultView(Instruments).Filter = InstrumentsFilter;
            CollectionViewSource.GetDefaultView(Slots).Filter       = SlotsFilter;

            CollectionViewSource.GetDefaultView(Slots).CollectionChanged += SlotsCollectionChanged;

            AddCommand    = new RelayCommand(ExecuteAdd, _o => Instruments.Any(_vm => _vm.Selected && InstrumentsFilter(_vm)));
            RemoveCommand = new RelayCommand(ExecuteRemove, _o => Slots.Any(_vm => _vm.Selected && SlotsFilter(_vm)));
        }
Exemplo n.º 8
0
        private string GetCastIntentName()
        {
            if (Slots == null || !Slots.Any())
            {
                return("Cast: Unknown");
            }

            if (Slots.Any(x => x.Name == "person"))
            {
                return("Get Character");
            }

            if (Slots.Any(x => x.Name == "character"))
            {
                return("Get Actor");
            }

            return("Get Cast");
        }
Exemplo n.º 9
0
 public bool Contains(Item item)
 => Slots.Any(x => x.Id == item.Id);
Exemplo n.º 10
0
        private async Task <DialogTurnResult> PromptForSlotStepAsync(WaterfallStepContext step, CancellationToken cancellationToken)
        {
            var state = await _stateAccessor.GetAsync(step.Context, cancellationToken : cancellationToken);

            if (state.StartDate == null && step.Result is IList <DateTimeResolution> resolution)
            {
                var timex = new TimexProperty(resolution[0].Timex);
                state.Timex = timex;
                var hour = timex.Hour ?? 0;
                state.StartDate = new DateTime(
                    timex.Year.Value,
                    timex.Month.Value,
                    timex.DayOfMonth.Value,
                    hour,
                    0,
                    0);
                await _stateAccessor.SetAsync(step.Context, state, cancellationToken);
            }

            var reservationCapacity = new List <CarwashService.ReservationCapacity>();

            try
            {
                var api = new CarwashService(step, cancellationToken);

                reservationCapacity = (List <CarwashService.ReservationCapacity>) await api.GetReservationCapacityAsync(state.StartDate.Value, cancellationToken);
            }
            catch (AuthenticationException)
            {
                await step.Context.SendActivityAsync(AuthDialog.NotAuthenticatedMessage, cancellationToken : cancellationToken);

                return(await step.ClearStateAndEndDialogAsync(_stateAccessor, cancellationToken : cancellationToken));
            }
            catch (Exception e)
            {
                _telemetryClient.TrackException(e);
                await step.Context.SendActivityAsync(e.Message, cancellationToken : cancellationToken);

                return(await step.ClearStateAndEndDialogAsync(_stateAccessor, cancellationToken : cancellationToken));
            }

            // Check whether we already know the slot.
            if (Slots.Any(s => s.StartTime == state.StartDate?.Hour))
            {
                // Check if slot is available.
                if (!reservationCapacity.Any(c => c.StartTime == state.StartDate && c.FreeCapacity > 0))
                {
                    await step.Context.SendActivityAsync("Sorry, this slot is already full.", cancellationToken : cancellationToken);
                }
                else
                {
                    return(await step.NextAsync(cancellationToken : cancellationToken));
                }
            }
            else if (!string.IsNullOrEmpty(state.Timex?.PartOfDay))
            {
                // Check whether we can find out the slot from timex.
                Slot slot = null;
                switch (state.Timex.PartOfDay)
                {
                case "MO":
                    slot = Slots[0];
                    break;

                case "AF":
                    slot = Slots[1];
                    break;

                case "EV":
                    slot = Slots[2];
                    break;
                }

                if (slot != null)
                {
                    state.StartDate = new DateTime(
                        state.StartDate.Value.Year,
                        state.StartDate.Value.Month,
                        state.StartDate.Value.Day,
                        slot.StartTime,
                        0,
                        0);

                    await _stateAccessor.SetAsync(step.Context, state, cancellationToken);

                    return(await step.NextAsync(cancellationToken : cancellationToken));
                }
            }

            var choices = new List <Choice>();

            state.SlotChoices = new List <DateTime>();
            foreach (var slot in reservationCapacity)
            {
                if (slot.FreeCapacity < 1)
                {
                    continue;
                }

                choices.Add(new Choice($"{slot.StartTime.ToNaturalLanguage()} ({slot.StartTime.Hour}-{Slots.Single(s => s.StartTime == slot.StartTime.Hour).EndTime})"));

                // Save recommendations to state
                state.SlotChoices.Add(slot.StartTime);
            }

            await _stateAccessor.SetAsync(step.Context, state, cancellationToken);

            return(await step.PromptAsync(
                       SlotPromptName,
                       new PromptOptions
            {
                Prompt = MessageFactory.Text("Please choose one of these slots:"),
                Choices = choices,
            },
                       cancellationToken));
        }
Exemplo n.º 11
0
 public bool OccupiedByUnit(OwnedIdol idol)
 {
     return(Slots.Any(x => x == idol));
 }
Exemplo n.º 12
0
 public bool AlreadyInUnit(OwnedIdol idol)
 {
     return(Slots.Any(x => x?.Iid == idol.Iid));
 }
Exemplo n.º 13
-1
        private int GetAppeal(OwnedIdol idol, AppealType type)
        {
            if (idol == null)
            {
                return(0);
            }

            var effect   = Center?.CenterEffect;
            var rawValue = (int)idol.GetType().GetProperty(type.ToString()).GetValue(idol);

            if (effect != null)
            {
                if (effect is CenterEffect.AppealUp)
                {
                    var e = effect as CenterEffect.AppealUp;
                    if (e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(type) == true)
                    {
                        return((int)Math.Ceiling(Math.Round(rawValue + rawValue * e.Rate, 3)));
                    }
                }
                else if (effect is CenterEffect.ConditionalAppealUp)
                {
                    var e = effect as CenterEffect.ConditionalAppealUp;
                    var conditionFulfilled = false;
                    switch (e.Condition)
                    {
                    case AppealUpCondition.UnitContainsAllTypes:
                        conditionFulfilled = Slots.Any(x => x.Category == IdolCategory.Cool) &&
                                             Slots.Any(x => x.Category == IdolCategory.Cute) &&
                                             Slots.Any(x => x.Category == IdolCategory.Passion);
                        break;

                    default:
                        break;
                    }

                    if (conditionFulfilled && e.Targets.HasFlag(idol.Category) == true && e.TargetAppeal.HasFlag(type) == true)
                    {
                        return((int)Math.Ceiling(Math.Round(rawValue + rawValue * e.Rate, 3)));
                    }
                }
            }

            return(rawValue);
        }