Code: Select all
List<UserVariable> vars = Arrays.asList
(
new SFSUserVariable("seat", uid),
new SFSUserVariable("id", uid),
new SFSUserVariable("headurl", headurl),
new SFSUserVariable("nickname", nickname),
new SFSUserVariable("score", 0),
new SFSUserVariable("isLandlord", 0),
new SFSUserVariable("remain", 0)
);
getApi().setUserVariables(theUser, vars);
Code: Select all
List<RoomVariable> vars = Arrays.asList
(
new SFSRoomVariable("user1", uid),
new SFSRoomVariable("user2", 0),
new SFSRoomVariable("user3", 0),
new SFSRoomVariable("user4", 0),
new SFSRoomVariable("landlord", 0),
new SFSRoomVariable("facedown", 0),
new SFSRoomVariable("round", round),
new SFSRoomVariable("currentRound", 0),
new SFSRoomVariable("times", times),
new SFSRoomVariable("next", uid),
new SFSRoomVariable("ready", 1)
);
cfg.setRoomVariables(vars);
I use below lines to get those variables on client side
Code: Select all
myself = sfs.MySelf;
theRoom = sfs.LastJoinedRoom;
roomVars = theRoom.GetVariables ();
userVars = myself.GetVariables ();
User variables are arranged in the same order on both server side and client side, but the order of room variables are different, the order of room variables on client side is
Code: Select all
user1
next
user2
currentRound
times
landlord
round
ready
facedown
user3
user4
Did I do anything wrong?
As you can see, I've set 11 room variables, if I want to change just 1 or 3 of them, what should I do?
Code: Select all
RoomVariable user2 = new SFSRoomVariable("user2", uid2);
getApi().setRoomVariables(null, theRoom, Arrays.asList(user2));
Code: Select all
RoomVariable user2 = new SFSRoomVariable("user2", uid2);
RoomVariable user3 = new SFSRoomVariable("user3", uid3);
getApi().setRoomVariables(null, theRoom, Arrays.asList(user2, user3));