Display names in snake order

So I have a simple application that my friends and I use to draft players for the NCAA tournament upcoming. I have the entire draft process down & it works, but I want the app to reveal whose turn it is.

So let’s say we have the names:

That is the first round draft order, but the 2nd round, it’ll snake, so the draft order will be:

What logic would I need to use within my app for a simple textbox to display who is next after a player is selected? Thanks!

If you have the names of the player in a table, just put a rank field so it looks like this

name, rank
John, 2
Jordan, 3
Chris, 4
Ben, 5

Then for the first round sort the list by rank normally and for the second round sort it by rank DESC, and then keep alternating each round.

Basically what I want to happen here is it says: [Whoever is up] is on the clock.

Once they draft somebody, it changes to the next person is up.

Here’s the app. https://application.bballtools.com/version-test/2018pd

I have every owner’s name and original draft position as field types under a data type called 2018pdowners. There are 9 draftees.

In theory, when it’s the first person’s turn to pick, I have a text field that says if your draft position is 1, you’re on the clock & it displays that.

Once they pick, the person who is draft position #2 has their name displayed as on the clock. The logic is pretty easy until it snakes back around to pick #10, when the person who was just pick #9 goes again.

I presume you have a workflow for when someone drafts a player and in that workflow you must set the current “owner”. So after Owner 1 drafts someone , you change the current owner to owner #2. Right?

Create a numeric custom state called nextOwnerIndex and when the draft starts, use a workflow to set it to 1. Then in the action you currently have that sets who the NEXT “currentOwner” is, make an expression that says NEXT currentOwner = currentOwner’s postion + nextOwnerIndex , but BEFORE that action, have two other actions. One that says “update nextOwnerIndex to 1 only when currentOwnerPosition is 1” and the other action that says “update nextOwnerIndex to -1 only when currentOwnerPosition is count of all owners”.

This way, when you are going up the list, you will keep adding 1 until you hit the last owner, no matter how many there are (count of all owners), but once you hit that 10th (or 15th or 30th) owner, you will starting going DOWN the list, with the -1 until you hit the first owner, and you will start all over again.

Make sense?

@mguerrasio yes, thanks so much! I almost have it exactly how I want it.

The only issue I have is the when it gets up to #9, #9 doesn’t get to pick twice, it just goes back down to #8.

Same when it’s decreasing and gets to #1, #1 should get two picks, but it goes to #2 after they get 1.

Seems like it should be an easy fix, but struggling a bit with it.

Thanks again for your help!

@mguerrasio welp, I actually figured out the logic of this, but just realized a custom state only works for the person accessing. I’ll have 10 or so people on here…is there another way to do this logic but not with custom states?

My mistake on suggesting the custom state and not thinking through the scope. Custom state is practically the same thing as creating a database table with a field. So either you can use a table you already have like if for instance there is a table that holds the information about the current draft you could put a field in that table called current owner index or you can just create a whole new table simply to hold that one field.

thanks! that’s what I ended up doing and it works great! thanks again!

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