Newer
Older
CarrotServer / src / game / TestPlayerSearchVisitorjava2.java
t-nakanishi on 18 Jul 2017 3 KB [add] project
package game;

import account.Account;
import account.AccountManager;
import room.Room;
import room.RoomManager;
import game.Game;

public class TestPlayerSearchVisitorjava2{

	public static void main(String[] args) {
		
		AccountManager acmgr = AccountManager.getInstance();
		RoomManager roommgr = RoomManager.getInstance();
		GameManager gamemgr = GameManager.getInstance();
		
		//MAX_MEMBER = 2用
		
		String TEST_SID = "1";
		
		//Player4人作成
		for(int i=0; i<4; i++) {
			acmgr.registration("name"+i, "pass", String.valueOf(i));
		}
		
		//Player4人作成確認
		for(int i=0; i<4; i++) {
			Account ac = new Account();
			ac = acmgr.getAccount(String.valueOf(i));
System.out.println("Name : " +ac.getName() + "  sId : " + ac.getsId());
		}
		
		//room 2部屋作成 name0~1 と name2〜3 の部屋
		roommgr.createRoom("room0-5", "mode0", "pass0", "0");
		roommgr.createRoom("room6-11", "mode1", "pass1", "2");
		
		//room0-1に name1 を追加
		Account ac0 = new Account();
		Room room0 = new Room();
		ac0 = acmgr.getAccount("0");
		room0 = ac0.getRoom();
		
			Account ac1 = acmgr.getAccount("1");
			room0.addMember(ac1);

		//room0-1のチーム分け、game作成
		room0.divideTeam();
		
		//room2-3に name3 を追加
		Account ac2 = acmgr.getAccount("2");
		Room room2 = ac2.getRoom();
		
			Account ac3 = new Account();
			ac3 = acmgr.getAccount("3");
			room2.addMember(ac3);

		//room2-3のチーム分け、game作成
		room2.divideTeam();
		
		Game mygame = gamemgr.getGame(0);
		
		
/***********************以下チーム分け表示分*************************/
		
System.out.println("==========room0-1==========");
		Game game0 = room0.getGame();
System.out.println("  --------RedTeam--------  ");
		for(int i=0; i<1; i++) {
			Account ac = game0.getTeamMember(i,0);
System.out.println("   Name:"+ac.getName()+" sId:"+ac.getsId());
		}
System.out.println("  -------BlueTeam--------  ");
		for(int i=0; i<1; i++) {
			Account ac = game0.getTeamMember(i,1);
System.out.println("   Name:"+ac.getName()+" sId:"+ac.getsId());
		}
System.out.println("===========================");
System.out.println("");
		
		//room2-3のチーム表示
System.out.println("==========room2-3=========");
		Game game2 = room2.getGame();
System.out.println("  --------RedTeam--------  ");
		for(int i=0; i<1; i++) {
			Account ac = game2.getTeamMember(i,0);
System.out.println("   Name:"+ac.getName()+" sId:"+ac.getsId());
		}
System.out.println("  -------BlueTeam--------  ");
		for(int i=0; i<1; i++) {
			Account ac = game2.getTeamMember(i,1);
System.out.println("   Name:"+ac.getName()+" sId:"+ac.getsId());
		}
System.out.println("===========================");
System.out.println("");

/***********************以上チーム分け表示分*************************/

		
		//visitor
		PlayerSearchVisitor visitor = new PlayerSearchVisitor(TEST_SID);
		gamemgr.accept(visitor);
		
		
		Game game = visitor.getGame();
		Team team = visitor.getTeam();
		Account account = visitor.getPlayerAccount();
		
		String teamColor;
		if(account.getTeam() == 0){
			teamColor = "RedTeam";
		} else {
			teamColor = "BlueTeam";
		}
		
System.out.println("search sid " + TEST_SID );
System.out.println("----------Result----------");
System.out.println("Name : " + account.getName());
System.out.println("sId  : " + account.getsId());
System.out.println("Room : " + game.getRoomName());
System.out.println("Team : " + teamColor);
		
	}
		
}