Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
568 additions
and
29 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const GameChannel = require("../../channel/GameChannel.bs"); | ||
|
||
exports.subscribe = game => () => | ||
GameChannel.subscribe(game); | ||
|
||
exports.commit = subscriber => game => () => | ||
GameChannel.commit(subscriber, game); | ||
|
||
exports.report_progress = subscriber => x => () => | ||
GameChannel.report_progress(subscriber, x); |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module App.Channel.GameChannel where | ||
|
||
import Prelude | ||
|
||
import App.Command.Manager (CommandGroup) | ||
import App.Game (Game) | ||
import Effect (Effect) | ||
|
||
foreign import data Subscriber :: Type | ||
|
||
foreign import subscribe :: Game -> Effect Subscriber | ||
foreign import commit :: Subscriber -> CommandGroup -> Effect Unit | ||
foreign import report_progress :: Subscriber -> Number -> Effect Unit |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
exports.isMerge = cmd => { | ||
switch (cmd.tag | 0) { | ||
case /* Merge */0 : | ||
return true; | ||
case /* Translate */1 : | ||
return false; | ||
case /* Rotate */2 : | ||
return false; | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module App.Command.Command where | ||
|
||
foreign import data Command :: Type | ||
|
||
foreign import isMerge :: Command -> Boolean |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const CommandManager = require("../../playboard/command/CommandManager.bs"); | ||
|
||
exports.onPost = action => () => CommandManager.onPost(cmd => action(cmd)()); | ||
exports.onCommit = action => () => | ||
CommandManager.onCommit(cmds => { | ||
Object.assign(cmds, { commands: cmds[0], extrinsic: cmds[1] }); | ||
action(cmds)(); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module App.Command.Manager where | ||
|
||
import Prelude | ||
|
||
import App.Command.Command (Command) | ||
import Effect (Effect) | ||
|
||
type CommandGroup = | ||
{ extrinsic :: Boolean | ||
, commands :: Array Command | ||
} | ||
|
||
foreign import onPost :: (Command -> Effect Unit) -> Effect Unit | ||
foreign import onCommit :: (CommandGroup -> Effect Unit) -> Effect Unit |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const Game = require("../playboard/Game.bs"); | ||
|
||
|
||
exports.create = (id) => (field) => () => { | ||
const obj = Game.create(id, field); | ||
obj.id = obj[0]; | ||
obj.isStandalone = obj[1]; | ||
obj.puzzleActor = obj[2]; | ||
obj.pieceActors = obj[3]; | ||
obj.image = obj[4]; | ||
obj.isImageLoaded = obj[5]; | ||
obj.isUpdated = obj[6]; | ||
obj.readyHandlers = obj[7]; | ||
obj.updatedHandlers = obj[8]; | ||
return obj; | ||
}; | ||
|
||
exports.progress = game => () => | ||
Game.progress(game); | ||
|
||
exports.loadImage = game => url => () => { | ||
Game.loadImage(url, game); | ||
}; | ||
|
||
exports.loadContent = game => content => () => { | ||
Game.loadContent(content, game); | ||
}; | ||
|
||
exports.setUpdated = game => () => { | ||
Game.setUpdated(game); | ||
}; | ||
|
||
exports.shuffle = game => () => { | ||
Game.shuffle(game); | ||
}; | ||
|
||
exports.onReady = game => action => () => { | ||
Game.onReady(action, game); | ||
}; | ||
|
||
exports.onUpdated = game => action => () => { | ||
Game.onUpdated(action, game); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module App.Game where | ||
|
||
import Prelude | ||
|
||
import Effect (Effect) | ||
import Web.DOM (Element) | ||
|
||
foreign import create :: Int -> Element -> Effect Game | ||
foreign import progress :: Game -> Effect Number | ||
foreign import loadImage :: Game -> String -> Effect Unit | ||
foreign import loadContent :: Game -> String -> Effect Unit | ||
foreign import setUpdated :: Game -> Effect Unit | ||
foreign import shuffle :: Game -> Effect Unit | ||
foreign import onReady :: Game -> Effect Unit -> Effect Unit | ||
foreign import onUpdated :: Game -> Effect Unit -> Effect Unit | ||
|
||
type Game = | ||
{ id :: Int | ||
, isStandalone :: Boolean | ||
, isImageLoaded :: Boolean | ||
, isUpdated :: Boolean | ||
-- , puzzleActor | ||
-- , pieceActors | ||
-- , image | ||
-- , readyHandlers | ||
-- , updatedHandlers | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const BrowserInteractor = require("../../playboard/interactor/BrowserInteractor.bs"); | ||
|
||
exports.attach = gi => () => | ||
BrowserInteractor.attach(gi); |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module App.Interactor.BrowserInteractor where | ||
|
||
import Prelude | ||
|
||
import App.Interactor.GameInteractor (GameInteractor) | ||
import Effect (Effect) | ||
|
||
foreign import attach :: GameInteractor -> Effect Unit |
Oops, something went wrong.