> Functions
Returns the items your leek can use to build a loadout in code with setLoadout: the weapons, chips and components of your farmer that their other leeks in the team don't wear (one copy per leek), with their quantity, and the leek's total capital. Call it in beforeFight() (see Fight hooks), before setLoadout.
// This function is called automatically before turn 1
function beforeFight() {
var inventory = getInventory()
// null when the inventory is not known in this fight
if (inventory == null) return;
// What this leek can still wear: the farmer's other leeks may already have helped themselves
debug("Capital: " + inventory.capital)
for (var weapon in inventory.weapons) {
debug(getWeaponName(weapon.item) + " ×" + weapon.quantity)
}
// A loadout built in code: the laser if it is still free, otherwise the pistol
var laser = false
for (var weapon in inventory.weapons) {
if (weapon.item == WEAPON_M_LASER) laser = true
}
var weapons = [laser ? WEAPON_M_LASER : WEAPON_PISTOL]
// All free chips: beyond the leek's RAM, the last ones are ignored
var chips = []
for (var chip in inventory.chips) push(chips, chip.item)
// Without a stats key, the leek keeps its capital allocation: no restat potion
setLoadout({weapons: weapons, chips: chips})
}
// This function is called automatically before turn 1
function beforeFight() {
const inventory = Fight.me.getInventory()
// null when the inventory is not known in this fight
if (inventory === null) return
// What this leek can still wear: the farmer's other leeks may already have helped themselves
Debug.log("Capital: " + inventory.capital)
for (const weapon of inventory.weapons) {
Debug.log(weapon.item + " ×" + weapon.quantity)
}
// A loadout built in code: the laser if it is still free, otherwise the pistol
const laser = inventory.weapons.some(weapon => weapon.item === Weapon.mLaser.id)
const weapons = [laser ? Weapon.mLaser.id : Weapon.pistol.id]
// All free chips: beyond the leek's RAM, the last ones are ignored
const chips = inventory.chips.map(chip => chip.item)
// Without a stats key, the leek keeps its capital allocation: no restat potion
Fight.me.setLoadout({ weapons, chips })
}
// In TypeScript and JavaScript, hooks are only called if the AI defines turn()
function turn() {
// ...
}
# This function is called automatically before turn 1
def beforeFight():
inventory = Fight.me.getInventory()
# None when the inventory is not known in this fight
if inventory is None:
return
# What this leek can still wear: the farmer's other leeks may already have helped themselves
Debug.log("Capital: " + str(inventory["capital"]))
for weapon in inventory["weapons"]:
Debug.log(str(weapon["item"]) + " ×" + str(weapon["quantity"]))
# A loadout built in code: the laser if it is still free, otherwise the pistol
laser = any(weapon["item"] == Weapon.mLaser.id for weapon in inventory["weapons"])
weapons = [Weapon.mLaser.id if laser else Weapon.pistol.id]
# All free chips: beyond the leek's RAM, the last ones are ignored
chips = [chip["item"] for chip in inventory["chips"]]
# Without a stats key, the leek keeps its capital allocation: no restat potion
Fight.me.setLoadout({"weapons": weapons, "chips": chips})
# In Python, hooks are only called if the AI defines turn()
def turn():
pass
weapons and chips, lists of {item, quantity} objects (item is the item's id: the one of the WEAPON_* and CHIP_* constants; a forgotten weapon also has forgotten: true), components and capital, the leek's total capital. null when the inventory is not known in this fight (in an AI tournament, for example). components has one entry per improved piece, like the inventory page: {item, quantity: 1, leek, base, stats, bonuses}, where item is the component's template (COMPONENT_* constants), base the template's stats, stats the total, bonuses what the alteration changes and leek the leek wearing the piece (null if it is free). The base copies follow in one entry {item, quantity, base, stats, bonuses: {}}. Pieces worn by your leeks that are not in the fight are included and setLoadout can take them; those of your leeks in the fight stay theirs. Each entry can be passed as is in the components of setLoadout. The old alterations field remains, always empty. For the loadout currently worn, see getCurrentLoadout.Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.