Package model

Examples of model.SpeciesType


    private void updateEnvironmentScore() {
        double biomass = 0;

        for (int speciesTypeID : totalSpeciesList.keySet()) {
            SpeciesType speciesType = null;

            if (speciesTypeID > Constants.MODIFIER_PLANT) {
                speciesType = GameServer.getInstance().getPlantType(speciesTypeID);
            } else {
                speciesType = GameServer.getInstance().getAnimalType(speciesTypeID);
            }

            biomass += speciesType.getAvgBiomass() * Math.pow(totalSpeciesList.get(speciesTypeID), speciesType.getTrophicLevel());
        }

        if (biomass > 0) {
            biomass = Math.round(Math.log(biomass) / Math.log(2)) * 5;
        }
View Full Code Here


                    } catch (SQLException ex) {
                        System.err.println(ex.getMessage());
                    }

                    Player player = GameServer.getInstance().getActivePlayer(zone.getEnvironment().getOwnerID());
                    SpeciesType species = GameServer.getInstance().getSpecies(species_id);
                    GameServer.getInstance().updateExperience(player, (int) Math.ceil(species.getCost() * 0.75));
                }
            }
        }
    }
View Full Code Here

            HashMap<Organism, Integer> numBirthList = new HashMap<Organism, Integer>();

            int size = organismList.size();
           
            for (int i = 0; i < Math.max(Constants.MAX_SPECIES_SIZE, size) && amount > 0; i++) {
                SpeciesType species = GameServer.getInstance().getSpecies(species_id);

                Organism organism = null;
                int numBirths = 0;

                if (i < size) {
                    organism = organismList.get(i);
                    int numSpace = species.getGroupCapacity() - organism.getGroupSize();

                    if (numSpace > 0) {
                        numBirths = Math.min(numSpace, amount);
                        amount -= numBirths;

                        organism.setGroupSize(organism.getGroupSize() + numBirths);
                    }
                } else {
                    numBirths = Math.min(amount, species.getGroupCapacity());
                    amount -= numBirths;

                    organism = createOrganism(species_id, numBirths);
                    organismList.add(organism);
                }
View Full Code Here

    public short buyOrganism(int organism_type, int player_id, int species_id, int amount, int zone_id, float xCoor, float yCoor) {
        Player player = GameServer.getInstance().getActivePlayer(player_id);
        Avatar avatar = player.getAvatar();

        if (avatar != null) {
            SpeciesType species = null;

            if (organism_type == Constants.ORGANISM_TYPE_PLANT) {
                species = GameServer.getInstance().getPlantType(species_id);
            } else if (organism_type == Constants.ORGANISM_TYPE_ANIMAL) {
                species = GameServer.getInstance().getAnimalType(species_id);
            }

            boolean canBuy = avatar.spendCash(species.getCost());

            if (canBuy) {
                GameServer.getInstance().updateCash(player, 0);

                Zone zone = zones.get(zone_id);

                if (zone != null) {
                    Organism organism = createOrganism(species_id, amount);

                    for (int node_id : organism.getSpeciesType().getNodeList()) {
                        zone.addNewNode(node_id, amount * organism.getSpeciesType().getNodeAmount(node_id));
                    }

                    createOrganismByResponse(organism, organism.getGroupSize(), zone_id, Constants.CREATE_STATUS_PURCHASE, xCoor, yCoor, Constants.CREATE_USER);

                    try {
                        if (organism_type == Constants.ORGANISM_TYPE_PLANT) {
                            PlantStatDAO.insertPlantStat(organism.getID(), species_id, currentMonth, "Purchase", world.getEnvByUserID(player_id).getEnvironmentScore(), null, player_id, zone_id);
                        } else if (organism_type == Constants.ORGANISM_TYPE_ANIMAL) {
                            AnimalStatDAO.insertAnimalStat(organism.getID(), species_id, currentMonth, "Purchase", world.getEnvByUserID(player_id).getEnvironmentScore(), null, player_id, zone_id);
                        }

                        for (int node_id : species.getNodeList()) {
                            UserActionsDAO.createAction(zone.getManipulationID(), zone.getCurrentTimeStep(), 0, node_id, GameServer.getInstance().getSpeciesTypeByNodeID(node_id).getAvgBiomass() * organism.getGroupSize());
                        }
                    } catch (SQLException ex) {
                        System.err.println(ex.getMessage());
                    }

                    GameServer.getInstance().updateExperience(player, species.getCost() * 2);

                    return 0;
                }
            }
        }
View Full Code Here

TOP

Related Classes of model.SpeciesType

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.