Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npctrade: revisit price rules #77961

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andrei8l
Copy link
Contributor

@andrei8l andrei8l commented Nov 18, 2024

Summary

None

Purpose of change

Update shopkeeper price rules with new EOC technology

Describe the solution

Allow selecting items by item conditions
Example:This blacklist blocks cannibal food
  {
    "id": "no_cannibals",
    "type": "shopkeeper_blacklist",
    "entries": [ { "item_condition": { "math": [ "n_vitamin('human_flesh_vitamin') > 0" ] }, "message": "!!!CANNIBAL!!!" } ]
  },

Screenshot From 2024-11-18 02-52-22

Example:This price rule increases markup for heavy items
    "price_rules": [
      { "item_condition": { "math": [ " n_weight() >= 10000000 " ] }, "markup": 2 }
    ],
Allow price adjustments to use dialogue variables/math functions
Example: The price for strawberries varies with day of year, bottoming out in the middle of summer and topping in the middle of winter
  {
    "type": "jmath_function",
    "id": "year_length",
    "num_args": 0,
    "return": "game_option('SEASON_LENGTH') * 4"
  },
  {
    "type": "jmath_function",
    "id": "day_of_year",
    "num_args": 0,
    "return": "time('now', 'unit': 'days') % year_length()"
  },
  {
    "type": "faction",
    "id": "strawberry_merchants",
    "name": "The Straberry Merchants",
    "likes_u": 30,
    "respects_u": 30,
    "known_by_u": false,
    "size": 100,
    "power": 100,
    "fac_food_supply": { "calories": 9000000000, "vitamins": { "iron": 288000, "calcium": 288000, "vitC": 288000 } },
    "wealth": 75000000,
    "currency": "FMCNote",
    "price_rules": [
      {
        "item": "strawberries",
        "premium": { "math": [ "1 + 0.5 * sin((day_of_year() + 3*year_length()/8) * 2*pi/year_length())" ] }
      }
    ],

This was my original reason for writing math

Describe alternatives you've considered

N/A

Testing

Updated test units

Additional context

N/A

@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. NPC / Factions NPCs, AI, Speech, Factions, Ownership Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` [Markdown] Markdown issues and PRs new contributor astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs new contributor NPC / Factions NPCs, AI, Speech, Factions, Ownership
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant