# Game grove - code

**URL:** <https://discourse.codecombat.com/t/game-grove-code/20096>\
**Category:** Level Help\
**Created:** [January 25, 2020, 9:56am UTC](https://discourse.codecombat.com/t/game-grove-code/20096 "2020-01-25T09:56:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zambi25](https://avatars.discourse-cdn.com/v4/letter/z/7c8e57/32.png) [@Zambi25](https://discourse.codecombat.com/u/Zambi25)\
**Post date:** [January 25, 2020, 9:56am UTC](https://discourse.codecombat.com/t/game-grove-code/20096/1 "2020-01-25T09:56:36Z")

</div>

hello  
I got question what does this line of code means, could someone explain it to me

db.add(“plays”,1);  
ui.track(db, “plays”);  
ui.track(db, “defeated”);

function onVictory(event) {  
db.add(“defeated”, game.defeated);  
}

game.on(“victory”, onVictory);

how to make  
ui.track(game,“time” ); time count down

please help 🙂

---

<div class="post-metadata">

**Author:** ![theroyalrobot](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/theroyalrobot/32/11323_2.png) [@theroyalrobot](https://discourse.codecombat.com/u/theroyalrobot)\
**Post date:** [January 25, 2020, 9:16pm UTC](https://discourse.codecombat.com/t/game-grove-code/20096/2 "2020-01-25T21:16:57Z")

</div>

my best geust is that is what controls the win lose code

---

<div class="post-metadata">

**Author:** ![Zambi25](https://avatars.discourse-cdn.com/v4/letter/z/7c8e57/32.png) [@Zambi25](https://discourse.codecombat.com/u/Zambi25)\
**Post date:** [January 26, 2020, 10:56am UTC](https://discourse.codecombat.com/t/game-grove-code/20096/3 "2020-01-26T10:56:50Z")

</div>

i still don’t understand ☹

---

<div class="post-metadata">

**Author:** ![Zambi25](https://avatars.discourse-cdn.com/v4/letter/z/7c8e57/32.png) [@Zambi25](https://discourse.codecombat.com/u/Zambi25)\
**Post date:** [January 26, 2020, 10:58am UTC](https://discourse.codecombat.com/t/game-grove-code/20096/4 "2020-01-26T10:58:29Z")

</div>

how to make time count down?

---

<div class="post-metadata">

**Author:** ![Zambi25](https://avatars.discourse-cdn.com/v4/letter/z/7c8e57/32.png) [@Zambi25](https://discourse.codecombat.com/u/Zambi25)\
**Post date:** [January 26, 2020, 11:05am UTC](https://discourse.codecombat.com/t/game-grove-code/20096/5 "2020-01-26T11:05:28Z")

</div>

![groove;](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/e/eb8c8212cbb1eb2ea29f209c43a03734d9ee4306.jpeg)

I don’t understand those lines of code,  
please anyone explain it to me 🙂

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [January 26, 2020, 6:54pm UTC](https://discourse.codecombat.com/t/game-grove-code/20096/6 "2020-01-26T18:54:55Z")

</div>

Hi @Zambi25,

```javascript
ui.track(db, "defeated");
// this tracks the number of enemies you've defeated

```

```javascript
game.on("victory", onVictory);
// this checks if victory is true, then it runs the onVictory function:

function onVictory(event) {
    db.add("defeated", game.defeated);
}
// this tracks how many enemies you've defeated in each game, and adds it to the total. (which can be over multiple games).

```

I’m not very experienced with the game editor so I’m not sure how you would get the time to count down rather than up.  
If you wanted to make it go down from 60sec, the maths would be:  
count = 61-(the value shown by ui.track(game, “time”)  
But I’m not sure how you would show that.  
@Chaboi_3000 do you know?

---

<div class="post-metadata">

**Author:** ![Zambi25](https://avatars.discourse-cdn.com/v4/letter/z/7c8e57/32.png) [@Zambi25](https://discourse.codecombat.com/u/Zambi25)\
**Post date:** [January 27, 2020, 9:20am UTC](https://discourse.codecombat.com/t/game-grove-code/20096/7 "2020-01-27T09:20:39Z")

</div>

thx a lot [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)

but i still have one more question

what does

db.add(“plays”,1);  
ui.track(db, “plays”);

and mean?

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [January 27, 2020, 5:29pm UTC](https://discourse.codecombat.com/t/game-grove-code/20096/8 "2020-01-27T17:29:12Z")

</div>

I’m not sure I’m afraid. It doesn’t really seem to do anything does it? Maybe leave it out…  
It works without it.
