diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e4ab999f..195a5fbab 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,8 +22,9 @@ jobs: sudo apt-get install -y curl - name: Download Dojo release artifact + # curl -L -o dojo-linux-x86_64.tar.gz https://github.com/dojoengine/dojo/releases/download/nightly/dojo_nightly_linux_amd64.tar.gz run: | - curl -L -o dojo-linux-x86_64.tar.gz https://github.com/dojoengine/dojo/releases/download/nightly/dojo_nightly_linux_amd64.tar.gz + curl -L -o dojo-linux-x86_64.tar.gz https://github.com/dojoengine/dojo/releases/download/v0.2.2/dojo_v0.2.2_linux_amd64.tar.gz tar -xzf dojo-linux-x86_64.tar.gz sudo mv sozo /usr/local/bin/ diff --git a/src/components/drug.cairo b/src/components/drug.cairo index 678d547f7..3215e51db 100644 --- a/src/components/drug.cairo +++ b/src/components/drug.cairo @@ -1,5 +1,3 @@ -use array::{ArrayTrait, SpanTrait}; -use traits::{Into, TryInto}; use starknet::ContractAddress; #[derive(Component, Copy, Drop, Serde, SerdeLen)] @@ -16,14 +14,7 @@ struct Drug { #[generate_trait] impl DrugImpl of DrugTrait { fn all() -> Span { - let mut drugs = array::ArrayTrait::new(); - drugs.append('Acid'.into()); - drugs.append('Weed'.into()); - drugs.append('Ludes'.into()); - drugs.append('Speed'.into()); - drugs.append('Heroin'.into()); - drugs.append('Cocaine'.into()); - + let mut drugs = array!['Acid', 'Weed', 'Ludes', 'Speed', 'Heroin', 'Cocaine']; drugs.span() } } diff --git a/src/components/game.cairo b/src/components/game.cairo index b13222e8d..212c0374a 100644 --- a/src/components/game.cairo +++ b/src/components/game.cairo @@ -1,5 +1,3 @@ -use box::BoxTrait; -use traits::Into; use starknet::ContractAddress; #[derive(Component, Copy, Drop, Serde)] diff --git a/src/components/location.cairo b/src/components/location.cairo index 4364a5c41..b9eff9b60 100644 --- a/src/components/location.cairo +++ b/src/components/location.cairo @@ -1,6 +1,3 @@ -use array::{ArrayTrait, SpanTrait}; -use option::OptionTrait; -use traits::{Into, TryInto}; use starknet::ContractAddress; struct Location {} @@ -8,14 +5,9 @@ struct Location {} #[generate_trait] impl LocationImpl of LocationTrait { fn all() -> Span { - let mut locations = array::ArrayTrait::new(); - locations.append('Queens'.into()); - locations.append('The Bronx'.into()); - locations.append('Brooklyn'.into()); - locations.append('Jersey City'.into()); - locations.append('Central Park'.into()); - locations.append('Coney Island'.into()); - + let mut locations = array![ + 'Queens', 'The Bronx', 'Brooklyn', 'Jersey City', 'Central Park', 'Coney Island' + ]; locations.span() } diff --git a/src/components/market.cairo b/src/components/market.cairo index 23411d046..2bb92aadd 100644 --- a/src/components/market.cairo +++ b/src/components/market.cairo @@ -1,7 +1,3 @@ -use traits::{Into, TryInto}; -use option::OptionTrait; -use debug::PrintTrait; - use rollyourown::constants::SCALING_FACTOR; #[derive(Component, Copy, Drop, Serde)] diff --git a/src/components/risks.cairo b/src/components/risks.cairo index 00d29c1ee..9173e0823 100644 --- a/src/components/risks.cairo +++ b/src/components/risks.cairo @@ -1,7 +1,4 @@ -use traits::{Into, TryInto}; -use option::OptionTrait; use debug::PrintTrait; - use rollyourown::constants::{ SCALING_FACTOR, COPS_DRUG_THRESHOLD, GANGS_CASH_THRESHOLD, ENCOUNTER_BIAS_GANGS }; diff --git a/src/systems/create.cairo b/src/systems/create.cairo index 078396a42..e1adf1ba1 100644 --- a/src/systems/create.cairo +++ b/src/systems/create.cairo @@ -1,10 +1,5 @@ #[system] mod create_game { - use array::ArrayTrait; - use array::SpanTrait; - use box::BoxTrait; - use option::OptionTrait; - use traits::{Into, TryInto}; use starknet::ContractAddress; use dojo::world::Context; diff --git a/src/systems/decide.cairo b/src/systems/decide.cairo index 975aeb8c1..ba8a7d0b7 100644 --- a/src/systems/decide.cairo +++ b/src/systems/decide.cairo @@ -1,8 +1,5 @@ #[system] mod decide { - use array::ArrayTrait; - use box::BoxTrait; - use traits::{Into, TryInto}; use starknet::ContractAddress; use dojo::world::Context; @@ -54,9 +51,10 @@ mod decide { cash_loss: u128 } + fn execute(ctx: Context, game_id: u32, action: Action, next_location_id: felt252) { let player_id = ctx.origin; - let mut player = get!(ctx.world, (game_id, player_id).into(), Player); + let mut player: Player = get!(ctx.world, (game_id, player_id).into(), Player); assert(player.status != PlayerStatus::Normal, 'player response not needed'); let (mut outcome, cash_loss, drug_loss, health_loss) = match action { @@ -78,13 +76,15 @@ mod decide { match player.status { PlayerStatus::Normal => (Outcome::Unsupported, 0, 0, 0), PlayerStatus::BeingMugged => { - let cash_loss = (player.cash * GANGS_PAYMENT.into()) / 100; - (Outcome::Paid, cash_loss, 0, 0) + // using same name cash_loss makes LS crash + let cash_loss_ = (player.cash * GANGS_PAYMENT.into()) / 100; + (Outcome::Paid, cash_loss_, 0, 0) }, PlayerStatus::BeingArrested => { - let drug_loss = take_drugs(ctx, game_id, player_id, COPS_PAYMENT); - (Outcome::Paid, 0, drug_loss, 0) - } + // using same name drug_loss makes LS crash + let drug_loss_ = take_drugs(ctx, game_id, player_id, COPS_PAYMENT); + (Outcome::Paid, 0, drug_loss_, 0) + }, } }, }; @@ -110,12 +110,14 @@ mod decide { } set!(ctx.world, (player)); - emit!(ctx.world, Decision { game_id, player_id, action }); - emit!( - ctx.world, - Consequence { game_id, player_id, outcome, health_loss, drug_loss, cash_loss } - ); + + // makes LS crash if inlined in emit! ( outcome / enum issue ?) + let consequence_event = Consequence { + game_id, player_id, outcome, health_loss, drug_loss, cash_loss + }; + emit!(ctx.world, consequence_event); + } fn take_drugs( @@ -148,3 +150,4 @@ mod decide { total_drug_loss } } + diff --git a/src/systems/join.cairo b/src/systems/join.cairo index 5c6c7e1ab..95132a026 100644 --- a/src/systems/join.cairo +++ b/src/systems/join.cairo @@ -1,8 +1,5 @@ #[system] mod join_game { - use traits::Into; - use box::BoxTrait; - use array::ArrayTrait; use starknet::ContractAddress; use dojo::world::Context; diff --git a/src/systems/set_name.cairo b/src/systems/set_name.cairo index 2dbc455b1..78f6c9632 100644 --- a/src/systems/set_name.cairo +++ b/src/systems/set_name.cairo @@ -1,8 +1,5 @@ #[system] mod set_name { - use array::ArrayTrait; - use traits::Into; - use dojo::world::Context; use rollyourown::components::game::Game; use rollyourown::components::name::Name; diff --git a/src/systems/trade.cairo b/src/systems/trade.cairo index 2e0c11ede..924e53867 100644 --- a/src/systems/trade.cairo +++ b/src/systems/trade.cairo @@ -1,8 +1,5 @@ #[system] mod buy { - use traits::Into; - use array::ArrayTrait; - use debug::PrintTrait; use starknet::ContractAddress; use dojo::world::Context; @@ -76,8 +73,6 @@ mod buy { #[system] mod sell { - use traits::Into; - use array::ArrayTrait; use starknet::ContractAddress; use dojo::world::Context; diff --git a/src/systems/travel.cairo b/src/systems/travel.cairo index 20c246dd9..31c269c83 100644 --- a/src/systems/travel.cairo +++ b/src/systems/travel.cairo @@ -1,10 +1,6 @@ #[system] mod travel { - use traits::Into; - use box::BoxTrait; - use array::ArrayTrait; use starknet::ContractAddress; - use debug::PrintTrait; use dojo::world::{Context}; @@ -84,6 +80,7 @@ mod travel { } use dojo::world::{Context, IWorld, IWorldDispatcher, IWorldDispatcherTrait}; + use rollyourown::components::drug::{Drug, DrugTrait}; use rollyourown::components::location::{Location, LocationTrait}; use rollyourown::components::market::{Market, MarketTrait}; diff --git a/web/next.config.js b/web/next.config.js index f6d5a7f9b..85f7be7d2 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -14,5 +14,6 @@ module.exports = withPWA({ dest: "public", register: true, skipWaiting: true, - // disable: process.env.NODE_ENV === 'development' + disableDevLogs: true, + disable: process.env.NODE_ENV === 'development' })(nextConfig); \ No newline at end of file diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index 8bace3aa5..2e6ff588f 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -1,4 +1,4 @@ -import { Clock, Gem, Bag, Arrow, Heart } from "./icons"; +import { Clock, Gem, Bag, Arrow, Heart, Siren } from "./icons"; import { Button, Divider, Flex, HStack, Text } from "@chakra-ui/react"; import { useEffect, useState } from "react"; import { IsMobile, generatePixelBorderPath } from "@/utils/ui"; @@ -92,6 +92,14 @@ const Header = ({ back }: HeaderProps) => { {playerEntity.health} + {/* + + 69% + */} diff --git a/web/src/components/Leaderboard.tsx b/web/src/components/Leaderboard.tsx index 7039db1a6..cf25391b4 100644 --- a/web/src/components/Leaderboard.tsx +++ b/web/src/components/Leaderboard.tsx @@ -54,16 +54,14 @@ const Leaderboard = ({ useEffect(() => { setHasNextPage(visibleScores < scores.length); + if (!listRef.current) return; + const lastEl = listRef.current["lastElementChild"]; + lastEl && lastEl.scrollIntoView({ behavior: "smooth" }); }, [scores, visibleScores]); const fetchNextPage = useCallback(() => { setVisibleScores(visibleScores + pageSize); - setTimeout(() => { - if (!listRef.current) return; - const lastEl = listRef.current["lastElementChild"]; - lastEl && lastEl.scrollIntoView({ behavior: "smooth" }); - }, 150); - }, [listRef.current]); + }, [listRef.current, visibleScores]); const onSubmitName = useCallback(async () => { if (!name) return; @@ -122,7 +120,8 @@ const Leaderboard = ({ > {displayName} @@ -158,10 +158,13 @@ const Leaderboard = ({ backgroundRepeat="repeat-x" flexGrow={1} color="transparent" + > {"."} - {formatCash(score.cash)} + {formatCash(score.cash)} ); diff --git a/web/src/components/icons/Siren.tsx b/web/src/components/icons/Siren.tsx new file mode 100644 index 000000000..8ed2709eb --- /dev/null +++ b/web/src/components/icons/Siren.tsx @@ -0,0 +1,17 @@ +import { Icon, IconProps } from "."; + +export const Siren = (props: IconProps) => { + return ( + + <> + + + + + + + + + + ); +}; diff --git a/web/src/components/icons/index.tsx b/web/src/components/icons/index.tsx index 896fce3de..7f3a893a9 100644 --- a/web/src/components/icons/index.tsx +++ b/web/src/components/icons/index.tsx @@ -46,6 +46,7 @@ export * from "./Close"; export * from "./ExternalLink"; export * from "./Heart"; export * from "./Skull"; +export * from "./Siren"; // Template for adding new icons. When copying svg from figma, viewBox is assumed // to be 36x36, otherwise override within individual icons. diff --git a/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx b/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx index 86da87874..ba3fd8976 100644 --- a/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx +++ b/web/src/pages/[gameId]/[locationSlug]/[drugSlug]/[tradeDirection].tsx @@ -171,7 +171,7 @@ export default function Market() { )} -