public bool CheckUnitTypeCount(ExtOrder extOrder)
 {
     return(extOrder.Step.ExtGameUserInfo.ExtUnit
            .Count(p => p.TempUnitType == this) < this.WCFUnitType.Count
         ? true
         : false);
 }
 void OrderTypeMenu2_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     _ExtOrder = (ExtOrder)e.NewValue;
 }
Exemple #3
0
 private void OrderView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     _ExtOrder = (ExtOrder)DataContext;
 }
Exemple #4
0
        private void ExtOrder_SelectedOrderChange(ExtOrder newValue)
        {
            if (string.IsNullOrEmpty(newValue.WCFOrder.OrderType) ||
                string.IsNullOrEmpty(this.WCFOrder.OrderType))
            {
                return;
            }

            if (newValue == this)
            {
                switch (newValue.ExtOrderType.WCFOrderType.DoType)
                {
                case "Набег":
                    Step.Game.ClientStep.WCFStep.Raid = new WCFRaid
                    {
                        SourceOrder = newValue.WCFOrder.Id
                    };
                    break;

                case "Поход":
                case "Отступление":
                case "Усиление_власти":
                case "Усиление_власти_Вестерос":
                    Step.Game.ClientStep.ExtMarch.Clear();
                    Step.Game.ClientStep.ExtMarch.WCFMarch.SourceOrder = newValue.WCFOrder.Id.ToString();
                    break;

                default:
                    break;
                }
            }
            else
            {
                this.IsSelected = false;

                switch (newValue.ExtOrderType.WCFOrderType.DoType)
                {
                case "Набег":
                    //только чужие приказы
                    if (this.Step.WCFStep.GameUser == newValue.Step.WCFStep.GameUser)
                    {
                        return;
                    }
                    //только соседние приказы
                    if (this.ExtTerrain.JoinTerrainCol
                        .SingleOrDefault(p => p.Order == newValue) == null)
                    {
                        return;
                    }
                    if (newValue.ExtTerrain.WCFTerrain.TerrainType == "Земля" &&
                        this.ExtTerrain.WCFTerrain.TerrainType != "Земля")
                    {
                        return;
                    }
                    //не походы
                    if (this.ExtOrderType.WCFOrderType.DoType == "Поход")
                    {
                        return;
                    }
                    //если усиленный приказ то можно снять оборону
                    if (!newValue.ExtOrderType.WCFOrderType.IsSpecial &&
                        this.ExtOrderType.WCFOrderType.DoType == "Оборона")
                    {
                        return;
                    }

                    this.Opacity        = 1;
                    this.RaidVisibility = Visibility.Visible;
                    break;

                default:
                    break;
                }
            }
        }
Exemple #5
0
        public bool CheckStep()
        {
            switch (WCFStep.StepType)
            {
            case "Событие_Вестероса":
                if (WCFStep.VesterosAction.ActionNumber == null)
                {
                    App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), Name);
                    return(false);
                }
                break;

            case "Доран_Мартелл":
                if (WCFStep.BattleUser.AdditionalEffect == null)
                {
                    App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_Track"));
                    return(false);
                }
                break;

            case "Набег":
            case "Усиление_власти":
            case "Усиление_власти_Вестерос":
            case "Поход":
                if (Game.SelectedOrder == null)
                {
                    App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_order"));
                    return(false);
                }
                break;

            case "Сражение":
                if (string.IsNullOrEmpty(WCFStep.BattleUser.HomeCardType))
                {
                    App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_homeCard"));
                    return(false);
                }
                break;
            }

            if (WCFStep.StepType == "Поход")
            {
                //Количество нападений
                IEnumerable <ExtTerrain> tempTerrain = ExtMarch.ExtMarchUnit.Select(p => p.ExtUnit.TempTerrain).Distinct();
                AttackTerrain = tempTerrain.Where(p => (p.ExtHolderUser != this.ExtGameUser && (p.Unit.Count() > 0 || p.ExtGarrison != null)) ||
                                                  (p.ExtHolderUser == null && p.ExtGarrison != null));
                switch (AttackTerrain.Count())
                {
                case 0: break;

                case 1:
                    //Нейтральные лорды
                    ExtTerrain garrisonTerrain = AttackTerrain.SingleOrDefault(p => p.ExtHolderUser == null && p.ExtGarrison != null);
                    if (garrisonTerrain != null)
                    {
                        int resultStrength = garrisonTerrain.TempUnit.Sum(p => p.WCFUnit.IsWounded ? 0 : p.ExtUnitType.WCFUnitType.Strength);
                        resultStrength += Game.SelectedOrder.ExtOrderType.WCFOrderType.Strength;

                        foreach (ExtTerrain item in garrisonTerrain.JoinTerrainCol)
                        {
                            if (item.ExtHolderUser != this.ExtGameUser)
                            {
                                continue;
                            }

                            ExtOrder order = item.Order;
                            if (order == null)
                            {
                                continue;
                            }
                            if (order.ExtOrderType.WCFOrderType.DoType == "Подмога")
                            {
                                resultStrength += order.ExtOrderType.WCFOrderType.Strength;
                                resultStrength += item.TempUnit.Sum(p => p.WCFUnit.IsWounded ? 0 : p.ExtUnitType.WCFUnitType.Strength);
                            }
                        }

                        if (resultStrength < garrisonTerrain.ExtGarrison.WCFGarrison.Strength)
                        {
                            App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), string.Format(App.GetResources("validation_lordFalse"), resultStrength, garrisonTerrain.ExtGarrison.WCFGarrison.Strength));
                            return(false);
                        }

                        App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), string.Format(App.GetResources("validation_lordTrue"), resultStrength, garrisonTerrain.ExtGarrison.WCFGarrison.Strength));
                    }
                    break;

                default:
                    App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_march"));
                    return(false);
                }
            }

            //снабжение
            List <int> supplyArmy = null;

            switch (WCFStep.GameUserInfo.Supply)
            {
            case 0:
                supplyArmy = new List <int>()
                {
                    2, 2
                };
                break;

            case 1:
                supplyArmy = new List <int>()
                {
                    2, 3
                };
                break;

            case 2:
                supplyArmy = new List <int>()
                {
                    2, 2, 3
                };
                break;

            case 3:
                supplyArmy = new List <int>()
                {
                    2, 2, 2, 3
                };
                break;

            case 4:
                supplyArmy = new List <int>()
                {
                    2, 2, 3, 3
                };
                break;

            case 5:
                supplyArmy = new List <int>()
                {
                    2, 2, 3, 4
                };
                break;

            case 6:
                supplyArmy = new List <int>()
                {
                    2, 2, 2, 3, 4
                };
                break;
            }

            foreach (ExtTerrain terrain in ExtGameUserInfo.ExtUnit.Select(p => p.TempTerrain).Distinct())
            {
                int unitCount = terrain.TempUnit.Count(p => p.Step == this && (p.Step.WCFStep.StepType != "Роспуск_войск" || !p.IsSelected));
                if (unitCount < 2)
                {
                    continue;
                }

                int supply = supplyArmy.FirstOrDefault(p => (p - unitCount) >= 0);
                if (supplyArmy.Count == 0 || supply == 0)
                {
                    App.Agot2.errorView.ShowByDispatcher(App.GetResources("text_notify"), App.GetResources("validation_supply"));
                    return(false);
                }

                supplyArmy.Remove(supply);
            }

            return(true);
        }
Exemple #6
0
 private void OnSelecteOrderChanged(ExtOrder newValue)
 {
     SelecteOrderChanged?.Invoke(newValue);
 }
 void ExtGame_SelectedOrderChange(ExtOrder newValue)
 {
     ((Popup)this.Parent).IsOpen = false;
 }
 void OrderTypeMenu2_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     _ExtOrder = (ExtOrder)e.NewValue;
     _ExtOrder.IsDisposeEvent += _ExtOrder_IsDispose;
     _ExtOrder.Step.Game.SelecteOrderChanged += ExtGame_SelectedOrderChange;
 }