Package org.freerealm.settlement

Source Code of org.freerealm.settlement.SettlementModifierImpl

package org.freerealm.settlement;

import java.util.Iterator;
import org.freerealm.ModifierImpl;
import org.freerealm.property.ModifyEfficiency;
import org.freerealm.property.ModifyMaximumWorkers;
import org.freerealm.property.ModifyProduction;
import org.freerealm.property.ModifyTaxIncome;
import org.freerealm.property.Property;
import org.freerealm.property.StoreResource;
import org.freerealm.resource.Resource;

/**
*
* @author Deniz ARIKAN
*/
public class SettlementModifierImpl extends ModifierImpl implements SettlementModifier {

    public int getProductionModifier() {
        int productionModifier = 0;
        Iterator propertyIterator = getPropertiesIterator();
        while (propertyIterator.hasNext()) {
            Property property = (Property) propertyIterator.next();
            if (property instanceof ModifyProduction) {
                ModifyProduction increaseProduction = (ModifyProduction) property;
                productionModifier = productionModifier + increaseProduction.getModifier();
            }
        }

        return productionModifier;
    }

    public int getTaxModifier() {
        int taxModifier = 0;
        Iterator propertyEditor = getPropertiesIterator();
        while (propertyEditor.hasNext()) {
            Property property = (Property) propertyEditor.next();
            if (property instanceof ModifyTaxIncome) {
                ModifyTaxIncome increaseTaxIncome = (ModifyTaxIncome) property;
                taxModifier = taxModifier + increaseTaxIncome.getModifier();
            }
        }
        return taxModifier;
    }

    public int getMaximumTileWorkersModifier() {
        int increasePercent = 0;
        Iterator propertyEditor = getPropertiesIterator();
        while (propertyEditor.hasNext()) {
            Property property = (Property) propertyEditor.next();
            if (property instanceof ModifyMaximumWorkers) {
                ModifyMaximumWorkers modifyMaximumWorkers = (ModifyMaximumWorkers) property;
                increasePercent = increasePercent + modifyMaximumWorkers.getModifier();
            }
        }
        return increasePercent;
    }

    public int getEfficiencyModifier() {
        int efficiencyModifier = 0;
        Iterator propertyEditor = getPropertiesIterator();
        while (propertyEditor.hasNext()) {
            Property property = (Property) propertyEditor.next();
            if (property instanceof ModifyEfficiency) {
                ModifyEfficiency increaseEfficiency = (ModifyEfficiency) property;
                efficiencyModifier = efficiencyModifier + increaseEfficiency.getModifier();
            }
        }
        return efficiencyModifier;
    }

    public int getCapacityModifier(Resource resource) {
        int capacityModifier = 0;
        Iterator<Property> propertyEditor = getPropertiesIterator();
        while (propertyEditor.hasNext()) {
            Property property = propertyEditor.next();
            if (property instanceof StoreResource) {
                StoreResource storeResource = (StoreResource) property;
                if (resource.equals(storeResource.getResource())) {
                    capacityModifier = capacityModifier + storeResource.getStorage();
                }
            }
        }
        return capacityModifier;
    }
}
TOP

Related Classes of org.freerealm.settlement.SettlementModifierImpl

TOP
Copyright © 2018 www.massapi.com. 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.