create-dubhe 1.2.0-pre.98 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +16 -16
- package/templates/101/sui-template/docker-compose.testnet.yml +73 -0
- package/templates/101/sui-template/packages/client/src/app/page.tsx +545 -41
- package/templates/101/sui-template/packages/client/src/app/providers.tsx +12 -4
- package/templates/101/sui-template/packages/contracts/Pub.localnet.toml +4 -4
- package/templates/101/sui-template/packages/contracts/counter.lock.json +20 -0
- package/templates/101/sui-template/packages/contracts/deployment.ts +8 -3
- package/templates/101/sui-template/packages/contracts/dubhe.config.json +59 -13
- package/templates/101/sui-template/packages/contracts/dubhe.config.ts +1 -4
- package/templates/101/sui-template/packages/contracts/metadata.json +1015 -68
- package/templates/101/sui-template/packages/contracts/package.json +7 -4
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/dapp_key.move +45 -31
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/error.move +8 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/genesis.move +30 -13
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/init_test.move +19 -14
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2.move +198 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2withkey.move +90 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/resources/value.move +30 -20
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
- package/templates/101/sui-template/packages/contracts/src/counter/sources/scripts/deploy_hook.move +6 -11
- package/templates/101/sui-template/packages/contracts/src/counter/sources/systems/counter.move +23 -11
- package/templates/101/sui-template/packages/contracts/src/counter/sources/tests/counter.move +15 -14
- package/templates/101/sui-template/packages/contracts/src/dubhe/Move.lock +33 -30
- package/templates/101/sui-template/packages/contracts/src/dubhe/Move.toml +8 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/dapp_key.move +45 -31
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/error.move +170 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/genesis.move +16 -13
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/init_test.move +8 -14
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/account_key.move +1 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/dapp_service.move +1776 -137
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/data_key.move +1 -20
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/events.move +864 -25
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/scripts/deploy_hook.move +15 -16
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/scripts/migrate.move +0 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/address_system.move +25 -17
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/dapp_system.move +2802 -343
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/utils.move +1 -1
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/address.move +173 -55
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/dapp_test.move +769 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/fee_test.move +2965 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/integration_test.move +303 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/listing_test.move +1422 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/scene_session_test.move +269 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/session_test.move +624 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/storage_test.move +700 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/typed_object_test.move +177 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/typed_scene_test.move +452 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/tests/user_storage_test.move +160 -0
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/utils/math.move +4 -3
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/utils/type_info.move +2 -2
- package/templates/contract/sui-template/dubhe.config.ts +0 -1
- package/templates/contract/sui-template/package.json +3 -3
- package/templates/contract/sui-template/src/dubhe/Move.lock +33 -30
- package/templates/contract/sui-template/src/dubhe/Move.toml +8 -3
- package/templates/contract/sui-template/src/dubhe/sources/codegen/dapp_key.move +45 -31
- package/templates/contract/sui-template/src/dubhe/sources/codegen/error.move +170 -0
- package/templates/contract/sui-template/src/dubhe/sources/codegen/genesis.move +16 -13
- package/templates/contract/sui-template/src/dubhe/sources/codegen/init_test.move +8 -14
- package/templates/contract/sui-template/src/dubhe/sources/core/account_key.move +1 -3
- package/templates/contract/sui-template/src/dubhe/sources/core/dapp_service.move +1776 -137
- package/templates/contract/sui-template/src/dubhe/sources/core/data_key.move +1 -20
- package/templates/contract/sui-template/src/dubhe/sources/core/events.move +864 -25
- package/templates/contract/sui-template/src/dubhe/sources/scripts/deploy_hook.move +15 -16
- package/templates/contract/sui-template/src/dubhe/sources/scripts/migrate.move +0 -3
- package/templates/contract/sui-template/src/dubhe/sources/systems/address_system.move +25 -17
- package/templates/contract/sui-template/src/dubhe/sources/systems/dapp_system.move +2802 -343
- package/templates/contract/sui-template/src/dubhe/sources/systems/utils.move +1 -1
- package/templates/contract/sui-template/src/dubhe/sources/tests/address.move +173 -55
- package/templates/contract/sui-template/src/dubhe/sources/tests/dapp_test.move +769 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/fee_test.move +2965 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/integration_test.move +303 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/listing_test.move +1422 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/scene_session_test.move +269 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/session_test.move +624 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/storage_test.move +700 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/typed_object_test.move +177 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/typed_scene_test.move +452 -0
- package/templates/contract/sui-template/src/dubhe/sources/tests/user_storage_test.move +160 -0
- package/templates/contract/sui-template/src/dubhe/sources/utils/math.move +4 -3
- package/templates/contract/sui-template/src/dubhe/sources/utils/type_info.move +2 -2
- package/templates/contract/sui-template/src/template/Move.toml +12 -0
- package/templates/contract/sui-template/src/template/sources/codegen/dapp_key.move +47 -0
- package/templates/contract/sui-template/src/template/sources/codegen/genesis.move +34 -0
- package/templates/contract/sui-template/src/template/sources/codegen/init_test.move +23 -0
- package/templates/contract/sui-template/src/template/sources/codegen/user_storage_init.move +27 -0
- package/templates/contract/sui-template/src/template/sources/scripts/deploy_hook.move +13 -0
- package/templates/contract/sui-template/src/template/sources/scripts/migrate.move +7 -0
- package/templates/nextjs/sui-card-duel/.gitignore_ +51 -0
- package/templates/nextjs/sui-card-duel/README.md +213 -0
- package/templates/nextjs/sui-card-duel/docker-compose.yml +34 -0
- package/templates/nextjs/sui-card-duel/mprocs.yaml +17 -0
- package/templates/nextjs/sui-card-duel/package.json +43 -0
- package/templates/nextjs/sui-card-duel/packages/client/.gitignore_ +48 -0
- package/templates/nextjs/sui-card-duel/packages/client/.prettierignore +1 -0
- package/templates/nextjs/sui-card-duel/packages/client/.prettierrc.json +8 -0
- package/templates/nextjs/sui-card-duel/packages/client/eslint.config.mjs +22 -0
- package/templates/nextjs/sui-card-duel/packages/client/next.config.mjs +8 -0
- package/templates/nextjs/sui-card-duel/packages/client/package.json +47 -0
- package/templates/nextjs/sui-card-duel/packages/client/postcss.config.mjs +8 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/admin/ArenaPanel.tsx +307 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/admin/page.tsx +622 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/brawl/[id]/page.tsx +559 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/collection/page.tsx +202 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/components/CardView.tsx +66 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/components/GameShell.tsx +294 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/components/icons.tsx +101 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/duel/[id]/page.tsx +477 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/favicon.ico +0 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/globals.css +85 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/hooks/useGame.ts +313 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/layout.tsx +24 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/leaderboard/page.tsx +123 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/lib/game.ts +77 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/lib/scenes.ts +226 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/market/page.tsx +418 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/page.tsx +427 -0
- package/templates/nextjs/sui-card-duel/packages/client/src/app/providers.tsx +69 -0
- package/templates/nextjs/sui-card-duel/packages/client/tailwind.config.ts +21 -0
- package/templates/nextjs/sui-card-duel/packages/client/tsconfig.json +30 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/.gitignore_ +51 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/.prettierignore +1 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/.prettierrc.json +8 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/Dockerfile +5 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/Pub.localnet.toml +13 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/card_duel.lock.json +66 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/docker-compose.yml +34 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/dubhe.config.ts +150 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/logs/combined.log +31383 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/package.json +49 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/config.ts +17 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-brawl.ts +270 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-duel.ts +272 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-lobby.ts +177 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-market.ts +219 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/e2e-session.ts +342 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/query-dapp-revenue.ts +95 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/seed.ts +92 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/scripts/withdraw-dapp-revenue.ts +56 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/Move.toml +15 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/dapp_key.move +46 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/card_kind.move +47 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/match_state.move +37 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/enums/rarity.move +37 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/error.move +126 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/genesis.move +33 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/init_test.move +23 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/objects/arena.move +137 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/permits/brawl_permit.move +125 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/permits/duel_permit.move +125 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/battle_state.move +255 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/card.move +282 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/deck.move +64 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/game_config.move +267 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/gold.move +205 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/resources/profile.move +255 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/scenes/brawl.move +313 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/scenes/duel.move +313 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/scripts/deploy_hook.move +32 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/scripts/migrate.move +7 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/arena_system.move +57 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/brawl_system.move +559 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/card_system.move +146 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/duel_system.move +515 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/market_system.move +115 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/systems/player_system.move +37 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/brawl_tests.move +385 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/duel_tests.move +656 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/src/card_duel/sources/tests/test_helpers.move +31 -0
- package/templates/nextjs/sui-card-duel/packages/contracts/sui-indexer-schema.graphql +5973 -0
- package/templates/nextjs/sui-card-duel/pnpm-workspace.yaml +2 -0
- package/templates/nextjs/sui-farm/.gitignore_ +51 -0
- package/templates/nextjs/sui-farm/README.md +15 -0
- package/templates/nextjs/sui-farm/UPGRADE_NOTES.md +97 -0
- package/templates/nextjs/sui-farm/docker-compose.yml +34 -0
- package/templates/nextjs/sui-farm/mprocs.yaml +17 -0
- package/templates/nextjs/sui-farm/package.json +43 -0
- package/templates/nextjs/sui-farm/packages/client/.gitignore_ +48 -0
- package/templates/nextjs/sui-farm/packages/client/.prettierignore +1 -0
- package/templates/nextjs/sui-farm/packages/client/.prettierrc.json +8 -0
- package/templates/nextjs/sui-farm/packages/client/eslint.config.mjs +22 -0
- package/templates/nextjs/sui-farm/packages/client/next.config.mjs +8 -0
- package/templates/nextjs/sui-farm/packages/client/package.json +47 -0
- package/templates/nextjs/sui-farm/packages/client/postcss.config.mjs +8 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/admin/page.tsx +618 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/FarmLand.tsx +526 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/FarmPlotCard.tsx +215 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/PetAvatar.tsx +868 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/PetPanel.tsx +1360 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/PlantModal.tsx +147 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/ProxyCard.tsx +684 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/RanchLand.tsx +822 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/ResourceHUD.tsx +125 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/ShopPanel.tsx +232 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/components/icons/GameIcons.tsx +574 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/favicon.ico +0 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/globals.css +423 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/hooks/useWorldPermitId.ts +66 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/layout.tsx +23 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/leaderboard/page.tsx +185 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/lib/crops.ts +97 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/market/page.tsx +763 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/page.tsx +1173 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/providers.tsx +69 -0
- package/templates/nextjs/sui-farm/packages/client/src/app/state/index.tsx +5 -0
- package/templates/nextjs/sui-farm/packages/client/tailwind.config.ts +25 -0
- package/templates/nextjs/sui-farm/packages/client/tsconfig.json +30 -0
- package/templates/nextjs/sui-farm/packages/contracts/.gitignore_ +51 -0
- package/templates/nextjs/sui-farm/packages/contracts/.prettierignore +1 -0
- package/templates/nextjs/sui-farm/packages/contracts/.prettierrc.json +8 -0
- package/templates/nextjs/sui-farm/packages/contracts/Dockerfile +5 -0
- package/templates/nextjs/sui-farm/packages/contracts/Pub.localnet.toml +13 -0
- package/templates/nextjs/sui-farm/packages/contracts/counter.lock.json +14 -0
- package/templates/nextjs/sui-farm/packages/contracts/docker-compose.yml +34 -0
- package/templates/nextjs/sui-farm/packages/contracts/dubhe.config.ts +178 -0
- package/templates/nextjs/sui-farm/packages/contracts/harvest.lock.json +120 -0
- package/templates/nextjs/sui-farm/packages/contracts/package.json +48 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/config.ts +17 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/query-dapp-revenue.ts +95 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/read-permit.ts +72 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/seed.ts +85 -0
- package/templates/nextjs/sui-farm/packages/contracts/scripts/withdraw-dapp-revenue.ts +56 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/Move.toml +14 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/dapp_key.move +31 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/error.move +10 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/genesis.move +33 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/init_test.move +23 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/resources/counter1.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/resources/counter2.move +70 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/scripts/deploy_hook.move +8 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/scripts/migrate.move +8 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/systems/counter.move +13 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/counter/sources/tests/counter.move +28 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/Move.toml +14 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/dapp_key.move +46 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/crop_type.move +47 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/egg_type.move +42 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/pet_rarity.move +37 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/enums/pet_species.move +52 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/error.move +110 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/genesis.move +33 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/init_test.move +23 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/permits/world.move +125 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/carrot.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/carrot_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/common_egg.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/corn.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/corn_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/crow_charges.move +162 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/crow_damage.move +207 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/farm_plot.move +261 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/gold.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet.move +467 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_config.move +372 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_hatch.move +162 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_slot_index.move +83 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pet_slots.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/profile.move +162 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pumpkin.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/pumpkin_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/rare_egg.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/scarecrow.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/season_config.move +197 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/season_stats.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/seasonal_egg.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/shop_config.move +267 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/trophy.move +245 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/wheat.move +136 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/wheat_seed.move +80 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/resources/world_permit_id.move +64 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/scripts/deploy_hook.move +45 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/scripts/migrate.move +7 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/crow_system.move +96 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/farm_system.move +182 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/market_system.move +172 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/pet_system.move +495 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/season_system.move +70 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/shop_system.move +112 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/systems/world_system.move +34 -0
- package/templates/nextjs/sui-farm/packages/contracts/src/harvest/sources/tests/farm_tests.move +1192 -0
- package/templates/nextjs/sui-farm/pnpm-workspace.yaml +2 -0
- package/templates/nextjs/sui-template/packages/client/src/app/components/ProxyCard.tsx +683 -0
- package/templates/nextjs/sui-template/packages/client/src/app/page.tsx +510 -5
- package/templates/nextjs/sui-template/packages/client/src/app/providers.tsx +13 -5
- package/templates/nextjs/sui-template/packages/contracts/Pub.localnet.toml +4 -4
- package/templates/nextjs/sui-template/packages/contracts/counter.lock.json +14 -0
- package/templates/nextjs/sui-template/packages/contracts/deployment.ts +8 -3
- package/templates/nextjs/sui-template/packages/contracts/dubhe.config.json +9 -9
- package/templates/nextjs/sui-template/packages/contracts/dubhe.config.ts +0 -4
- package/templates/nextjs/sui-template/packages/contracts/metadata.json +180 -124
- package/templates/nextjs/sui-template/packages/contracts/package.json +8 -4
- package/templates/nextjs/sui-template/packages/contracts/src/counter/Move.toml +4 -0
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/dapp_key.move +45 -31
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/error.move +10 -0
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/genesis.move +30 -13
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/init_test.move +19 -14
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter1.move +30 -20
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/resources/counter2.move +35 -24
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/user_storage_init.move +26 -0
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/scripts/deploy_hook.move +6 -10
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/systems/counter.move +7 -20
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/tests/counter.move +14 -27
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/Move.lock +33 -30
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/Move.toml +8 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/dapp_key.move +45 -31
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/error.move +170 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/genesis.move +16 -13
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/init_test.move +8 -14
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/account_key.move +1 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/dapp_service.move +1776 -137
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/data_key.move +1 -20
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/events.move +864 -25
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/scripts/deploy_hook.move +15 -16
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/scripts/migrate.move +0 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/address_system.move +25 -17
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/dapp_system.move +2802 -343
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/utils.move +1 -1
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/address.move +173 -55
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/dapp_test.move +769 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/fee_test.move +2965 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/integration_test.move +303 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/listing_test.move +1422 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/scene_session_test.move +269 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/session_test.move +624 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/storage_test.move +700 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/typed_object_test.move +177 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/typed_scene_test.move +452 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/tests/user_storage_test.move +160 -0
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/utils/math.move +4 -3
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/utils/type_info.move +2 -2
- package/templates/101/sui-template/packages/contracts/src/counter/Move.lock +0 -41
- package/templates/101/sui-template/packages/contracts/src/counter/Published.toml +0 -9
- package/templates/101/sui-template/packages/contracts/src/counter/sources/codegen/errors.move +0 -12
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/errors.move +0 -140
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/core/dapp_store.move +0 -29
- package/templates/101/sui-template/packages/contracts/src/dubhe/sources/systems/session_system.move +0 -44
- package/templates/contract/sui-template/src/dubhe/sources/codegen/errors.move +0 -140
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
- package/templates/contract/sui-template/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
- package/templates/contract/sui-template/src/dubhe/sources/core/dapp_store.move +0 -29
- package/templates/contract/sui-template/src/dubhe/sources/systems/session_system.move +0 -44
- package/templates/nextjs/sui-template/packages/contracts/src/counter/Move.lock +0 -47
- package/templates/nextjs/sui-template/packages/contracts/src/counter/Published.toml +0 -9
- package/templates/nextjs/sui-template/packages/contracts/src/counter/sources/codegen/errors.move +0 -12
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/errors.move +0 -140
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_config.move +0 -186
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_fee_state.move +0 -306
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dapp_metadata.move +0 -396
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/codegen/resources/dubhe_config.move +0 -246
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/core/dapp_store.move +0 -29
- package/templates/nextjs/sui-template/packages/contracts/src/dubhe/sources/systems/session_system.move +0 -44
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef } from 'react';
|
|
4
|
+
import { motion, AnimatePresence } from 'framer-motion';
|
|
5
|
+
import { PetAvatar, IconWarning } from './PetAvatar';
|
|
6
|
+
import {
|
|
7
|
+
type PetData,
|
|
8
|
+
type PetInventory,
|
|
9
|
+
SPECIES_NAME,
|
|
10
|
+
RARITY_COLOR,
|
|
11
|
+
RARITY_LABEL,
|
|
12
|
+
FAVORITE_FOOD,
|
|
13
|
+
CROP_FULL
|
|
14
|
+
} from './PetPanel';
|
|
15
|
+
|
|
16
|
+
// ── Isometric geometry constants ───────────────────────────────────────────────
|
|
17
|
+
const TW = 110; // tile diamond width
|
|
18
|
+
const TH = 55; // tile diamond height (TW/2)
|
|
19
|
+
const TD = 20; // depth thickness
|
|
20
|
+
const COLS = 4;
|
|
21
|
+
const ROWS = 3;
|
|
22
|
+
|
|
23
|
+
// ViewBox: fits 4×3 isometric grid with extra headroom for fence posts/bubbles
|
|
24
|
+
const VBX = -185,
|
|
25
|
+
VBY = -30,
|
|
26
|
+
VBW = 450,
|
|
27
|
+
VBH = 240;
|
|
28
|
+
const ASPECT = VBH / VBW;
|
|
29
|
+
|
|
30
|
+
// ── Color palette ──────────────────────────────────────────────────────────────
|
|
31
|
+
const GRASS = { t: '#4A8A28', r: '#2A5010', l: '#3A7018', s: '#5AAA34' };
|
|
32
|
+
const GRASS_H = { t: '#5CAA30', r: '#3A6818', l: '#4A8820', s: '#70CC40' };
|
|
33
|
+
const FENCE_TOP = '#A0683A';
|
|
34
|
+
const FENCE_SIDE = '#7A4A22';
|
|
35
|
+
const FENCE_DARK = '#5A3010';
|
|
36
|
+
|
|
37
|
+
// ── tileGeo ────────────────────────────────────────────────────────────────────
|
|
38
|
+
function tileGeo(col: number, row: number) {
|
|
39
|
+
const px = ((col - row) * TW) / 2;
|
|
40
|
+
const py = ((col + row) * TH) / 2;
|
|
41
|
+
const pt = (x: number, y: number) => `${x},${y}`;
|
|
42
|
+
return {
|
|
43
|
+
top: [
|
|
44
|
+
pt(px + TW / 2, py),
|
|
45
|
+
pt(px + TW, py + TH / 2),
|
|
46
|
+
pt(px + TW / 2, py + TH),
|
|
47
|
+
pt(px, py + TH / 2)
|
|
48
|
+
].join(' '),
|
|
49
|
+
right: [
|
|
50
|
+
pt(px + TW, py + TH / 2),
|
|
51
|
+
pt(px + TW, py + TH / 2 + TD),
|
|
52
|
+
pt(px + TW / 2, py + TH + TD),
|
|
53
|
+
pt(px + TW / 2, py + TH)
|
|
54
|
+
].join(' '),
|
|
55
|
+
left: [
|
|
56
|
+
pt(px, py + TH / 2),
|
|
57
|
+
pt(px + TW / 2, py + TH),
|
|
58
|
+
pt(px + TW / 2, py + TH + TD),
|
|
59
|
+
pt(px, py + TH / 2 + TD)
|
|
60
|
+
].join(' '),
|
|
61
|
+
cx: px + TW / 2,
|
|
62
|
+
cy: py + TH / 2,
|
|
63
|
+
topV: { x: px + TW / 2, y: py },
|
|
64
|
+
rightV: { x: px + TW, y: py + TH / 2 },
|
|
65
|
+
bottomV: { x: px + TW / 2, y: py + TH },
|
|
66
|
+
leftV: { x: px, y: py + TH / 2 }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ── Perimeter vertices (clockwise, continuous path) ────────────────────────────
|
|
71
|
+
// Mathematical proof: each consecutive pair is a tile-edge-connected vertex.
|
|
72
|
+
// - topV(c,0) → topV(c+1,0) : topV(c+1,0) = rightV(c,0) ✓
|
|
73
|
+
// - topV(COLS-1,0) → rightV(COLS-1,0) : adjacent on same tile ✓
|
|
74
|
+
// - rightV(c,r) → rightV(c,r+1) : rightV(c,r+1) = bottomV(c,r) ✓
|
|
75
|
+
// - rightV(COLS-1,ROWS-1) → bottomV(COLS-1,ROWS-1) : adjacent ✓
|
|
76
|
+
// - bottomV(c,ROWS-1) → bottomV(c-1,ROWS-1) : bottomV(c-1,R) = leftV(c,R) ✓
|
|
77
|
+
// - bottomV(0,ROWS-1) → leftV(0,ROWS-1) : adjacent ✓
|
|
78
|
+
// - leftV(0,r) → leftV(0,r-1) : leftV(0,r-1) = topV(0,r) ✓
|
|
79
|
+
// - leftV(0,0) → topV(0,0) : adjacent (closes loop) ✓
|
|
80
|
+
function buildPerimeter(): Array<{ x: number; y: number }> {
|
|
81
|
+
const v: Array<{ x: number; y: number }> = [];
|
|
82
|
+
for (let c = 0; c < COLS; c++) v.push(tileGeo(c, 0).topV);
|
|
83
|
+
v.push(tileGeo(COLS - 1, 0).rightV);
|
|
84
|
+
for (let r = 1; r < ROWS; r++) v.push(tileGeo(COLS - 1, r).rightV);
|
|
85
|
+
v.push(tileGeo(COLS - 1, ROWS - 1).bottomV);
|
|
86
|
+
for (let c = COLS - 2; c >= 0; c--) v.push(tileGeo(c, ROWS - 1).bottomV);
|
|
87
|
+
v.push(tileGeo(0, ROWS - 1).leftV);
|
|
88
|
+
for (let r = ROWS - 2; r >= 0; r--) v.push(tileGeo(0, r).leftV);
|
|
89
|
+
return v;
|
|
90
|
+
}
|
|
91
|
+
const PERIMETER = buildPerimeter();
|
|
92
|
+
|
|
93
|
+
// ── SVG helpers ────────────────────────────────────────────────────────────────
|
|
94
|
+
function toPercent(svgX: number, svgY: number) {
|
|
95
|
+
return {
|
|
96
|
+
left: `${((svgX - VBX) / VBW) * 100}%`,
|
|
97
|
+
top: `${((svgY - VBY) / VBH) * 100}%`
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function isoToScreen(col: number, row: number) {
|
|
102
|
+
const px = ((col - row) * TW) / 2 + TW / 2;
|
|
103
|
+
const py = ((col + row) * TH) / 2;
|
|
104
|
+
return toPercent(px, py);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function isoZ(col: number, row: number) {
|
|
108
|
+
return Math.round(row * COLS + col) + 10;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ── Types ──────────────────────────────────────────────────────────────────────
|
|
112
|
+
interface WanderPos {
|
|
113
|
+
col: number;
|
|
114
|
+
row: number;
|
|
115
|
+
flip: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface RanchLandProps {
|
|
119
|
+
inventory: PetInventory;
|
|
120
|
+
cropInventory: Record<number, bigint>;
|
|
121
|
+
isLoading: boolean;
|
|
122
|
+
onFeedPet: (petId: string, cropType: number, amount: number) => void;
|
|
123
|
+
onAssignSlot: (petId: string, slot: number) => void;
|
|
124
|
+
onUnassignSlot: (slot: number) => void;
|
|
125
|
+
onDismissPet: (petId: string) => void;
|
|
126
|
+
onListPet: (petId: string, price: bigint) => void;
|
|
127
|
+
onBuySlot: () => void;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ── Satiety decay ──────────────────────────────────────────────────────────────
|
|
131
|
+
function currentSatiety(pet: PetData, now: number) {
|
|
132
|
+
const drained = Math.floor((now - pet.fedAt) / (4 * 3600 * 1000)) * 20;
|
|
133
|
+
return Math.max(0, pet.satiety - drained);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ── ActionBubble ───────────────────────────────────────────────────────────────
|
|
137
|
+
function ActionBubble({
|
|
138
|
+
pet,
|
|
139
|
+
now,
|
|
140
|
+
cropInventory,
|
|
141
|
+
isLoading,
|
|
142
|
+
emptySlots,
|
|
143
|
+
onFeed,
|
|
144
|
+
onAssign,
|
|
145
|
+
onUnassign,
|
|
146
|
+
onDismiss,
|
|
147
|
+
onList,
|
|
148
|
+
onClose,
|
|
149
|
+
isActive,
|
|
150
|
+
activeSlot
|
|
151
|
+
}: {
|
|
152
|
+
pet: PetData;
|
|
153
|
+
now: number;
|
|
154
|
+
cropInventory: Record<number, bigint>;
|
|
155
|
+
isLoading: boolean;
|
|
156
|
+
emptySlots: number[];
|
|
157
|
+
onFeed: (ct: number, amt: number) => void;
|
|
158
|
+
onAssign: (slot: number) => void;
|
|
159
|
+
onUnassign: () => void;
|
|
160
|
+
onDismiss: () => void;
|
|
161
|
+
onList: (price: bigint) => void;
|
|
162
|
+
onClose: () => void;
|
|
163
|
+
isActive: boolean;
|
|
164
|
+
activeSlot?: number;
|
|
165
|
+
}) {
|
|
166
|
+
const [mode, setMode] = useState<'actions' | 'feed' | 'list' | 'assign'>('actions');
|
|
167
|
+
const [feedCrop, setFeedCrop] = useState(1);
|
|
168
|
+
const [feedAmt, setFeedAmt] = useState(1);
|
|
169
|
+
const [listPrice, setListPrice] = useState('');
|
|
170
|
+
const satiety = currentSatiety(pet, now);
|
|
171
|
+
const isFav = (ct: number) => FAVORITE_FOOD[pet.species] === CROP_FULL[ct];
|
|
172
|
+
const CROP_SHORT: Record<number, string> = { 1: 'W', 2: 'C', 3: 'Ca', 4: 'P' };
|
|
173
|
+
|
|
174
|
+
return (
|
|
175
|
+
<motion.div
|
|
176
|
+
initial={{ opacity: 0, scale: 0.85, y: 8 }}
|
|
177
|
+
animate={{ opacity: 1, scale: 1, y: 0 }}
|
|
178
|
+
exit={{ opacity: 0, scale: 0.85, y: 8 }}
|
|
179
|
+
transition={{ duration: 0.15 }}
|
|
180
|
+
className="bg-gray-950/95 border border-amber-600/50 rounded-xl shadow-2xl p-3 w-52 space-y-2"
|
|
181
|
+
style={{ backdropFilter: 'blur(6px)' }}
|
|
182
|
+
onClick={(e) => e.stopPropagation()}
|
|
183
|
+
>
|
|
184
|
+
{/* Header */}
|
|
185
|
+
<div className="flex items-center justify-between">
|
|
186
|
+
<div className="flex items-center gap-1.5">
|
|
187
|
+
<PetAvatar species={pet.species} level={pet.level} size={28} />
|
|
188
|
+
<div>
|
|
189
|
+
<p className="font-pixel text-amber-200 text-xs">{SPECIES_NAME[pet.species]}</p>
|
|
190
|
+
<p className={`text-xs ${RARITY_COLOR[pet.rarity]}`}>
|
|
191
|
+
{RARITY_LABEL[pet.rarity]} Lv.{pet.level}
|
|
192
|
+
</p>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
<button
|
|
196
|
+
onClick={onClose}
|
|
197
|
+
className="text-amber-700 hover:text-amber-400 text-xs leading-none pb-0.5"
|
|
198
|
+
>
|
|
199
|
+
×
|
|
200
|
+
</button>
|
|
201
|
+
</div>
|
|
202
|
+
|
|
203
|
+
{/* Satiety bar */}
|
|
204
|
+
<div className="flex items-center gap-1.5">
|
|
205
|
+
<span className="text-xs text-amber-700 w-12 font-pixel">Satiety</span>
|
|
206
|
+
<div className="flex-1 bg-gray-800 rounded-full h-1.5 overflow-hidden">
|
|
207
|
+
<div
|
|
208
|
+
className={`h-full rounded-full transition-all ${
|
|
209
|
+
satiety >= 60 ? 'bg-green-500' : satiety >= 30 ? 'bg-yellow-500' : 'bg-red-500'
|
|
210
|
+
}`}
|
|
211
|
+
style={{ width: `${satiety}%` }}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
<span className="text-xs text-amber-600 w-5 text-right">{satiety}</span>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
{isActive && activeSlot !== undefined && (
|
|
218
|
+
<p className="text-xs text-emerald-500 font-pixel">Active — Slot {activeSlot + 1}</p>
|
|
219
|
+
)}
|
|
220
|
+
|
|
221
|
+
{/* Actions */}
|
|
222
|
+
{mode === 'actions' && (
|
|
223
|
+
<div className="flex flex-wrap gap-1">
|
|
224
|
+
<button
|
|
225
|
+
onClick={() => setMode('feed')}
|
|
226
|
+
disabled={isLoading}
|
|
227
|
+
className="px-2 py-1 rounded-lg text-xs font-pixel bg-green-900/60 hover:bg-green-800 text-green-300 disabled:opacity-50 transition-colors"
|
|
228
|
+
>
|
|
229
|
+
Feed
|
|
230
|
+
</button>
|
|
231
|
+
{isActive ? (
|
|
232
|
+
<button
|
|
233
|
+
onClick={() => {
|
|
234
|
+
onUnassign();
|
|
235
|
+
onClose();
|
|
236
|
+
}}
|
|
237
|
+
disabled={isLoading}
|
|
238
|
+
className="px-2 py-1 rounded-lg text-xs font-pixel bg-amber-900/60 hover:bg-amber-800 text-amber-300 disabled:opacity-50 transition-colors"
|
|
239
|
+
>
|
|
240
|
+
→ Ranch
|
|
241
|
+
</button>
|
|
242
|
+
) : (
|
|
243
|
+
<button
|
|
244
|
+
onClick={() => setMode('assign')}
|
|
245
|
+
disabled={isLoading || emptySlots.length === 0}
|
|
246
|
+
className="px-2 py-1 rounded-lg text-xs font-pixel bg-emerald-900/60 hover:bg-emerald-800 text-emerald-300 disabled:opacity-50 transition-colors"
|
|
247
|
+
title={emptySlots.length === 0 ? 'No empty slots' : ''}
|
|
248
|
+
>
|
|
249
|
+
Activate
|
|
250
|
+
</button>
|
|
251
|
+
)}
|
|
252
|
+
<button
|
|
253
|
+
onClick={() => setMode('list')}
|
|
254
|
+
disabled={isLoading}
|
|
255
|
+
className="px-2 py-1 rounded-lg text-xs font-pixel bg-blue-900/60 hover:bg-blue-800 text-blue-300 disabled:opacity-50 transition-colors"
|
|
256
|
+
>
|
|
257
|
+
List
|
|
258
|
+
</button>
|
|
259
|
+
<button
|
|
260
|
+
onClick={() => {
|
|
261
|
+
onDismiss();
|
|
262
|
+
onClose();
|
|
263
|
+
}}
|
|
264
|
+
disabled={isLoading}
|
|
265
|
+
className="px-2 py-1 rounded-lg text-xs font-pixel bg-red-950/60 hover:bg-red-900 text-red-400 disabled:opacity-50 transition-colors"
|
|
266
|
+
>
|
|
267
|
+
Dismiss
|
|
268
|
+
</button>
|
|
269
|
+
</div>
|
|
270
|
+
)}
|
|
271
|
+
|
|
272
|
+
{/* Feed */}
|
|
273
|
+
{mode === 'feed' && (
|
|
274
|
+
<div className="space-y-2">
|
|
275
|
+
<div className="grid grid-cols-4 gap-1">
|
|
276
|
+
{[1, 2, 3, 4].map((ct) => (
|
|
277
|
+
<button
|
|
278
|
+
key={ct}
|
|
279
|
+
onClick={() => setFeedCrop(ct)}
|
|
280
|
+
className={`py-1 rounded text-xs font-pixel transition-colors relative
|
|
281
|
+
${
|
|
282
|
+
feedCrop === ct ? 'bg-amber-700 text-white' : 'bg-amber-900/40 text-amber-400'
|
|
283
|
+
}`}
|
|
284
|
+
>
|
|
285
|
+
{isFav(ct) && (
|
|
286
|
+
<span className="absolute -top-1 -right-0.5 text-red-400 text-[9px]">♥</span>
|
|
287
|
+
)}
|
|
288
|
+
<div>{CROP_SHORT[ct]}</div>
|
|
289
|
+
<div className="text-amber-700 opacity-80">{Number(cropInventory[ct] ?? 0)}</div>
|
|
290
|
+
</button>
|
|
291
|
+
))}
|
|
292
|
+
</div>
|
|
293
|
+
<div className="flex gap-1.5 items-center">
|
|
294
|
+
<input
|
|
295
|
+
type="number"
|
|
296
|
+
min={1}
|
|
297
|
+
max={Number(cropInventory[feedCrop] ?? 0)}
|
|
298
|
+
value={feedAmt}
|
|
299
|
+
onChange={(e) => setFeedAmt(Math.max(1, Number(e.target.value)))}
|
|
300
|
+
className="w-14 bg-gray-800 text-amber-200 text-xs rounded px-1.5 py-1 border border-amber-700/40"
|
|
301
|
+
/>
|
|
302
|
+
<button
|
|
303
|
+
onClick={() => {
|
|
304
|
+
onFeed(feedCrop, feedAmt);
|
|
305
|
+
setMode('actions');
|
|
306
|
+
}}
|
|
307
|
+
disabled={isLoading || Number(cropInventory[feedCrop] ?? 0) < feedAmt}
|
|
308
|
+
className="flex-1 bg-green-700 hover:bg-green-600 text-white text-xs font-pixel py-1 rounded-lg disabled:opacity-50 transition-colors"
|
|
309
|
+
>
|
|
310
|
+
Feed x{feedAmt}
|
|
311
|
+
{isFav(feedCrop) ? ' ♥' : ''}
|
|
312
|
+
</button>
|
|
313
|
+
</div>
|
|
314
|
+
<button
|
|
315
|
+
onClick={() => setMode('actions')}
|
|
316
|
+
className="text-amber-700 text-xs hover:text-amber-500"
|
|
317
|
+
>
|
|
318
|
+
← back
|
|
319
|
+
</button>
|
|
320
|
+
</div>
|
|
321
|
+
)}
|
|
322
|
+
|
|
323
|
+
{/* Assign slot */}
|
|
324
|
+
{mode === 'assign' && (
|
|
325
|
+
<div className="space-y-2">
|
|
326
|
+
<p className="text-amber-600 text-xs font-pixel">Choose slot:</p>
|
|
327
|
+
<div className="flex gap-1.5">
|
|
328
|
+
{emptySlots.map((s) => (
|
|
329
|
+
<button
|
|
330
|
+
key={s}
|
|
331
|
+
onClick={() => {
|
|
332
|
+
onAssign(s);
|
|
333
|
+
onClose();
|
|
334
|
+
}}
|
|
335
|
+
disabled={isLoading}
|
|
336
|
+
className="flex-1 bg-emerald-700 hover:bg-emerald-600 text-white text-xs font-pixel py-1.5 rounded-lg disabled:opacity-50"
|
|
337
|
+
>
|
|
338
|
+
Slot {s + 1}
|
|
339
|
+
</button>
|
|
340
|
+
))}
|
|
341
|
+
</div>
|
|
342
|
+
<button
|
|
343
|
+
onClick={() => setMode('actions')}
|
|
344
|
+
className="text-amber-700 text-xs hover:text-amber-500"
|
|
345
|
+
>
|
|
346
|
+
← back
|
|
347
|
+
</button>
|
|
348
|
+
</div>
|
|
349
|
+
)}
|
|
350
|
+
|
|
351
|
+
{/* List */}
|
|
352
|
+
{mode === 'list' && (
|
|
353
|
+
<div className="space-y-2">
|
|
354
|
+
<input
|
|
355
|
+
type="number"
|
|
356
|
+
min={1}
|
|
357
|
+
placeholder="Price (MIST)"
|
|
358
|
+
value={listPrice}
|
|
359
|
+
onChange={(e) => setListPrice(e.target.value)}
|
|
360
|
+
className="w-full bg-gray-800 text-amber-200 text-xs rounded px-2 py-1.5 border border-amber-700/40"
|
|
361
|
+
/>
|
|
362
|
+
<button
|
|
363
|
+
onClick={() => {
|
|
364
|
+
const p = BigInt(listPrice || '0');
|
|
365
|
+
if (p > 0n) {
|
|
366
|
+
onList(p);
|
|
367
|
+
setMode('actions');
|
|
368
|
+
onClose();
|
|
369
|
+
}
|
|
370
|
+
}}
|
|
371
|
+
disabled={isLoading || !listPrice || BigInt(listPrice || '0') <= 0n}
|
|
372
|
+
className="w-full bg-blue-700 hover:bg-blue-600 text-white text-xs font-pixel py-1.5 rounded-lg disabled:opacity-50 transition-colors"
|
|
373
|
+
>
|
|
374
|
+
List on Market
|
|
375
|
+
</button>
|
|
376
|
+
<button
|
|
377
|
+
onClick={() => setMode('actions')}
|
|
378
|
+
className="text-amber-700 text-xs hover:text-amber-500"
|
|
379
|
+
>
|
|
380
|
+
← back
|
|
381
|
+
</button>
|
|
382
|
+
</div>
|
|
383
|
+
)}
|
|
384
|
+
</motion.div>
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// ── RanchLand ──────────────────────────────────────────────────────────────────
|
|
389
|
+
export function RanchLand({
|
|
390
|
+
inventory,
|
|
391
|
+
cropInventory,
|
|
392
|
+
isLoading,
|
|
393
|
+
onFeedPet,
|
|
394
|
+
onAssignSlot,
|
|
395
|
+
onUnassignSlot,
|
|
396
|
+
onDismissPet,
|
|
397
|
+
onListPet
|
|
398
|
+
}: RanchLandProps) {
|
|
399
|
+
const [nowTick, setNowTick] = useState(() => Date.now());
|
|
400
|
+
const [hoveredTile, setHoveredTile] = useState<string | null>(null);
|
|
401
|
+
const [selectedPetId, setSelectedPetId] = useState<string | null>(null);
|
|
402
|
+
const [wanderPos, setWanderPos] = useState<Map<string, WanderPos>>(new Map());
|
|
403
|
+
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
|
404
|
+
|
|
405
|
+
const { activeSlots, ranchPets, slotsOwned, hatch } = inventory;
|
|
406
|
+
const slottedPets = activeSlots
|
|
407
|
+
.map((p, i) => (p ? { pet: p, slot: i } : null))
|
|
408
|
+
.filter(Boolean) as Array<{ pet: PetData; slot: number }>;
|
|
409
|
+
const allPets: PetData[] = [...slottedPets.map((s) => s.pet), ...ranchPets];
|
|
410
|
+
const emptySlots = Array.from({ length: slotsOwned }, (_, i) => i).filter(
|
|
411
|
+
(i) => activeSlots[i] === null
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
// Init / sync wander positions
|
|
415
|
+
useEffect(() => {
|
|
416
|
+
setWanderPos((prev) => {
|
|
417
|
+
const next = new Map(prev);
|
|
418
|
+
allPets.forEach((pet) => {
|
|
419
|
+
if (!next.has(pet.petId)) {
|
|
420
|
+
next.set(pet.petId, {
|
|
421
|
+
col: 0.7 + Math.random() * (COLS - 1.5),
|
|
422
|
+
row: 0.5 + Math.random() * (ROWS - 1.2),
|
|
423
|
+
flip: Math.random() > 0.5
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
for (const id of next.keys()) {
|
|
428
|
+
if (!allPets.find((p) => p.petId === id)) next.delete(id);
|
|
429
|
+
}
|
|
430
|
+
return next;
|
|
431
|
+
});
|
|
432
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
433
|
+
}, [allPets.length]);
|
|
434
|
+
|
|
435
|
+
// Wander tick
|
|
436
|
+
useEffect(() => {
|
|
437
|
+
timerRef.current = setInterval(() => {
|
|
438
|
+
setWanderPos((prev) => {
|
|
439
|
+
const next = new Map(prev);
|
|
440
|
+
allPets.forEach((pet) => {
|
|
441
|
+
const cur = next.get(pet.petId);
|
|
442
|
+
const nc = 0.7 + Math.random() * (COLS - 1.5);
|
|
443
|
+
const nr = 0.5 + Math.random() * (ROWS - 1.2);
|
|
444
|
+
next.set(pet.petId, {
|
|
445
|
+
col: nc,
|
|
446
|
+
row: nr,
|
|
447
|
+
flip: cur ? nc < cur.col : Math.random() > 0.5
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
return next;
|
|
451
|
+
});
|
|
452
|
+
}, 3800 + Math.random() * 2400);
|
|
453
|
+
return () => {
|
|
454
|
+
if (timerRef.current) clearInterval(timerRef.current);
|
|
455
|
+
};
|
|
456
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
457
|
+
}, [allPets.length]);
|
|
458
|
+
|
|
459
|
+
// Wall-clock tick for satiety decay + hatch empty-state messaging
|
|
460
|
+
useEffect(() => {
|
|
461
|
+
const id = setInterval(() => setNowTick(Date.now()), 1000);
|
|
462
|
+
return () => clearInterval(id);
|
|
463
|
+
}, []);
|
|
464
|
+
|
|
465
|
+
// ── Tile grid ──
|
|
466
|
+
const tiles: Array<{ col: number; row: number; key: string; g: ReturnType<typeof tileGeo> }> = [];
|
|
467
|
+
for (let row = 0; row < ROWS; row++) {
|
|
468
|
+
for (let col = 0; col < COLS; col++) {
|
|
469
|
+
tiles.push({ col, row, key: `${col}-${row}`, g: tileGeo(col, row) });
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// ── Decorations ──
|
|
474
|
+
const troughG = tileGeo(COLS - 1, 0);
|
|
475
|
+
const hayG = tileGeo(0, ROWS - 1);
|
|
476
|
+
|
|
477
|
+
return (
|
|
478
|
+
// Outer: padding-bottom keeps aspect ratio; NO overflow-hidden here so bubbles can escape
|
|
479
|
+
<div className="relative w-full select-none" style={{ paddingBottom: `${ASPECT * 100}%` }}>
|
|
480
|
+
{/* ── Layer 1: clipped background + SVG ── */}
|
|
481
|
+
<div
|
|
482
|
+
className="absolute inset-0 rounded-2xl overflow-hidden pointer-events-none"
|
|
483
|
+
style={{
|
|
484
|
+
background: 'radial-gradient(ellipse at 50% 20%, #3A7040 0%, #1C4420 60%, #0C2010 100%)'
|
|
485
|
+
}}
|
|
486
|
+
>
|
|
487
|
+
{/* Grass texture dots */}
|
|
488
|
+
<div
|
|
489
|
+
className="absolute inset-0 opacity-[0.08]"
|
|
490
|
+
style={{
|
|
491
|
+
backgroundImage: 'radial-gradient(circle, #8AEE50 0.5px, transparent 0.5px)',
|
|
492
|
+
backgroundSize: '16px 16px'
|
|
493
|
+
}}
|
|
494
|
+
/>
|
|
495
|
+
|
|
496
|
+
<svg
|
|
497
|
+
className="absolute inset-0 w-full h-full"
|
|
498
|
+
viewBox={`${VBX} ${VBY} ${VBW} ${VBH}`}
|
|
499
|
+
preserveAspectRatio="xMidYMid meet"
|
|
500
|
+
>
|
|
501
|
+
<defs>
|
|
502
|
+
<pattern
|
|
503
|
+
id="ranch-grass-dots"
|
|
504
|
+
x="0"
|
|
505
|
+
y="0"
|
|
506
|
+
width="12"
|
|
507
|
+
height="9"
|
|
508
|
+
patternUnits="userSpaceOnUse"
|
|
509
|
+
patternTransform="rotate(-25)"
|
|
510
|
+
>
|
|
511
|
+
<circle cx="3" cy="3" r="0.7" fill="rgba(120,220,60,0.18)" />
|
|
512
|
+
<circle cx="8" cy="6" r="0.5" fill="rgba(80,180,30,0.14)" />
|
|
513
|
+
</pattern>
|
|
514
|
+
</defs>
|
|
515
|
+
|
|
516
|
+
{/* Grass tiles */}
|
|
517
|
+
{tiles.map(({ key, col, row, g }) => {
|
|
518
|
+
const isHov = hoveredTile === key;
|
|
519
|
+
const isBorL = col === 0;
|
|
520
|
+
const isBorR = col === COLS - 1;
|
|
521
|
+
const isBorB = row === ROWS - 1;
|
|
522
|
+
const c = isHov ? GRASS_H : GRASS;
|
|
523
|
+
return (
|
|
524
|
+
<g
|
|
525
|
+
key={key}
|
|
526
|
+
onMouseEnter={() => setHoveredTile(key)}
|
|
527
|
+
onMouseLeave={() => setHoveredTile(null)}
|
|
528
|
+
>
|
|
529
|
+
<polygon points={g.top} fill={c.t} />
|
|
530
|
+
<polygon points={g.top} fill="url(#ranch-grass-dots)" />
|
|
531
|
+
<polygon points={g.top} fill="none" stroke={c.s} strokeWidth="0.6" />
|
|
532
|
+
{/* Perimeter side faces use fence colour; interior faces use dark green */}
|
|
533
|
+
<polygon points={g.right} fill={isBorR || isBorB ? FENCE_SIDE : c.r} />
|
|
534
|
+
<polygon points={g.left} fill={isBorL || isBorB ? FENCE_DARK : c.l} />
|
|
535
|
+
</g>
|
|
536
|
+
);
|
|
537
|
+
})}
|
|
538
|
+
|
|
539
|
+
{/* Water trough at back-right */}
|
|
540
|
+
<g>
|
|
541
|
+
<polygon
|
|
542
|
+
points={`${troughG.cx - 16},${troughG.cy - 8} ${troughG.cx + 16},${troughG.cy - 8} ${
|
|
543
|
+
troughG.cx + 16
|
|
544
|
+
},${troughG.cy} ${troughG.cx - 16},${troughG.cy}`}
|
|
545
|
+
fill="#5A3820"
|
|
546
|
+
/>
|
|
547
|
+
<polygon
|
|
548
|
+
points={`${troughG.cx - 13},${troughG.cy - 7} ${troughG.cx + 13},${troughG.cy - 7} ${
|
|
549
|
+
troughG.cx + 13
|
|
550
|
+
},${troughG.cy - 2} ${troughG.cx - 13},${troughG.cy - 2}`}
|
|
551
|
+
fill="#3888CC"
|
|
552
|
+
opacity="0.85"
|
|
553
|
+
>
|
|
554
|
+
<animate
|
|
555
|
+
attributeName="opacity"
|
|
556
|
+
values="0.65;0.95;0.65"
|
|
557
|
+
dur="2s"
|
|
558
|
+
repeatCount="indefinite"
|
|
559
|
+
/>
|
|
560
|
+
</polygon>
|
|
561
|
+
</g>
|
|
562
|
+
|
|
563
|
+
{/* Hay pile at front-left */}
|
|
564
|
+
<g>
|
|
565
|
+
<ellipse cx={hayG.cx} cy={hayG.cy - 4} rx="15" ry="7" fill="#C8A030" opacity="0.9" />
|
|
566
|
+
<ellipse cx={hayG.cx} cy={hayG.cy - 6} rx="10" ry="5" fill="#E8BC40" opacity="0.9" />
|
|
567
|
+
<line
|
|
568
|
+
x1={hayG.cx - 8}
|
|
569
|
+
y1={hayG.cy - 5}
|
|
570
|
+
x2={hayG.cx - 3}
|
|
571
|
+
y2={hayG.cy - 9}
|
|
572
|
+
stroke="#DAAE30"
|
|
573
|
+
strokeWidth="1"
|
|
574
|
+
/>
|
|
575
|
+
<line
|
|
576
|
+
x1={hayG.cx + 4}
|
|
577
|
+
y1={hayG.cy - 4}
|
|
578
|
+
x2={hayG.cx + 9}
|
|
579
|
+
y2={hayG.cy - 8}
|
|
580
|
+
stroke="#DAAE30"
|
|
581
|
+
strokeWidth="1"
|
|
582
|
+
/>
|
|
583
|
+
<line
|
|
584
|
+
x1={hayG.cx - 1}
|
|
585
|
+
y1={hayG.cy - 3}
|
|
586
|
+
x2={hayG.cx + 3}
|
|
587
|
+
y2={hayG.cy - 8}
|
|
588
|
+
stroke="#F0C84A"
|
|
589
|
+
strokeWidth="1"
|
|
590
|
+
/>
|
|
591
|
+
</g>
|
|
592
|
+
|
|
593
|
+
{/* ── Fence rails: continuous perimeter polylines ── */}
|
|
594
|
+
{/* Close the loop by appending PERIMETER[0] at the end */}
|
|
595
|
+
{(() => {
|
|
596
|
+
const closed = [...PERIMETER, PERIMETER[0]];
|
|
597
|
+
const rail1 = closed.map((v) => `${v.x},${v.y - 6}`).join(' ');
|
|
598
|
+
const rail2 = closed.map((v) => `${v.x},${v.y - 11}`).join(' ');
|
|
599
|
+
return (
|
|
600
|
+
<>
|
|
601
|
+
<polyline
|
|
602
|
+
points={rail1}
|
|
603
|
+
fill="none"
|
|
604
|
+
stroke={FENCE_SIDE}
|
|
605
|
+
strokeWidth="2"
|
|
606
|
+
strokeLinejoin="round"
|
|
607
|
+
/>
|
|
608
|
+
<polyline
|
|
609
|
+
points={rail2}
|
|
610
|
+
fill="none"
|
|
611
|
+
stroke={FENCE_TOP}
|
|
612
|
+
strokeWidth="1.5"
|
|
613
|
+
strokeLinejoin="round"
|
|
614
|
+
/>
|
|
615
|
+
</>
|
|
616
|
+
);
|
|
617
|
+
})()}
|
|
618
|
+
|
|
619
|
+
{/* ── Fence posts at each perimeter vertex ── */}
|
|
620
|
+
{PERIMETER.map((v, i) => {
|
|
621
|
+
const hw = 3.5,
|
|
622
|
+
h = 15;
|
|
623
|
+
const bx = v.x,
|
|
624
|
+
by = v.y;
|
|
625
|
+
const ty = by - h;
|
|
626
|
+
return (
|
|
627
|
+
<g key={`post-${i}`}>
|
|
628
|
+
{/* top cap */}
|
|
629
|
+
<polygon
|
|
630
|
+
points={`${bx},${ty} ${bx + hw},${ty + hw * 0.5} ${bx},${ty + hw} ${bx - hw},${
|
|
631
|
+
ty + hw * 0.5
|
|
632
|
+
}`}
|
|
633
|
+
fill={FENCE_TOP}
|
|
634
|
+
/>
|
|
635
|
+
{/* right face */}
|
|
636
|
+
<polygon
|
|
637
|
+
points={`${bx + hw},${ty + hw * 0.5} ${bx + hw},${by + hw * 0.5} ${bx},${
|
|
638
|
+
by + hw * 0.5
|
|
639
|
+
} ${bx},${ty + hw}`}
|
|
640
|
+
fill={FENCE_SIDE}
|
|
641
|
+
/>
|
|
642
|
+
{/* left face */}
|
|
643
|
+
<polygon
|
|
644
|
+
points={`${bx - hw},${ty + hw * 0.5} ${bx},${ty + hw} ${bx},${by + hw * 0.5} ${
|
|
645
|
+
bx - hw
|
|
646
|
+
},${by + hw * 0.5}`}
|
|
647
|
+
fill={FENCE_DARK}
|
|
648
|
+
/>
|
|
649
|
+
</g>
|
|
650
|
+
);
|
|
651
|
+
})}
|
|
652
|
+
</svg>
|
|
653
|
+
|
|
654
|
+
{/* Labels (clipped layer) */}
|
|
655
|
+
<div className="absolute top-2 left-3">
|
|
656
|
+
<p className="text-[9px] font-pixel text-[#6ABF3A]/70 tracking-widest uppercase">
|
|
657
|
+
Your Ranch
|
|
658
|
+
</p>
|
|
659
|
+
</div>
|
|
660
|
+
<div className="absolute bottom-2 right-3">
|
|
661
|
+
<p className="text-[9px] font-pixel text-[#2A5A18]/60">tap a pet to interact</p>
|
|
662
|
+
</div>
|
|
663
|
+
{allPets.length === 0 && (
|
|
664
|
+
<div className="absolute inset-0 flex flex-col items-center justify-center gap-1 px-4 text-center pointer-events-none">
|
|
665
|
+
{hatch ? (
|
|
666
|
+
nowTick >= hatch.hatchAt ? (
|
|
667
|
+
<>
|
|
668
|
+
<p className="text-emerald-400/90 font-pixel text-xs">Pet is ready!</p>
|
|
669
|
+
<p className="text-[#3A7020] font-pixel text-[10px] opacity-80 max-w-[220px]">
|
|
670
|
+
Open PETS → Hatch tab and tap <span className="text-emerald-500">Open Egg</span>{' '}
|
|
671
|
+
to bring them to your ranch.
|
|
672
|
+
</p>
|
|
673
|
+
</>
|
|
674
|
+
) : (
|
|
675
|
+
<>
|
|
676
|
+
<p className="text-[#5A9040] font-pixel text-xs">Egg is incubating…</p>
|
|
677
|
+
<p className="text-[#3A7020] font-pixel text-[10px] opacity-80 max-w-[220px]">
|
|
678
|
+
Your pet appears here after incubation finishes and you complete{' '}
|
|
679
|
+
<span className="text-amber-600/90">Open Egg</span> in the Hatch tab.
|
|
680
|
+
</p>
|
|
681
|
+
</>
|
|
682
|
+
)
|
|
683
|
+
) : (
|
|
684
|
+
<p className="text-[#3A7020] font-pixel text-xs opacity-60 max-w-[240px]">
|
|
685
|
+
Buy an egg in PETS → Shop, then start incubation in the Hatch tab. After the timer,
|
|
686
|
+
use Open Egg to get your first pet.
|
|
687
|
+
</p>
|
|
688
|
+
)}
|
|
689
|
+
</div>
|
|
690
|
+
)}
|
|
691
|
+
</div>
|
|
692
|
+
|
|
693
|
+
{/* ── Layer 2: pets + action bubbles — NOT clipped ── */}
|
|
694
|
+
{/* This layer sits on top of the clipped background and can overflow for bubbles. */}
|
|
695
|
+
<div className="absolute inset-0" onClick={() => setSelectedPetId(null)}>
|
|
696
|
+
{allPets.map((pet) => {
|
|
697
|
+
const pos = wanderPos.get(pet.petId);
|
|
698
|
+
if (!pos) return null;
|
|
699
|
+
const { left, top } = isoToScreen(pos.col, pos.row);
|
|
700
|
+
const z = isoZ(pos.col, pos.row);
|
|
701
|
+
const sat = currentSatiety(pet, nowTick);
|
|
702
|
+
const hungry = sat < 30;
|
|
703
|
+
const slotInfo = slottedPets.find((s) => s.pet.petId === pet.petId);
|
|
704
|
+
const isSelected = selectedPetId === pet.petId;
|
|
705
|
+
|
|
706
|
+
const idleClass = (() => {
|
|
707
|
+
const base: Record<number, string> = {
|
|
708
|
+
1: 'pet-anim-bunny',
|
|
709
|
+
2: 'pet-anim-chick',
|
|
710
|
+
3: 'pet-anim-fox',
|
|
711
|
+
4: 'pet-anim-deer',
|
|
712
|
+
5: 'pet-anim-dragon'
|
|
713
|
+
};
|
|
714
|
+
const b = base[pet.species] ?? '';
|
|
715
|
+
if (sat < 30) return 'pet-anim-starving';
|
|
716
|
+
return sat < 60 ? `${b} pet-anim-slow` : b;
|
|
717
|
+
})();
|
|
718
|
+
|
|
719
|
+
return (
|
|
720
|
+
<div
|
|
721
|
+
key={pet.petId}
|
|
722
|
+
className="absolute pointer-events-none"
|
|
723
|
+
style={{
|
|
724
|
+
left,
|
|
725
|
+
top,
|
|
726
|
+
zIndex: z,
|
|
727
|
+
transform: 'translate(-50%, -80%)',
|
|
728
|
+
transition: 'left 2.8s ease-in-out, top 2.8s ease-in-out'
|
|
729
|
+
}}
|
|
730
|
+
>
|
|
731
|
+
{/* Pet sprite */}
|
|
732
|
+
<div
|
|
733
|
+
className={`relative pointer-events-auto cursor-pointer ${idleClass} ${
|
|
734
|
+
isSelected ? 'level-up-glow' : ''
|
|
735
|
+
}`}
|
|
736
|
+
style={{ transform: pos.flip ? 'scaleX(-1)' : 'scaleX(1)' }}
|
|
737
|
+
onClick={(e) => {
|
|
738
|
+
e.stopPropagation();
|
|
739
|
+
setSelectedPetId((prev) => (prev === pet.petId ? null : pet.petId));
|
|
740
|
+
}}
|
|
741
|
+
>
|
|
742
|
+
<PetAvatar species={pet.species} level={pet.level} size={42} />
|
|
743
|
+
{hungry && (
|
|
744
|
+
<motion.div
|
|
745
|
+
className="absolute -top-1 -right-1"
|
|
746
|
+
animate={{ opacity: [1, 0.2, 1] }}
|
|
747
|
+
transition={{ duration: 0.7, repeat: Infinity }}
|
|
748
|
+
>
|
|
749
|
+
<IconWarning size={12} />
|
|
750
|
+
</motion.div>
|
|
751
|
+
)}
|
|
752
|
+
{slotInfo && (
|
|
753
|
+
<div className="absolute -top-1 -left-1 w-4 h-4 rounded-full bg-emerald-700 border border-emerald-400 flex items-center justify-center">
|
|
754
|
+
<span className="text-white font-pixel" style={{ fontSize: '7px' }}>
|
|
755
|
+
{slotInfo.slot + 1}
|
|
756
|
+
</span>
|
|
757
|
+
</div>
|
|
758
|
+
)}
|
|
759
|
+
</div>
|
|
760
|
+
{/* Ground shadow */}
|
|
761
|
+
<div className="absolute -bottom-1 left-1/2 -translate-x-1/2 w-7 h-2 bg-black/30 rounded-full blur-sm pointer-events-none pet-shadow" />
|
|
762
|
+
</div>
|
|
763
|
+
);
|
|
764
|
+
})}
|
|
765
|
+
|
|
766
|
+
{/* Action bubble for selected pet — rendered in the UNCLIPPED layer */}
|
|
767
|
+
<AnimatePresence>
|
|
768
|
+
{selectedPetId &&
|
|
769
|
+
(() => {
|
|
770
|
+
const pet = allPets.find((p) => p.petId === selectedPetId);
|
|
771
|
+
if (!pet) return null;
|
|
772
|
+
const pos = wanderPos.get(selectedPetId);
|
|
773
|
+
if (!pos) return null;
|
|
774
|
+
|
|
775
|
+
const { left, top } = isoToScreen(pos.col, pos.row);
|
|
776
|
+
const z = isoZ(pos.col, pos.row) + 50;
|
|
777
|
+
const slotInfo = slottedPets.find((s) => s.pet.petId === selectedPetId);
|
|
778
|
+
|
|
779
|
+
// Show bubble above the pet normally.
|
|
780
|
+
// If pet is in upper half of ranch (row < ROWS/2), show below instead.
|
|
781
|
+
const showBelow = pos.row < ROWS / 2;
|
|
782
|
+
const bubbleTransform = showBelow
|
|
783
|
+
? 'translate(-50%, 8px)' // below the pet
|
|
784
|
+
: 'translate(-50%, -230%)'; // above the pet
|
|
785
|
+
|
|
786
|
+
return (
|
|
787
|
+
<div
|
|
788
|
+
key={selectedPetId}
|
|
789
|
+
className="absolute pointer-events-none"
|
|
790
|
+
style={{
|
|
791
|
+
left,
|
|
792
|
+
top,
|
|
793
|
+
zIndex: z,
|
|
794
|
+
transform: bubbleTransform,
|
|
795
|
+
transition: 'left 2.8s ease-in-out, top 2.8s ease-in-out'
|
|
796
|
+
}}
|
|
797
|
+
>
|
|
798
|
+
<div className="pointer-events-auto">
|
|
799
|
+
<ActionBubble
|
|
800
|
+
pet={pet}
|
|
801
|
+
now={nowTick}
|
|
802
|
+
cropInventory={cropInventory}
|
|
803
|
+
isLoading={isLoading}
|
|
804
|
+
emptySlots={emptySlots}
|
|
805
|
+
onFeed={(ct, amt) => onFeedPet(pet.petId, ct, amt)}
|
|
806
|
+
onAssign={(slot) => onAssignSlot(pet.petId, slot)}
|
|
807
|
+
onUnassign={() => slotInfo && onUnassignSlot(slotInfo.slot)}
|
|
808
|
+
onDismiss={() => onDismissPet(pet.petId)}
|
|
809
|
+
onList={(price) => onListPet(pet.petId, price)}
|
|
810
|
+
onClose={() => setSelectedPetId(null)}
|
|
811
|
+
isActive={!!slotInfo}
|
|
812
|
+
activeSlot={slotInfo?.slot}
|
|
813
|
+
/>
|
|
814
|
+
</div>
|
|
815
|
+
</div>
|
|
816
|
+
);
|
|
817
|
+
})()}
|
|
818
|
+
</AnimatePresence>
|
|
819
|
+
</div>
|
|
820
|
+
</div>
|
|
821
|
+
);
|
|
822
|
+
}
|