Newer
Older
CarrotServer / src / game / TestPlayerSearchVisitorjava.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 TestPlayerSearchVisitorjava extends Game {

	public static void main(String[] args) {
		
		AccountManager acmgr = AccountManager.getInstance();
		RoomManager roommgr = RoomManager.getInstance();
		GameManager gamemgr = GameManager.getInstance();
		
		/* Test時はRoomのMAX_MENBERを6に変更する */
		
		String TEST_SID = "7";
		
		//Player12人作成
		for(int i=0; i<12; i++) {
			acmgr.registration("name"+i, "pass", String.valueOf(i));
		}
		
		//Player12人作成確認
		for(int i=0; i<12; i++) {
			Account ac = new Account();
			ac = acmgr.getAccount(String.valueOf(i));
		}
		
		//room 2部屋作成 name0~5 と name6〜11 の部屋
		roommgr.createRoom("room0-5", "mode0", "pass0", "0");
		roommgr.createRoom("room6-11", "mode1", "pass1", "6");
		
		//room0-5に name1〜5 を追加
		Account ac0 = new Account();
		Room room0 = new Room();
		ac0 = acmgr.getAccount("0");
		room0 = ac0.getRoom();
		
		for(int i=1; i<=5; i++) {
			Account ac = new Account();
			ac = acmgr.getAccount(String.valueOf(i));
			room0.addMember(ac);
		}

		//room0-5のチーム分け、game作成
		room0.divideTeam();
		
		//room6-11に name7〜11 を追加
		Account ac6 = new Account();
		ac6 = acmgr.getAccount("6");
		Room room6 = ac6.getRoom();
		
		for(int i=7; i<=11; i++) {
			Account ac = new Account();
			ac = acmgr.getAccount(String.valueOf(i));
			room6.addMember(ac);
		}

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