Package ch.fusun.baron.basic.initialization

Source Code of ch.fusun.baron.basic.initialization.TreasuryPlayerInitializer

package ch.fusun.baron.basic.initialization;

import ch.fusun.baron.basic.messages.Messages;
import ch.fusun.baron.core.initialization.GameInitializer;
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.printing.MessagingService;
import ch.fusun.baron.treasury.api.TreasuryService;

/**
* Initializes each player with a treasury
*/
public class TreasuryPlayerInitializer implements GameInitializer {

  @Inject
  private TreasuryService treasuryService;
  @Inject
  private UserService userService;
  @Inject
  private PlayerService playerService;
  @Inject
  private MessagingService messagingService;

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

  @Override
  public void initialize() {
    for (User user : userService.getUsers()) {
      Dynasty dynasty = playerService.getDynasty(user);
      treasuryService.setMoney(dynasty, 1000);
    }
    messagingService.addMessage(null,
        Messages.TreasuryPlayerInitializer_TreasuryInitialized);
  }
}
TOP

Related Classes of ch.fusun.baron.basic.initialization.TreasuryPlayerInitializer

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.