Checking text entry against table for treasure hunt game

Hello all,

I am attempting to implement a game of sorts into our conference app and am having a little trouble with how to action the main feature as I’m still relatively new to Glide.

What I want:
Users find a code IRL which they enter into a text field in the app.
When clicking the Check My Code! button, the app first checks if the code entered is valid based on a table containing two things: The Code and a Points value.
If the code is invalid, it displays a notification saying so and the user has to try again.
If the code is valid then:

  • The User is awarded the current points value of the code in the code table.
  • The points awarded is displayed on screen.
  • The points value of the code is reduced by 10.
  • The user cannot gain points from this code any more.

Currently, what I have is the following:

  • The Users table has 2 relevant columns: A Boolean called “Joined Hunt” and a Text column called “Code Check”.
  • The user is given a free code to get them started. When they enter this into the text field, it writes their entry to the “Code Check” field and checks if it matches the first code. If it is correct, the “Joined Hunt” Boolean is checked and a new column is created in the “Hunters” table. Their name is written to a text column and 1000 points are awarded into a number column. There is also a Lookup column containing all the valid codes from a “Codes” table. This is the end of the tutorial and the page now just displays the text entry field and button. The user can now enter any other codes they find.
  • When the user enters a code into the text field, it once again writes to their “Code Check” field in the User table and checks it against the lookup column to see if there is a match.

This is the point where I am stuck. I can successfully make the check against the lookup column, but I don’t know how to make it so
a) Each user can only enter a code once
b) The point value for the code is reduced by 10 every time it is submitted.

Is anyone able to give me some help with this? Is it possible to do?

In the Codes table, you can add a boolean column that is user-specific, let’s call it “Awarded?”. Add another number user-specific column, call it “Points awarded”.

When the user writes to the “Code Check” column in the Users table, create a single relation from that to the actual Codes in the Codes table. Add a lookup column to retrieve the “Awarded” boolean, and another lookup column to retrieve the “Points awarded” column.

  • If there’s no match from the relation, show the “try again” notification when the user presses the button.

  • If there’s a relation, but the “Awarded” lookup is checked, then show a notification that the code has already been claimed by you.

  • If there’s a relation, but the “Awarded” lookup is not checked, then do the steps here:

1/Set the current points value of the code to the “Points awarded” column that is user-specific, set the Awarded boolean to true.

2/Increment the current points value of the code by -10.

3/Display the points awarded on the screen through the lookup. Add a template column to prettify it if you need, e.g: “You have earned X points”.

2 Likes

Thank you ThinhDinh, That is an amazing help. I’ve gotten 90% of the way there but need a little bit more help with the action for checking the code.

I don’t believe I am doing the check correctly here as no matter what I enter into the form, whether it is invalid, valid but used or valid but unused, It always displays the middle notification “Code already claimed!”. The configure condition only lets me use “is empty” or “is not empty” for the Code Check Relation column, What am I meant to be putting here?

Good morning @ThinhDinh. Are you able to offer any help for my above issue on checking the code please?

From your screenshot, can you tell me what your Code Found column is doing? In my comment above, I expected that to be a lookup column from the Codes table.

The Code Found is a user-specific Boolean in the Codes table. In your tutorial above you named it “Awarded?”

Ah I think I see the problem. I missed the step of adding the Lookup to the user table for the Boolean. Let me add that and see what I get :slight_smile:

1 Like

Thank you ThinhDinh! Turns out I misunderstood some of the instructions and put the lookups in the code table instead of the user table. The game is now fully functional and is working fantastically!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.