9. Persistence pays. C++

correct default code for persistence pays :

auto onVictory(auto event) {
    db.add("wins", 1);
    // Use db.add(key, value) to add the value of
    // game.defeated to the database with the key "total defeated"
    
}
int main() {
  auto generator = game.spawnXY("generator", 60, 40);
  generator.spawnType = "munchkin";
  generator.spawnDelay = 1;
  auto player = game.spawnPlayerXY("raider", 36, 30);
  player.maxHealth = 70;
  player.attackDamage = 10;
  game.addSurviveGoal(8);
// db stands for database
// db.add(key, value) increments a value stored in the database.
// This adds 1 to the "plays" key in the database.
  db.add("plays", 1);
// Show the value of the "plays" and other keys in the db
  ui.track(db, "plays");
  ui.track(db, "wins");
  ui.track(db, "total defeated");
  ui.track(game, "time");
// Show the value of the "defeated" property of the game object
// The code below will run when the player wins the game.
    game.on("victory", onVictory);
    return 0;
}

explanation here: Ошибка на уровне "Игровая Роща"

1 Like