The most prominent part of Treasure Chest is the tile map. In the game, the map is build out of an array that stores the type of gem and image objects that represent the visible part of the game. For sure, it could be handled differently, but we will take this route for now.
Let's start with two methods that will determine the slot positions of a corresponding gem image object. Remember, its position has to be divided by its width to get the slot position.