Skip to content

Commit a5e7f70

Browse files
committed
update labor
1 parent aef638a commit a5e7f70

File tree

7 files changed

+12
-23
lines changed

7 files changed

+12
-23
lines changed

contracts/game/manifest_sepolia.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@
23822382
},
23832383
{
23842384
"address": "0x5827e314ca954f7eb04127a2a321e5c1f8fa6d51546b8fa6d6b38830f2b6d18",
2385-
"class_hash": "0x7fb2e9574aa693d81a15f3734dd0a8612ba8d64057b2aef692bd3117118a446",
2385+
"class_hash": "0x37798122f6085a277eedb203c93fe5ee2fbc99afe7427e4508b79000301dc2c",
23862386
"abi": [
23872387
{
23882388
"type": "impl",
@@ -2995,10 +2995,6 @@
29952995
{
29962996
"name": "produced_amount",
29972997
"type": "core::integer::u128"
2998-
},
2999-
{
3000-
"name": "labor_amount",
3001-
"type": "core::integer::u128"
30022998
}
30032999
],
30043000
"outputs": [],
@@ -5405,7 +5401,7 @@
54055401
},
54065402
{
54075403
"address": "0x43b2a3f4e47fa52ef2549162f89258dbcbd23bc62a51d0a331b80039a66bc9b",
5408-
"class_hash": "0x48a8ae3f6841aed95fb3186cf390db19854c8174fea69fdca19c88fd8c58c63",
5404+
"class_hash": "0x1829437a65fddf03e8f1322558035b38be8c06a5dd81f6a863a68569364b4cc",
54095405
"abi": [
54105406
{
54115407
"type": "impl",
@@ -6345,7 +6341,7 @@
63456341
},
63466342
{
63476343
"address": "0x47773b52867c0867b40b26408e3ff84fca0b1a9afe55c0cb0fe284c1a18c3d8",
6348-
"class_hash": "0x72be272c9af1769ad38beaf68495533628fdb4ead0a7879760d17b1f6bab196",
6344+
"class_hash": "0x580ae58de580e41af4107e2b651ba52fa4ebeb5266568c6658cfa95fdecf48b",
63496345
"abi": [
63506346
{
63516347
"type": "impl",

contracts/game/src/models/config.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ pub struct ProductionConfig {
530530
resource_type: u8,
531531
// production amount per tick
532532
produced_amount: u128,
533-
// labor cost amount per tick
533+
// todo: remove
534534
labor_cost: u128,
535535
}
536536

contracts/game/src/models/resource/production/production.cairo

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use dojo::world::WorldStorage;
77
use s1_eternum::alias::ID;
88
use s1_eternum::models::config::{ProductionConfig};
99
use s1_eternum::models::config::{TickConfig, TickImpl, TickTrait};
10-
use s1_eternum::models::resource::resource::{Resource, ResourceImpl, ResourceTypes, ResourceFoodImpl};
10+
use s1_eternum::models::resource::resource::{Resource, RESOURCE_PRECISION, ResourceImpl, ResourceTypes, ResourceFoodImpl};
1111
use starknet::get_block_timestamp;
1212

1313
#[derive(IntrospectPacked, Copy, Drop, Serde)]
@@ -52,11 +52,9 @@ impl ProductionImpl of ProductionTrait {
5252
fn spend_labor_resource(ref self: Production, production_config: @ProductionConfig, labor_amount: u128) {
5353
assert!(labor_amount.is_non_zero(), "zero labor amount");
5454
assert!(
55-
labor_amount % (*production_config).labor_cost == 0, "labor amount not exactly divisible by labor cost"
55+
labor_amount % RESOURCE_PRECISION == 0, "labor amount not exactly divisible by resource precision"
5656
);
57-
58-
let additional_labor_units: u64 = (labor_amount / (*production_config).labor_cost).try_into().unwrap();
59-
self.increase_labor_units(additional_labor_units);
57+
self.increase_labor_units(labor_amount.try_into().unwrap());
6058
}
6159

6260
#[inline(always)]

contracts/game/src/systems/config/contracts.cairo

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ trait IMapConfig<T> {
131131

132132
#[starknet::interface]
133133
trait IProductionConfig<T> {
134-
fn set_production_config(ref self: T, resource_type: u8, produced_amount: u128, labor_amount: u128);
134+
fn set_production_config(ref self: T, resource_type: u8, produced_amount: u128);
135135
}
136136

137137
#[starknet::interface]
@@ -601,14 +601,13 @@ mod config_systems {
601601
#[abi(embed_v0)]
602602
impl ProductionConfigImpl of super::IProductionConfig<ContractState> {
603603
fn set_production_config(
604-
ref self: ContractState, resource_type: u8, produced_amount: u128, labor_amount: u128
604+
ref self: ContractState, resource_type: u8, produced_amount: u128
605605
) {
606606
let mut world: WorldStorage = self.world(DEFAULT_NS());
607607
assert_caller_is_admin(world);
608608

609609
let mut resource_production_config: ProductionConfig = world.read_model(resource_type);
610610
resource_production_config.produced_amount = produced_amount;
611-
resource_production_config.labor_cost = labor_amount;
612611
world.write_model(@resource_production_config);
613612
}
614613
}

contracts/game/src/systems/map/map_generation.cairo

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ mod map_generation_systems {
153153
}
154154

155155
fn get_shards_reward(ref world: WorldStorage, randomness: u256, mine_entity_id: ID) -> u128 {
156-
let shards_production_config: ProductionConfig = world.read_model(ResourceTypes::EARTHEN_SHARD);
157156
let random_multiplier: u128 = *random::choices(
158157
array![1, 2, 3, 4, 5, 6, 7, 8, 9, 10].span(),
159158
array![1, 1, 1, 1, 1, 1, 1, 1, 1, 1].span(),
@@ -164,10 +163,7 @@ mod map_generation_systems {
164163
)[0];
165164
let min_production_amount: u128 = 100_000 * RESOURCE_PRECISION;
166165
let actual_production_amount: u128 = min_production_amount * random_multiplier;
167-
let mut labor_amount_required: u128 = actual_production_amount / shards_production_config.labor_cost;
168-
if actual_production_amount % shards_production_config.labor_cost != 0 {
169-
labor_amount_required += 1;
170-
}
166+
let mut labor_amount_required: u128 = actual_production_amount;
171167

172168
labor_amount_required
173169
}

contracts/game/src/utils/testing/config.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn set_battle_config(config_systems_address: ContractAddress) {
141141

142142
fn set_mine_production_config(config_systems_address: ContractAddress) {
143143
IProductionConfigDispatcher { contract_address: config_systems_address }
144-
.set_production_config(ResourceTypes::EARTHEN_SHARD, EARTHEN_SHARD_PRODUCTION_AMOUNT_PER_TICK, array![].span());
144+
.set_production_config(ResourceTypes::EARTHEN_SHARD, EARTHEN_SHARD_PRODUCTION_AMOUNT_PER_TICK);
145145
}
146146

147147
fn set_stamina_config(config_systems_address: ContractAddress) {

packages/core/src/provider/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,7 @@ export class EternumProvider extends EnhancedDojoProvider {
19181918
return {
19191919
contractAddress: getContractByName(this.manifest, `${NAMESPACE}-config_systems`),
19201920
entrypoint: "set_production_config",
1921-
calldata: [call.resource_type, call.amount, call.amount],
1921+
calldata: [call.resource_type, call.amount],
19221922
};
19231923
});
19241924

0 commit comments

Comments
 (0)