Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Friend Info To Battle List #252

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/model/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const settingsSchema = Type.Object({
battlesHidePvE: Type.Boolean({ default: false }),
battlesHideLocked: Type.Boolean({ default: false }),
battlesHideEmpty: Type.Boolean({ default: true }),
battlesHideNoFriends: Type.Boolean({ default: false }),
});
23 changes: 21 additions & 2 deletions src/renderer/views/multiplayer/custom.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Checkbox v-model="settings.battlesHideLocked" label="Hide Locked" />
<Checkbox v-model="settings.battlesHideEmpty" label="Hide Empty" />
<Checkbox v-model="settings.battlesHideInProgress" label="Hide Running" />
<Checkbox v-model="settings.battlesHideNoFriends" label="Only Friends" />
<SearchBox v-model="searchVal" />
</div>

Expand Down Expand Up @@ -60,7 +61,11 @@
<template #body="{ data }">
<div class="flex-row flex-center-items gap-md">
<div v-if="data.players.value.length > 0" class="flex-row flex-center-items" style="gap: 2px">
<Icon :icon="account" height="17" />{{ data.players.value.length }}
<Icon
:color="friendsInBattle(data).length > 0 ? 'green' : ''"
:icon="friendsInBattle(data).length > 0 ? accountMultiple : account"
height="17"
/>{{ data.players.value.length }}
</div>
<div v-if="data.spectators.value.length > 0" class="flex-row flex-center-items gap-xs" style="gap: 4px">
<Icon :icon="eye" height="17" />{{ data.spectators.value.length }}
Expand Down Expand Up @@ -104,6 +109,7 @@

import { Icon } from "@iconify/vue";
import account from "@iconify-icons/mdi/account";
import accountMultiple from "@iconify-icons/mdi/account-multiple";
import eye from "@iconify-icons/mdi/eye";
import lock from "@iconify-icons/mdi/lock";
import robot from "@iconify-icons/mdi/robot";
Expand Down Expand Up @@ -155,6 +161,9 @@ const battles = computed(() => {
return false;
}
}
if (settings.battlesHideNoFriends && friendsInBattle(battle).length === 0) {
return false;
}
if (searchVal.value.length > 0) {
const searchTerm = searchVal.value.toLowerCase();
if (battle.battleOptions.title.toLowerCase().includes(searchTerm)) {
Expand Down Expand Up @@ -189,6 +198,13 @@ const battles = computed(() => {
return scoredBattles;
});

function friendsInBattle(battle: SpadsBattle) {
const friends = api.session.friends.value;
const playersInBattle = battle.players.value;
const friendsInBattle = playersInBattle.filter((player) => friends.includes(player));
return friendsInBattle;
}

function battleScoreTooltip(data: ScoredSpadsBattle) {
const scoreExplanation = `\
All Sorting Factors: ${data.score.toFixed(2)}
Expand Down Expand Up @@ -271,7 +287,10 @@ function scoreBattle(battle: SpadsBattle) {

// TODO: within skill range
// TODO: median skill close to won
// TODO: friend in lobby
const friendsInBattleList = friendsInBattle(battle);
if (friendsInBattleList.length > 0) {
addFactor("Friends In Battle", friendsInBattleList.length * 0.5);
}
// TODO: blocked in lobby
// TODO: Highly rated map
// TODO: Downloaded map
Expand Down
Loading