Skip to content

Commit

Permalink
adding new labor system (#2682)
Browse files Browse the repository at this point in the history
* new production

* new production

* new production

* new production

* new production

* new production

* fix pr comments

* fix pr comments

* fix pr comments

* fix pr comments

* new deploy

* fix bug

* update policies

* update structure entity id in scenes

* update demon hide to labor

* add production module

* first draft new production

* add raw resources into resource

* fix: production output amount

* add labor burn

* adding burn resource for labor

* fix labor bugs and add more realms info

* small fixes

* clean + remove console.logs

* redeployed sepolia and changed config values for labor

* new config

* new config

* new config

* contrct fix

* add transfer resources above modals

* fix overlay

* update policies and capacity info

* selected realm for production

* remove console.log

* feedback

* knip + prettier

* knip

* prettier torii launcher

* update sepolia env

* fix build issues

---------

Co-authored-by: Credence <[email protected]>
  • Loading branch information
aymericdelab and credence0x authored Feb 8, 2025
1 parent 7021d04 commit e39317d
Show file tree
Hide file tree
Showing 107 changed files with 25,928 additions and 31,161 deletions.
4 changes: 4 additions & 0 deletions .knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@

"client/apps/game-docs/env.ts",


"client/apps/torii-launcher/**",

"config/**",
"contracts/**",

"**/global.d.ts"

]
}
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
# ignore generated files
**/gql
**/*.graphql
**/*.gen.ts
**/*.gen.ts

# ignore json files
**/*.json
6 changes: 3 additions & 3 deletions client/apps/game/.env.sepolia
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ VITE_PUBLIC_CLIENT_FEE_RECIPIENT=0x045c587318c9ebcf2fbe21febf288ee2e3597a21cd486

VITE_PUBLIC_CHAIN=sepolia
VITE_PUBLIC_SLOT=eternum
VITE_PUBLIC_TORII=https://api.cartridge.gg/x/eternum/torii
VITE_PUBLIC_TORII=https://api.cartridge.gg/x/eternum-sepolia/torii
VITE_PUBLIC_NODE_URL=https://api.cartridge.gg/x/starknet/sepolia
VITE_PUBLIC_TORII_RELAY=/dns4/api.cartridge.gg/tcp/443/x-parity-wss/%2Fx%2Feternum%2Ftorii%2Fwss
VITE_PUBLIC_TORII_RELAY=/dns4/api.cartridge.gg/tcp/443/x-parity-wss/%2Fx%2Feternum-sepolia%2Ftorii%2Fwss

// optional
VITE_PUBLIC_GAME_VERSION="v0.0.0"
VITE_PUBLIC_GAME_VERSION="v1.0.0-rc7"
VITE_PUBLIC_GRAPHICS_DEV=false
VITE_SOCIAL_LINK=http://bit.ly/3Zz1mpp
8 changes: 4 additions & 4 deletions client/apps/game/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
<link rel="prefetch" href="/images/buildings/construction/workers_hut.png" />
<!-- thumb -->
<link rel="prefetch" href="/images/buildings/thumb/banks.png" />
<link rel="prefetch" href="/images/buildings/thumb/castleZero.png" />
<link rel="prefetch" href="/images/buildings/thumb/castleOne.png" />
<link rel="prefetch" href="/images/buildings/thumb/castleTwo.png" />
<link rel="prefetch" href="/images/buildings/thumb/castleThree.png" />
<link rel="prefetch" href="/images/buildings/construction/castleZero.png" />
<link rel="prefetch" href="/images/buildings/construction/castleOne.png" />
<link rel="prefetch" href="/images/buildings/construction/castleTwo.png" />
<link rel="prefetch" href="/images/buildings/construction/castleThree.png" />
<link rel="prefetch" href="/images/buildings/thumb/crane.png" />
<link rel="prefetch" href="/images/buildings/thumb/discord.png" />
<link rel="prefetch" href="/images/buildings/thumb/fragment-mine.png" />
Expand Down
58 changes: 31 additions & 27 deletions client/apps/game/src/hooks/context/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x22fca458aa0869b4cacca2098ae8fe3cc462bc5cef9dd222a5a68055cb8906b": {
"0x561b10faf4a0809ea306e266bb3c3c91022af032575483fcc633ed6b9d0c9ac": {
methods: [
{
name: "dojo_name",
Expand All @@ -30,7 +30,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x158114da9a538d75512dc29b3d1995ff551dfb61bee80996232abe54b8febc2": {
"0x4da090eae1bd76c455948aa43755ce1a322c4c717abb98ffd2992fd4d9fe5fe": {
methods: [
{
name: "dojo_name",
Expand All @@ -46,7 +46,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x66bc2d8ef45ce10d3847cc901a41af6a05db34c0ea0ab87fc332ca8c9b2ccb0": {
"0x29c169487fb01d1692f7d7eb3f8e1e0cb84956b4d202483c1673baeec878f49": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -82,7 +82,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x73dff02735d7031496afb34d28f6fd935d8f8e2db14b0877aaf871b3d11f524": {
"0x32762adec37d1e60a05fcba2637ec7549f3c53ebf049fcb5d210cab0e1e5049": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -130,7 +130,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x5827e314ca954f7eb04127a2a321e5c1f8fa6d51546b8fa6d6b38830f2b6d18": {
"0xb3d474aded507a7350baa69474463d33886be66ed6d1a0ae8d1a4f19d919a": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -270,7 +270,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x6c0ae788bf4a46b49a57a67944bfb614c8da00b2b99c5d2917ec9bafb8ed460": {
"0x502c164cb455df87523c1dedd1bca31f84d2e606ddc65bcb269a498aa359ed": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -302,7 +302,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x1c8793d542cb6fb3cb140279ece63cdb8265868874e2aed3dce8a7b7cffd256": {
"0x7f180ec4de002861bf8e86cdd9f41e19165c468ea7703ccc7c707702fa6909c": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -330,7 +330,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x345779feb4e212431505dff8d8581c38de82201ad9cb6bc32d7bb547087f402": {
"0x654e2cfc842dd37395a4595dc8bb78f6546c2b377b5fa74ff2487a3ea8c25d6": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -366,7 +366,7 @@ export const policies: ContractPolicies = {
},
],
},
"0xd4a3c274fbdc8ca6fc0c0a2e1bdb9f4ef78ec6efe253592e936bd2e5db712f": {
"0x1c148f3082414b1bf1320d421bad2a325675545f1f213af3219c3727f0de11e": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -402,7 +402,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x12b32981130d1089c5642125fbe96cdb4da0562e904eb8da590a30ea4f0aa9d": {
"0x171c6fae95acd58233dfa472e86184a53f42da7d9a4dd94ff4b2a2f3dd8e9de": {
methods: [
{
name: "dojo_name",
Expand All @@ -422,7 +422,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x43b2a3f4e47fa52ef2549162f89258dbcbd23bc62a51d0a331b80039a66bc9b": {
"0x6f29997ad3fec03fa79e043d69260b39baf0690cc5198bdec510ba0d9d200af": {
methods: [
{
name: "dojo_name",
Expand All @@ -442,7 +442,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x6e173c5aca48a948de710aea5492c1df18a3f477b666a9af82281e1024e7bd2": {
"0x79300036c247389c377da6b3f01106509aa35c75e16a290d385ceec66857f98": {
methods: [
{
name: "dojo_name",
Expand All @@ -458,7 +458,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x7ad2d6a7a566fece8c3cb08b96ca16c43f6981c77f7e1b2fa2112aac2976661": {
"0x34a8564ce24af9c57333fdf579945eba6a99a0624ca0d0a428905e074c2ada0": {
methods: [
{
name: "dojo_name",
Expand All @@ -478,7 +478,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x5f20dfb2ac256e7b8394d2ac6bbd12288c2844c64143a87e27cb5bd3027ebc0": {
"0x442687ef27c6fcb84177efac8b75ec80b8be87d40f9befe2780bf2ea98a8c08": {
methods: [
{
name: "dojo_name",
Expand All @@ -494,7 +494,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x30b9c5bf6c05b8e950901079bba39766f4a4d23466f2df0258e1ecca3731e19": {
"0x13f688b9e847a188d6e3306c57ad4cedc846207ec0d4214d3adb966f89abda6": {
methods: [
{
name: "dojo_name",
Expand All @@ -514,7 +514,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x1e859bd917c725f938d7ffecdd9f687e04af2b44cf534848895e7efa946378a": {
"0x3eb0f666216653f8bd1b27b4640e4730580f5899b73456c059fb157e1e1e9a": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -542,7 +542,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x7e9f737c5c89d0f4e2c2b9f0ffda396da22b2c9fa14106f2d940dddae35497a": {
"0x524a24ace42046b73845153567d5a31ca914aaabbf34fd4c4fe758da41e66df": {
methods: [
{
name: "dojo_name",
Expand All @@ -566,7 +566,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x6f2ca7adc33ebf6cbe7d539cb50dff53cffcc701ac252b65eadc9454e12e247": {
"0x6f1ecad7e45043715d052ec7075910fe49379ccec56caa30773bffb1bd8ce42": {
methods: [
{
name: "dojo_name",
Expand All @@ -586,7 +586,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x67d9fbdbb222b30679aa4b6d4d15f0e16f984603996111c6ef8b425293d29c7": {
"0x3c4b44ff5b2dd18a8e388d38f453cfc4c5262d110b13f5f26a5c28e5ac40fd9": {
methods: [
{
name: "dojo_name",
Expand All @@ -606,7 +606,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x4949075e31363f02ac3d4374bf1cb726873cd55a3f572dc85ddc9f8ef89c351": {
"0x2dde744795e94a6c8934f224741da3e0408d82c07463858b7566664f7bb8633": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -634,7 +634,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x5bb3ed403abb2ceeb6ce8911052a4f9c922f2d4777427454fcbea605192ddc9": {
"0x7d2fb638516c4a32858ef7bf09865389edc60c3cb9e6d4d0049c0ad7a214c6a": {
methods: [
{
name: "dojo_name",
Expand All @@ -650,7 +650,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x4d6d43ec3fe5fb0d22398f9aee1846285e7c44bfa3900b7e490d18a9fb4eae4": {
"0x133660106d03c9811a9ce63fe2464e99f0816b83439c55003ebdde53f560655": {
methods: [
{
name: "dojo_name",
Expand Down Expand Up @@ -678,7 +678,7 @@ export const policies: ContractPolicies = {
},
],
},
"0x47773b52867c0867b40b26408e3ff84fca0b1a9afe55c0cb0fe284c1a18c3d8": {
"0x56347b8808383046242a9240124ac42b4d8a718ba2925bb900ba6a3ac7c8454": {
methods: [
{
name: "dojo_name",
Expand All @@ -701,12 +701,16 @@ export const policies: ContractPolicies = {
entrypoint: "resume_building_production",
},
{
name: "make_production_labor",
entrypoint: "make_production_labor",
name: "burn_labor_resources_for_other_production",
entrypoint: "burn_labor_resources_for_other_production",
},
{
name: "burn_production_labor",
entrypoint: "burn_production_labor",
name: "burn_other_predefined_resources_for_resources",
entrypoint: "burn_other_predefined_resources_for_resources",
},
{
name: "burn_other_resources_for_labor_production",
entrypoint: "burn_other_resources_for_labor_production",
},
{
name: "world_dispatcher",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const useNavigateToRealmViewByAccount = (components: ClientComponents) =>
if (!account) {
const randomRealmEntity = getRandomRealmEntity(components);
const position = randomRealmEntity ? getComponentValue(components.Position, randomRealmEntity) : undefined;
navigateToHexView(new Position(position || { x: 0, y: 0 }));
position && navigateToHexView(new Position(position));
} else {
const playerRealm = getPlayerFirstRealm(components, ContractAddress(account?.address || NULL_ACCOUNT.address));
const position = playerRealm ? getComponentValue(components.Position, playerRealm) : undefined;
Expand Down
52 changes: 52 additions & 0 deletions client/apps/game/src/three/managers/biome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,58 @@ export class Biome {
}
}

function analyzeBiomeDistribution(centerX: number, centerY: number, radius: number) {
const biome = new Biome();
const biomeCounts: Record<BiomeType, number> = {
DeepOcean: 0,
Ocean: 0,
Beach: 0,
Scorched: 0,
Bare: 0,
Tundra: 0,
Snow: 0,
TemperateDesert: 0,
Shrubland: 0,
Taiga: 0,
Grassland: 0,
TemperateDeciduousForest: 0,
TemperateRainForest: 0,
SubtropicalDesert: 0,
TropicalSeasonalForest: 0,
TropicalRainForest: 0,
};

const startX = centerX - radius;
const endX = centerX + radius;
const startY = centerY - radius;
const endY = centerY + radius;
let totalTiles = 0;

for (let x = startX; x <= endX; x++) {
for (let y = startY; y <= endY; y++) {
const biomeType = biome.getBiome(x, y);
biomeCounts[biomeType]++;
totalTiles++;
}
}

console.log(`\nBiome Distribution Analysis`);
console.log(`Center: (${centerX}, ${centerY})`);
console.log(`Radius: ${radius} tiles`);
console.log(`Total area: ${totalTiles} tiles\n`);
console.log("Biome Counts:");

Object.entries(biomeCounts)
.sort(([, a], [, b]) => b - a)
.forEach(([biomeType, count]) => {
const percentage = ((count / totalTiles) * 100).toFixed(2);
console.log(`${biomeType}: ${count} tiles (${percentage}%)`);
});
}

// Example usage:
// analyzeBiomeDistribution(2147483646, 2147483646, 500);

// function testBiomeGeneration() {
// const biome = new Biome();
// const start = 5000871265127650;
Expand Down
4 changes: 3 additions & 1 deletion client/apps/game/src/three/scenes/hexagon-scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ export abstract class HexagonScene {
(state) => ({
leftNavigationView: state.leftNavigationView,
rightNavigationView: state.rightNavigationView,
structureEntityId: state.structureEntityId,
}),
({ leftNavigationView, rightNavigationView }) => {
({ leftNavigationView, rightNavigationView, structureEntityId }) => {
this.state.leftNavigationView = leftNavigationView;
this.state.rightNavigationView = rightNavigationView;
this.state.structureEntityId = structureEntityId;
},
);
}
Expand Down
2 changes: 1 addition & 1 deletion client/apps/game/src/three/scenes/hexception.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ export default class HexceptionScene extends HexagonScene {
) => {
const existingBuildings: any[] = this.tileManager.existingBuildings();
const structureType = this.tileManager.structureType();
if (structureType) {
if (structureType && structureType !== StructureType.Realm) {
existingBuildings.push({
col: BUILDINGS_CENTER[0],
row: BUILDINGS_CENTER[1],
Expand Down
1 change: 1 addition & 0 deletions client/apps/game/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ID } from "@bibliothecadao/eternum";
export enum RightView {
None,
ResourceTable,
Production,
}

export enum LeftView {
Expand Down
Loading

0 comments on commit e39317d

Please sign in to comment.