getInventory() → any inventory
function beforeFight() {'{'}
var inventory = getInventory() // null when the inventory isn't known
if (inventory != null) debug(inventory.weapons) // [{'{'}item: 37, quantity: 1{'}'}, …]
setLoadout(getLoadout('builds/tank.json'))
{'}'}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, chips and components, lists of {item, quantity} objects (item is the item's id: the one of the WEAPON_* and CHIP_* constants, the template for a component; a forgotten weapon also has forgotten: true), and capital, the leek's total capital. null when the inventory is not known in this fight. For a component, base gives the model's stats and alterations what each available improved piece adds; putting one of these alterations in a component's stats in setLoadout picks that piece.Impossible de charger les données du jeu.
Vérifiez votre connexion et réessayez.