Amending a rankings list

Hello,

I am trying to build a ladder league where players will challenging others for games and if the player who makes the challenge wins takes the place of the player who loses and the players who loses goes the position where the player who made the challenge was.

My data structure is as follows:
Users:

  • Name
  • Ranking
  • Email

Scores:

  • Player 1 name = user
  • Player 2 name = user
  • Player 1 sets won (called challenger also) = number
  • Player 2 sets won (called challenged also) = number

and imagine my league table is something like this

Name Ranking
John Rank 1
Ben Rank 2
Chris Rank 3
David Rank 4
Theo Rank 5

Now, when Theo challenges Ben and wins Theo should go to number 2 and Ben to number 5 and the list should be like this

John Rank 1
Theo Rank 2
Chris Rank 3
David Rank 4
Ben Rank 5

I manage to make the changes for player 1 (theo) to take player 2 (ben) rank. However when i am trying to change his position with Theo the data base considers that Theo took the place of Ben so he is number 2, Ben should take the place of Theo which currently is number 2 therefore Ben remains to number 2. What i need is to find a way to transfer Ben to Theo’s position before the change.

This is when Theo (player 1) takes the place of Ben (player 2)
image

and this is when Ben suppose to take Theo’s place

image

I hope this helps.

I would highly appreciate your assistance, maybe there is something easy that i am missing out.

Thanks a lot guys.

Hi there, @kyr28… your description of what is happening makes perfect sense because once you change player 1’s rank, you no longer have access to the player 1’s original rank in order to assign it to player 2. So, one way you could solve the issue is to create a custom state and use it to hold player 1’s original rank before you change the rank. Then, you would simply set player 2’s rank to the value of the custom state (which is player 1’s original rank). Any of that make sense?

Hope this helps, even if it’s just food for thought.

Best…
Mike

Hi @mikeloc ,

Thank you for taking time to reply to me!

lets say that this works, the new ranking of player 2 will now become his original rank?

I mean that when Ben makes a challenge to any player above him and wins, Ben (player 1) must take the other’s player’s ranking and the other player (player 2) should take Ben’s current ranking and so on and so forth.

I don’t know if i confused you, i hope not.

Thanks a lot in advance.

Hmm, I thought your original post was pretty clear, so I probably confused myself at some point.

What I was trying to say in my initial response still seems like it would work… when Ben challenges a player and wins, you have to “hold” Ben’s current rank somewhere (I suggested a custom state) before you change Ben’s rank to the rank of the player who Ben beat. If you change Ben’s rank without putting his original rank somewhere else, you don’t know what Ben’s original rank was so you can give it to the other player.

I still might be confused, though, so let’s use the example in your original post, with Ben ranked at 2 and Theo ranked at 5. Now, Theo challenges Ben and wins. So, the workflow goes like this…

  • Put Theo’s current rank into a custom state… so, the custom state’s value is now 5.
  • Change Theo’s rank to Ben’s current rank… so, Theo’s rank is now 2.
  • Change Ben’s rank to the value of the custom state… so, Ben’s rank is now 5.

Anyway, hopefully I have understood your post correctly, and I hope I was able to clarify my proposed solution. My apologies if I have only made things more confusing, but it seems to make sense in my head, at least. :slight_smile:

Best…
Mike

Hi Mike,

thanks once again for taking time to reply. I will try that to check if it works… The app is about a tennis league with appx 20 players challenging each other so the workflows must work without any errors.

any i also thought of something and i would be gratefull if i receive your feedback.

i changed my data type of users as follows

Name= Text
Original ranking (will be created upon registration) = Number
Current ranking = Number (default is 0)

Now I thought of the following:

When Player 1 wons change Player 1 current ranking and this ranking will be Player’s 2 original ranking.
Then change player 2’s current ranking and this will be Player 1 original ranking.
Then change player 1 original ranking to be player 1 current ranking (in order to transfer current ranking to the original)
Then change player 2 original ranking to be player 2 current ranking (in order to transfer current ranking to the original)

i havent gave it a shot yes but as i am thinking of it, it is more or less the same as your proposal.

thanks for the assistance Mike.

My pleasure, @kyr28… happy to try to help.

Yup, I almost suggested using a separate field as you have described, but I went the custom state route instead. Like you said, our proposals are pretty much the same… as long as you have a way to access the first player’s original rank after you change that player’s rank, then you should be good to go, if I understand everything correctly.

Best…
Mike

I will give a try to both ways and see which one works and let you know.

I owe you one once i know the platfrom well :slight_smile:

1 Like

It worked fine!!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.