top of page
  • Writer's pictureCRM Science

Dr. Nim is struck by lightning!

The last Lab Coat Lesson used the tried and true tools of Apex and Visualforce. Times are changing and Lightning isn't just the future, it's the here and now. This Dr. Nim series of lab coat lessons wouldn't be complete without a Lightning implementation of Dr. Nim. We took advantage of the Lightning Design System to give the game a sleek user interface and Lightning Components to run the entire game client-side. No trips to the server means the Artificially Intelligent opponent will beat you even faster!

Here's the redesigned app, with built-in responsiveness so you can play on your phone.


Here's a little extra styling. This gives the game a little extra breathing room.

Here's the controller

Here's the helper

The challenge is in the helper. There is a function named doPlayer2Turn that is empty. Convert the algorithm from the last post from Apex to Javascript and add a few more lines and the game will be complete! For bonus points, make the game even prettier by changing out the Os we're using for the coins to an SVG icon from the Lightning Design System of your choosing.

Recent Posts
bottom of page