{
  "name": "Bosskills",
  "author": "Mad",
  "supportedGames": [
    "all"
  ],
  "takaroVersion": "v0.0.21",
  "versions": [
    {
      "tag": "2.0.0",
      "description": "Provides automated rewards and announcements upon the killing of specific boss entities in the game.\n\n  ## Key Functionality\n\n  * **Boss Kill Detection:** The module monitors game server logs for events indicating the death of designated boss entities.\n  * **Player Identification:** It extracts the name of the player who killed the boss.\n  * **Currency Rewards:** Configurable amounts of in-game currency are automatically awarded to the player who killed the boss.\n  * **Chat Announcements:** Customizable messages are broadcast to the server chat, congratulating the player on the kill and announcing the reward.\n  * **Boss-Specific Configuration:** Rewards and announcements can be configured independently for different boss types.\n\n  ## How to Use\n\n  1.  **Configuration:**\n      * `coinAmountDevourer`, `coinAmountMiniBoss`, `coinAmountBoss`, `coinAmountTinyBoss`:  Define the amount of currency to award for killing different categories of bosses.\n      * `announceDevourer`, `announceGargul`, `announceBear`, `announceBitch`, `announceBurningFlesh`, `announceCholera`, `announceBull`, `announceShocker`, `announceVeteran`, `announceCarrier`, `announceOstiarius`:  Customize the messages that are broadcast to the chat when a specific boss is killed. Use `{pname}` as a placeholder for the player's name and `{amount}` for the currency amount.\n  2.  **Module Operation:**\n      * The module automatically monitors the server logs for boss kill events. No manual commands are required.\n\n  ## Important Considerations\n\n  * **Log Format:** This module relies on a specific format for the game server's log messages. Ensure that the log output contains the necessary information (e.g., player name, killed entity type) in a parsable format.\n  * **Boss Names:** Correctly configure the module with the exact entity names used by the game server logs.\n  * **Currency System:** This module assumes that your server has a functional currency system that can be accessed and modified via API calls.\n  * **Performance:** Log processing can potentially impact server performance, especially with high activity. Monitor server resources and adjust module settings if necessary.\n",
      "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"required\":[\"coinAmountDevourer\"],\"additionalProperties\":false,\"properties\":{\"coinAmountDevourer\":{\"title\":\"coinAmountDevourer\",\"description\":\"Amoint of Coin to award\",\"default\":0,\"type\":\"number\"},\"announceDevourer\":{\"title\":\"announceDevourer\",\"description\":\"Post in chat Boss Kill\",\"type\":\"string\"}}}",
      "uiSchema": "{}",
      "commands": [],
      "hooks": [
        {
          "name": "Devourer",
          "eventType": "log",
          "description": "Hook for log events",
          "regex": null,
          "function": "import { data, takaro } from '@takaro/helpers';\n\nasync function main() {\n    const { gameServerId, eventData } = data;\n\n    const namePattern = /entityKilled: (\\w+) \\(Steam_/;\n    const nameMatch = eventData.msg.match(namePattern);\n    const playerName = nameMatch ? nameMatch[1] : \"Unknown\";\n\n\n    const pattern = /Steam_(\\d+)/;\n    const match = data.eventData.msg.match(pattern);\n    const steamIdx = match[1];\n    const playerid = (await takaro.player.playerControllerSearch({ filters: { steamId: [steamIdx] } })).data.data[0].id;\n    const mainPlayer = (await takaro.playerOnGameserver.playerOnGameServerControllerSearch({\n        filters: { gameServerId: [gameServerId], playerId: [playerid] },\n    })).data.data[0];\n\n    // Send the message with backticks\n    await takaro.gameserver.gameServerControllerSendMessage(gameServerId, {\n        message: `[FFFF33]${playerName} just killed a [-][00FEED]Devourer[-] and received 300 [D49F69]Twinkies[-]`\n    });\n\n    // Grant currency to the player\n    await takaro.playerOnGameserver.playerOnGameServerControllerAddCurrency(gameServerId, playerid, {\n        currency: 300\n    });\n}\n\nawait main();"
        }
      ],
      "cronJobs": [],
      "functions": [],
      "permissions": []
    }
  ]
}