Skip to content

Commit

Permalink
Merge pull request BibliothecaDAO#206 from BibliothecaDAO/fix-road
Browse files Browse the repository at this point in the history
fix: road amount precision
  • Loading branch information
r0man1337 authored Oct 25, 2023
2 parents 48b728c + 9210f1e commit dca9bc7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getComponentValue } from "@latticexyz/recs";
import { getEntityIdFromKeys } from "../../../../../utils/utils";
import { useGetRealm } from "../../../../../hooks/helpers/useRealm";
import * as realmsData from "../../../../../geodata/realms.json";
import { ROAD_COST_PER_USAGE } from "@bibliothecadao/eternum";

type RoadBuildPopupProps = {
toEntityId: number;
Expand Down Expand Up @@ -40,9 +41,8 @@ export const RoadBuildPopup = ({ toEntityId, onClose }: RoadBuildPopupProps) =>
let costResources: { resourceId: number; amount: number }[] = [];

for (const resourceIdCost of [2]) {
const amount = 10;
const totalAmount = amount * usageAmount;
amount && costResources.push({ resourceId: resourceIdCost, amount: totalAmount });
const totalAmount = ROAD_COST_PER_USAGE * usageAmount;
costResources.push({ resourceId: resourceIdCost, amount: totalAmount });
}

const onBuild = () => {
Expand Down
4 changes: 2 additions & 2 deletions client/src/dojo/createOptimisticSystemCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getEntityIdFromKeys } from "../utils/utils";
import { Type, getComponentValue } from "@latticexyz/recs";
import { Resource } from "../types";
import { LaborCostInterface } from "../hooks/helpers/useLabor";
import { LABOR_CONFIG } from "@bibliothecadao/eternum";
import { LABOR_CONFIG, ROAD_COST_PER_USAGE } from "@bibliothecadao/eternum";
import {
CancelFungibleOrderProps,
ClaimFungibleOrderProps,
Expand Down Expand Up @@ -347,7 +347,7 @@ export function createOptimisticSystemCalls({
entity: getEntityIdFromKeys([BigInt(creator_id), BigInt(2)]),
value: {
// 10 stone per usage
balance: balance - usageCount * 10,
balance: balance - usageCount * ROAD_COST_PER_USAGE,
},
});

Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/set_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ commands=(
# # fee resource type = 2 # Stone
# # fee amount = 10
# # speed up transit by 2x = 2
"sozo execute $CONFIG_SYSTEMS set_road_config --account-address $DOJO_ACCOUNT_ADDRESS --calldata $SOZO_WORLD,2,10,2"
"sozo execute $CONFIG_SYSTEMS set_road_config --account-address $DOJO_ACCOUNT_ADDRESS --calldata $SOZO_WORLD,2,$((10 * resource_precision)),2"

)

Expand Down
2 changes: 2 additions & 0 deletions sdk/packages/eternum/src/constants/travel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export const CAPACITY_PER_DONKEY = 100000;

export const DONKEYS_PER_CITY = 100;
export const WEIGHT_PER_DONKEY_KG = 100;

export const ROAD_COST_PER_USAGE = 10000;

0 comments on commit dca9bc7

Please sign in to comment.