Compare commits
1
Commits
main
...
d6cea9649a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6cea9649a |
@@ -6,6 +6,7 @@ build/
|
||||
!**/src/test/**/build/
|
||||
.postgres
|
||||
/db-migration.sql
|
||||
/thecrew-missions.json
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
echo "Checking Database Migration"
|
||||
${pkgs.flyway}/bin/flyway "-url=$MISAEL_DATABASE" -user=misael "-password=$MISAEL_PASSWORD" -locations="filesystem:${misael}/resources/main/db/migration/" -schemas=misael migrate
|
||||
|
||||
export THECREW_IMAGES_FOLDER=${thecrew-images}
|
||||
echo "Launching misael"
|
||||
${jdk}/bin/java -jar ${misael}/misael.jar --spring.datasource.url=$MISAEL_DATABASE --spring.datasource.password=$MISAEL_PASSWORD "$@"
|
||||
'';
|
||||
@@ -45,10 +46,18 @@
|
||||
mkdir -p .postgres
|
||||
${pkgs.podman}/bin/podman run -e POSTGRES_USER=misael -e POSTGRES_PASSWORD=misael-dev -e POSTGRES_DB=misael --volume ./.postgres:/var/lib/postgresql -p 127.0.0.1:5432:5432 postgres:18.4 & > .postgres/postgres.log &
|
||||
'';
|
||||
thecrew-images = pkgs.runCommand "thecrew-images" {} ''
|
||||
mkdir $out
|
||||
cd $out
|
||||
export PATH=${pkgs.inkscape}/bin:$PATH
|
||||
${lib.getExe pkgs.python3} ${./src/main/resources/static/images/thecrew-make.py}\
|
||||
${./src/main/resources/static/images/thecrew.svg}\
|
||||
${./src/main/resources/static/images/thecrew-modifiers.svg}
|
||||
'';
|
||||
in {
|
||||
packages.${system} = {
|
||||
default = self.packages.${system}.misael;
|
||||
misael = misael;
|
||||
inherit thecrew-images misael;
|
||||
};
|
||||
|
||||
apps.${system} = {
|
||||
@@ -79,6 +88,8 @@
|
||||
shellHook = ''
|
||||
echo "Starting Gradle daemon ..."
|
||||
gradle
|
||||
export THECREW_IMAGES_FOLDER=${thecrew-images}
|
||||
export THECREW_MISSIONS_FILE=$PWD/thecrew-missions.json
|
||||
echo "Gradle daemon started."
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.bernard.misael;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class ThecrewConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
|
||||
String imgFolder = System.getenv("THECREW_IMAGES_FOLDER");
|
||||
registry.addResourceHandler("/thecrew/**")
|
||||
.addResourceLocations("file://"+imgFolder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.bernard.misael.web;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/thecrew")
|
||||
public class TheCrewController {
|
||||
|
||||
@GetMapping("/")
|
||||
public String getTheCrewPage() {
|
||||
return "thecrew.html";
|
||||
}
|
||||
|
||||
@GetMapping("/missions.json")
|
||||
public ResponseEntity<String> getMissions() {
|
||||
File missionsFile = new File(System.getenv("THECREW_MISSIONS_FILE"));
|
||||
try {
|
||||
String missionsData = FileCopyUtils.copyToString(new FileReader(missionsFile));
|
||||
return ResponseEntity.ok()
|
||||
.header("Content-Type","application/json")
|
||||
.body(missionsData);
|
||||
} catch (IOException e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import xml.etree.ElementTree
|
||||
import copy
|
||||
import sys
|
||||
import subprocess
|
||||
import pathlib
|
||||
|
||||
thecrewSvgFile = sys.argv[1]
|
||||
thecrewModifiersSvgFile = sys.argv[2]
|
||||
|
||||
def withShownHidden(origXML,toShow,toHide,recolorize={}):
|
||||
|
||||
outXML = copy.deepcopy(origXML)
|
||||
|
||||
for th in toHide:
|
||||
node = outXML.find(f".//{{http://www.w3.org/2000/svg}}*[@{{http://www.inkscape.org/namespaces/inkscape}}label='{th}']")
|
||||
if node is None:
|
||||
print(f"Could not hide node with label {th} : Not Found")
|
||||
exit(1)
|
||||
node.attrib['style'] = "display: none"
|
||||
for ts in toShow:
|
||||
node = outXML.find(f".//{{http://www.w3.org/2000/svg}}*[@{{http://www.inkscape.org/namespaces/inkscape}}label='{ts}']")
|
||||
if node is None:
|
||||
print(f"Could not show node with label {ts} : Not Found")
|
||||
exit(1)
|
||||
nodes = outXML.findall(f".//{{http://www.w3.org/2000/svg}}*[@style]")
|
||||
for node in nodes:
|
||||
for rc in recolorize:
|
||||
node.attrib['style'] = node.attrib['style'].replace(rc,recolorize[rc])
|
||||
return outXML
|
||||
|
||||
def inkscapeToPng(fi,fo):
|
||||
subprocess.run(["inkscape","--export-type","png","--export-dpi","300","--export-filename",fo,fi])
|
||||
|
||||
|
||||
|
||||
|
||||
# Reading file:
|
||||
origXML = xml.etree.ElementTree.parse(thecrewSvgFile)
|
||||
|
||||
suits = ["Hearts","Spades","Diamonds","Clubs","Square","Circle","Triangle","Cross"]
|
||||
suitColors = ["e36a6a","545454","e36a6a","545454","e87caf","0085ca","94c11e","e6b436"]
|
||||
numbers = ["One","Two","Three","Four","Five","Six","Seven","Eight","Nine"]
|
||||
modifiers = numbers + ["Omega","OneArrow","TwoArrow","ThreeArrow","FourArrow"]
|
||||
|
||||
for s,sc in zip(suits,suitColors):
|
||||
for n in numbers:
|
||||
outFile = f"{n.lower()}-of-{s.lower()}.png"
|
||||
toShow = [s,n]
|
||||
toHide = list(set(suits+numbers) - set(toShow))
|
||||
out = withShownHidden(origXML,toShow,toHide, recolorize = {
|
||||
"123456": sc
|
||||
})
|
||||
out.write('card.tmp.svg')
|
||||
inkscapeToPng('card.tmp.svg',outFile)
|
||||
|
||||
origXML = xml.etree.ElementTree.parse(thecrewModifiersSvgFile)
|
||||
for m in modifiers:
|
||||
outFile = f"{m.lower()}.png"
|
||||
toShow = [m]
|
||||
toHide = list(set(modifiers) - set(toShow))
|
||||
out = withShownHidden(origXML,toShow,toHide)
|
||||
out.write('card.tmp.svg')
|
||||
inkscapeToPng('card.tmp.svg',outFile)
|
||||
pathlib.Path.unlink('card.tmp.svg')
|
||||
print("Done !")
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="10mm"
|
||||
height="10mm"
|
||||
viewBox="0 0 10 10"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xml:space="preserve"
|
||||
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
|
||||
sodipodi:docname="thecrew-modifiers.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="true"
|
||||
inkscape:zoom="11.313708"
|
||||
inkscape:cx="17.191534"
|
||||
inkscape:cy="25.411651"
|
||||
inkscape:window-width="1680"
|
||||
inkscape:window-height="1022"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1"
|
||||
showguides="true"><inkscape:grid
|
||||
id="grid8"
|
||||
units="mm"
|
||||
originx="0"
|
||||
originy="0"
|
||||
spacingx="0.99999997"
|
||||
spacingy="0.99999997"
|
||||
empcolor="#0099e5"
|
||||
empopacity="0.30196078"
|
||||
color="#0099e5"
|
||||
opacity="0.14901961"
|
||||
empspacing="5"
|
||||
enabled="true"
|
||||
visible="true" /></sodipodi:namedview><defs
|
||||
id="defs1"><inkscape:path-effect
|
||||
effect="tiling"
|
||||
id="path-effect34"
|
||||
is_visible="true"
|
||||
lpeversion="1.3.1"
|
||||
unit="px"
|
||||
seed="1;1"
|
||||
lpesatellites=""
|
||||
num_rows="17"
|
||||
num_cols="1"
|
||||
gapx="-4"
|
||||
gapy="0"
|
||||
offset="0"
|
||||
offset_type="false"
|
||||
scale="0"
|
||||
rotate="0"
|
||||
mirrorrowsx="false"
|
||||
mirrorrowsy="false"
|
||||
mirrorcolsx="false"
|
||||
mirrorcolsy="false"
|
||||
mirrortrans="false"
|
||||
shrink_interp="false"
|
||||
split_items="false"
|
||||
link_styles="false"
|
||||
interpolate_scalex="false"
|
||||
interpolate_scaley="true"
|
||||
interpolate_rotatex="false"
|
||||
interpolate_rotatey="true"
|
||||
random_scale="false"
|
||||
random_rotate="false"
|
||||
random_gap_y="false"
|
||||
random_gap_x="false"
|
||||
transformorigin="" />
|
||||
|
||||
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath242"><path
|
||||
style="opacity:1;fill:#415c12;fill-opacity:1;stroke:#000000;stroke-width:0.671709;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 1709.2189,406.13284 c -4.2633,2.90065 -1.7186,8.85042 -2.4113,13.16379 0,48.65635 0,97.31269 0,145.96904 0.1247,4.23038 5.9488,5.23308 7.8742,1.65405 7.587,-10.10644 18.2878,-16.3931 28.9918,-22.67885 22.5621,-14.49643 36.3572,-41.58453 34.2383,-68.39796 -1.6209,-30.89618 -24.6859,-59.00274 -54.3368,-67.43023 -4.602,-1.35315 -9.578,-2.61297 -14.3562,-2.27984 z"
|
||||
id="path243" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath243"><path
|
||||
style="opacity:1;fill:#415c12;fill-opacity:1;stroke:#000000;stroke-width:0.671709;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 1568.5723,615.59047 c -3.9338,3.0891 -1.483,8.76578 -2.166,13.04576 0,44.19669 0,88.39337 0,132.59005 0.4192,4.82868 5.839,4.15875 9.2599,3.4029 21.5358,-3.23562 41.2278,-16.72175 52.2964,-35.44977 6.5292,-10.63248 13.3334,-21.63647 23.9575,-28.67732 4.2146,-3.42916 9.8684,-4.63414 13.8018,-8.32172 1.9716,-4.68498 -3.5275,-6.40277 -6.75,-8.00905 -14.2712,-7.5491 -24.312,-20.8286 -32.1004,-34.61212 -12.2796,-19.18606 -33.756,-32.48789 -56.482,-34.284 -0.6058,0.10456 -1.2115,0.21019 -1.8172,0.31528 z"
|
||||
id="path244" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath244"><path
|
||||
style="opacity:1;fill:#415c12;fill-opacity:1;stroke:#000000;stroke-width:0.671709;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 1644.3233,522.44617 c -3.748,3.17056 -1.3791,8.72096 -2.0457,12.98096 0,44.10374 0,88.20747 0,132.31121 0.3605,4.57601 5.4519,4.27785 8.7705,3.47115 36.1672,-4.81331 65.025,-39.63862 63.7253,-75.98111 -0.055,-16.95341 -6.5914,-33.48486 -17.4777,-46.3916 -12.665,-14.7911 -30.87,-25.70564 -50.5877,-26.88931 -0.7949,0.16622 -1.5898,0.33244 -2.3847,0.49866 z"
|
||||
id="path245" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath251"><path
|
||||
style="opacity:1;fill:#415c12;fill-opacity:1;stroke:#000000;stroke-width:0.94994;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 1821.5575,363.26619 c -21.4621,-0.3126 -42.5982,7.61778 -59.6293,20.42026 -12.0506,9.58617 -21.3723,22.46414 -34.9745,29.97835 -4.3462,2.44276 -12.837,1.2715 -12.0875,8.27159 0,99.97469 0,199.9494 0,299.92411 0.7288,5.67004 7.1425,3.89104 9.9624,0.92125 59.3638,-40.45963 116.3623,-86.63884 158.6972,-145.27945 21.0582,-29.94486 39.0038,-63.9963 41.8724,-101.08789 1.3831,-21.46882 -1.8003,-43.77497 -13.2705,-62.34701 -17.7689,-29.99071 -51.1684,-51.25706 -86.4957,-50.78858 -1.358,-0.0241 -2.7164,-0.0228 -4.0745,-0.0126 z"
|
||||
id="path251" /></clipPath></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"><rect
|
||||
style="display:inline;fill:#001aaa;fill-opacity:1;stroke:#001277;stroke-width:0.6;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect13"
|
||||
width="9.999999"
|
||||
height="9.999999"
|
||||
x="1.4999962"
|
||||
y="0"
|
||||
transform="translate(-1.4999962)" /><g
|
||||
id="g27"
|
||||
transform="translate(-0.22206006)"
|
||||
inkscape:label="Numbers"
|
||||
style="display:inline;fill:#123456;fill-opacity:1"><path
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 3.0555119,2.5671475 1.36312,-1.36312 h 2.265848 v 5.930925 h 0.704128 v 1.66102 h -3.538695 v -1.606856 h 0.848565 v -4.062278 l -0.839538,0.839538 z"
|
||||
id="path1"
|
||||
inkscape:label="One" /><path
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 2.6662109,8.689902 h 5.163605 V 7.245537 h -2.310984 l 2.15752,-2.157521 c 0,0 0,-2.390954 0,-2.78943 0,-0.398477 -0.553503,-0.988488 -0.988487,-0.988488 -0.434984,0 -2.554528,0 -3.082817,0 -0.528289,0 -0.990744,0.475441 -0.990744,0.990744 0,0.515304 0,1.821255 0,1.821255 h 1.821254 V 2.695786 h 1.173547 V 4.663734 L 2.6391289,7.63371 Z"
|
||||
id="path17"
|
||||
sodipodi:nodetypes="ccccczzzzccccccc"
|
||||
inkscape:label="Two" /><path
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 2.7361059,3.5603965 v -2.323504 h 5.183202 v 1.391549 l -1.200052,1.404316 v 0.165964 c 0.677046,0 1.027704,0.471789 1.027704,1.027704 0,0 0,1.715691 0,2.214989 0,0.499298 -0.619358,1.321693 -1.222393,1.321693 -0.603035,0 -2.042752,0 -2.537343,0 -0.494591,0 -1.462412,-0.406745 -1.462412,-0.943624 v -1.514288 h 1.998605 v 0.893655 h 1.212818 v -1.736244 h -1.238351 v -0.919189 l 1.31495,-1.774544 h -1.366016 v 0.80429 z"
|
||||
id="path18"
|
||||
sodipodi:nodetypes="cccccczzzzzccccccccccc"
|
||||
inkscape:label="Three" /><path
|
||||
id="path19"
|
||||
style="display:inline;opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 5.0597959,1.1994565 -2.636015,3.538802 v 1.697054 h 2.906799 v 0.75861 h -0.8847 v 1.606621 h 3.556372 v -1.606621 h -0.77618 v -0.812353 h 0.794267 v -1.498617 h -0.830441 v -3.683496 z m 0.234611,1.841748 v 1.931665 h -1.390096 z"
|
||||
inkscape:label="Four" /><path
|
||||
style="display:inline;opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 2.6432259,1.221114 h 5.119369 v 1.634113 h -3.076728 v 0.817056 c 0,0 1.346344,0 1.953275,0 0.606931,0 1.161752,0.391594 1.161752,1.161752 0,0.770159 0,2.127308 0,2.859698 0,0.664285 -0.426838,1.085153 -1.085152,1.085153 -0.658315,0 -2.06756,0 -2.821398,0 -0.753838,0 -1.212818,-0.602587 -1.212818,-1.110686 0,-0.508099 0,-1.480915 0,-1.480915 h 1.889442 v 1.136219 h 1.289417 V 5.306396 h -3.204393 z"
|
||||
id="path20"
|
||||
sodipodi:nodetypes="ccccczzszzzccccccc"
|
||||
inkscape:label="Five" /><g
|
||||
id="g22"
|
||||
transform="translate(-9.1161521,-0.1206331)"
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.00036;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="Six"><path
|
||||
id="path21"
|
||||
style="opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 12.881901,1.381311 c -0.879342,0 -1.543575,0.2853348 -1.543575,1.5435751 0,1.2582403 -0.0052,3.6036771 -0.0052,4.6632812 0,1.0596041 0.68622,1.2510864 1.413351,1.2510864 h 2.784746 C 14.95819,7.5670265 15.64519,7.0621748 16.493018,6.698106 V 5.3712484 c 0,-0.5323266 -0.606087,-1.1647868 -1.164787,-1.1647868 H 13.43274 v -1.317749 h 1.173572 V 3.6111491 H 16.36176 V 2.5771037 c 0,-0.726466 -0.581711,-1.1957927 -1.195793,-1.1957927 h -2.284098 z m 0.550871,4.3511556 h 1.236617 v 1.6066203 h -1.236617 z"
|
||||
sodipodi:nodetypes="czzzcczzccccczzzcccccc" /><circle
|
||||
style="display:inline;opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path22"
|
||||
cx="16.532625"
|
||||
cy="8.0492821"
|
||||
r="0.81067312" /></g><path
|
||||
style="display:inline;opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="M 2.4644949,3.68505 V 1.157282 h 5.51513 v 1.200051 l -2.195839,6.485385 h -2.37457 l 2.37457,-6.000258 h -1.404315 v 0.868123 z"
|
||||
id="path23"
|
||||
inkscape:label="Seven" /><path
|
||||
id="path24"
|
||||
style="display:inline;opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 3.6048469,1.2694785 c -0.642741,0 -0.893486,0.525011 -0.893486,1.092439 v 1.715141 c 0,0.509739 0.437201,0.725072 0.83044,0.83044 -0.420935,0.11279 -0.927592,0.388208 -0.927592,1.065052 v 1.541508 c 0,0.661002 0.58919,1.216463 1.216464,1.216463 h 3.010669 c 0.485027,0 0.98857,-0.369975 0.98857,-0.98857 v -1.86862 c 0,-0.480076 -0.439475,-0.806637 -0.941028,-0.941028 0.465545,-0.124742 0.873332,-0.390235 0.873332,-0.873332 v -1.566312 c 0,-0.482508 -0.221212,-1.223181 -1.024744,-1.223181 z m 1.038179,1.489314 h 1.209745 v 1.453658 h -1.209745 z m -0.02687,2.825668 h 1.272791 v 1.634009 h -1.272791 z"
|
||||
inkscape:label="Eight" /><g
|
||||
id="g25"
|
||||
transform="rotate(180,3.797988,10.438783)"
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-dasharray:none;stroke-opacity:1"
|
||||
inkscape:label="Nine"><g
|
||||
id="g26"
|
||||
transform="translate(-11.208993,10.902596)"
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-dasharray:none;stroke-opacity:1"><path
|
||||
id="path25"
|
||||
style="opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 12.881901,1.381311 c -0.117873,0 -0.23188,0.00513 -0.340941,0.017037 0.39752,1.1466262 -0.417494,1.7180355 -1.202634,1.6669695 0,1.2582403 -0.0052,3.4632455 -0.0052,4.5228496 0,1.0596041 0.68622,1.2510864 1.413351,1.2510864 h 2.68996 c 0.80934,0 1.056581,-0.6103529 1.056581,-1.2994692 V 5.3712484 c 0,-0.5323266 -0.606087,-1.1647868 -1.164787,-1.1647868 H 13.43274 v -1.317749 h 1.173572 V 3.6111491 H 16.36176 V 2.5771037 c 0,-0.726466 -0.581711,-1.1957927 -1.195793,-1.1957927 h -2.284098 z m 0.550871,4.3511556 h 1.236617 v 1.6066203 h -1.236617 z"
|
||||
sodipodi:nodetypes="ccczzsszzccccczzzcccccc" /><circle
|
||||
style="opacity:1;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.6;stroke-linecap:square;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="circle25"
|
||||
cx="11.483473"
|
||||
cy="1.9213587"
|
||||
r="0.81067312" /></g></g><path
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.600001;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
|
||||
d="m 1.22206,8.0000002 v 0.9999999 h 2.9999999 c 0,-2.9999998 -1.9999999,-6.470833 1.0000002,-6.4708329 2.9999997,0 0.9999998,3.4708331 0.9999998,6.4708329 H 9.2220597 V 8.0000002 h -2 c 0,0 1.9999999,-4.470833 0,-6.4708331 -0.9999998,-0.99999998 -2.9999999,-1.00000012 -3.9999999,0 -1.9999998,2 0,6.4708331 0,6.4708331 z"
|
||||
id="path14"
|
||||
sodipodi:nodetypes="cccsccccsscc"
|
||||
inkscape:label="Omega" /></g><g
|
||||
id="g5"
|
||||
inkscape:label="FourArrow"
|
||||
transform="translate(0.50000393)"
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-opacity:1"><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 4.9999997,0.99999995 2.9999998,4.9999997 4.9999997,8.9999996 H 3.9999999 l -2,-3.9999999 2,-3.99999975 z"
|
||||
id="path2" /><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 6.9999996,0.99999997 4.9999997,4.9999997 6.9999996,8.9999996 H 5.9999998 l -2,-3.9999999 2,-3.99999973 z"
|
||||
id="path3" /><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 8.9999997,0.99999997 6.9999998,4.9999997 8.9999997,8.9999996 H 7.9999999 l -2,-3.9999999 2,-3.99999973 z"
|
||||
id="path4" /><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 2.9999997,0.99999997 0.99999984,4.9999997 2.9999997,8.9999996 H 1.9999999 L -6.3578292e-8,4.9999997 1.9999999,0.99999997 Z"
|
||||
id="path5" /></g><g
|
||||
id="g9"
|
||||
inkscape:label="ThreeArrow"
|
||||
transform="translate(-0.49999605)"
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-opacity:1"><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 4.9999997,0.99999995 2.9999998,4.9999997 4.9999997,8.9999996 H 3.9999999 l -2,-3.9999999 2,-3.99999975 z"
|
||||
id="path6" /><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 6.9999996,0.99999997 4.9999997,4.9999997 6.9999996,8.9999996 H 5.9999998 l -2,-3.9999999 2,-3.99999973 z"
|
||||
id="path7" /><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 8.9999997,0.99999997 6.9999998,4.9999997 8.9999997,8.9999996 H 7.9999999 l -2,-3.9999999 2,-3.99999973 z"
|
||||
id="path8" /></g><g
|
||||
id="g11"
|
||||
inkscape:label="TwoArrow"
|
||||
transform="translate(-1.499996)"
|
||||
style="display:inline;fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-opacity:1"><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 6.9999996,0.99999997 4.9999997,4.9999997 6.9999996,8.9999996 H 5.9999998 l -2,-3.9999999 2,-3.99999973 z"
|
||||
id="path10" /><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 8.9999997,0.99999997 6.9999998,4.9999997 8.9999997,8.9999996 H 7.9999999 l -2,-3.9999999 2,-3.99999973 z"
|
||||
id="path11" /></g><g
|
||||
id="g13"
|
||||
inkscape:label="OneArrow"
|
||||
transform="translate(-1.4999962)"
|
||||
style="display:inline"><path
|
||||
style="fill:#ffd700;fill-opacity:1;stroke:#d6b500;stroke-width:0.3;stroke-linejoin:round;stroke-opacity:1"
|
||||
d="M 7.9999998,1.0000002 5.9999999,4.9999999 7.9999998,8.9999998 H 7 L 5,4.9999999 7,1.0000002 Z"
|
||||
id="path13" /></g></g></svg>
|
||||
|
After Width: | Height: | Size: 16 KiB |
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 91 KiB |
@@ -0,0 +1,305 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||
<title>The Crew</title>
|
||||
<style>
|
||||
form {
|
||||
background: #CCCCCC;
|
||||
}
|
||||
|
||||
.bordered {
|
||||
border: 1ex solid black;
|
||||
display: inline-block;
|
||||
margin: 1ex;
|
||||
padding: 1ex;
|
||||
}
|
||||
|
||||
div.card.done {
|
||||
opacity: .3;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<form id="thecrew-config-form">
|
||||
<label for="thecrew-player1">Player 1</label><input id="thecrew-player1" type="text"/><br/>
|
||||
<label for="thecrew-player2">Player 2</label><input id="thecrew-player2" type="text"/><br/>
|
||||
<label for="thecrew-player3">Player 3</label><input id="thecrew-player3" type="text"/><br/>
|
||||
<label for="thecrew-player4">Player 4</label><input id="thecrew-player4" type="text"/><br/>
|
||||
<label for="thecrew-player5">Player 5</label><input id="thecrew-player5" type="text"/><br/>
|
||||
<label for="thecrew-cardtype">Cartes classiques</label><input id="thecrew-cardtype" type="checkbox"/><br/>
|
||||
<input id="thecrew-validate" type="submit" value="Valider"/>
|
||||
</form>
|
||||
<form id="thecrew-run-form">
|
||||
<select id="thecrew-level" name="thecrew-level">
|
||||
</select>
|
||||
<input id="thecrew-run" type="submit" value="Démarrer la partie"/>
|
||||
</form>
|
||||
<span id="thecrew-question">Sélectionnez les paramètres de base</span>
|
||||
<div id="thecrew-select-captain">
|
||||
</div>
|
||||
<div id="thecrew-select-tasks">
|
||||
</div>
|
||||
<div id="thecrew-game">
|
||||
<dl id="thecrew-special-rules"></dl>
|
||||
<ul id="thecrew-assigned-tasks"></ul>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// Helpers
|
||||
function listProd(l1,l2) {
|
||||
var o = []
|
||||
for (i in l1) {
|
||||
for (j in l2) {
|
||||
o.push([l1[i],l2[j]])
|
||||
}
|
||||
}
|
||||
return o
|
||||
}
|
||||
function emptyListList(k) {
|
||||
var o = []
|
||||
for (let i=0;i<k;i++) {
|
||||
o.push([])
|
||||
}
|
||||
return o
|
||||
}
|
||||
function takeNRandom(l,n) {
|
||||
let ll = l.slice()
|
||||
let o = []
|
||||
for (let i=0; i<n; i++) {
|
||||
k = Math.floor(Math.random() * ll.length)
|
||||
o.push(ll[k])
|
||||
ll.splice(k,1)
|
||||
}
|
||||
return o
|
||||
}
|
||||
function joinLists(l1,l2) {
|
||||
let ll = l1.slice()
|
||||
ll.push.apply(ll,l2)
|
||||
return ll
|
||||
}
|
||||
function makeCardImg(l) {
|
||||
s = l[1]
|
||||
n = l[0]
|
||||
b = l[2]
|
||||
i = numbers.indexOf(n)
|
||||
tn = numbersText[i]
|
||||
cardFileName=tn+"-of-"+s+".png"
|
||||
out = $('<div/>')
|
||||
.addClass('bordered')
|
||||
.addClass('card')
|
||||
$('<img/>')
|
||||
.attr('src','/thecrew/'+cardFileName)
|
||||
.appendTo(out)
|
||||
if(b){
|
||||
modifierFileName=modifierMap[b].toLowerCase()+".png"
|
||||
$('<img/>')
|
||||
.attr('src','/thecrew/'+modifierFileName)
|
||||
.appendTo(out)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
const thecrewSuits = ['square','triangle','circle','cross']
|
||||
const regularSuits = ['hearts','spades','clubs','diamonds']
|
||||
const numbers = ['1','2','3','4','5','6','7','8','9']
|
||||
const numbersText = ['one','two','three','four','five','six','seven','eight','nine']
|
||||
const trumpNumbers = ['1','2','3','4']
|
||||
const otherThecrewCards = listProd(numbers,thecrewSuits)
|
||||
const otherRegularCards = listProd(numbers,regularSuits)
|
||||
const trumpCards = listProd(trumpNumbers, [null])
|
||||
const allCards = joinLists
|
||||
const modifierMap = {
|
||||
">": "onearrow",
|
||||
">>": "twoarrow",
|
||||
">>>": "threearrow",
|
||||
">>>>": "fourarrow",
|
||||
"1": "one",
|
||||
"2": "two",
|
||||
"3": "three",
|
||||
"4": "four",
|
||||
"5": "five",
|
||||
"Ω": "omega",
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
var missionsData = {}
|
||||
$.getJSON('missions.json',function(data) {
|
||||
missionsData = data
|
||||
for (md in missionsData['missions']) {
|
||||
$('<option/>')
|
||||
.data('thecrew-mission',md)
|
||||
.text(md)
|
||||
.appendTo('#thecrew-level')
|
||||
}
|
||||
});
|
||||
|
||||
function makeMissionRules(i) {
|
||||
var out = {}
|
||||
var missionRules = missionsData['missions'][i]
|
||||
out['cards'] = takeNRandom(otherCards, missionRules['cards'].length)
|
||||
for (c in out['cards']) {
|
||||
out['cards'][c].push(missionRules['cards'][c])
|
||||
}
|
||||
out['specialRules'] = {}
|
||||
for (mr in missionRules['special']) {
|
||||
let specialRule = missionRules['special'][mr]
|
||||
out['specialRules'][specialRule] = missionsData['specialRules'][specialRule]
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
var joueureuses = []
|
||||
var jl = 0
|
||||
var otherCards = otherThecrewCards
|
||||
|
||||
function configGame(e) {
|
||||
e.preventDefault()
|
||||
joueureuses = []
|
||||
for (let i=0;i<5;i++){
|
||||
player = $('#thecrew-player'+(i+1)).val()
|
||||
if (player) {
|
||||
joueureuses.push(player)
|
||||
}
|
||||
}
|
||||
jl = joueureuses.length
|
||||
if ($('#thecrew-cardtype').is(":checked")) {
|
||||
otherCards = otherRegularCards
|
||||
} else {
|
||||
otherCards = otherThecrewCards
|
||||
}
|
||||
$('#thecrew-config-form').hide()
|
||||
$('#thecrew-run-form').show()
|
||||
}
|
||||
$('#thecrew-validate').click(configGame)
|
||||
|
||||
|
||||
var missionRules = null
|
||||
var captain = -1
|
||||
var assignedTasks = emptyListList(jl)
|
||||
var nextToAssign = -1
|
||||
var toAssign = []
|
||||
var specialRules = {}
|
||||
|
||||
function startMission(e) {
|
||||
e.preventDefault()
|
||||
missionNumber = $('#thecrew-level').val()
|
||||
missionRules = makeMissionRules(missionNumber)
|
||||
toAssign = missionRules['cards']
|
||||
specialRules = missionRules['specialRules']
|
||||
captain = -1
|
||||
assignedTasks = emptyListList(jl)
|
||||
nextToAssign = -1
|
||||
|
||||
$('#thecrew-question').text('Qui est capitaine ?')
|
||||
$('#thecrew-select-captain').empty()
|
||||
for (j in joueureuses) {
|
||||
$('<button/>')
|
||||
.text(joueureuses[j])
|
||||
.click(selectedCaptain)
|
||||
.appendTo('#thecrew-select-captain')
|
||||
}
|
||||
$('#thecrew-game').hide()
|
||||
$('#thecrew-select-tasks').hide()
|
||||
$('#thecrew-select-captain').show()
|
||||
}
|
||||
$('#thecrew-run').click(startMission)
|
||||
|
||||
function selectedCaptain(e) {
|
||||
let captainName = e.currentTarget.innerText
|
||||
captain = joueureuses.indexOf(captainName)
|
||||
nextToAssign = captain
|
||||
if (toAssign.length == 1) {
|
||||
assignTask(0)
|
||||
startPlaying()
|
||||
} else if (toAssign.length == 0) {
|
||||
startPlaying()
|
||||
} else {
|
||||
nextAssignTask()
|
||||
}
|
||||
$('#thecrew-select-captain').hide()
|
||||
$('#thecrew-select-tasks').show()
|
||||
}
|
||||
|
||||
function nextAssignTask(){
|
||||
$('#thecrew-question').text(joueureuses[nextToAssign%jl]+': Quelle tâche choisit-tu ?')
|
||||
$('#thecrew-select-tasks').empty()
|
||||
for (at in toAssign) {
|
||||
makeCardImg(toAssign[at])
|
||||
.data("thecrew-task",at)
|
||||
.click(chooseAssignation)
|
||||
.appendTo('#thecrew-select-tasks')
|
||||
}
|
||||
}
|
||||
|
||||
function assignTask(tindex) {
|
||||
assignedTasks[nextToAssign%jl].push(toAssign[tindex])
|
||||
toAssign.splice(tindex,1)
|
||||
nextToAssign += 1
|
||||
}
|
||||
|
||||
function chooseAssignation(e) {
|
||||
assignedIndex = $(e.currentTarget).data("thecrew-task")
|
||||
assignTask(assignedIndex)
|
||||
|
||||
if(toAssign.length==1){
|
||||
assignTask(0)
|
||||
startPlaying()
|
||||
} else {
|
||||
nextAssignTask()
|
||||
}
|
||||
}
|
||||
|
||||
function startPlaying() {
|
||||
$('#thecrew-question').text("Bon jeu !")
|
||||
$('#thecrew-select-tasks').empty()
|
||||
$('#thecrew-assigned-tasks').empty()
|
||||
$('#thecrew-special-rules').empty()
|
||||
for (at in assignedTasks) {
|
||||
thePlayerLi = $('<li/>').addClass('bordered')
|
||||
$('<h2/>')
|
||||
.text("Tâches de "+joueureuses[at])
|
||||
.appendTo(thePlayerLi)
|
||||
playerList = $('<ul/>')
|
||||
for (tt in assignedTasks[at]) {
|
||||
theTaskLi = $('<li/>')
|
||||
makeCardImg(assignedTasks[at][tt])
|
||||
.data("thecrew-task",[at,tt])
|
||||
.click(taskDone)
|
||||
.appendTo(theTaskLi)
|
||||
theTaskLi.appendTo(playerList)
|
||||
}
|
||||
playerList.appendTo(thePlayerLi)
|
||||
thePlayerLi.appendTo('#thecrew-assigned-tasks')
|
||||
}
|
||||
for (sr in specialRules) {
|
||||
$('<dt/>').text(sr).appendTo('#thecrew-special-rules')
|
||||
$('<dd/>').text(specialRules[sr]).appendTo('#thecrew-special-rules')
|
||||
}
|
||||
$('#thecrew-select-captain').hide()
|
||||
$('#thecrew-select-tasks').hide()
|
||||
$('#thecrew-game').show()
|
||||
}
|
||||
|
||||
function taskDone(e) {
|
||||
ll = $(e.currentTarget).data("thecrew-task")
|
||||
$(e.currentTarget).toggleClass('done')
|
||||
}
|
||||
$('#thecrew-run-form').hide()
|
||||
$('#thecrew-select-captain').hide()
|
||||
$('#thecrew-select-tasks').hide()
|
||||
$('#thecrew-game').hide()
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user