This commit is contained in:
afornerot 2024-02-24 03:13:02 +01:00
parent bae336b31b
commit ca53930b51
7 changed files with 311 additions and 170 deletions

71
doc/data.json Normal file
View File

@ -0,0 +1,71 @@
# card
var obj = initCard(ctx, { _id: "lose10", image: "images/cards/loose10.png", title: "Hey ! t'avais pas un billet de 10 ?", description: "Vous perdez 10€" effect: "-10", sound: "looser" });
var obj = initCard(ctx, { _id: "lose20", image: "images/cards/loose20.png", title: "On t'as vu balancer ton papier dans la rue !", description: "Vous perdez 20€" effect: "-20", sound: "looser" });
var obj = initCard(ctx, { _id: "lose30", image: "images/cards/loose30.png", title: "T'as oublié l'anniversaire de ta mère !", description: "Vous perdez 30€" effect: "-30", sound: "looser" });
var obj = initCard(ctx, { _id: "brokenglass", image: "images/cards/borken-glass.png", title: "T'as deux mains gauches ? Attention les verres !", description: "Tu rembourses un verre cassé, valeur 10€" effect: "-10", sound: "looser" });
var obj = initCard(ctx, { _id: "lownight", image: "images/cards/lownight.png", title: "C'est mort ce soir ! Personne dans le rad !", description: "Tu perds 50€" effect: "-50", sound: "looser" });
var obj = initCard(ctx, { _id: "flood", image: "images/cards/flood.png", title: "Soirée piscine ! Enfin soirée plomberie surtout !", description: "Tu perds 40€" effect: "-40", sound: "looser" });
var obj = initCard(ctx, { _id: "robber", image: "images/cards/robber.png", title: "Il a tapé dans la caisse !", description: "On t'as volé 60€" effect: "-60", sound: "looser" });
var obj = initCard(ctx, { _id: "tomuch", image: "images/cards/tomuch.png", title: "Un p'tit dernier pour la route !", description: "Le verre de trop, amande de 80€" effect: "-80", sound: "looser" });
var obj = initCard(ctx, { _id: "somethingiswrong", image: "images/cards/somethingiswrong.png", title: "Tu ne sais pas rendre la monnaie !", description: "Tu rends 20€ de trop a un client chanceux !" effect: "-20", sound: "looser" });
var obj = initCard(ctx, { _id: "rebuild", image: "images/cards/rebuild.png", title: "On refait la déco !", description: "Rénove ton bar pour la modique somme de 50€" effect: "-50", sound: "looser" });
var obj = initCard(ctx, { _id: "shortage", image: "images/cards/shortage.png", title: "Dévalisé !", description: "Tu t'es fait dévaliser, plus rien en stock" effect: "100", sound: "winner" });
var obj = initCard(ctx, { _id: "luckyday", image: "images/cards/luckyday.png", title: "C'est un billet de 10 non ?", description: "Tu trouves 10€ devant ton bar" effect: "10", sound: "winner" });
var obj = initCard(ctx, { _id: "rushhour", image: "images/cards/rushhour.png", title: "C'est la folie dans ton bar !", description: "Tu gagnes 50€ !" effect: "50", sound: "winner" });
var obj = initCard(ctx, { _id: "blindtest", image: "images/cards/blindtest.png", title: "Tu gagnes la soirée blind test !", description: "Premier prix 20€ !" effect: "20", sound: "winner" });
var obj = initCard(ctx, { _id: "bigtip", image: "images/cards/bigtip.png", title: "Tes clients t'adores !", description: "20€ de pourboire !" effect: "20", sound: "winner" });
var obj = initCard(ctx, { _id: "baroftheweek", image: "images/cards/baroftheweek.png", title: "Tu gagnes le concours du bar de la semaine !", description: "Premier prix 50€ !" effect: "50", sound: "winner" });
var obj = initCard(ctx, { _id: "goodnight", image: "images/cards/goodnight.png", title: "On t'en a trop rendus !", description: "Tu gagnes 30€ !" effect: "30", sound: "winner" });
var obj = initCard(ctx, { _id: "yourdadishere", image: "images/cards/yourdadishere.png", title: "Ton père est là ! Paye une tournée de plus !", description: "Payer 30€ de plus !" effect: "-30", sound: "looser" });
var obj = initCard(ctx, { _id: "dontdrive", image: "images/cards/dontdrive.png", title: "Le ballon a dit non !", description: "Paye un taxi pour rentrer 10€ !" effect: "-10", sound: "looser" });
var obj = initCard(ctx, { _id: "flambeur", image: "images/cards/flambeur.png", title: "Tournée générale !", description: "Paye 60€ !" effect: "-60", sound: "looser" });
var obj = initCard(ctx, { _id: "cuteashell", image: "images/cards/cuteashell.png", title: "Tu es de toute beauté !", description: "On t'offres 40€ !" effect: "40", sound: "winner" });
var obj = initCard(ctx, { _id: "loseitall", image: "images/cards/loseitall.png", title: "Tu as oublié ton portefeuille !", description: "Tu perds 50€ !" effect: "-50", sound: "looser" });
# Types de tile
var obj = initTiletype(ctx, { _id: "bar", description: "bar" });
var obj = initTiletype(ctx, { _id: "meetup", description: "Rencontre" });
var obj = initTiletype(ctx, { _id: "happyHour", description: "Happy Hour" });
var obj = initTiletype(ctx, { _id: "prison", description: "Cellule de dégrisement"});
var obj = initTiletype(ctx, { _id: "start", description: "Week-end"});
# Level de bars
var obj = initTilelevel(ctx, { _id: "pmu", order: 1, description: "PMU" });
var obj = initTilelevel(ctx, { _id: "bistro", order: 2, description: "Bistro de quartien"});
var obj = initTilelevel(ctx, { _id: "brasserie", order: 3, description: "Brasserie" });
var obj = initTilelevel(ctx, { _id: "barabiere", order: 4, description: "Bar à bières" });
var obj = initTilelevel(ctx, { _id: "baravin", order: 5, description: "Bar à vin" });
var obj = initTilelevel(ctx, { _id: "cocktails", order: 6, description: "Bar a cocktails" });
var obj = initTilelevel(ctx, { _id: "lounge", order: 7, description: "Lounge" });
var obj = initTilelevel(ctx, { _id: "clubprive", order: 8, description: "Club privé" });
# Cases
var obj = initTile(ctx, { _id: "st", position: "0", tiletype: "start", name: "Week-end" });
var obj = initTile(ctx, { _id: "b1", position: "1", tiletype: "bar", name: "Les hirondelles", prixDeBase: "1" });
var obj = initTile(ctx, { _id: "b2", position: "2", tiletype: "bar", name: "Le cheval blanc", prixDeBase: "1" });
var obj = initTile(ctx, { _id: "meetup1", position: "3", tiletype: "meetup", name: "Rencontre" });
var obj = initTile(ctx, { _id: "b3", position: "4", tiletype: "bar", name: "L'ABC", prixDeBase: "2" });
var obj = initTile(ctx, { _id: "b4", position: "5", tiletype: "bar", name: "La taverne", prixDeBase: "2" });
var obj = initTile(ctx, { _id: "hh1", position: "6", tiletype: "happyHour", name: "Happy hour" });
var obj = initTile(ctx, { _id: "b6", position: "7", tiletype: "bar", name: "La fine mousse", prixDeBase: "3" });
var obj = initTile(ctx, { _id: "b7", position: "8", tiletype: "bar", name: "Le barboteur", prixDeBase: "3" });
var obj = initTile(ctx, { _id: "b7", position: "9", tiletype: "bar", name: "Le palais de la bière", prixDeBase: "3" });
var obj = initTile(ctx, { _id: "meetup2", position: "10", tiletype: "meetup", name: "Rencontre" });
var obj = initTile(ctx, { _id: "b8", position: "11", tiletype: "bar", name: "Le comptoir des bières", prixDeBase: "4" });
var obj = initTile(ctx, { _id: "b9", position: "12", tiletype: "bar", name: "Les moulins bleus", prixDeBase: "4" });
var obj = initTile(ctx, { _id: "b10", position: "13", tiletype: "bar", name: "Le fourquet", prixDeBase: "4" });
var obj = initTile(ctx, { _id: "prs", position: "14", tiletype: "prison", name: "Cellule de dégrisement" });
var obj = initTile(ctx, { _id: "b11", position: "15", tiletype: "bar", name: "Au beaux fûts", prixDeBase: "5" });
var obj = initTile(ctx, { _id: "b12", position: "16", tiletype: "bar", name: "Le Bacchus", prixDeBase: "5" });
var obj = initTile(ctx, { _id: "b13", position: "17", tiletype: "bar", name: "Matusalém", prixDeBase: "5" });
var obj = initTile(ctx, { _id: "meetup3", position: "18", tiletype: "meetup", name: "Rencontre" });
var obj = initTile(ctx, { _id: "b14", position: "19", tiletype: "bar", name: "Bloody Marianne", prixDeBase: "6" });
var obj = initTile(ctx, { _id: "b15", position: "20", tiletype: "bar", name: "Shake it up", prixDeBase: "6" });
var obj = initTile(ctx, { _id: "b16", position: "21", tiletype: "bar", name: "Le mixologue", prixDeBase: "6" });
var obj = initTile(ctx, { _id: "hh2", position: "22", tiletype: "happyHour", name: "Happy hour" });
var obj = initTile(ctx, { _id: "b17", position: "23", tiletype: "bar", name: "Le senateur", prixDeBase: "7" });
var obj = initTile(ctx, { _id: "b18", position: "24", tiletype: "bar", name: "La dame blanche", prixDeBase: "7" });
var obj = initTile(ctx, { _id: "meetup4", position: "25", tiletype: "meetup", name: "Rencontre" });
var obj = initTile(ctx, { _id: "b19", position: "26", tiletype: "bar", name: "Le Kube", prixDeBase: "8" });
var obj = initTile(ctx, { _id: "b20", position: "27", tiletype: "bar", name: "L'amirauté", prixDeBase: "8" });

View File

@ -17,8 +17,79 @@ function setFixures() {
}
// Config
console.log("Fixures Config");
console.log("Fixtures Config");
var obj = initConfig(ctx, {"_id": "version", "default": "0.0.0","visible":false});
// Card
var obj = initCard(ctx, { _id: "lose10", image: "images/cards/loose10.png", title: "Hey ! t'avais pas un billet de 10 ?", description: "Vous perdez 10€", effect: "-10", sound: "looser" });
var obj = initCard(ctx, { _id: "lose20", image: "images/cards/loose20.png", title: "On t'as vu balancer ton papier dans la rue !", description: "Vous perdez 20€", effect: "-20", sound: "looser" });
var obj = initCard(ctx, { _id: "lose30", image: "images/cards/loose30.png", title: "T'as oublié l'anniversaire de ta mère !", description: "Vous perdez 30€", effect: "-30", sound: "looser" });
var obj = initCard(ctx, { _id: "brokenglass", image: "images/cards/borken-glass.png", title: "T'as deux mains gauches ? Attention les verres !", description: "Tu rembourses un verre cassé, valeur 10€", effect: "-10", sound: "looser" });
var obj = initCard(ctx, { _id: "lownight", image: "images/cards/lownight.png", title: "C'est mort ce soir ! Personne dans le rad !", description: "Tu perds 50€", effect: "-50", sound: "looser" });
var obj = initCard(ctx, { _id: "flood", image: "images/cards/flood.png", title: "Soirée piscine ! Enfin soirée plomberie surtout !", description: "Tu perds 40€", effect: "-40", sound: "looser" });
var obj = initCard(ctx, { _id: "robber", image: "images/cards/robber.png", title: "Il a tapé dans la caisse !", description: "On t'as volé 60€", effect: "-60", sound: "looser" });
var obj = initCard(ctx, { _id: "tomuch", image: "images/cards/tomuch.png", title: "Un p'tit dernier pour la route !", description: "Le verre de trop, amande de 80€", effect: "-80", sound: "looser" });
var obj = initCard(ctx, { _id: "somethingiswrong", image: "images/cards/somethingiswrong.png", title: "Tu ne sais pas rendre la monnaie !", description: "Tu rends 20€ de trop a un client chanceux !", effect: "-20", sound: "looser" });
var obj = initCard(ctx, { _id: "rebuild", image: "images/cards/rebuild.png", title: "On refait la déco !", description: "Rénove ton bar pour la modique somme de 50€", effect: "-50", sound: "looser" });
var obj = initCard(ctx, { _id: "shortage", image: "images/cards/shortage.png", title: "Dévalisé !", description: "Tu t'es fait dévaliser, plus rien en stock", effect: "100", sound: "winner" });
var obj = initCard(ctx, { _id: "luckyday", image: "images/cards/luckyday.png", title: "C'est un billet de 10 non ?", description: "Tu trouves 10€ devant ton bar", effect: "10", sound: "winner" });
var obj = initCard(ctx, { _id: "rushhour", image: "images/cards/rushhour.png", title: "C'est la folie dans ton bar !", description: "Tu gagnes 50€ !", effect: "50", sound: "winner" });
var obj = initCard(ctx, { _id: "blindtest", image: "images/cards/blindtest.png", title: "Tu gagnes la soirée blind test !", description: "Premier prix 20€ !", effect: "20", sound: "winner" });
var obj = initCard(ctx, { _id: "bigtip", image: "images/cards/bigtip.png", title: "Tes clients t'adores !", description: "20€ de pourboire !", effect: "20", sound: "winner" });
var obj = initCard(ctx, { _id: "baroftheweek", image: "images/cards/baroftheweek.png", title: "Tu gagnes le concours du bar de la semaine !", description: "Premier prix 50€ !", effect: "50", sound: "winner" });
var obj = initCard(ctx, { _id: "goodnight", image: "images/cards/goodnight.png", title: "On t'en a trop rendus !", description: "Tu gagnes 30€ !", effect: "30", sound: "winner" });
var obj = initCard(ctx, { _id: "yourdadishere", image: "images/cards/yourdadishere.png", title: "Ton père est là ! Paye une tournée de plus !", description: "Payer 30€ de plus !", effect: "-30", sound: "looser" });
var obj = initCard(ctx, { _id: "dontdrive", image: "images/cards/dontdrive.png", title: "Le ballon a dit non !", description: "Paye un taxi pour rentrer 10€ !", effect: "-10", sound: "looser" });
var obj = initCard(ctx, { _id: "flambeur", image: "images/cards/flambeur.png", title: "Tournée générale !", description: "Paye 60€ !", effect: "-60", sound: "looser" });
var obj = initCard(ctx, { _id: "cuteashell", image: "images/cards/cuteashell.png", title: "Tu es de toute beauté !", description: "On t'offres 40€ !", effect: "40", sound: "winner" });
var obj = initCard(ctx, { _id: "loseitall", image: "images/cards/loseitall.png", title: "Tu as oublié ton portefeuille !", description: "Tu perds 50€ !", effect: "-50", sound: "looser" });
// Tiletype
var obj = initTiletype(ctx, { _id: "bar", description: "bar" });
var obj = initTiletype(ctx, { _id: "meetup", description: "Rencontre" });
var obj = initTiletype(ctx, { _id: "happyHour", description: "Happy Hour" });
var obj = initTiletype(ctx, { _id: "prison", description: "Cellule de dégrisement"});
var obj = initTiletype(ctx, { _id: "start", description: "Week-end"});
// Titlelevel
var obj = initTilelevel(ctx, { _id: "pmu", order: 1, description: "PMU" });
var obj = initTilelevel(ctx, { _id: "bistro", order: 2, description: "Bistro de quartien"});
var obj = initTilelevel(ctx, { _id: "brasserie", order: 3, description: "Brasserie" });
var obj = initTilelevel(ctx, { _id: "barabiere", order: 4, description: "Bar à bières" });
var obj = initTilelevel(ctx, { _id: "baravin", order: 5, description: "Bar à vin" });
var obj = initTilelevel(ctx, { _id: "cocktails", order: 6, description: "Bar a cocktails" });
var obj = initTilelevel(ctx, { _id: "lounge", order: 7, description: "Lounge" });
var obj = initTilelevel(ctx, { _id: "clubprive", order: 8, description: "Club privé" });
// Case
var obj = initTile(ctx, { _id: "st", position: 0, tiletype: "start", name: "Week-end", img: "https://static.actu.fr/uploads/2017/05/rue-de-la-soif-Rennes-960x640.jpg" });
var obj = initTile(ctx, { _id: "b1", position: 1, tiletype: "bar", name: "Les hirondelles", prixDeBase: "1", img: "https://media-cdn.tripadvisor.com/media/photo-s/08/99/ef/5a/les-hirondelles.jpg" });
var obj = initTile(ctx, { _id: "b2", position: 2, tiletype: "bar", name: "Le cheval blanc", prixDeBase: "1", img: "https://media-cdn.tripadvisor.com/media/photo-s/14/f4/ed/0f/le-cheval-blanc.jpg" });
var obj = initTile(ctx, { _id: "meetup1", position: 3, tiletype: "meetup", name: "Rencontre", img: "https://hoptodate.com/wp-content/uploads/2022/10/Depositphotos_331369428_XL-scaled.jpg" });
var obj = initTile(ctx, { _id: "b3", position: 4, tiletype: "bar", name: "L'ABC", prixDeBase: "2", img: "https://www.pagesjaunes.fr/media/agc/52/85/77/00/00/d1/00/ab/e8/ca/62bc5285770000d100abe8ca/62bc5285770000d100abe8cc.jpg" });
var obj = initTile(ctx, { _id: "b4", position: 5, tiletype: "bar", name: "La taverne", prixDeBase: "2", img: "https://www.clamecyhautnivernais-tourisme.fr/wp-content/uploads/wpetourisme/Bar-La-Taverne-Clamecy----D.Data-900x535.jpg" });
var obj = initTile(ctx, { _id: "hh1", position: 6, tiletype: "happyHour", name: "Happy hour", img: "https://blog.laddition.com/sites/default/files/2022-03/sans-titre-17_0.png" });
var obj = initTile(ctx, { _id: "b6", position: 7, tiletype: "bar", name: "La fine mousse", prixDeBase: "3", img: "https://cdn.eat-list.fr/establishment/photo/gallery_photo/75011-paris-11/la-fine-mousse_91615_c4c.jpg" });
var obj = initTile(ctx, { _id: "b7", position: 8, tiletype: "bar", name: "Le barboteur", prixDeBase: "3", img: "https://storage.googleapis.com/statics-wp/sites/lebarboteurlille.com/Le-Barboteur-0-1-1.jpg" });
var obj = initTile(ctx, { _id: "b7", position: 9, tiletype: "bar", name: "Le palais de la bière", prixDeBase: "3", img: "https://www.tourisme-pontaudemer-rislenormande.com/wp-content/uploads/2017/03/Palais-de-la-bi%C3%A8re.jpeg" });
var obj = initTile(ctx, { _id: "meetup2", position: 10, tiletype: "meetup", name: "Rencontre", img: "https://www.monpetitdate.fr/wp-content/uploads/2022/01/rencontre-trans-paris.jpg" });
var obj = initTile(ctx, { _id: "b8", position: 11, tiletype: "bar", name: "Le comptoir des bières", prixDeBase: "4", img: "https://lh3.googleusercontent.com/p/AF1QipPRj-YgeXsNxXjkpxill-QMSh20T9jeNl8OLcuj=s1600-w640" });
var obj = initTile(ctx, { _id: "b9", position: 12, tiletype: "bar", name: "Les moulins bleus", prixDeBase: "4", img: "https://www.brunnenbraeu.org/Alben2/MoulinsBleusDijon/album/slides/Les%20Moulins%20Bleus%20%E2%80%93%20Craft%20Beer%20and%20Food%20%281%29.jpg" });
var obj = initTile(ctx, { _id: "b10", position: 13, tiletype: "bar", name: "Le fourquet", prixDeBase: "4", img: "https://media-cdn.tripadvisor.com/media/photo-s/0c/ce/ca/87/le-fourquet.jpg" });
var obj = initTile(ctx, { _id: "prs", position: 14, tiletype: "prison", name: "Cellule de dégrisement", img: "https://lvdneng.rosselcdn.net/sites/default/files/dpistyles_v2/ena_16_9_extra_big/2022/09/05/node_1224621/55601340/public/2022/09/05/B9732002324Z.1_20220905182824_000%2BGBHL6LBT5.1-0.jpg?itok=UqmdxUiM1662450019" });
var obj = initTile(ctx, { _id: "b11", position: 15, tiletype: "bar", name: "Au beaux fûts", prixDeBase: "5", img: "https://because-gus.com/wp-content/uploads/2020/02/Bars-MaryRebeccaElliott.jpg" });
var obj = initTile(ctx, { _id: "b12", position: 16, tiletype: "bar", name: "Le Bacchus", prixDeBase: "5", img: "https://media-cdn.tripadvisor.com/media/photo-s/10/f6/a8/75/facade.jpg" });
var obj = initTile(ctx, { _id: "b13", position: 17, tiletype: "bar", name: "Matusalém", prixDeBase: "5", img: "https://foodforthought.com.my/wp-content/uploads/Franks-Bar-Matusalem-Rum-x-Franks-Food-For-Thought-1024x731.jpeg" });
var obj = initTile(ctx, { _id: "meetup3", position: 18, tiletype: "meetup", name: "Rencontre", img: "https://test.psychologies.com/var/tests/storage/images/2/3/3/1/11332-2-fre-FR/Test-pret-rencontre_thumb_434_265.jpg" });
var obj = initTile(ctx, { _id: "b14", position: 19, tiletype: "bar", name: "Bloody Marianne", prixDeBase: "6", img: "https://lh3.googleusercontent.com/p/AF1QipPAS0edvVXEiY7_ttg_wBIegJs1Nz2lxIXmqmr3=s1600-w640" });
var obj = initTile(ctx, { _id: "b15", position: 20, tiletype: "bar", name: "Shake it up", prixDeBase: "6", img: "https://images.barrons.com/im-839994?width=700&height=466" });
var obj = initTile(ctx, { _id: "b16", position: 21, tiletype: "bar", name: "Le mixologue", prixDeBase: "6", img: "https://www.ciga.fr/img/cms/le-mixologue/mise-en-situation-le-mixologue.jpg" });
var obj = initTile(ctx, { _id: "hh2", position: 22, tiletype: "happyHour", name: "Happy hour", img: "https://img.freepik.com/vecteurs-libre/fond-dessin-anime-happy-hours_52683-81243.jpg" });
var obj = initTile(ctx, { _id: "b17", position: 23, tiletype: "bar", name: "Le senateur", prixDeBase: "7", img: "https://media-cdn.tripadvisor.com/media/photo-s/0f/72/99/b4/montreal-marriott-chateau.jpg" });
var obj = initTile(ctx, { _id: "b18", position: 24, tiletype: "bar", name: "La dame blanche", prixDeBase: "7", img: "https://decibelles-data.media.tourinsoft.eu/upload/dame-jour.jpeg" });
var obj = initTile(ctx, { _id: "meetup4", position: 25, tiletype: "meetup", name: "Rencontre", img: "https://www.commeuncamion.com/content/uploads/2015/08/Rencontre-Couple-Bar.jpg" });
var obj = initTile(ctx, { _id: "b19", position: 26, tiletype: "bar", name: "Le Kube", prixDeBase: "8", img: "https://www.lesbarres.com/media/image/slideshow/726a6f8ea266c7c0cbb72cbc261d3520bf8f90df.jpg" });
var obj = initTile(ctx, { _id: "b20", position: 27, tiletype: "bar", name: "L'amirauté", prixDeBase: "8", img: "https://www.lamiraute-restaurant-saintes-maries-de-la-mer.com/media/cache/resolve/l800/websites/b510beeb640a5dc50a78118b3c8f7ce2/img/restaurant-amiraute-saintes-maries-de-la-mer-04_20210927172840.jpg" });
}
// La fonction "onInit()" (si déclarée) est automatiquement
@ -40,6 +111,7 @@ function onInit() {
rpc.register("initCard");
rpc.register("getTile");
rpc.register("getTilebyorder");
rpc.register("upsertTile");
rpc.register("initTile");
@ -63,7 +135,7 @@ function onInit() {
rpc.register("upsertPlayer");
rpc.register("getPlayerParty");
rpc.register("upsertlayerParty");
rpc.register("upsertPlayerParty");
rpc.register("getPlayerPartyTile");
rpc.register("upsertlayerPartyTile");
@ -134,8 +206,12 @@ async function getTile(ctx,id) {
if(obj&&!obj.value) obj.value=obj.default;
return obj;
}
async function upsertTile(ctx,card) {
var obj = await store.upsert(ctx, "Tile", config);
async function getTilebyorder(ctx,position) {
var obj = await store.query(ctx, "Tile",{"eq":{ "position": position }},);
return obj[0];
}
async function upsertTile(ctx,tile) {
var obj = await store.upsert(ctx, "Tile", tile);
return obj;
}
function initTile(ctx,tile) {
@ -165,8 +241,8 @@ async function getTilelevel(ctx,id) {
if(obj&&!obj.value) obj.value=obj.default;
return obj;
}
async function upsertTilelevel(ctx,card) {
var obj = await store.upsert(ctx, "Tilelevel", config);
async function upsertTilelevel(ctx,titlelevel) {
var obj = await store.upsert(ctx, "Tilelevel", titlelevel);
return obj;
}
function initTilelevel(ctx,tilelevel) {
@ -232,16 +308,16 @@ async function upsertPlayer(ctx,player) {
}
// Repository PlayerParty
async function getPlayerParty(ctx,playerid,partyid) {
async function getPlayerParty(ctx,ids) {
var obj = await store.query(ctx, "PlayerParty",
{
"and": [
"eq":{ "playerid": playerid },
"eq":{ "partyid": partyid }
{"eq":{ "playerid": ids.playerid }},
{"eq":{ "partyid": ids.partyid }}
]
}
);
return obj;
return obj[0];
}
async function upsertPlayerParty(ctx,playerparty) {
var obj = await store.upsert(ctx, "PlayerParty", playerparty);
@ -249,17 +325,17 @@ async function upsertPlayerParty(ctx,playerparty) {
}
// Repository PlayerPartyCase
async function getPlayerPartyTile(ctx,playerid,partyid,Tileid) {
async function getPlayerPartyTile(ctx,ids) {
var obj = await store.query(ctx, "PlayerPartyTile",
{
"and": [
"eq":{ "playerid": playerid },
"eq":{ "partyid": partyid },
"eq":{ "tileid": tileid },
{"eq":{ "playerid": ids.playerid }},
{"eq":{ "partyid": ids.partyid }},
{"eq":{ "tileid": ids.tileid }}
]
}
);
return obj;
return obj[0];
}
async function upsertPlayerPartyCase(ctx,playerpartycase) {
var obj = await store.upsert(ctx, "PlayerPartyCase", playerpartycase);

View File

@ -1,7 +1,6 @@
<script>
import { createEventDispatcher } from 'svelte';
export let id;
export let selected;
export let value;
const dispatch = createEventDispatcher();
@ -25,9 +24,7 @@
}
</script>
{#if !selected}
<span id={id} class="dice cursor-pointer text-3xl flex justify-center items-center bg-red-600 text-white rounded-lg m-1 w-14 h-14">
{value}
</span>
{/if}

View File

@ -14,42 +14,7 @@ export async function load({ params }) {
else window.location.href = '/';
if(party.status=="playerwait") {
let plateau=[
{"_id":0 ,"type":"week" ,"buyable":false,"value":50 ,"owner":[],update:0,"name":"WEEK END"},
{"_id":1 ,"type":"bar" ,"buyable":true ,"value":2 ,"owner":[],update:0,"name":"BAR 1-1"},
{"_id":2 ,"type":"bar" ,"buyable":true ,"value":2 ,"owner":[],update:0,"name":"BAR 1-2"},
{"_id":3 ,"type":"question" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Chance - Malchance"},
{"_id":4 ,"type":"bar" ,"buyable":true ,"value":4 ,"owner":[],update:0,"name":"BAR 3-1"},
{"_id":5 ,"type":"bar" ,"buyable":true ,"value":4 ,"owner":[],update:0,"name":"BAR 3-2"},
{"_id":6 ,"type":"bar" ,"buyable":true ,"value":4 ,"owner":[],update:0,"name":"BAR 3-3"},
{"_id":7 ,"type":"happy" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Happy Hour"},
{"_id":8 ,"type":"bar" ,"buyable":true ,"value":6 ,"owner":[],update:0,"name":"BAR 3-1"},
{"_id":9 ,"type":"bar" ,"buyable":true ,"value":6 ,"owner":[],update:0,"name":"BAR 3-2"},
{"_id":10,"type":"bar" ,"buyable":true ,"value":6 ,"owner":[],update:0,"name":"BAR 3-3"},
{"_id":11,"type":"prison" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Cellule de Dégrissement"},
{"_id":12,"type":"bar" ,"buyable":true ,"value":8 ,"owner":[],update:0,"name":"BAR 4-1"},
{"_id":13,"type":"bar" ,"buyable":true ,"value":8 ,"owner":[],update:0,"name":"BAR 4-2"},
{"_id":14,"type":"bar" ,"buyable":true ,"value":8 ,"owner":[],update:0,"name":"BAR 4-3"},
{"_id":15,"type":"happy" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Happy Hour"},
{"_id":16,"type":"bar" ,"buyable":true ,"value":10 ,"owner":[],update:0,"name":"BAR 5-1"},
{"_id":17,"type":"bar" ,"buyable":true ,"value":10 ,"owner":[],update:0,"name":"BAR 5-2"},
{"_id":18,"type":"bar" ,"buyable":true ,"value":10 ,"owner":[],update:0,"name":"BAR 5-3"},
{"_id":19,"type":"question" ,"buyable":false,"value":null ,"owner":[],update:0,"name":"Chance - Malchance"},
{"_id":20,"type":"bar" ,"buyable":true ,"value":12 ,"owner":[],update:0,"name":"BAR 6-1"},
{"_id":21,"type":"bar" ,"buyable":true ,"value":12 ,"owner":[],update:0,"name":"BAR 6-2"},
];
let score=[];
players.forEach(async(player) => {
score.push({"_id":player._id,"money":100,"plateauid":0});
});
party.score=score;
let dices=[
{"id":1,"value":""},
{"id":2,"value":""},
];
party.dices=dices;
console.log("wait");
}
let data = {

View File

@ -29,7 +29,7 @@
let dice5;
let results=[];
Edge.Client.addEventListener("message", function(evt) {
Edge.Client.addEventListener("message", async function(evt) {
if(evt.detail.hasOwnProperty(data.party._id)) {
console.log("RECEPTION MESSAGE");
@ -55,25 +55,53 @@
// Action retour
if(my._id===data.party.playercurrent._id) {
console.log("here");
console.log("ACTION = "+data.party.playerstatus);
switch (data.party.playerstatus) {
case "":
case "dice":
data.party.playerparty = await Edge.Client.rpc("getPlayerParty", {playerid: data.party.playercurrent._id, partyid: data.party._id}).catch(err => console.error(err));
console.log(data.party.playerparty.tileid);
data.party.playertile = await Edge.Client.rpc("getTile",data.party.playerparty.tileid).catch(err => console.error(err));
console.log(data.party.playerparty);
console.log(data.party.playertile);
break;
case "diceroll":
data.party.playerdice+=data.party.dices[0].value+data.party.dices[1].value;
// si resulat > 0 et non double = on passe à l'étape suivant sinon on peut rejeter
if(data.party.playerdice&&data.party.dices[0].value!=data.party.dices[1].value)
data.party.playerstatus="move";
else
data.party.playerstatus="dice";
if(data.party.dices[0].value>0&&data.party.dices[1].value>0) {
data.party.playerdice+=data.party.dices[0].value;
data.party.playerdice+=data.party.dices[1].value;
// si resulat > 0 et non double = on passe à l'étape suivant sinon on peut rejeter
if(data.party.playerdice&&data.party.dices[0].value!=data.party.dices[1].value)
data.party.playerstatus="move";
else
data.party.playerstatus="dice";
sendMessage("DICEROLL to "+data.party.playerstatus);
}
break;
case "move":
console.log("MOVE + "+data.party.playerdice);
let position=parseInt(data.party.playertile.position)+parseInt(data.party.playerdice);
// Là il faut faire la régle de passage à par la casse week enk
// Voir si le mouve et super gros gérer le multipassage par weekend
if(position>27) position=position-27
// Mise à jour de la position du joueur
data.party.playertile.position=position;
console.log(data.party.playertile.position)
data.party.playertile = await Edge.Client.rpc("getTilebyorder",data.party.playertile.position).catch(err => console.error(err));
console.log(data.party.playertile);
data.party.playerparty.tileid=data.party.playertile._id;
Edge.Client.rpc("upsertPlayerParty",data.party.playerparty);
// temporaire on passe au suivant
playernext();
sendMessage("DICEROLL to "+data.party.playerstatus);
break;
}
}
console.log(data);
}
});
@ -89,37 +117,64 @@
sendMessage("START PARTY");
Edge.Client.send({ "cmd": "REFRESH"});
}
async function partykill() {
if (window.confirm("Voulez-vous vraiment supprimer la partie ?")) {
data.party.status="partykill";
sendMessage("KILL PARTY");
}
}
function diceresult(event) {
data.party.dices.forEach(async (dice,id) => {
if(dice.id===event.detail.id) {
data.party.dices[id].value=event.detail.value;
async function playerkill(id) {
if (window.confirm("Voulez-vous êtes sure de vous ?")) {
// On supprime son resultat
// Si le player courrant et celui killé on passe au suivant
if(data.party.playercurrent._id==id) {
// Rechercher le player suivant
let nextplayer=0;
data.players.forEach(async (player,i) => {
if(player._id===data.party.playercurrent._id) {
if(data.players.hasOwnProperty(i+1))
nextplayer=i+1;
else
nextplayer=0;
}
});
// Passer sur le player suivant
data.party.playercurrent=data.players[nextplayer];
// Reint les dices et round et diceresultchoiced
var dices=[
{"id":1,"value":""},
{"id":2,"value":""},
];
data.party.round=0;
data.party.dices=dices;
data.party.diceresultchoiced=false;
}
});
sendMessage("RESULT ROLL");
}
async function roll() {
await data.party.dices.forEach(async (dice) => {
if(!dice.selected||data.party.round==0) {
switch (dice.id) {
case 1: await dice1.roll(); break;
case 2: await dice2.roll(); break;
case 3: await dice3.roll(); break;
case 4: await dice4.roll(); break;
case 5: await dice5.roll(); break;
// On supprime le player de la liste des players et on lui enlève la partie courrante
data.players.forEach(async (player,i) => {
if(player._id===id) {
player.partyid=null;
Edge.Client.rpc("upsertPlayer",player);
data.players.splice(i,1);
}
});
// Si la partie est wait on libère une place
if(data.party.status=="playerwait") {
data.party.playernb-=1;
Edge.Client.rpc("upsertParty",data.party);
Edge.Client.send({ "cmd": "REFRESH"});
}
});
data.party.playerstatus="diceroll";
sendMessage("NEXT ROLL");
window.scrollTo(0, 0);
sendMessage("KILL PLAYER");
}
}
function playernext() {
// Rechercher le player suivant
let nextplayer=0;
@ -165,66 +220,36 @@
await Edge.Client.rpc("upsertPlayer", my).catch(err => console.error(err));
goto("/");
}
async function playerkill(id) {
if (window.confirm("Voulez-vous êtes sure de vous ?")) {
// On supprime son resultat
// Si le player courrant et celui killé on passe au suivant
if(data.party.playercurrent._id==id) {
// Rechercher le player suivant
let nextplayer=0;
data.players.forEach(async (player,i) => {
if(player._id===data.party.playercurrent._id) {
if(data.players.hasOwnProperty(i+1))
nextplayer=i+1;
else
nextplayer=0;
}
});
// Passer sur le player suivant
data.party.playercurrent=data.players[nextplayer];
// Reint les dices et round et diceresultchoiced
var dices=[
{"id":1,"value":"","selected":false,"order":1},
{"id":2,"value":"","selected":false,"order":2},
{"id":3,"value":"","selected":false,"order":3},
{"id":4,"value":"","selected":false,"order":4},
{"id":5,"value":"","selected":false,"order":5}
];
data.party.round=0;
data.party.dices=dices;
data.party.diceresultchoiced=false;
function diceresult(event) {
data.party.dices.forEach(async (dice,id) => {
if(dice.id===event.detail.id) {
data.party.dices[id].value=event.detail.value;
}
});
// On supprime le player de la liste des players et on lui enlève la partie courrante
data.players.forEach(async (player,i) => {
if(player._id===id) {
player.partyid=null;
Edge.Client.rpc("upsertPlayer",player);
data.players.splice(i,1);
}
});
// Si la partie est wait on libère une place
if(data.party.status=="playerwait") {
data.party.playernb-=1;
Edge.Client.rpc("upsertParty",data.party);
Edge.Client.send({ "cmd": "REFRESH"});
}
sendMessage("KILL PLAYER");
}
data.party.playerstatus="diceroll";
sendMessage("RESULT ROLL");
}
async function partykill() {
if (window.confirm("Voulez-vous vraiment supprimer la partie ?")) {
data.party.status="partykill";
sendMessage("KILL PARTY");
}
}
async function roll() {
await data.party.dices.forEach(async (dice) => {
switch (dice.id) {
case 1: await dice1.roll(); break;
case 2: await dice2.roll(); break;
}
});
//sendMessage("NEXT ROLL");
window.scrollTo(0, 0);
}
</script>
{#if data.party }
@ -305,39 +330,44 @@
{/if}
</div>
<!-- DICE -->
{#if data.party.status==="partyplay"}
<!-- PARTY -->
{#if data.party.status!=="playerwait" && data.party.status!=="partyend"}
{#if data.party.playercurrent._id===my._id}
<div class="flex flex-wrap">
<div class="w-1/2 flex flex-wrap mb-3 my-auto">
<div use:sortable={{cursor:'grabbing', zIndex:100}} class="w-full flex flex-wrap p-1 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
{#each data.party.dices as mydice}
{#if mydice.id === 1}
<Dice bind:this={dice1} {...mydice} on:diceresult={diceresult} />
{:else if mydice.id === 2}
<Dice bind:this={dice2} {...mydice} on:diceresult={diceresult} />
{/if}
{/each}
</div>
<div use:sortable={{cursor:'grabbing', zIndex:100}} class="w-full flex flex-wrap p-1 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
{#each data.party.dices as mydice}
{#if mydice.id === 1}
<Dice bind:this={dice1} {...mydice} on:diceresult={diceresult} />
{:else if mydice.id === 2}
<Dice bind:this={dice2} {...mydice} on:diceresult={diceresult} />
{/if}
{/each}
</div>
</div>
{:else}
<div class="flex flex-wrap">
<div class="w-full md:w-1/2 flex flex-wrap mb-3 md:pr-3">
<div class="w-full flex flex-wrap p-1 md:p-5 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
{#each data.party.dices as mydice}
{#if !mydice.selected}
<span class="cursor-pointer text-3xl flex justify-center items-center bg-red-600 text-white rounded-lg m-1 w-14 h-14 md:m-3 md:w-20 md:h-20">
{mydice.value}
</span>
{/if}
{/each}
</div>
<div class="w-full flex flex-wrap p-1 md:p-5 bg-lime-500 items-center justify-center rounded-lg border-8 border-black">
{#each data.party.dices as mydice}
{#if !mydice.selected}
<span class="cursor-pointer text-3xl flex justify-center items-center bg-red-600 text-white rounded-lg m-1 w-14 h-14 md:m-3 md:w-20 md:h-20">
{mydice.value}
</span>
{/if}
{/each}
</div>
</div>
{/if}
{/if}
<div>
{#if data.party.playertile }
Nom = {data.party.playertile.name}<br>
Position = {data.party.playertile.position}<br>
<img src="{data.party.playertile.img}" alt="tile" style="width:800px; max-width: 100%; margin:auto;">
{/if}
</div>
<!-- KILL -->
{#if data.party.status==="partyplay" && my._id===data.party.playerid }
<button class="w-full bg-red-500 hover:bg-red-400 mt-3 text-black md:text-3xl p-1 md:p-3" on:click={partykill}>

View File

@ -13,8 +13,10 @@ export async function load({ params }) {
"playernbmax": 3,
"status": "playerwait",
"playercurrent": player,
"playerdata": null,
"playerstatus": "dice",
"playerdice": null,
"playerdice": 0,
"dices": [ {"id":1,"value":""}, {"id":2,"value":""} ]
};
let partyplayer=player;

View File

@ -41,7 +41,7 @@
// On affecte la party au player submiter
data.player.partyid=party._id;
await Edge.Client.rpc("upsertPlayer", data.player).catch(err => console.error(err));
await Edge.Client.rpc("upsertPlayerParty", { "playerid": data.player._id, "partyid": party._id, "tileid": "st", "cash": 100, "nbhappy": 0}).catch(err => console.error(err));
}
// refresh des party