Package ch.fusun.baron.player

Examples of ch.fusun.baron.player.Player


  public void testGettersAndSetters() {
    Dynasty dynasty = new Dynasty("TestDynasty", null); //$NON-NLS-1$
    Dynasty dynasty2 = new Dynasty("TestDynasty2", null); //$NON-NLS-1$
    User user = new User("username", "password"); //$NON-NLS-1$ //$NON-NLS-2$
    User user2 = new User("username2", "password2"); //$NON-NLS-1$ //$NON-NLS-2$
    Player player1 = new Player(0, "player1", Gender.MALE); //$NON-NLS-1$
    dynasty.addPlayer(player1);
    Player player2 = new Player(1, "player2", Gender.FEMALE); //$NON-NLS-1$
    dynasty.addPlayer(player2);

    PlayerService service = new PlayerServiceImpl();
    assertNotNull(service.getAllPlayers());
View Full Code Here


  }

  @Override
  public Image getImage(Object obj) {
    if (obj instanceof Player) {
      Player player = (Player) obj;
      if (player.getAge() < 5) {
        return Activator.getImage(Activator.BABY);
      }
      if (Gender.MALE.equals(player.getGender())) {
        if (player.getAge() < 16) {
          return Activator.getImage(Activator.BOY);
        }
        return Activator.getImage(Activator.MAN);
      } else if (Gender.FEMALE.equals(player.getGender())) {
        if (player.getAge() < 16) {
          return Activator.getImage(Activator.GIRL);
        }
        return Activator.getImage(Activator.WOMAN);
      }
View Full Code Here

  @Override
  public void execute() {
    Map<Player, List<Country>> countries = propertyService
        .getAllOwnerships(Player.class, Country.class);
    for (Entry<Player, List<Country>> entry : countries.entrySet()) {
      Player defunct = entry.getKey();
      if (defunct.isDead()) {
        for (Country country : countries.get(defunct)) {
          Player heir = findHeir(defunct);
          if (heir == null) {
            Player spouse = marriageService.getSpouse(defunct);
            if (spouse != null) {
              heir = findHeir(spouse);
            }
          }
          propertyService.setOwnership(heir, country);
View Full Code Here

  private Player findHeir(Player player) { // SDZ move to
                        // PlayerService
    if (!player.isDead()) {
      return player;
    }
    Player heir = findHeirInDescendants(player);
    if (heir != null) {
      return heir;
    }

    Player father = player.getFather();
    if (father != null) {
      return findHeir(father);
    }

    return null;
View Full Code Here

        return child;
      }
    }
    // No child alive, search in nephews
    for (Player child : defunct.getChildren()) {
      Player possibleHeir = findHeirInDescendants(child);
      if (possibleHeir != null) {
        return possibleHeir;
      }
    }
    // No descendants
View Full Code Here

    for (Player player : playerService.getAllPlayers()) {
      if (Gender.FEMALE.equals(player.getGender())
          && player.getAge() >= AGE_FOR_CHILDREN && !player.isDead()) {
        if (marriageService.isMarried(player)) {
          if (Math.random() < CHILDREN_PROBABILITY) {
            Player husband = marriageService.getSpouse(player);
            if (husband.getAge() >= AGE_FOR_CHILDREN
                && !husband.isDead()) {
              Dynasty dynasty = playerService.getDynasty(husband);
              Gender gender = Gender.random();
              Player child = playerService
                  .generateNewPlayer(gender);
              child.setFather(husband);
              child.setMother(player);
              child.setAge(0);
              playerService.addPlayerToDynasty(dynasty, child);
              messagingService
                  .addMessage(
                      null,
                      "A new child was born for " + husband.getName() //$NON-NLS-1$
                          + " and " + player.getName() + ": " //$NON-NLS-1$ //$NON-NLS-2$
                          + child.getName() + " of " //$NON-NLS-1$
                          + dynasty.getName() + "."); //$NON-NLS-1$
            }
          }
        }
      }
View Full Code Here

   * Tests the scenario without children and without spouse and the person is
   * dead
   */
  @Test
  public void testSimpleDead() {
    Player person = new Player(0, "Albert", Gender.MALE);
    person.kill();
    Country country = new Country(0, "Country");
    propertyService.setOwnership(person, country);
    reinject();
    turntask.execute();
    Object owner = propertyService.getOwnership(country);
View Full Code Here

   * Tests the scenario without children and with spouse and the person is
   * dead
   */
  @Test
  public void testSimpleFamily() {
    Player male = new Player(0, "Albert", Gender.MALE);
    Player female = new Player(1, "Alberta", Gender.FEMALE);
    marriageService.marry(male, female);
    male.kill();
    Country country = new Country(0, "Country");
    propertyService.setOwnership(male, country);
    reinject();
View Full Code Here

   * Tests the scenario with a single male child and with spouse and the
   * person is dead
   */
  @Test
  public void testSimpleFamilyWithChild() {
    Player male = new Player(0, "Albert", Gender.MALE);
    Player female = new Player(1, "Alberta", Gender.FEMALE);
    marriageService.marry(male, female);
    Player son = new Player(2, "Albertino", Gender.MALE);
    giveBirth(male, female, son);
    male.kill();
    Country country = new Country(0, "Country");
    propertyService.setOwnership(male, country);
    reinject();
View Full Code Here

   * Tests the scenario with a single male child and with spouse and the
   * person is dead and the spouse as well
   */
  @Test
  public void testSimpleFamilyWithChildWomanDies() {
    Player male = new Player(0, "Albert", Gender.MALE);
    Player female = new Player(1, "Alberta", Gender.FEMALE);
    marriageService.marry(male, female);
    Player son = new Player(2, "Albertino", Gender.MALE);
    giveBirth(male, female, son);
    male.kill();
    female.kill();
    Country country = new Country(0, "Country");
    propertyService.setOwnership(female, country);
View Full Code Here

TOP

Related Classes of ch.fusun.baron.player.Player

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.