Package de.ailis.xadrian.data.factories

Examples of de.ailis.xadrian.data.factories.WareFactory


     * @param complex
     *            The current complex
     */
    private void initContent(final Complex complex)
    {
        final WareFactory wareFactory = this.game.getWareFactory();
        final Color gray = new Color(0xee, 0xee, 0xee);
        final NumberFormat formatter = NumberFormat.getNumberInstance();
        JSpinner focusComponent = null;

        final GridBagConstraints c = new GridBagConstraints();

        c.fill = GridBagConstraints.BOTH;
        c.anchor = GridBagConstraints.WEST;
        c.gridy = 0;
        c.insets = new Insets(0, 0, 0, 0);
        c.fill = GridBagConstraints.BOTH;
        for (final Ware ware : wareFactory.getWares())
        {
            // Ignore ware if not used by the complex
            if (!complex.usesWare(ware)) continue;

            // Get price and check if ware is used
View Full Code Here


        final Game game = GameFactory.getInstance().getGame(gameId);

        final Complex complex = new Complex(game);
        final FactoryFactory factoryFactory = game.getFactoryFactory();
        final SectorFactory sectorFactory = game.getSectorFactory();
        final WareFactory wareFactory = game.getWareFactory();
        final SunFactory sunsFactory = game.getSunFactory();

        complex.setSuns(sunsFactory.getSun(Integer.parseInt(root
            .attributeValue("suns"))));
        complex.setSector(sectorFactory
            .getSector(root.attributeValue("sector")));
        complex.setAddBaseComplex(Boolean.parseBoolean(root.attributeValue(
            "addBaseComplex", "false")));
        complex.showingProductionStats = Boolean.parseBoolean(root
            .attributeValue("showingProductionStats", "false"));
        complex.showingShoppingList = Boolean.parseBoolean(root.attributeValue(
            "showingShoppingList", "false"));
        complex.showingStorageCapacities = Boolean.parseBoolean(root
            .attributeValue("showingStorageCapacities", "false"));
        complex.showingComplexSetup = Boolean.parseBoolean(root.attributeValue(
            "showingComplexSetup", "true"));

        // Get the factories parent element (In older version this was the root
        // node)
        Element factoriesE = root.element("complexFactories");
        if (factoriesE == null) factoriesE = root;

        // Read the complex factories
        for (final Object item: factoriesE.elements("complexFactory"))
        {
            final Element element = (Element) item;
            final Factory factory = factoryFactory.getFactory(element
                .attributeValue("factory"));
            final ComplexFactory complexFactory;
            final Element yieldsE = element.element("yields");
            if (yieldsE == null)
            {
                final int yield =
                    Integer.parseInt(element.attributeValue("yield", "0"));
                final int quantity = Integer.parseInt(element
                    .attributeValue("quantity"));
                complexFactory =
                    new ComplexFactory(game, factory, quantity, yield);
            }
            else
            {
                final List<Integer> yields = new ArrayList<Integer>();
                for (final Object yieldItem: yieldsE.elements("yield"))
                {
                    final Element yieldE = (Element) yieldItem;
                    yields.add(Integer.parseInt(yieldE.getText()));
                }
                complexFactory = new ComplexFactory(game, factory, yields);
            }
            if (Boolean.parseBoolean(element
                .attributeValue("disabled", "false")))
                complexFactory.disable();
            complex.addFactory(complexFactory);
        }

        // Read the complex wares
        final Element waresE = root.element("complexWares");
        if (waresE != null)
        {
            complex.customPrices.clear();
            for (final Object item: waresE.elements("complexWare"))
            {
                final Element element = (Element) item;
                final Ware ware = wareFactory.getWare(element
                    .attributeValue("ware"));
                final boolean use = Boolean.parseBoolean(element
                    .attributeValue("use"));
                final int price = Integer.parseInt(element
                    .attributeValue("price"));
View Full Code Here

        this.id = id;
        this.nid = nid;
        this.messageId = "game." + id;
        this.sunFactory = new SunFactory(this);
        this.raceFactory = new RaceFactory(this);
        this.wareFactory = new WareFactory(this);
        this.sectorFactory = new SectorFactory(this);
        this.factoryFactory = new FactoryFactory(this);
    }
View Full Code Here

TOP

Related Classes of de.ailis.xadrian.data.factories.WareFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.