Page 1 of 1

[Java] How to know player id

Posted: 23 Oct 2014, 00:23
by bioinfornatics
Hi stupid question,

How to know player id ?

My AI inherit from OOAI so I have his skirmishAIId.
I can to get is allyteam with Game object callback.getGame().getMyTeam()

But I do not see how to get the playerId!

thanks

Re: [Java] How to know player id

Posted: 24 Oct 2014, 13:54
by playerO1
For check all team I using:

Code: Select all

for(int teamI clb.getTeams().getSize();teamI++) {
  //some work here
  if (game.getTeamColor(teamI).equals(msgColor))...
}
See also: clb.getGame().getPlayerTeam(player); clb.getGame().getTeamAllyTeam(owner.clb.getGame().getPlayerTeam(player));
Java AI documentation link: http://spring.abma.de/doc-Interface-JavaOO/

Re: [Java] How to know player id

Posted: 24 Oct 2014, 18:31
by jK
AI is no player, it's a design flaw.

Re: [Java] How to know player id

Posted: 24 Oct 2014, 22:15
by PauloMorfeo
Is your class declaration like this?:
https://github.com/spring/spring/blob/d ... I.java#L38

Code: Select all

public class NullOOJavaAI extends OOAI
That is, do you inherit ("extend") from OOAI?

Are you trying to find the ID of *your* AI? If so, that is sent in the init():
https://github.com/spring/spring/blob/d ... .java#L105

Code: Select all

	@Override
	public int init(int skirmishAIId, OOAICallback callback)
I'm not in my "development" computer right now to confirm but from memory you should also have:

Code: Select all

callback.getTeamId();

Re: [Java] How to know player id

Posted: 26 Oct 2014, 22:41
by bioinfornatics
ok thanks,
I will use callback.getTeamId(); as a player ID

Re: [Java] How to know player id

Posted: 28 Oct 2014, 09:44
by hoijui
player ID and team ID are not the same. only humans have player IDs. AIs are not players (that is totally wrong, but it is how it works in spring at the moment). each AI is "owned" or "controlled" by a player, so that players ID is closest to its player ID. though, if i remember right, you need just the team ID in most places.