forked from cdanis/urzas-overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lifetotals.js
41 lines (37 loc) · 1.06 KB
/
lifetotals.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
firebase.database().ref('player1').on('value', function (v) {
if (v.val()) {
$("#player1_name").text(v.val().name);
$("#player1_life").text(v.val().life);
}
});
firebase.database().ref('player2').on('value', function (v) {
if (v.val()) {
$("#player2_name").text(v.val().name);
$("#player2_life").text(v.val().life);
}
});
function adjustValue(amount) {
var life = $(this).siblings(".life");
var newAmount = parseInt(life.text()) + amount;
firebase.database().ref($(life).attr("id").replace("_", "/")).set(newAmount);
}
$(function () {
$(".plus1").click(function () {
adjustValue.call(this, 1);
});
$(".plus2").click(function () {
adjustValue.call(this, 2);
});
$(".plus3").click(function () {
adjustValue.call(this, 3);
});
$(".minus1").click(function () {
adjustValue.call(this, -1);
});
$(".minus2").click(function () {
adjustValue.call(this, -2);
});
$(".minus3").click(function () {
adjustValue.call(this, -3);
});
});