Skip to content

Commit 2c95847

Browse files
committed
minor changes
1 parent 731699d commit 2c95847

File tree

8 files changed

+84
-45
lines changed

8 files changed

+84
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/TotalRiskbuggar
12
/node_modules
23
/assetsDist
34
/dist

electron/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ const createDefaultWindow = () => {
235235
}
236236

237237
if (!dontUseWebTools) {
238-
//win.webContents.openDevTools();
238+
win.webContents.openDevTools();
239239
}
240240

241241
win.setMenu(null);

js/authentication/authenticationController.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ class AuthenticationController {
291291
this.$scope.$apply();
292292
})
293293
.then(() => {
294-
this.socketService.lobbiesSocket.emit('signOutUser', uid);
294+
if (this.socketService.lobbiesSocket) {
295+
this.socketService.lobbiesSocket.emit('signOutUser', uid);
296+
}
295297
})
296298
.catch(err => {
297299
console.log('Logout error', err),

js/editor/characterCreatorController.js

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -76,31 +76,30 @@ class CharacterCreatorController {
7676
'#a6775b',
7777
'#7d5137'
7878
];
79-
80-
firebase.auth().onAuthStateChanged(user => {
81-
if (user) {
82-
this.vm.isAuthenticated = true;
83-
this.vm.showEditor = false;
84-
const user = firebase.auth().currentUser;
85-
86-
firebase.database().ref('users/' + user.uid).on('value', snapshot => {
87-
const user = snapshot.val();
88-
if (user && user.characters) {
89-
this.vm.characters = snapshot.val().characters;
90-
setTimeout(() => {
91-
this.$scope.$apply();
92-
//this.loadSavedCharacterPortraits();
93-
}, 200);
94-
} else {
95-
this.vm.characters = [];
96-
}
97-
});
98-
} else {
99-
this.vm.isAuthenticated = false;
100-
this.vm.showEditor = false;
101-
this.vm.characters = [];
102-
}
103-
});
79+
80+
const currentUser = firebase.auth().currentUser;
81+
if (currentUser) {
82+
this.vm.isAuthenticated = true;
83+
this.vm.showEditor = false;
84+
const user = currentUser;
85+
86+
firebase.database().ref('users/' + user.uid).on('value', snapshot => {
87+
const user = snapshot.val();
88+
if (user && user.characters) {
89+
this.vm.characters = snapshot.val().characters;
90+
setTimeout(() => {
91+
this.$scope.$apply();
92+
//this.loadSavedCharacterPortraits();
93+
}, 200);
94+
} else {
95+
this.vm.characters = [];
96+
}
97+
});
98+
} else {
99+
this.vm.isAuthenticated = false;
100+
this.vm.showEditor = false;
101+
this.vm.characters = [];
102+
}
104103

105104
$(document).ready(() => {
106105
this.vm.currentSelection.forEach(part => {

js/helpers.js

Lines changed: 16 additions & 1 deletion
Large diffs are not rendered by default.

js/leaderboard/leaderboardController.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ class LeaderboardController {
1919

2020
this.vm.scrollToMe = this.scrollToMe;
2121

22-
firebase.auth().onAuthStateChanged(authUser => {
23-
if (authUser) {
24-
this.vm.userUid = authUser.uid;
25-
} else {
26-
this.vm.userUid = null;
27-
}
28-
});
22+
const user = firebase.auth().currentUser;
23+
if (user) {
24+
this.vm.userUid = user.uid;
25+
} else {
26+
this.vm.userUid = null;
27+
}
2928

3029
this.$rootScope.$watch('currentGamePhase', () => {
3130
if (this.$rootScope.currentGamePhase === GAME_PHASES.LEADERBOARD) {

js/leaderboard/rankConstants.js

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,43 @@
11
const firebase = require('firebase/app');
22
const CountryCodes = require('./../editor/countryCodes');
3-
const {devMode} = require('./../helpers');
3+
const {devMode, randomIntFromInterval, generateName, chancePercentage} = require('./../helpers');
44

55
const getLeaderboard = () => {
66
return firebase.database().ref('/users/').once('value').then(snapshot => {
77
let leaderboardList;
88

99
if (devMode() && false) {
10-
leaderboardList = new Array(100).fill({}).map((x, i) => ({
11-
id: 'id'+i,
12-
normalizedRating: i * 100 + 500,
13-
userName: `Player ${i}`,
14-
ratingDifference: -200,
15-
flag: './assets/flagsSvg/countries/se.svg',
16-
countryName: 'Sweden'
17-
})).reverse();
10+
const countryNames = Object.values(CountryCodes).map(x => x.name);
11+
leaderboardList = new Array(200).fill({}).map((x, i) => {
12+
const countryName = countryNames[randomIntFromInterval(0, countryNames.length - 1)]
13+
const flag = './assets/flagsSvg/countries/' + Object.keys(CountryCodes).find(x => CountryCodes[x].name === countryName).toLowerCase() + '.svg';
14+
15+
const totalWins = randomIntFromInterval(10, 100)
16+
let totalDefeats = totalWins - randomIntFromInterval(10, 60);
17+
if (totalDefeats < 0) {
18+
totalDefeats = 0;
19+
}
20+
return {
21+
id: 'id'+i,
22+
normalizedRating: i * 100 + 500 + randomIntFromInterval(-50, 50),
23+
userName: generateName().replace(' ', '_'),
24+
ratingDifference: randomIntFromInterval(-25, 25),
25+
totalWins,
26+
totalDefeats,
27+
totalDisconnects: chancePercentage(70) ? 0 : randomIntFromInterval(0, 10),
28+
flag,
29+
countryName
30+
}
31+
}).reverse();
32+
33+
leaderboardList[0].userName = 'MartinGomez89';
34+
leaderboardList[11].userName = 'pepe420';
35+
leaderboardList[4].userName = 'Kim_Jong-CHILL';
36+
leaderboardList[20].userName = 'DoktorAlban123';
37+
38+
leaderboardList[12].userName = 'pelle1234';
39+
leaderboardList[12].flag = './assets/flagsSvg/countries/se.svg';
40+
leaderboardList[12].id = 'zaprcqKg9ycG6P6jKF8VD3MhNj63';
1841
} else {
1942
const usersFromDatabase = snapshot.val();
2043
let users = Object.entries(usersFromDatabase).map(x => (Object.assign({id: x[0]}, x[1])));

src/views/leaderboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h3 class="leaderboardLeagueLabel">
6666
<td class="rank">
6767
{{ $index + 1 }}
6868
</td>
69-
<td class="userName" uib-tooltip-html="leaderboard.playerTooltips[user.id]" tooltip-placement="right">
69+
<td class="userName">
7070
{{ user.userName || 'N/A' }}
7171
</td>
7272
<td class="from">

0 commit comments

Comments
 (0)