kts.WinGame – instantly end the game, declaring a given player or team as the winner
kts.WinGame(player_or_knight)
This function is called with exactly one parameter, which is either a Player, or a Creature representing a knight. The given player (or the player controlling the given knight) will be declared the winner. If it is a team game, then all players on the same team will also be declared winners. All other players will be declared losers, and the game will end.
None.
The Lua code is responsible for checking quest conditions and calling kts.WinGame
when a quest is complete. Code for doing this can be seen in quest_funcs.lua, which defines a couple of functions for that purpose. For example, a function check_escape_quest
is defined which checks the conditions for an "escape from the dungeon" type quest. This function is then attached to the on_approach
function of a dungeon exit (or "home") tile, as can be seen here; the net effect of this is that kts.WinGame
gets called whenever a knight approaches the correct exit point while meeting all necessary conditions (for example, holding the correct number of gems).
Another example is the Tutorial which calls kts.WinGame
when the tutorial is complete: see tutorial/init.lua.