territorial_functions.lua

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

To make these functions available include this file at the beginning of a script via:

include "scripting/win_conditions/territorial_functions.lua"
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 (integer) – Number of all valuable fields

  • players (array of Player) – Table of all players

  • wc_descname (string) – The win condition’s descname

  • wc_version (integer) – The win condition’s version

territory_status(fields, has_had)

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

Parameters
  • fields (integer) – Number of all valuable fields

  • has_had (string) – 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 (array of Player) – 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 (integer) – Number of all valuable fields

  • players (array of Player) – Table of all players

  • wc_descname (string) – The win condition’s descname

  • wc_version (integer) – The win condition’s version