Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. /// mutates the current state of the board given a [move]
  2. /// and provides a list of Block Actions that should be executed in linear order
  3. /// to sync UI to this logic container
  4. ///
  5. /// For Instance:
  6. /// - if a block is moved east, and that block falls, this method will return
  7. /// two actions. One action for moving east, one for "falling" the block
  8. List<dynamic> commitChange(AvailableMove move) {
  9. var changes = List();
  10.  
  11. /// do nothing if nothing is supplied
  12. if (move == null) {
  13. return changes;
  14. }
  15.  
  16. /// first resolve any East or West movements as that is the first thing a
  17. /// user can initiate. A user cannot initiate a fall without a lateral move.
  18. ///
  19. /// we set the current location of the block to a "blank space", but first make
  20. /// a copy of the block so that it can be moved laterally
  21. changes.add(BlockActionMove(this[move.currentBlock].uniqueId,
  22. move.currentBlock, move.currentBlockMoveTo));
  23. _swap(move.currentBlock, move.currentBlockMoveTo);
  24.  
  25. /// normalize the board!
  26. changes.addAll(resolvePrimedActions());
  27.  
  28. return changes;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement