-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update SpecialMoves to utilize state management, coincidentally fix #33
- Loading branch information
1 parent
b5ca294
commit afd1662
Showing
10 changed files
with
174 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,27 @@ | ||
package jchess.common.moveset; | ||
|
||
import jchess.common.IChessGame; | ||
import jchess.ecs.Entity; | ||
|
||
public record MoveIntention(Entity displayTile, Runnable onClick, IMoveSimulator moveSimulator) { | ||
|
||
/** | ||
* This is a utility Method for constructing a MoveIntention in the specific use-case where the moveSimulator matches the actual move. | ||
*/ | ||
public static MoveIntention fromMoveSimulator(IChessGame game, Entity displayTile, IMoveSimulator moveSimulator) { | ||
return new MoveIntention( | ||
displayTile, | ||
() -> { | ||
moveSimulator.simulate(); | ||
game.endTurn(); | ||
}, | ||
moveSimulator | ||
); | ||
} | ||
|
||
public interface IMoveSimulator { | ||
void simulate(); | ||
|
||
void revert(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.