Exemplo n.º 1
0
        private void conquerPlanet_Click(object sender, ImageClickEventArgs e)
        {
            if (_ruler.Planets.Length >= _ruler.MaxPlanets)
            {
                Information.AddError(info.getContent("conquerplanet_maxPlanetsError"));
                return;
            }

            int    index         = _itemsTable.SelectedIndex;
            string fleetName     = _itemsTable.getSpecificText(index, 0);
            string planetNewName = GetPlanetNewName(index);

            Chronos.Core.Fleet fleet = _ruler.getFleet(fleetName);
            if (fleet == null)
            {
                throw new Exception("There is no fleet!");
            }

            Coordinate c = Coordinate.translateCoordinate(_itemsTable.getSpecificText(index, 1));

            //Planet p = Universe.instance.getPlanet( c );

            if (!fleet.isQuantityAvailable("ColonyShip", 1))
            {
                Information.AddError(info.getContent("conquerplanet_thereisnoColonyShip"));
                return;
            }

            if (Regex.IsMatch(planetNewName, @"(\w|( )|[.!?])+") && !_ruler.hasFleet(planetNewName))
            {
                Universe.instance.conquerPlanet(c, planetNewName, fleet);
                updateTable();
                buttonClicked = true;
            }
            else
            {
                Information.AddError(info.getContent("conquerplanet_invalidName"));
            }
        }