Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// mutates the current state of the board given a [move]
- /// and provides a list of Block Actions that should be executed in linear order
- /// to sync UI to this logic container
- ///
- /// For Instance:
- /// - if a block is moved east, and that block falls, this method will return
- /// two actions. One action for moving east, one for "falling" the block
- List<dynamic> commitChange(AvailableMove move) {
- var changes = List();
- /// do nothing if nothing is supplied
- if (move == null) {
- return changes;
- }
- /// first resolve any East or West movements as that is the first thing a
- /// user can initiate. A user cannot initiate a fall without a lateral move.
- ///
- /// we set the current location of the block to a "blank space", but first make
- /// a copy of the block so that it can be moved laterally
- changes.add(BlockActionMove(this[move.currentBlock].uniqueId,
- move.currentBlock, move.currentBlockMoveTo));
- _swap(move.currentBlock, move.currentBlockMoveTo);
- /// normalize the board!
- changes.addAll(resolvePrimedActions());
- return changes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement