Makefiles and small reformatting

This commit is contained in:
Daniel Ziltener 2021-01-08 23:35:24 +01:00
parent 9cc0e7b2f7
commit b1195f2c7a
8 changed files with 96 additions and 39 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.png

8
Makefile Normal file
View File

@ -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

View File

@ -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)))

15
resources/Makefile Normal file
View File

@ -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

View File

@ -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">
<defs
id="defs2">
@ -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)">
<g
id="g1329"
id="water"
transform="translate(-134.60573,-17.50951)">
<g
id="g1877">
@ -120,7 +120,7 @@
</g>
</g>
<g
id="g1064"
id="temple"
transform="translate(-135.4667)">
<rect
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.698002;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@ -361,7 +361,7 @@
sodipodi:nodetypes="ccc" />
</g>
<g
id="g1118"
id="market"
transform="translate(-135.4667)">
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.176389;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@ -530,7 +530,7 @@
sodipodi:nodetypes="cc" />
</g>
<g
id="g1178"
id="gate"
transform="translate(-135.4667)">
<rect
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.352348;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@ -725,7 +725,7 @@
r="1.9792167" />
</g>
<g
id="g1279">
id="treasury">
<path
id="rect1727-7"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.05833;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@ -768,8 +768,9 @@
r="1.8438855" />
</g>
<g
id="g1942"
transform="translate(-204.70008,-96.34842)">
id="flower"
transform="translate(-204.70008,-96.34842)"
inkscape:label="#flower">
<path
id="rect1104"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.352777;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@ -850,13 +851,13 @@
r="1.6715595" />
</g>
<circle
style="fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.352778;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1215"
style="fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.35277799;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="piece-black-bottom"
cx="-122.44247"
cy="226.39716"
cy="226.66443"
r="11.145638" />
<g
id="g1330"
id="piece-black-top"
transform="translate(140.71186,-12.307438)">
<circle
style="fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.352778;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@ -896,7 +897,7 @@
r="1.8438855" />
</g>
<g
id="g1338"
id="piece-white-top"
transform="translate(139.92157,1.2827925)">
<circle
style="fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.352778;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
@ -937,13 +938,13 @@
</g>
<circle
style="fill:#b3b3b3;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.352778;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1215-6-9"
id="piece-white-bottom"
cx="-122.9573"
cy="267.88086"
r="11.145638" />
<rect
style="opacity:0.997;fill:#f18274;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.700009;stroke-miterlimit:4;stroke-dasharray:none"
id="rect160"
id="button"
width="231.11613"
height="22.55224"
x="-394.35709"
@ -952,7 +953,7 @@
inkscape:export-ydpi="65.709999" />
<rect
style="opacity:0.997;fill:#ec533e;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.700008;stroke-miterlimit:4;stroke-dasharray:none"
id="rect160-3"
id="button-hover"
width="231.11613"
height="22.55224"
x="-394.70844"
@ -961,13 +962,13 @@
inkscape:export-ydpi="65.709999" />
<rect
style="fill:#fee2bb;fill-opacity:1;fill-rule:evenodd;stroke:#161962;stroke-width:2.64583;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect163"
id="house"
width="44.134106"
height="44.134106"
x="-387.59775"
y="157.81102" />
<g
id="DieW1"
id="die1"
transform="matrix(0.26458333,0,0,0.26458333,-274.82042,211.04092)">
<path
d="m 3.05,53.3 a 2.65,2.65 0 0 1 -2.3,-1.3 2.62,2.62 0 0 1 0,-2.7 L 28.15,1.8 a 2.68,2.68 0 0 1 4.6,0 l 27.4,47.5 a 2.62,2.62 0 0 1 0,2.7 2.65,2.65 0 0 1 -2.3,1.3 z"
@ -1007,7 +1008,7 @@
id="path181" />
</g>
<g
id="DieB1"
id="die0"
transform="matrix(0.26458333,0,0,0.26458333,-297.35837,210.92554)">
<path
d="m 3.15,53.4 a 2.65,2.65 0 0 1 -2.3,-1.3 2.62,2.62 0 0 1 0,-2.7 L 28.25,1.9 a 2.68,2.68 0 0 1 4.6,0 l 27.4,47.5 a 2.62,2.62 0 0 1 0,2.7 2.65,2.65 0 0 1 -2.25,1.3 z"

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -0,0 +1,7 @@
all: die0.png die1.png piece-black-bottom.png piece-black-top.png piece-white-bottom.png piece-white-top.png
clean:
rm *.png
%.png: ../drawingboard.svg
inkscape --export-id="$*" --export-id-only $< --export-width=75 --export-height=75 --export-png="$@"

10
resources/tiles/Makefile Normal file
View File

@ -0,0 +1,10 @@
all: house.png flower.png water.png temple.png market.png gate.png treasury.png
clean:
rm *.png
house.png: ../drawingboard.svg
inkscape --export-id="house" --export-id-only ../drawingboard.svg --export-width=120 --export-height=120 --export-png="$@"
%.png: ../drawingboard.svg
inkscape --export-id="$*" --export-id-only $< --export-width=100 --export-height=100 --export-png="$@"

7
resources/ui/Makefile Normal file
View File

@ -0,0 +1,7 @@
all: button.png button-hover.png
clean:
rm -f button.png button-hover.png
%.png: ../drawingboard.svg
inkscape --export-id="$*" --export-id-only $< --export-width=750 --export-height=50 --export-png="$@"