GameActions.js 794 B

123456789101112131415161718192021222324252627282930313233
  1. const GameConstants = require('../constants/GameConstants');
  2. const AppDispatcher = require('../dispatcher/AppDispatcher');
  3. const GameActions = {
  4. makeMove(from, to, capture, emitMove) {
  5. AppDispatcher.handleViewAction({
  6. actionType: GameConstants.MAKE_MOVE,
  7. from: from,
  8. to: to,
  9. capture: capture,
  10. emitMove: emitMove
  11. });
  12. },
  13. rematch() {
  14. AppDispatcher.handleViewAction({
  15. actionType: GameConstants.REMATCH
  16. });
  17. },
  18. gameOver(options) {
  19. AppDispatcher.handleViewAction({
  20. actionType: GameConstants.GAME_OVER,
  21. options: options
  22. });
  23. },
  24. changePromotion(promotion) {
  25. AppDispatcher.handleViewAction({
  26. actionType: GameConstants.CHANGE_PROMOTION,
  27. promotion: promotion
  28. });
  29. }
  30. };
  31. module.exports = GameActions;