diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aab52d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.png \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..891df13 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +run: resources + csi -s main.scm + +resources: resources/drawingboard.svg resources/Makefile + make -C resources all + +clean: + make -C resources clean diff --git a/board.scm b/board.scm index 7fbfa28..f1f099b 100644 --- a/board.scm +++ b/board.scm @@ -112,11 +112,10 @@ (define (initialize-state!) (set! state `((active-player: . 1) + (phase: . roll-dice:) (players: . ((1 . ((type: . local:) - (state: . begin:) (piece-y-offset: . -10))) (2 . ((type: . local:) - (state: . wait:) (piece-y-offset: . 10))))) (pieces: . (,(init-piece 1 0) ,(init-piece 1 1) @@ -133,9 +132,15 @@ ,(init-piece 2 5) ,(init-piece 2 6)))))) + (define (update-state! player kw) + (set-cdr! (alist-ref player (alist-ref players: state) state) kw)) + (define (refo coll key val) (membero (cons key val) coll)) + (define (commando out key val) + (membero (cons key val) out)) + (define (field coords type) (membero (cons coords type) orig-board)) @@ -173,21 +178,22 @@ (conda ; v Subconditions ((piece-pos target-piece newpiece-pos) ; | Given there is a piece on the target house (conda ((refo target-piece player: player) ; | It's the player's faction - (membero (cons block: #t) out)) ; | | => Deny the movement + (commando out block: #t)) ; | | => Deny the movement ((refo target-piece uuid: target-uuid) ; | It's the enemy faction (conda ((field newpiece-pos flower:) ; | | Given the piece would end up on flower - (membero (cons block: #t) out)) ; | | | => Deny the movement + (commando out block: #t)) ; | | | => Deny the movement ; | | Else: yeet the piece back to start - ((membero (cons reset: target-uuid) out) ; | | | => Reset the enemy piece - (membero (cons move: piece-uuid) out)))))); | | | => Move the player piece + ((commando out reset: target-uuid) ; | | | => Reset the enemy piece + (commando out move: piece-uuid)))))) ; | | | => Move the player piece ; | Else: The target house is clear - ((conda ((field newpiece-pos flower:) ; | | Given the piece would end up on flower - (membero (cons move: piece-uuid) out) ; | | | => Move the piece - (membero (cons state: (cons player begin:)) out)) ; | | | => Set the state so the dice can be rolled again - ((membero (cons move: piece-uuid) out)))) ; | | Else: move the piece - ((membero (cons move: piece-uuid) out)))) ; | => Move the player piece + ((conda ((field newpiece-pos flower:) ; | | Given the piece would end up on flower + (commando out move: piece-uuid) ; | | | => Move the piece + (commando out phase: roll-dice:)) ; | | | => Set the state to the dice reroll + ((commando out move: piece-uuid) ; | | Else: move the piece + (commando out switch-player: #t) + (commando out phase: roll-dice:)))))) ; | => Move the player piece ; Else: Target would be off board - ((membero (cons block: #t) out))))) ; | => Deny the movement + ((commando out block: #t))))) ; | => Deny the movement (define (check-can-player-move player dice out) (fresh (piece commands) ; Initialize empty variables @@ -256,6 +262,8 @@ (define (check-piececlick) (let/cc break (let* ((active-player (alist-ref active-player: state)) + (player-state (alist-ref state: (alist-ref active-player (alist-ref players: state)))) + (nonsense (print "Player state:" player-state)) (piece (find (lambda (x) (and (sdl2:point-in-rect? (get 'sdlprops 'mouse-point) (alist-ref coords: x)) (eq? (alist-ref player: x) active-player))) diff --git a/resources/Makefile b/resources/Makefile new file mode 100644 index 0000000..d862fc9 --- /dev/null +++ b/resources/Makefile @@ -0,0 +1,15 @@ +all: tiles sprites ui + +clean: + make -C tiles clean + make -C sprites clean + make -C ui clean + +tiles: drawingboard.svg tiles/Makefile + make -C tiles all + +sprites: drawingboard.svg sprites/Makefile + make -C sprites all + +ui: drawingboard.svg ui/Makefile + make -C ui all diff --git a/resources/drawingboard.svg b/resources/drawingboard.svg index acb1515..66ff73b 100644 --- a/resources/drawingboard.svg +++ b/resources/drawingboard.svg @@ -12,7 +12,7 @@ viewBox="0 0 343.97772 128.64168" version="1.1" id="svg8" - inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" sodipodi:docname="drawingboard.svg"> @@ -34,19 +34,19 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="0.49497475" - inkscape:cx="814.234" - inkscape:cy="616.01878" + inkscape:zoom="0.98994949" + inkscape:cx="659.63446" + inkscape:cy="225.95461" inkscape:document-units="mm" inkscape:current-layer="layer1" inkscape:document-rotation="0" showgrid="false" inkscape:snap-global="false" - inkscape:window-width="1631" - inkscape:window-height="1063" - inkscape:window-x="835" - inkscape:window-y="203" - inkscape:window-maximized="0" + inkscape:window-width="1920" + inkscape:window-height="1015" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" fit-margin-top="0" fit-margin-left="0" fit-margin-right="0" @@ -69,7 +69,7 @@ id="layer1" transform="translate(395.05844,-156.4881)"> @@ -120,7 +120,7 @@ + id="treasury"> + id="flower" + transform="translate(-204.70008,-96.34842)" + inkscape:label="#flower">