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,115 @@
|
|
|
1
|
+
/// Public entry wrappers for the card / gold marketplace (listable codegen).
|
|
2
|
+
///
|
|
3
|
+
/// The framework's take_record / buy_record enforce
|
|
4
|
+
/// `ctx.sender() == canonical_owner(user_storage)`, so session keys are
|
|
5
|
+
/// rejected at the framework level — no extra check needed here.
|
|
6
|
+
///
|
|
7
|
+
/// CoinType = 0x2::sui::SUI (prices denominated in MIST).
|
|
8
|
+
module card_duel::market_system {
|
|
9
|
+
use sui::sui::SUI;
|
|
10
|
+
use sui::coin::{Self, Coin};
|
|
11
|
+
use dubhe::dapp_service::{DappHub, DappStorage, UserStorage, Listing};
|
|
12
|
+
use dubhe::dapp_system;
|
|
13
|
+
use card_duel::dapp_key::DappKey;
|
|
14
|
+
use card_duel::migrate;
|
|
15
|
+
use card_duel::error;
|
|
16
|
+
use card_duel::battle_state;
|
|
17
|
+
use card_duel::card;
|
|
18
|
+
use card_duel::deck;
|
|
19
|
+
use card_duel::gold;
|
|
20
|
+
|
|
21
|
+
// ── Card NFT market ────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
/// List an owned card for sale. The card is removed from the seller's
|
|
24
|
+
/// storage; if it was part of the battle deck the deck becomes invalid
|
|
25
|
+
/// until set_deck is called again, so listing is blocked mid-match.
|
|
26
|
+
public entry fun list_card(
|
|
27
|
+
dapp_storage: &DappStorage,
|
|
28
|
+
user_storage: &mut UserStorage,
|
|
29
|
+
card_id: address,
|
|
30
|
+
price: u64,
|
|
31
|
+
ctx: &mut TxContext,
|
|
32
|
+
) {
|
|
33
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
34
|
+
error::card_not_found(card::has(user_storage, card_id));
|
|
35
|
+
error::already_in_match(battle_state::get_match_id(user_storage) == @0x0);
|
|
36
|
+
|
|
37
|
+
// Remove the card from the battle deck if present.
|
|
38
|
+
if (deck::has(user_storage)) {
|
|
39
|
+
let current = deck::get(user_storage);
|
|
40
|
+
let (found, idx) = current.index_of(&card_id);
|
|
41
|
+
if (found) {
|
|
42
|
+
let mut updated = current;
|
|
43
|
+
updated.remove(idx);
|
|
44
|
+
deck::set(user_storage, updated, ctx);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
card::list<SUI>(user_storage, card_id, price, std::option::none(), ctx);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public entry fun buy_card(
|
|
52
|
+
dh: &DappHub,
|
|
53
|
+
dapp_storage: &mut DappStorage,
|
|
54
|
+
listing: Listing<SUI>,
|
|
55
|
+
user_storage: &mut UserStorage,
|
|
56
|
+
payment: Coin<SUI>,
|
|
57
|
+
ctx: &mut TxContext,
|
|
58
|
+
) {
|
|
59
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
60
|
+
let change = card::buy<SUI>(dh, dapp_storage, listing, user_storage, payment, ctx);
|
|
61
|
+
return_change(change, ctx);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public entry fun cancel_card_listing(
|
|
65
|
+
listing: Listing<SUI>,
|
|
66
|
+
user_storage: &mut UserStorage,
|
|
67
|
+
ctx: &TxContext,
|
|
68
|
+
) {
|
|
69
|
+
card::cancel_listing<SUI>(listing, user_storage, ctx);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── Gold market (fungible) ─────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
public entry fun list_gold(
|
|
75
|
+
dapp_storage: &DappStorage,
|
|
76
|
+
user_storage: &mut UserStorage,
|
|
77
|
+
amount: u64,
|
|
78
|
+
price: u64,
|
|
79
|
+
ctx: &mut TxContext,
|
|
80
|
+
) {
|
|
81
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
82
|
+
gold::list<SUI>(user_storage, amount, price, std::option::none(), ctx);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public entry fun buy_gold(
|
|
86
|
+
dh: &DappHub,
|
|
87
|
+
dapp_storage: &mut DappStorage,
|
|
88
|
+
listing: Listing<SUI>,
|
|
89
|
+
user_storage: &mut UserStorage,
|
|
90
|
+
payment: Coin<SUI>,
|
|
91
|
+
ctx: &mut TxContext,
|
|
92
|
+
) {
|
|
93
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
94
|
+
let change = gold::buy<SUI>(dh, dapp_storage, listing, user_storage, payment, ctx);
|
|
95
|
+
return_change(change, ctx);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public entry fun cancel_gold_listing(
|
|
99
|
+
listing: Listing<SUI>,
|
|
100
|
+
user_storage: &mut UserStorage,
|
|
101
|
+
ctx: &TxContext,
|
|
102
|
+
) {
|
|
103
|
+
gold::cancel_listing<SUI>(listing, user_storage, ctx);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ── Helper ─────────────────────────────────────────────────────────────
|
|
107
|
+
|
|
108
|
+
fun return_change(change: Coin<SUI>, ctx: &TxContext) {
|
|
109
|
+
if (coin::value(&change) > 0) {
|
|
110
|
+
sui::transfer::public_transfer(change, ctx.sender());
|
|
111
|
+
} else {
|
|
112
|
+
coin::destroy_zero(change);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module card_duel::player_system {
|
|
2
|
+
use dubhe::dapp_service::{DappStorage, UserStorage};
|
|
3
|
+
use dubhe::dapp_system;
|
|
4
|
+
use card_duel::dapp_key::DappKey;
|
|
5
|
+
use card_duel::migrate;
|
|
6
|
+
use card_duel::error;
|
|
7
|
+
use card_duel::gold;
|
|
8
|
+
use card_duel::profile;
|
|
9
|
+
use card_duel::battle_state;
|
|
10
|
+
use card_duel::deck;
|
|
11
|
+
use card_duel::game_config;
|
|
12
|
+
use card_duel::card_system;
|
|
13
|
+
|
|
14
|
+
const RATING_START: u32 = 1200;
|
|
15
|
+
|
|
16
|
+
/// One-time player registration: starting gold, a 5-card starter deck and
|
|
17
|
+
/// an empty ladder profile. The UserStorage itself is created beforehand
|
|
18
|
+
/// with dapp_system::create_user_storage.
|
|
19
|
+
public entry fun register(
|
|
20
|
+
dapp_storage: &DappStorage,
|
|
21
|
+
user_storage: &mut UserStorage,
|
|
22
|
+
ctx: &mut TxContext,
|
|
23
|
+
) {
|
|
24
|
+
dapp_system::ensure_latest_version<DappKey>(dapp_storage, migrate::on_chain_version());
|
|
25
|
+
dapp_system::ensure_not_paused<DappKey>(dapp_storage);
|
|
26
|
+
error::already_registered(!profile::has(user_storage));
|
|
27
|
+
|
|
28
|
+
gold::set(user_storage, game_config::get_starting_gold(dapp_storage), ctx);
|
|
29
|
+
profile::set(user_storage, 0, 0, RATING_START, ctx);
|
|
30
|
+
// match_id @0x0 means "not in a match"
|
|
31
|
+
battle_state::set(user_storage, @0x0, 0, 0, ctx);
|
|
32
|
+
|
|
33
|
+
// Mint the starter cards and select them as the battle deck.
|
|
34
|
+
let starter_ids = card_system::mint_starter_cards(user_storage, ctx);
|
|
35
|
+
deck::set(user_storage, starter_ids, ctx);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/// Tests for the multiplayer brawl (open-invite ScenePermit, dynamic join /
|
|
2
|
+
/// leave, elimination order and last-player-standing settlement).
|
|
3
|
+
///
|
|
4
|
+
/// Economy facts (deploy_hook defaults):
|
|
5
|
+
/// starting_gold=500 rake_bps=300 (3%) max_hp=30 turn_timeout_ms=300_000
|
|
6
|
+
/// Starter deck (in order): Strike(12) Strike(12) Strike(12) Fireball(18) Shield(8)
|
|
7
|
+
/// Brawl cards are reusable every turn (unlike duels).
|
|
8
|
+
#[test_only]
|
|
9
|
+
module card_duel::brawl_tests {
|
|
10
|
+
use sui::clock;
|
|
11
|
+
use sui::test_scenario;
|
|
12
|
+
use dubhe::dapp_service::{ScenePermit, SceneStorage, ObjectStorage};
|
|
13
|
+
use card_duel::test_helpers;
|
|
14
|
+
use card_duel::brawl_system;
|
|
15
|
+
use card_duel::gold;
|
|
16
|
+
use card_duel::profile;
|
|
17
|
+
use card_duel::deck;
|
|
18
|
+
use card_duel::battle_state;
|
|
19
|
+
use card_duel::brawl::{Self, Brawl};
|
|
20
|
+
use card_duel::brawl_permit::BrawlPermit;
|
|
21
|
+
use card_duel::arena::{Self, Arena};
|
|
22
|
+
|
|
23
|
+
const A: address = @0xA11CE;
|
|
24
|
+
const B: address = @0xB0B;
|
|
25
|
+
const C: address = @0xCA01;
|
|
26
|
+
const D: address = @0xDA4E;
|
|
27
|
+
|
|
28
|
+
const FEE: u64 = 50;
|
|
29
|
+
const STARTING_GOLD: u64 = 500;
|
|
30
|
+
const MAX_HP: u64 = 30;
|
|
31
|
+
const TURN_TIMEOUT_MS: u64 = 5 * 60 * 1000;
|
|
32
|
+
|
|
33
|
+
// ─── Full happy path ────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
/// host opens room → 2 players join → eliminations → winner takes the pot.
|
|
36
|
+
#[test]
|
|
37
|
+
fun test_brawl_full_flow_three_players() {
|
|
38
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
39
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
40
|
+
let mut us_b = test_helpers::new_player(&mut sc, &ds, B);
|
|
41
|
+
let mut us_c = test_helpers::new_player(&mut sc, &ds, C);
|
|
42
|
+
let deck_a = deck::get(&us_a);
|
|
43
|
+
let deck_b = deck::get(&us_b);
|
|
44
|
+
let fireball_a = *deck_a.borrow(3);
|
|
45
|
+
let fireball_b = *deck_b.borrow(3);
|
|
46
|
+
|
|
47
|
+
// A opens a 3-player room with a 50 gold entry fee.
|
|
48
|
+
sc.next_tx(A);
|
|
49
|
+
let mut clk = clock::create_for_testing(sc.ctx());
|
|
50
|
+
clk.set_for_testing(1_000);
|
|
51
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 3, &clk, sc.ctx());
|
|
52
|
+
assert!(gold::get(&us_a) == STARTING_GOLD - FEE, 0);
|
|
53
|
+
|
|
54
|
+
// B and C join through the open-invite permit.
|
|
55
|
+
sc.next_tx(B);
|
|
56
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
57
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
58
|
+
brawl_system::join_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
59
|
+
sc.next_tx(C);
|
|
60
|
+
brawl_system::join_brawl(&ds, &mut us_c, &mut permit, &mut scene, sc.ctx());
|
|
61
|
+
assert!(brawl::get_players(&scene).length() == 3, 1);
|
|
62
|
+
assert!(brawl::get_gold(&scene) == 3 * FEE, 2);
|
|
63
|
+
|
|
64
|
+
// Host starts: turn order = join order [A, B, C].
|
|
65
|
+
sc.next_tx(A);
|
|
66
|
+
brawl_system::start_brawl(&ds, &us_a, &permit, &mut scene, &clk, sc.ctx());
|
|
67
|
+
assert!(brawl::get_state(&scene) == 1, 3);
|
|
68
|
+
assert!(brawl::get_alive(&scene).length() == 3, 4);
|
|
69
|
+
|
|
70
|
+
// A fireballs C (18): C 30 → 12. Turn passes to B.
|
|
71
|
+
sc.next_tx(A);
|
|
72
|
+
brawl_system::brawl_attack(&ds, &mut us_a, &mut us_c, &permit, &mut scene, fireball_a, &clk, sc.ctx());
|
|
73
|
+
assert!(battle_state::get_hp(&us_c) == 12, 5);
|
|
74
|
+
|
|
75
|
+
// B fireballs C (18 ≥ 12): C eliminated. Alive [A, B], turn back to A.
|
|
76
|
+
sc.next_tx(B);
|
|
77
|
+
brawl_system::brawl_attack(&ds, &mut us_b, &mut us_c, &permit, &mut scene, fireball_b, &clk, sc.ctx());
|
|
78
|
+
assert!(brawl::get_alive(&scene).length() == 2, 6);
|
|
79
|
+
assert!(battle_state::get_match_id(&us_c) == @0x0, 7);
|
|
80
|
+
let (_, c_losses, _) = profile::get(&us_c);
|
|
81
|
+
assert!(c_losses == 1, 8);
|
|
82
|
+
|
|
83
|
+
// A and B trade fireballs (cards are reusable in brawls).
|
|
84
|
+
sc.next_tx(A);
|
|
85
|
+
brawl_system::brawl_attack(&ds, &mut us_a, &mut us_b, &permit, &mut scene, fireball_a, &clk, sc.ctx());
|
|
86
|
+
assert!(battle_state::get_hp(&us_b) == 12, 9);
|
|
87
|
+
sc.next_tx(B);
|
|
88
|
+
brawl_system::brawl_attack(&ds, &mut us_b, &mut us_a, &permit, &mut scene, fireball_b, &clk, sc.ctx());
|
|
89
|
+
assert!(battle_state::get_hp(&us_a) == 12, 10);
|
|
90
|
+
|
|
91
|
+
// A fireballs B (18 ≥ 12): last player standing → match decided.
|
|
92
|
+
sc.next_tx(A);
|
|
93
|
+
brawl_system::brawl_attack(&ds, &mut us_a, &mut us_b, &permit, &mut scene, fireball_a, &clk, sc.ctx());
|
|
94
|
+
assert!(brawl::get_state(&scene) == 2, 11);
|
|
95
|
+
assert!(brawl::get_winner(&scene) == A, 12);
|
|
96
|
+
|
|
97
|
+
// Settlement: pot 150, rake 3% = 4 → arena; 146 → winner.
|
|
98
|
+
sc.next_tx(A);
|
|
99
|
+
let mut arena_obj = test_scenario::take_shared<ObjectStorage<Arena>>(&sc);
|
|
100
|
+
brawl_system::finish_brawl(&ds, &mut us_a, &mut permit, &mut scene, &mut arena_obj, sc.ctx());
|
|
101
|
+
assert!(arena::get_gold(&arena_obj) == 4, 13);
|
|
102
|
+
assert!(gold::get(&us_a) == STARTING_GOLD - FEE + 146, 14);
|
|
103
|
+
let (a_wins, _, a_rating) = profile::get(&us_a);
|
|
104
|
+
assert!(a_wins == 1 && a_rating == 1225, 15);
|
|
105
|
+
assert!(brawl::get_gold(&scene) == 0, 16);
|
|
106
|
+
|
|
107
|
+
// Eliminated players exit the permit, then the brawl can be destroyed.
|
|
108
|
+
sc.next_tx(B);
|
|
109
|
+
brawl_system::leave_finished_brawl(&mut permit, &scene, &us_b, sc.ctx());
|
|
110
|
+
sc.next_tx(C);
|
|
111
|
+
brawl_system::leave_finished_brawl(&mut permit, &scene, &us_c, sc.ctx());
|
|
112
|
+
sc.next_tx(D);
|
|
113
|
+
brawl_system::cleanup_brawl(scene, permit, sc.ctx());
|
|
114
|
+
|
|
115
|
+
test_scenario::return_shared(arena_obj);
|
|
116
|
+
clk.destroy_for_testing();
|
|
117
|
+
std::unit_test::destroy(ds);
|
|
118
|
+
std::unit_test::destroy(us_a);
|
|
119
|
+
std::unit_test::destroy(us_b);
|
|
120
|
+
std::unit_test::destroy(us_c);
|
|
121
|
+
sc.end();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ─── Room management ────────────────────────────────────────────────────
|
|
125
|
+
|
|
126
|
+
#[test]
|
|
127
|
+
fun test_leave_brawl_refunds_entry_fee() {
|
|
128
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
129
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
130
|
+
let mut us_b = test_helpers::new_player(&mut sc, &ds, B);
|
|
131
|
+
|
|
132
|
+
sc.next_tx(A);
|
|
133
|
+
let clk = clock::create_for_testing(sc.ctx());
|
|
134
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 3, &clk, sc.ctx());
|
|
135
|
+
|
|
136
|
+
sc.next_tx(B);
|
|
137
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
138
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
139
|
+
brawl_system::join_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
140
|
+
assert!(gold::get(&us_b) == STARTING_GOLD - FEE, 0);
|
|
141
|
+
|
|
142
|
+
// B changes their mind: fee refunded, slot freed.
|
|
143
|
+
sc.next_tx(B);
|
|
144
|
+
brawl_system::leave_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
145
|
+
assert!(gold::get(&us_b) == STARTING_GOLD, 1);
|
|
146
|
+
assert!(battle_state::get_match_id(&us_b) == @0x0, 2);
|
|
147
|
+
assert!(brawl::get_players(&scene).length() == 1, 3);
|
|
148
|
+
assert!(brawl::get_gold(&scene) == FEE, 4);
|
|
149
|
+
|
|
150
|
+
// Host closes the empty room and reclaims their own fee.
|
|
151
|
+
sc.next_tx(A);
|
|
152
|
+
brawl_system::cancel_brawl(&ds, &mut us_a, &mut permit, &mut scene, sc.ctx());
|
|
153
|
+
assert!(gold::get(&us_a) == STARTING_GOLD, 5);
|
|
154
|
+
|
|
155
|
+
sc.next_tx(A);
|
|
156
|
+
brawl_system::cleanup_brawl(scene, permit, sc.ctx());
|
|
157
|
+
|
|
158
|
+
clk.destroy_for_testing();
|
|
159
|
+
std::unit_test::destroy(ds);
|
|
160
|
+
std::unit_test::destroy(us_a);
|
|
161
|
+
std::unit_test::destroy(us_b);
|
|
162
|
+
sc.end();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#[test]
|
|
166
|
+
#[expected_failure]
|
|
167
|
+
fun test_join_brawl_fails_when_room_full() {
|
|
168
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
169
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
170
|
+
let mut us_b = test_helpers::new_player(&mut sc, &ds, B);
|
|
171
|
+
let mut us_c = test_helpers::new_player(&mut sc, &ds, C);
|
|
172
|
+
|
|
173
|
+
sc.next_tx(A);
|
|
174
|
+
let clk = clock::create_for_testing(sc.ctx());
|
|
175
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 2, &clk, sc.ctx());
|
|
176
|
+
|
|
177
|
+
sc.next_tx(B);
|
|
178
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
179
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
180
|
+
brawl_system::join_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
181
|
+
// Room cap is 2 — the third join must abort.
|
|
182
|
+
sc.next_tx(C);
|
|
183
|
+
brawl_system::join_brawl(&ds, &mut us_c, &mut permit, &mut scene, sc.ctx());
|
|
184
|
+
|
|
185
|
+
test_scenario::return_shared(scene);
|
|
186
|
+
test_scenario::return_shared(permit);
|
|
187
|
+
clk.destroy_for_testing();
|
|
188
|
+
std::unit_test::destroy(ds);
|
|
189
|
+
std::unit_test::destroy(us_a);
|
|
190
|
+
std::unit_test::destroy(us_b);
|
|
191
|
+
std::unit_test::destroy(us_c);
|
|
192
|
+
sc.end();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
#[test]
|
|
196
|
+
#[expected_failure]
|
|
197
|
+
fun test_host_cannot_leave_open_room() {
|
|
198
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
199
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
200
|
+
|
|
201
|
+
sc.next_tx(A);
|
|
202
|
+
let clk = clock::create_for_testing(sc.ctx());
|
|
203
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 3, &clk, sc.ctx());
|
|
204
|
+
|
|
205
|
+
// The host must cancel_brawl instead of leaving.
|
|
206
|
+
sc.next_tx(A);
|
|
207
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
208
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
209
|
+
brawl_system::leave_brawl(&ds, &mut us_a, &mut permit, &mut scene, sc.ctx());
|
|
210
|
+
|
|
211
|
+
test_scenario::return_shared(scene);
|
|
212
|
+
test_scenario::return_shared(permit);
|
|
213
|
+
clk.destroy_for_testing();
|
|
214
|
+
std::unit_test::destroy(ds);
|
|
215
|
+
std::unit_test::destroy(us_a);
|
|
216
|
+
sc.end();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
#[test]
|
|
220
|
+
#[expected_failure]
|
|
221
|
+
fun test_start_brawl_fails_with_single_player() {
|
|
222
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
223
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
224
|
+
|
|
225
|
+
sc.next_tx(A);
|
|
226
|
+
let clk = clock::create_for_testing(sc.ctx());
|
|
227
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 3, &clk, sc.ctx());
|
|
228
|
+
|
|
229
|
+
sc.next_tx(A);
|
|
230
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
231
|
+
let permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
232
|
+
brawl_system::start_brawl(&ds, &us_a, &permit, &mut scene, &clk, sc.ctx());
|
|
233
|
+
|
|
234
|
+
test_scenario::return_shared(scene);
|
|
235
|
+
test_scenario::return_shared(permit);
|
|
236
|
+
clk.destroy_for_testing();
|
|
237
|
+
std::unit_test::destroy(ds);
|
|
238
|
+
std::unit_test::destroy(us_a);
|
|
239
|
+
sc.end();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
#[test]
|
|
243
|
+
#[expected_failure]
|
|
244
|
+
fun test_start_brawl_fails_for_non_host() {
|
|
245
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
246
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
247
|
+
let mut us_b = test_helpers::new_player(&mut sc, &ds, B);
|
|
248
|
+
|
|
249
|
+
sc.next_tx(A);
|
|
250
|
+
let clk = clock::create_for_testing(sc.ctx());
|
|
251
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 3, &clk, sc.ctx());
|
|
252
|
+
|
|
253
|
+
sc.next_tx(B);
|
|
254
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
255
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
256
|
+
brawl_system::join_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
257
|
+
// Only the host can start.
|
|
258
|
+
brawl_system::start_brawl(&ds, &us_b, &permit, &mut scene, &clk, sc.ctx());
|
|
259
|
+
|
|
260
|
+
test_scenario::return_shared(scene);
|
|
261
|
+
test_scenario::return_shared(permit);
|
|
262
|
+
clk.destroy_for_testing();
|
|
263
|
+
std::unit_test::destroy(ds);
|
|
264
|
+
std::unit_test::destroy(us_a);
|
|
265
|
+
std::unit_test::destroy(us_b);
|
|
266
|
+
sc.end();
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ─── Combat boundaries ──────────────────────────────────────────────────
|
|
270
|
+
|
|
271
|
+
#[test]
|
|
272
|
+
#[expected_failure]
|
|
273
|
+
fun test_brawl_attack_fails_out_of_turn() {
|
|
274
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
275
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
276
|
+
let mut us_b = test_helpers::new_player(&mut sc, &ds, B);
|
|
277
|
+
let deck_b = deck::get(&us_b);
|
|
278
|
+
|
|
279
|
+
sc.next_tx(A);
|
|
280
|
+
let clk = clock::create_for_testing(sc.ctx());
|
|
281
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 2, &clk, sc.ctx());
|
|
282
|
+
|
|
283
|
+
sc.next_tx(B);
|
|
284
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
285
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
286
|
+
brawl_system::join_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
287
|
+
sc.next_tx(A);
|
|
288
|
+
brawl_system::start_brawl(&ds, &us_a, &permit, &mut scene, &clk, sc.ctx());
|
|
289
|
+
|
|
290
|
+
// Turn 0 belongs to A (the host) — B attacking must abort.
|
|
291
|
+
sc.next_tx(B);
|
|
292
|
+
brawl_system::brawl_attack(&ds, &mut us_b, &mut us_a, &permit, &mut scene, *deck_b.borrow(0), &clk, sc.ctx());
|
|
293
|
+
|
|
294
|
+
test_scenario::return_shared(scene);
|
|
295
|
+
test_scenario::return_shared(permit);
|
|
296
|
+
clk.destroy_for_testing();
|
|
297
|
+
std::unit_test::destroy(ds);
|
|
298
|
+
std::unit_test::destroy(us_a);
|
|
299
|
+
std::unit_test::destroy(us_b);
|
|
300
|
+
sc.end();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
#[test]
|
|
304
|
+
fun test_brawl_surrender_decides_two_player_match() {
|
|
305
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
306
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
307
|
+
let mut us_b = test_helpers::new_player(&mut sc, &ds, B);
|
|
308
|
+
|
|
309
|
+
// Free room: demonstrates a zero-fee brawl (no escrow, no rake).
|
|
310
|
+
sc.next_tx(A);
|
|
311
|
+
let mut clk = clock::create_for_testing(sc.ctx());
|
|
312
|
+
clk.set_for_testing(1_000);
|
|
313
|
+
brawl_system::create_brawl(&ds, &mut us_a, 0, 2, &clk, sc.ctx());
|
|
314
|
+
|
|
315
|
+
sc.next_tx(B);
|
|
316
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
317
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
318
|
+
brawl_system::join_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
319
|
+
sc.next_tx(A);
|
|
320
|
+
brawl_system::start_brawl(&ds, &us_a, &permit, &mut scene, &clk, sc.ctx());
|
|
321
|
+
|
|
322
|
+
// B quits: A is the last player standing.
|
|
323
|
+
sc.next_tx(B);
|
|
324
|
+
brawl_system::brawl_surrender(&ds, &mut us_b, &mut permit, &mut scene, &clk, sc.ctx());
|
|
325
|
+
assert!(brawl::get_state(&scene) == 2, 0);
|
|
326
|
+
assert!(brawl::get_winner(&scene) == A, 1);
|
|
327
|
+
let (_, b_losses, _) = profile::get(&us_b);
|
|
328
|
+
assert!(b_losses == 1, 2);
|
|
329
|
+
|
|
330
|
+
sc.next_tx(A);
|
|
331
|
+
let mut arena_obj = test_scenario::take_shared<ObjectStorage<Arena>>(&sc);
|
|
332
|
+
brawl_system::finish_brawl(&ds, &mut us_a, &mut permit, &mut scene, &mut arena_obj, sc.ctx());
|
|
333
|
+
assert!(gold::get(&us_a) == STARTING_GOLD, 3);
|
|
334
|
+
let (a_wins, _, _) = profile::get(&us_a);
|
|
335
|
+
assert!(a_wins == 1, 4);
|
|
336
|
+
|
|
337
|
+
sc.next_tx(A);
|
|
338
|
+
brawl_system::cleanup_brawl(scene, permit, sc.ctx());
|
|
339
|
+
|
|
340
|
+
test_scenario::return_shared(arena_obj);
|
|
341
|
+
clk.destroy_for_testing();
|
|
342
|
+
std::unit_test::destroy(ds);
|
|
343
|
+
std::unit_test::destroy(us_a);
|
|
344
|
+
std::unit_test::destroy(us_b);
|
|
345
|
+
sc.end();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
#[test]
|
|
349
|
+
fun test_brawl_timeout_kick_removes_stalling_player() {
|
|
350
|
+
let (mut sc, ds) = test_helpers::setup();
|
|
351
|
+
let mut us_a = test_helpers::new_player(&mut sc, &ds, A);
|
|
352
|
+
let mut us_b = test_helpers::new_player(&mut sc, &ds, B);
|
|
353
|
+
|
|
354
|
+
sc.next_tx(A);
|
|
355
|
+
let mut clk = clock::create_for_testing(sc.ctx());
|
|
356
|
+
clk.set_for_testing(1_000);
|
|
357
|
+
brawl_system::create_brawl(&ds, &mut us_a, FEE, 2, &clk, sc.ctx());
|
|
358
|
+
|
|
359
|
+
sc.next_tx(B);
|
|
360
|
+
let mut scene = test_scenario::take_shared<SceneStorage<Brawl>>(&sc);
|
|
361
|
+
let mut permit = test_scenario::take_shared<ScenePermit<BrawlPermit>>(&sc);
|
|
362
|
+
brawl_system::join_brawl(&ds, &mut us_b, &mut permit, &mut scene, sc.ctx());
|
|
363
|
+
sc.next_tx(A);
|
|
364
|
+
brawl_system::start_brawl(&ds, &us_a, &permit, &mut scene, &clk, sc.ctx());
|
|
365
|
+
|
|
366
|
+
// It is A's turn; A stalls, so B kicks them after the timeout.
|
|
367
|
+
let started_at = brawl::get_last_action_ms(&scene);
|
|
368
|
+
clk.set_for_testing(started_at + TURN_TIMEOUT_MS + 1);
|
|
369
|
+
sc.next_tx(B);
|
|
370
|
+
brawl_system::brawl_timeout_kick(&ds, &mut us_b, &mut us_a, &permit, &mut scene, &clk, sc.ctx());
|
|
371
|
+
assert!(brawl::get_state(&scene) == 2, 0);
|
|
372
|
+
assert!(brawl::get_winner(&scene) == B, 1);
|
|
373
|
+
assert!(battle_state::get_match_id(&us_a) == @0x0, 2);
|
|
374
|
+
let (_, a_losses, _) = profile::get(&us_a);
|
|
375
|
+
assert!(a_losses == 1, 3);
|
|
376
|
+
|
|
377
|
+
test_scenario::return_shared(scene);
|
|
378
|
+
test_scenario::return_shared(permit);
|
|
379
|
+
clk.destroy_for_testing();
|
|
380
|
+
std::unit_test::destroy(ds);
|
|
381
|
+
std::unit_test::destroy(us_a);
|
|
382
|
+
std::unit_test::destroy(us_b);
|
|
383
|
+
sc.end();
|
|
384
|
+
}
|
|
385
|
+
}
|