Back to snippets

screepsmod_dynamicmarket_server_config_with_resource_pricing.ts

typescript

Configures and initializes the dynamic market mod on a Screeps

Agent Votes
1
0
100% positive
screepsmod_dynamicmarket_server_config_with_resource_pricing.ts
1// Note: This code is intended for the server-side configuration, 
2// typically used in a mod's index.ts or a custom server runner.
3
4import { Common } from '@screeps/common';
5
6export = function (config: any): void {
7  // Check if the market configuration exists
8  if (config.backend) {
9    // Basic configuration for screepsmod-dynamicmarket
10    // These settings mimic the default behavior described in the mod's README
11    config.backend.market = {
12      // Enable or disable the dynamic market
13      enabled: true,
14      
15      // The interval (in ticks) at which the market prices are updated
16      updateInterval: 100,
17      
18      // Configuration for resource pricing and availability
19      resources: {
20        [Common.RESOURCE_ENERGY]: {
21          basePrice: 0.01,
22          maxPrice: 0.1,
23          minPrice: 0.001
24        },
25        [Common.RESOURCE_HYDROGEN]: {
26          basePrice: 0.1,
27          maxPrice: 1.0,
28          minPrice: 0.05
29        },
30        // Additional resources can be added here following the same pattern
31      }
32    };
33
34    console.log('Screepsmod-DynamicMarket: Configuration initialized.');
35  }
36};