territorial_functions.lua

This file contains common code for the “Territorial Lord” and “Territorial Time” win conditions.

territory_points

This table contains information about the current points and winning status for all players and teams:

territory_points = {
   -- The currently winning team, if any. -1 means that no team is currently winning.
   last_winning_team = -1,
   -- The currently winning player, if any. -1 means that no player is currently winning.
   last_winning_player = -1,
   -- The name of the currently winning player, if any. Empty means that no player is currently winning.
   last_winning_player_name = "",
   -- Remaining time in secs for victory by > 50% territory. Default value is also used to calculate whether to send a report to players.
   remaining_time = 10,
   -- Points by player
   all_player_points = {},
   -- Points by rank, used to generate messages to the players
   points = {}
}
calculate_territory_points(fields, players, wc_descname, wc_version)

First checks if a player was defeated, then fills the territory_points table with current data.

Parameters
  • fields – Number of all valuable fields

  • players – Table of all players

  • wc_descname – String with the win condition’s descname

  • wc_version – Number with the win condition’s descname

territory_status(fields, has_had)

Returns a string containing the current land percentages of players/teams for messages to the players

Parameters
  • fields – Number of all valuable fields

  • has_had – Use “has” for an interim message, “had” for a game over message.

Returns

a richtext-formatted string with information on current points for each player/team

winning_status_header()

Returns a string containing a status message header for a winning player

Returns

a richtext-formatted string with header information for a winning player

losing_status_header(players)

Returns a string containing a status message header for a losing player

Parameters

players – Table of all players

Returns

a richtext-formatted string with header information for a losing player

territory_game_over(fields, players, wc_descname, wc_version)

Updates the territory points and sends game over reports

Parameters
  • fields – Number of all valuable fields

  • players – Table of all players