Newer
Older
CarrotServer / src / game / PlayerSearchVisitor.java
t-nakanishi on 18 Jul 2017 917 bytes [add] project
package game;

import account.Account;
import account.AccountManager;

public class PlayerSearchVisitor  implements IGameElementVisitor {
	private Game game;
	private Team team;
	private Account playerAccount;
	private String sId;
	
	public PlayerSearchVisitor(String sId) {
		this.sId = sId;
	}
	
	@Override
	public boolean visit(IGameElement e) {
		
		//visitorがGameにいる時
		if(e instanceof Game) {
			game = (Game) e;
		}
		
		//visitorがTeamにいる時
		if(e instanceof Team) {
			team = (Team) e;
		}
		
		//visitorがAccountにいる時、sIdを比較
		if(e instanceof Account) {
			playerAccount = (Account) e;
			
			if(sId.equals(playerAccount.getsId())) {
				return false;
			}
		
		}
		return true;
	}
	
	public Game getGame() {
		return game;
	}
	
	public Team getTeam() {
		return team;
	}
	
	public Account getPlayerAccount() {
		return playerAccount;
	}
}