Exemplo n.º 1
0
        protected void createBattle_Click(object sender, EventArgs e)
        {
            if (rulers.SelectedIndex == -1)
            {
                Information.AddError(info.getContent("battle_noRulerSelected"));
                return;
            }
            Ruler enemy = Universe.instance.getRuler(int.Parse(rulers.SelectedValue));

            if (!CanCreateBattle(enemy))
            {
                Information.AddError(info.getContent("battle_enemycanthave"));
                return;
            }

            Chronos.Core.Fleet f1 = ((FleetEventArgs )e).Fleet;
            Chronos.Core.Fleet f2 = f1.Clone() as Chronos.Core.Fleet;
            f2.Owner = enemy;

            int count = int.Parse(OrionGlobals.getConfigurationValue("alnitak", "shipsCount"));

            if (f1.Ships.Count > count)
            {
                Information.AddError(string.Format(info.getContent("battle_toMuchUnits"), count));
                return;
            }
            if (f1.HasShips)
            {
                Universe.instance.CreateBattle(_ruler, f1, enemy, f2, BattleType.FRIENDLY, battleTypes.SelectedValue);
                Information.AddInformation(info.getContent("battle_friendlyCreated"));
            }
            else
            {
                Information.AddError(info.getContent("battle_noUnitSelected"));
            }
        }