Code 2: Move Constraints

One limitation of codeless versions of Scramble and other games is the lack of facility for preventing illegal moves. A move constraint is a piece of code that determines whether or not the corresponding game rule is broken. Move constraints often work in conjunction with the game-state object, which encapsulates the current game-state.

 

Move constraints which are limited to preventing the dragging of Card or Card-stack objects from one container object to another can be accomplished without coding. This is due to the fact that every grid and Card-stack object has a property called drop-list, which is a list of objects that may accept drag-and-drop operations originating with the property owner.

 

Scramble

·      Next Button

Word is connected

Word is contiguous

Word is in dictionary

Interchanged blank is used on same turn

·      Double-Click on Board

Interchange blank if valid

·      Drag from Board

Prevent dragging letters not in current turn

·      Drop on Bag

If 3 of a kind, then accept

Else if user is scrambling, then accept