Examples of SpeciesType


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

Examples of model.SpeciesType

                    } 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

Examples of model.SpeciesType

            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

Examples of model.SpeciesType

    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

Examples of org.sbml.jsbml.SpeciesType

    assertTrue(M.getSpecies(0).equals(s) == true);
  }

  @Test
  public void test_Model_createSpeciesType() {
    SpeciesType c = M.createSpeciesType();
    assertTrue(c != null);
    assertTrue(M.getSpeciesTypeCount() == 1);
    assertEquals(M.getSpeciesType(0), c);
  }
View Full Code Here

Examples of org.sbml.jsbml.SpeciesType

    o3 = null;
  }

  @Test
  public void test_Model_removeSpeciesType() {
    SpeciesType o1, o2, o3;
    o1 = M.createSpeciesType();
    o2 = M.createSpeciesType();
    o3 = M.createSpeciesType();
    o3.setId("test");
    assertTrue(M.removeSpeciesType(0).equals(o1));
View Full Code Here

Examples of org.sbml.jsbml.SpeciesType

              return compartmentType;
            } else if (elementName.equals("speciesType")
                && list.getSBaseListType().equals(
                    ListOf.Type.listOfSpeciesTypes)
                && (model.getLevel() == 2 && model.getVersion() > 1)) {
              SpeciesType speciesType = (SpeciesType) newContextObject;
              model.addSpeciesType(speciesType);

              return speciesType;
            } else {
              log4jLogger.warn("The element " + elementName + " is not recognized");
View Full Code Here

Examples of org.sbml.jsbml.SpeciesType

  /**
   * Test method for {@link org.sbml.jsbml.Model#removeSpeciesType(java.lang.String)}.
   */
  @Test
  public void testRemoveSpeciesTypeString() {
    SpeciesType st = modelL2V4.createSpeciesType("st");
    assertTrue(modelL2V4.getSpeciesType(st.getId()) != null);
   
    modelL2V4.removeSpeciesType(st.getId());
    assertTrue(modelL2V4.getSpeciesType(st.getId()) == null);
  }
View Full Code Here

Examples of org.sbml.jsbml.SpeciesType

  private void setSpeciesSpeciesType(Species species, Model model) {

    if (species.isSetSpeciesType()) {
      String speciesTypeID = species.getSpeciesType();

      SpeciesType speciesType = model.getSpeciesType(speciesTypeID);

      if (speciesType != null) {
        species.setSpeciesType(speciesType);
      } else {
        // TODO: the speciesType ID doesn't match a speciesType, throw
View Full Code Here

Examples of org.sbml.jsbml.SpeciesType

    assertTrue(M.getSpecies(0).equals(s) == true);
  }

  @Test
  public void test_Model_createSpeciesType() {
    SpeciesType c = M.createSpeciesType();
    assertTrue(c != null);
    assertTrue(M.getNumSpeciesTypes() == 1);
    assertEquals(M.getSpeciesType(0), c);
  }
View Full Code Here
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.