{
  "entity_types": [
    {
      "name": "Player"
    },
    {
      "name": "TaxEvent"
    },
    {
      "name": "Reward"
    }
  ],
  "containers": [
    {
      "name": "WORLD",
      "kind": "simple",
      "entity_type": "Player"
    },
    {
      "name": "TAX_PENDING",
      "kind": "simple",
      "entity_type": "TaxEvent"
    },
    {
      "name": "TAX_DONE",
      "kind": "simple",
      "entity_type": "TaxEvent"
    },
    {
      "name": "REWARD_PENDING",
      "kind": "simple",
      "entity_type": "Reward"
    },
    {
      "name": "REWARD_DONE",
      "kind": "simple",
      "entity_type": "Reward"
    }
  ],
  "pools": [
    {
      "name": "gold",
      "property": "gold"
    }
  ],
  "transfers": [
    {
      "name": "collect_tax",
      "pool": "gold"
    },
    {
      "name": "give_reward",
      "pool": "gold"
    }
  ],
  "moves": [
    {
      "name": "finish_tax",
      "from": [
        "TAX_PENDING"
      ],
      "to": [
        "TAX_DONE"
      ],
      "entity_type": "TaxEvent"
    },
    {
      "name": "finish_reward",
      "from": [
        "REWARD_PENDING"
      ],
      "to": [
        "REWARD_DONE"
      ],
      "entity_type": "Reward"
    }
  ],
  "tensions": [
    {
      "name": "tax_collection",
      "priority": 20,
      "match": [
        {
          "container": "TAX_PENDING",
          "is": "occupied"
        },
        {
          "bind": "player",
          "in": "WORLD",
          "select": "each",
          "where": {
            "op": ">=",
            "left": {
              "prop": "gold",
              "of": "player"
            },
            "right": 10
          }
        }
      ],
      "emit": [
        {
          "transfer": "collect_tax",
          "from": "player",
          "to": "treasury",
          "amount": 10
        }
      ]
    },
    {
      "name": "tax_consume",
      "priority": 15,
      "match": [
        {
          "bind": "evt",
          "in": "TAX_PENDING",
          "select": "first"
        }
      ],
      "emit": [
        {
          "move": "finish_tax",
          "entity": "evt",
          "to": "TAX_DONE"
        }
      ]
    },
    {
      "name": "reward_distribution",
      "priority": 10,
      "match": [
        {
          "bind": "reward",
          "in": "REWARD_PENDING",
          "select": "first"
        },
        {
          "bind": "player",
          "in": "WORLD",
          "select": "max_by",
          "key": "gold"
        },
        {
          "guard": {
            "op": ">=",
            "left": {
              "prop": "gold",
              "of": "treasury"
            },
            "right": {
              "prop": "amount",
              "of": "reward"
            }
          }
        }
      ],
      "emit": [
        {
          "transfer": "give_reward",
          "from": "treasury",
          "to": "player",
          "amount": {
            "prop": "amount",
            "of": "reward"
          }
        },
        {
          "move": "finish_reward",
          "entity": "reward",
          "to": "REWARD_DONE"
        }
      ]
    }
  ],
  "entities": [
    {
      "name": "alice",
      "type": "Player",
      "in": "WORLD",
      "properties": {
        "gold": 500
      }
    },
    {
      "name": "bob",
      "type": "Player",
      "in": "WORLD",
      "properties": {
        "gold": 300
      }
    },
    {
      "name": "charlie",
      "type": "Player",
      "in": "WORLD",
      "properties": {
        "gold": 5
      }
    },
    {
      "name": "treasury",
      "type": "Player",
      "in": "WORLD",
      "properties": {
        "gold": 195
      }
    }
  ]
}
