From 889f09d5df23aefbc43bd5fd805ca296eb9d0ccc Mon Sep 17 00:00:00 2001 From: akhercha Date: Mon, 2 Oct 2023 19:46:10 +0200 Subject: [PATCH 1/6] feat: Escape to a random location (#199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(escape_to_random_location): Escaping to random location + Testing text in the frontend * feat(escape_to_random_location): Correctly move to a random location * feat(escape_to_random_location): Using description field + Update README * feat(escape_to_random_location): Updated README * feat(escape_to_random_location): Removed warning emoji * feat(escape_to_random_location): Removed useless new lines * feat(escape_to_random_location): Removed changes from scarb fmt * feat(escape_to_random_location): Typo in README 💀 * feat(escape_to_random_location): Removed HTML tags from README, now using MD only * feat(escape_to_random_location): Fixed mistake 😱 --- README.md | 22 +++++++++++++++++++++- src/systems/decide.cairo | 4 ++-- web/src/dojo/helpers.ts | 2 ++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 38d6e3d50..a00274a6d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ sozo migrate torii --world {world_address} # Setup default authorization -./scripts/default_auth.sh +./scripts/default_auth.sh [local] # Start frontend, located at http://localhost:3000 cd web @@ -41,6 +41,26 @@ Note: If the world address your game is deployed to is different, you'll need to - script/default_auth.sh - web/src/constants.ts +#### Any errors when doing `sozo build` ? + +This might be because your version of sozo is not correct. + +Check the `Scarb.toml` file and get the `rev` tag from the `dojo` dependency: +```toml +[dependencies] +dojo = { git = "https://github.com/dojoengine/dojo.git", rev = "ca2d2e6dd1ef0fe311310ba0728be8743b1d5cc8" } +``` + +In this example, this is how we would install the correct version: +```bash +git clone https://github.com/dojoengine/dojo.git +cd dojo +git checkout ca2d2e6dd1ef0fe311310ba0728be8743b1d5cc8 +dojoup -p . +``` + +This will reinstall the binaries in your `~/.dojo/bin` folder. + ### With Madara TBD diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index ba8a7d0b7..02a8165c8 100644 --- a/src/systems/decide.cairo +++ b/src/systems/decide.cairo @@ -10,6 +10,7 @@ mod decide { use rollyourown::components::risks::{Risks, RisksTrait}; use rollyourown::components::player::{Player, PlayerTrait}; use rollyourown::components::drug::{Drug, DrugTrait}; + use rollyourown::components::location::LocationTrait; use rollyourown::utils::random; #[derive(Copy, Drop, Serde, PartialEq)] @@ -94,7 +95,7 @@ mod decide { } else { player.status = PlayerStatus::Normal; player.turns_remaining -= 1; - player.location_id = next_location_id; + player.location_id = LocationTrait::random(); player.run_attempts = 0; } @@ -117,7 +118,6 @@ mod decide { game_id, player_id, outcome, health_loss, drug_loss, cash_loss }; emit!(ctx.world, consequence_event); - } fn take_drugs( diff --git a/web/src/dojo/helpers.ts b/web/src/dojo/helpers.ts index e9eb0c4a8..4bd4d6d79 100644 --- a/web/src/dojo/helpers.ts +++ b/web/src/dojo/helpers.ts @@ -136,6 +136,7 @@ export const outcomes: OutcomeInfo[] = [ imageSrc: "/images/sunset.png", getResponse: (isInitial: boolean) => getCopResponses(Outcome.Escaped, isInitial), + description: "You fled to a random location", color: "neon.200", }, { @@ -155,6 +156,7 @@ export const outcomes: OutcomeInfo[] = [ imageSrc: "/images/sunset.png", getResponse: (isInitial: boolean) => getMuggerResponses(Outcome.Escaped, isInitial), + description: "You fled to a random location", color: "neon.200", }, { From dead1cb85c9edadd268969d0a17d28b4d013357d Mon Sep 17 00:00:00 2001 From: akhercha Date: Wed, 4 Oct 2023 06:54:24 +0200 Subject: [PATCH 2/6] feat: Add inventory on the Travel page (#200) * feat(travel-inventory-bar): Added inventory bar in the Travel page * feat(travel-inventory-bar): Removed not needed icons in Menu * feat(travel-inventory-bar): Removed not needed imports * feat(travel-inventory-bar): Removed useless import * feat(travel-inventory-bar): Yet another useless import :) * feat(travel-inventory-bar): Fixes from review * feat(travel-inventory-bar): Fixes from review * feat(travel-inventory-bar): Fixes from review * feat(travel-inventory-bar): Updated the gradient for mobile version * feat(travel-inventory-bar): Updated border colors & spacing * feat(travel-inventory-bar): Padding bottom for inventory for desktop & mobile --------- Co-authored-by: akhercha --- web/.gitignore | 3 ++ web/src/components/Header.tsx | 7 ++-- web/src/components/Inventory.tsx | 19 ++++++++-- web/src/pages/[gameId]/travel.tsx | 58 ++++++++++++++++++++----------- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/web/.gitignore b/web/.gitignore index 066e1bc53..e6be26a0b 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -39,3 +39,6 @@ next-env.d.ts /public/sw.js /public/sw.js.map /public/workbox-* + +# editor configuration +.vscode diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index ad9a7b07a..565eeb1df 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -65,8 +65,7 @@ const Header = ({ back }: HeaderProps) => { align="flex-start" py={["0", "20px"]} > - - + {playerEntity && gameEntity && ( { px="20px" spacing={["10px", "30px"]} bg="neon.700" - sx={{...headerStyles}} + sx={{ ...headerStyles }} > @@ -104,7 +103,7 @@ const Header = ({ back }: HeaderProps) => { )} - + {!isMobile && ( <> diff --git a/web/src/components/Inventory.tsx b/web/src/components/Inventory.tsx index 2bce8f75a..0e8c97693 100644 --- a/web/src/components/Inventory.tsx +++ b/web/src/components/Inventory.tsx @@ -5,8 +5,12 @@ import { Text, VStack, Card, + Spacer, } from "@chakra-ui/react"; +import BorderImage from "@/components/icons/BorderImage"; +import colors from "@/theme/colors"; + import React from "react"; import { usePlayerEntity } from "@/dojo/entities/usePlayerEntity"; import { useRouter } from "next/router"; @@ -24,12 +28,18 @@ export const Inventory = ({ ...props }: StyleProps) => { }); return ( - + - + Your Inventory - + + {playerEntity?.drugCount}/{playerEntity?.bagLimit} @@ -42,6 +52,9 @@ export const Inventory = ({ ...props }: StyleProps) => { px="20px" justify="center" sx={{ + borderImageSource: `url("data:image/svg+xml,${BorderImage({ + color: colors.neon["700"].toString(), + })}")`, overflowY: "scroll", "&::-webkit-scrollbar": { display: "none", diff --git a/web/src/pages/[gameId]/travel.tsx b/web/src/pages/[gameId]/travel.tsx index 672512563..7edfb1d70 100644 --- a/web/src/pages/[gameId]/travel.tsx +++ b/web/src/pages/[gameId]/travel.tsx @@ -1,6 +1,9 @@ import { Arrow, Car, Siren, Truck } from "@/components/icons"; import Layout from "@/components/Layout"; import Button from "@/components/Button"; +import { Inventory } from "@/components/Inventory"; +import colors from "@/theme/colors"; +import BorderImage from "@/components/icons/BorderImage"; import { Box, HStack, @@ -142,11 +145,11 @@ export default function Travel() { const onContinue = useCallback(async () => { if (targetId) { setIsSubmitting(true); - const { event, events, hash } = await travel(gameId, targetId); + const { event, events, hash } = await travel(gameId, targetId); if (event) { return router.push(`/${gameId}/event/decision?nextId=${targetId}`); } - + toast( `You've traveled to ${locationName}`, Car, @@ -154,20 +157,19 @@ export default function Travel() { ); router.push(`/${gameId}/turn`); - // market events - if( events) { - for( let event of events) { + // market events + if (events) { + for (let event of events) { const e = event as MarketEventData; - const msg = e.increase ? - `Pigs seized ${getDrugById(e.drugId)?.name} in ${getLocationById(e.locationId)?.name}` : - `A shipment of ${getDrugById(e.drugId)?.name} has arrived to ${getLocationById(e.locationId)?.name}` + const msg = e.increase + ? `Pigs seized ${getDrugById(e.drugId)?.name} in ${ + getLocationById(e.locationId)?.name + }` + : `A shipment of ${getDrugById(e.drugId)?.name} has arrived to ${ + getLocationById(e.locationId)?.name + }`; const icon = e.increase ? Siren : Truck; - toast( - msg, - icon, - `http://amazing_explorer/${hash}`, - 6000 - ); + toast(msg, icon, `http://amazing_explorer/${hash}`, 6000); } } } @@ -193,7 +195,13 @@ export default function Travel() { > - + + Location - + - )} + )} */} {isMobile && } diff --git a/web/src/pages/index.tsx b/web/src/pages/index.tsx index df7e42d19..eeeb176e8 100644 --- a/web/src/pages/index.tsx +++ b/web/src/pages/index.tsx @@ -44,11 +44,12 @@ export default function Home() { const [isSubmitting, setIsSubmitting] = useState(false); const [isGated, setIsGated] = useState(false); - // useEffect( - // () => - // setIsGated(window.location.host === "rollyourown.preview.cartridge.gg"), - // [], - // ); + useEffect( + () => + //setIsGated(window.location.host === "rollyourown.preview.cartridge.gg"), + setIsGated(true), + [], + ); const [isTutorialOpen, setIsTutorialOpen] = useState(false); @@ -64,7 +65,7 @@ export default function Home() { Under Construction - Get ready hustlers... Season II starts in September + Get ready hustlers... Season III starts in November ) : (