LeekScript 2 (formerly LeekScript 1.1) is the second version of LeekScript, the language of Leek Wars, released on February 28, 2021. Its goals are to clean up the language, fix bugs and add object-oriented programming.
Since it makes deep changes to the way the language works, this version is not backward compatible: each user enables it manually in the editor.
Version 2 is a step toward the future version announced in 2016. Many of its planned features are therefore already in version 2, so the language can move forward gradually; these features are very useful for coding a complex AI.
A dedicated page to help you migrate is available here: Migrating from LeekScript 1 to 2.
Object-oriented programming has been added: classes and objects. See the Objects and Classes page for the full documentation of this addition.
The keywords new, class, extends, static, public, protected, private, implements, interface, constructor, this, super and instanceof are reserved for OOP, so they can no longer be used as variable or function names.
Non-primitive values, that is arrays and objects, are passed by reference by default. Primitive values (number, boolean, string) are always copied.
The @ syntax no longer has any use and is therefore deprecated everywhere. In LeekScript 2, you cannot create references to a primitive value.
You can now put references in arrays (and objects), which lets you build complex and/or recursive structures at a reasonable cost.
Examples of data structures that are hard to build in version 1 and very easy in version 2:
A clone(value, [level]) function has been added to clone a value precisely:
The editor reports several semantic errors instead of just one (also available in LS 1).


The full call stack is shown below each error, instead of a single line as before (also available in LS 1).

But you can of course still use them. (also available in LS 1)
The array size limit has been removed: the cost in operations is enough to keep their use in check.
arrayFilter has been fixed: the array is properly reindexed, without leaving null values behind.
The escaping of the string "\\" has been fixed: it now displays a single \ instead of two.
Global declarations across several files have been fixed.
The ^= operator has been fixed: it is now the bitwise XOR (exclusive OR) instead of the power operator.
The shuffle function now uses the random number generator tied to the fight seed, so it is deterministic for a given seed. It could cause differences between two fights generated from the same seed, which affected tests.
Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.