Since time immemorial, humans have always loved shiny, sparkly rocks. From cut diamonds that glitter like a pond at sunset to fool’s gold which doesn’t melt or react the way we need a precious metals to act, we gravitate toward shiny objects. We even call being easily distracted by other things that draw our attention away from our original goal: “shiny object syndrome”.
In our ReqDoc, there’s this line: “The deeper he goes into these ruins, the more and rarer the Legendary he releases. When he catches these dinosaurs, he’s given a special ROCK…” So we need to check if the Pokemon we caught was a Legendary Pokemon, and, if so, release a special rock as a reward.
Capture_Dino() Revision
var cellID : int = find_closest_empty_cell(dino)
var dino_family : String = all_pieces[game_board[dino]].family
if cellID != Empty and dino_family == "legendary":
print(" = GB Releasing Rock = ")
make_piece(1, "rock", -1) #Rocks are the bonus XP of the game.
place_piece(all_pieces.size()-1, cellID, dino)
else:
print(" = GB No Rock Released! Game board full! = ")
...This is easy enough to understand. We find_closest_empty_cell to the dino. Then check that the cellID is actually empty, and the dino we captured is in the “Legendary” family vs all dinos.
Then it’s simply a matter of making the piece of the rock family and placing it in the empty cell coming from the dino’s cell.
Test and Verify
Again, we’ve got a bit of work to get up to the level of releasing a Legendary, but we can also verify that it doesn’t release a rock when we capture a non-Legendary dino.
Now that we can get the Rocks released, we can also test that we can merge them together. We can’t yet pick them up or earn a bonus score from them, but that’s next.
Collecting Rocks
This is the easiest thing since you just need to modify 1 line of code. In the _on_cell_clicked section, from this …
...
if click_family == "crystal":
print(" GB Crystal Clicked Twice!")
update_score(click)
...… to this …
...
if click_family == "crystal" or click_family == "rock":
print(" GB Crystal or Rock Clicked Twice!")
update_score(click)
...Easy!
Update_Score() Revision Pt 1
...
var bonus_score : int = 0
var family : String = all_pieces[game_board[cell_id]].family
if family == "rock":
bonus_score = texture_id * 10
print (" = GB Bonus Score = ", bonus_score)So the crystals are the “new_score” that gets added together. The rocks are a “bonus_score” that get’s multiplied before it’s added in.
So we need to change the final score line from this …
score += new_score… to this …
score += new_score + bonus_scoreTest and Verify
The biggest problem that I noticed is sometimes the final score is higher than the level_score for the next level. If you add the score just a little bit at a time, it works ok, but the bigger jump in score that you make, the more likely it is to error. So let’s fix that.
Update_Score() Revision Pt 2
...
print(" = GB Updated Score = ", score, " & Level_score = ", level_score)
if score >= level_score:
...
<make chest>
<update score, level, and level_score>
print(" = GB Updated Score = ", score, " & Level_score = ", level_score)
else:
print(" GB Score < level_score")
passI uncommented the debugger print statements so I can see what’s going on easier. Basically, if I take a lot of points all at once, it only runs this code 1x but is still left with a score higher than level_score. Instead, I change it to a while loop like this…
...
print(" = GB Updated Score = ", score, " & level_goal = ", level_goal)
while (score >= level_goal):
...
<make chest>
<update score, level, and level_score>
print(" = GB Updated Score = ", score, " & level_goal = ", level_goal)It does the check up front the same as the if statement, but it also checks it at the end to see if I need to do this all again.
Test and Verify
To test, I played the game until I merged the crystals into a vial (max_texture). This is 45 points. Obviously that’s greater than the 10 needed to level up. In my debug comments, I see this:
= GB Updated Score = 45 & level_goal = 10This is exactly as expected: I gained 45 points, but the level_goal is only 10.
= GB Updated Score = 35 & level_goal = 20This is at the end of the 1st iteration. It’s reduced the score by the prior level_goal and increased the new level_goal to match the new level.
= GB Updated Score = 15 & level_goal = 30This is the end of the 2nd iteration. It’s reduced the score again by the new level_goal and increased the level_goal again to match the new level as the game board jumps from Level 1 to Level 3. Success!

