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:
Tony
John
Jordan
Chris
Ben
That is the first round draft order, but the 2nd round, it’ll snake, so the draft order will be:
Ben
Chris
Jordan
John
Tony
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!
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.
@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.