Matchmaking

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

saiteja1412
Posts: 6
Joined: 11 Feb 2021, 11:03

Matchmaking

Postby saiteja1412 » 23 Feb 2021, 13:28

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.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Matchmaking

Postby Lapo » 24 Feb 2021, 08:51

Hi and welcome,
can you show us the expression you are using and the results you get?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
saiteja1412
Posts: 6
Joined: 11 Feb 2021, 11:03

Re: Matchmaking

Postby saiteja1412 » 25 Feb 2021, 14:19

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
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Matchmaking

Postby Lapo » 26 Feb 2021, 16:46

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
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 49 guests