Hello,
I am new to smartfox.
I am trying to implement match expression.
find room if it is a game room and age variable +5 or -5 and distance variable should be1.
If I am trying to combine and or operator's together not getting the accurate results.
Can anyone please help me how to write the match expression for the above query.
Matchmaking
-
- Posts: 6
- Joined: 11 Feb 2021, 11:03
Re: Matchmaking
Hi and welcome,
can you show us the expression you are using and the results you get?
Thanks
can you show us the expression you are using and the results you get?
Thanks
-
- Posts: 6
- Joined: 11 Feb 2021, 11:03
Re: Matchmaking
Code: Select all
MatchExpression exp = new MatchExpression(Constants.IS_GAME_STARTED, BoolMatch.EQUALS, false).
and(Constants.TARGET_VALUE_VARIABLE, NumberMatch.EQUALS, player.distance).
and(Constants.AGE_VARIABLE, NumberMatch.GREATER_THAN_OR_EQUAL_TO, player.age-5);
List<Room> rooms = getApi().findRooms(user.getZone().getRoomList(), exp, 0);
Need to add like player age +5 or -5.
I need to add multiple or and logic gates. But the results are not according to the expression. I need help on how to combine and or.
Thank you in advance
Re: Matchmaking
Hi,
match expressions are essentially linear, meaning that you can chain a number of conditions together using logical operators but you can't create nested conditions, if this is what you're asking.
What you can do is use multiple passes: in other words first you create an expression to filter the rooms with IS_GAME_STARTED and a the TARGET_VALUE_VARIABLE.
With the resulting Room list you can do a second pass where you search for (age + 5) OR (age -5) .
Of course this should be done on the server side. From client side it would be slower and more expensive as you have to send two requests over the internet.
Hope it helps
match expressions are essentially linear, meaning that you can chain a number of conditions together using logical operators but you can't create nested conditions, if this is what you're asking.
What you can do is use multiple passes: in other words first you create an expression to filter the rooms with IS_GAME_STARTED and a the TARGET_VALUE_VARIABLE.
With the resulting Room list you can do a second pass where you search for (age + 5) OR (age -5) .
Of course this should be done on the server side. From client side it would be slower and more expensive as you have to send two requests over the internet.
Hope it helps
Who is online
Users browsing this forum: Ronaldniff, Stevenor and 79 guests