Player count and instance time on wrist overlay

This commit is contained in:
Natsumi
2021-03-03 14:23:55 +13:00
parent e73ee80ef5
commit a9d8003408
4 changed files with 80 additions and 22 deletions

View File

@@ -1158,7 +1158,7 @@ speechSynthesis.getVoices();
json.last_login = API.currentUser.last_login;
if ($app.lastLocation.location) {
json.location = $app.lastLocation.location;
json.$location_at = Date.parse($app.lastLocation.date);
json.$location_at = $app.lastLocation.date;
}
json.$online_for = API.currentUser.$online_for;
json.$offline_for = API.currentUser.$offline_for;
@@ -3770,7 +3770,10 @@ speechSynthesis.getVoices();
var wristFilter = this.sharedFeedFilters.wrist;
var notyFilter = this.sharedFeedFilters.noty;
var locationChange = false;
while ((w < 20) || (n < 5) || ((!locationChange) && (this.hideOnPlayerJoined))) {
var playerCountDone = false;
var playerCount = 0;
var friendCount = 0;
while ((w < 20) || (n < 5) || ((!locationChange) && (this.hideOnPlayerJoined)) || !playerCountDone) {
var ctx = data[--i];
if ((i <= -1) || (ctx.created_at < bias)) {
break;
@@ -3814,6 +3817,26 @@ speechSynthesis.getVoices();
break;
}
}
// instance player count
if (ctx.type === 'Location') {
playerCountDone = true;
}
if ((!playerCountDone) && (ctx.type === 'OnPlayerJoined')) {
playerCount++;
if (isFriend) {
friendCount++;
}
}
if ((!playerCountDone) && (ctx.type === 'OnPlayerLeft')) {
playerCount--;
if (isFriend) {
friendCount--;
}
}
if (((ctx.type === 'OnPlayerJoined') || (ctx.type === 'OnPlayerLeft')) &&
(ctx.data === API.currentUser.displayName)) {
continue;
}
if ((w < 20) && (wristFilter[ctx.type]) &&
((wristFilter[ctx.type] === 'On') ||
(wristFilter[ctx.type] === 'Everyone') ||
@@ -3839,6 +3862,9 @@ speechSynthesis.getVoices();
++n;
}
}
this.lastLocation.playerCount = playerCount;
this.lastLocation.friendCount = friendCount;
sharedRepository.setObject('last_location', this.lastLocation);
this.sharedFeed.gameLog.wrist = wristArr;
this.sharedFeed.gameLog.noty = notyArr;
this.sharedFeed.pendingUpdate = true;
@@ -5388,9 +5414,11 @@ speechSynthesis.getVoices();
// App: gameLog
$app.data.lastLocation = {
date: '',
date: 0,
location: '',
name: ''
name: '',
playerCount: 0,
friendCount: 0
};
$app.data.lastLocation$ = {};
$app.data.discordActive = configRepository.getBool('discordActive');
@@ -5414,6 +5442,11 @@ speechSynthesis.getVoices();
{
prop: 'data',
value: ''
},
{
prop: 'data',
value: true,
filterFn: (row, filter) => row.data !== API.currentUser.displayName
}
],
tableProps: {
@@ -5441,9 +5474,11 @@ speechSynthesis.getVoices();
await gameLogService.reset();
this.gameLogTable.data = [];
this.lastLocation = {
date: '',
date: 0,
location: '',
name: ''
name: '',
playerCount: 0,
friendCount: 0
};
};
@@ -5468,8 +5503,6 @@ speechSynthesis.getVoices();
};
$app.methods.updateGameLog = async function () {
var currentUserDisplayName = API.currentUser.displayName;
for (var gameLog of await gameLogService.poll()) {
var tableData = null;
@@ -5477,7 +5510,7 @@ speechSynthesis.getVoices();
case 'location':
if (this.isGameRunning) {
this.lastLocation = {
date: gameLog.dt,
date: Date.parse(gameLog.dt),
location: gameLog.location,
name: gameLog.worldName
};
@@ -5490,9 +5523,6 @@ speechSynthesis.getVoices();
break;
case 'player-joined':
if (currentUserDisplayName === gameLog.userDisplayName) {
continue;
}
tableData = {
created_at: gameLog.dt,
type: 'OnPlayerJoined',
@@ -5501,9 +5531,6 @@ speechSynthesis.getVoices();
break;
case 'player-left':
if (currentUserDisplayName === gameLog.userDisplayName) {
continue;
}
tableData = {
created_at: gameLog.dt,
type: 'OnPlayerLeft',
@@ -6836,10 +6863,12 @@ speechSynthesis.getVoices();
sharedRepository.setBool('is_game_running', false);
var isGameRunningStateChange = function () {
sharedRepository.setBool('is_game_running', this.isGameRunning);
$app.lastLocation = {
date: '',
this.lastLocation = {
date: 0,
location: '',
name: ''
name: '',
playerCount: 0,
friendCount: 0
};
if (this.isGameRunning) {
API.currentUser.$online_for = Date.now();