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

bugfix/fix broken rw indicator #579

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
16 changes: 12 additions & 4 deletions target/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from django.shortcuts import redirect, render
from django.views.decorators.csrf import csrf_exempt

from faction.models import Faction, FactionTarget
from faction.models import Faction, FactionTarget, Member
from player.models import Key, Player
from target.functions import getTargets, updateAttacks, updateRevives
from yata.handy import apiCall, getFaction, getPlayer, returnError
Expand Down Expand Up @@ -230,12 +230,16 @@ def attack(request):
returnError(type=403, msg="Unknown request")
faction = getFaction(player.factionId)

faction_targets = FactionTarget.objects.filter(target_id__in=faction.getTargetsId())
enemy_faction = Faction.objects.filter(tId=faction.warAgainst).first()
faction_targets = [] if not enemy_faction else (
Member.objects.filter(faction=enemy_faction).values_list('tId', flat=True)
)

context = {
"v": attack,
"targets": getTargets(player),
"ts": int(time.time()),
"faction_targets": faction_targets.values_list("target_id", flat=True),
'enemy_faction_targets': faction_targets,
}
return render(request, "target/attacks/button-target.html", context)

Expand All @@ -257,12 +261,16 @@ def targets(request):
# get faction
faction = Faction.objects.filter(tId=player.factionId).first()
factionTargets = [] if faction is None else faction.getTargetsId()

enemy_faction = Faction.objects.filter(tId=faction.warAgainst).first()
faction_targets = [] if not enemy_faction else (
Member.objects.filter(faction=enemy_faction).values_list('tId', flat=True)
)
context = {
"player": player,
"targetcat": True,
"targets": targets,
"factionTargets": factionTargets,
"enemy_faction_targets": faction_targets,
"ts": int(time.time()),
"view": {"targets": True},
}
Expand Down
4 changes: 2 additions & 2 deletions templates/target/targets/line.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<!-- add to faction -->
{% include "target/targets/faction.html" %}
</td>
<td class="text-center" data-val="{% if targetId in factionTargets %}1{% else %}0{% endif %}">
{% if targetId in faction_targets %}
<td class="text-center" data-val="{% if targetId in enemy_faction_targets %}1{% else %}0{% endif %}">
{% if targetId in enemy_faction_targets %}
<i class="fas fa-check-circle text-success" title="Target is in ranked war targets"></i>
{% else %}
<i class="fas fa-xmark-circle text-danger" title="Target is not in ranked war targets"></i>
Expand Down