Package ch.fusun.baron.basic.turntask

Source Code of ch.fusun.baron.basic.turntask.SoldierExpensesTurnTask

package ch.fusun.baron.basic.turntask;

import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.core.rmi.User;
import ch.fusun.baron.core.service.UserService;
import ch.fusun.baron.player.Dynasty;
import ch.fusun.baron.player.api.PlayerService;
import ch.fusun.baron.property.api.PropertyService;
import ch.fusun.baron.treasury.api.TreasuryService;
import ch.fusun.baron.turn.TurnTask;
import ch.fusun.baron.unit.Unit;
import ch.fusun.baron.unit.service.UnitService;

/**
* Computes the soldier expenses and subtracts them from the player treasury
*/
public class SoldierExpensesTurnTask implements TurnTask {

  @Inject
  private UserService userService;
  @Inject
  private PlayerService playerService;
  @Inject
  private TreasuryService treasuryService;
  @Inject
  private UnitService unitService;
  @Inject
  private PropertyService propertyService;

  /**
   * Constructor
   */
  public SoldierExpensesTurnTask() {
  }

  @Override
  public void execute() {
    for (User user : userService.getUsers()) {
      Dynasty dynasty = playerService.getDynasty(user);
      for (Unit unit : unitService.getAllUnits()) {
        if (dynasty.equals(propertyService.getOwnership(unit))) {
          treasuryService.removeMoney(dynasty,
              unit.getNumberOfUnits());
        }
      }
    }
  }
}
TOP

Related Classes of ch.fusun.baron.basic.turntask.SoldierExpensesTurnTask

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.