Skip to content

Commit

Permalink
Display target of bonus hits
Browse files Browse the repository at this point in the history
  • Loading branch information
Kivou-2000607 committed Nov 10, 2019
1 parent 2fafd8b commit 09f090c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chain/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def fillReport(faction, members, chain, report, attacks):
attackers[attackerID][12] += 1
r = getBonusHits(v['chain'], v["timestamp_ended"])
print('[function.chain.fillReport] bonus {}: {} respects'.format(v['chain'], r))
bonus.append((v['chain'], attackerID, attackerName, respect, r))
bonus.append((v['chain'], attackerID, attackerName, respect, r, v.get('defender_id', '0'), v.get('defender_name', 'Unkown')))
else:
attackers[attackerID][1] += 1
attackers[attackerID][2] += float(v['modifiers']['fairFight'])
Expand Down Expand Up @@ -402,7 +402,7 @@ def fillReport(faction, members, chain, report, attacks):
print('[function.chain.fillReport] fill database with bonus')
report.bonus_set.all().delete()
for b in bonus:
report.bonus_set.create(hit=b[0], tId=b[1], name=b[2], respect=b[3], respectMax=b[4])
report.bonus_set.create(hit=b[0], tId=b[1], name=b[2], respect=b[3], respectMax=b[4], targetId=b[5], targetName=b[6])

if chain.wall:
finished = not chain.createReport
Expand Down
43 changes: 43 additions & 0 deletions chain/migrations/0073_auto_20191110_2227.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 2.2.7 on 2019-11-10 22:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('chain', '0072_faction_respect'),
]

operations = [
migrations.AddField(
model_name='bonus',
name='targetName',
field=models.CharField(default='Unkown', max_length=15),
),
migrations.AddField(
model_name='bonus',
name='targetId',
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name='bonus',
name='name',
field=models.CharField(default='Duke', max_length=15),
),
migrations.AlterField(
model_name='count',
name='name',
field=models.CharField(default='Duke', max_length=15),
),
migrations.AlterField(
model_name='wall',
name='attackerFactionName',
field=models.CharField(default='AttackFaction', max_length=15),
),
migrations.AlterField(
model_name='wall',
name='defenderFactionName',
field=models.CharField(default='DefendFaction', max_length=15),
),
]
10 changes: 6 additions & 4 deletions chain/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ def __str__(self):
class Bonus(models.Model):
report = models.ForeignKey(Report, on_delete=models.CASCADE)
tId = models.IntegerField(default=0)
name = models.CharField(default="Duke", max_length=64)
name = models.CharField(default="Duke", max_length=15)
hit = models.IntegerField(default=0)
respect = models.FloatField(default=0)
respectMax = models.FloatField(default=0)
targetId = models.IntegerField(default=0)
targetName = models.CharField(default="Unkown", max_length=15)

def __str__(self):
return("Bonus of {}".format(self.report.chain))
Expand All @@ -215,7 +217,7 @@ def __str__(self):
class Count(models.Model):
report = models.ForeignKey(Report, on_delete=models.CASCADE)
attackerId = models.IntegerField(default=0)
name = models.CharField(default="Duke", max_length=64)
name = models.CharField(default="Duke", max_length=15)
hits = models.IntegerField(default=0)
bonus = models.IntegerField(default=0)
wins = models.IntegerField(default=0)
Expand Down Expand Up @@ -262,9 +264,9 @@ class Wall(models.Model):
attackers = models.TextField(default="{}", null=True, blank=True)
defenders = models.TextField(default="{}", null=True, blank=True)
attackerFactionId = models.IntegerField(default=0)
attackerFactionName = models.CharField(default="AttackFaction", max_length=200)
attackerFactionName = models.CharField(default="AttackFaction", max_length=15)
defenderFactionId = models.IntegerField(default=0)
defenderFactionName = models.CharField(default="DefendFaction", max_length=200)
defenderFactionName = models.CharField(default="DefendFaction", max_length=15)
territory = models.CharField(default="AAA", max_length=3)
result = models.CharField(default="Unset", max_length=10)
factions = models.ManyToManyField(Faction, blank=True)
Expand Down
2 changes: 1 addition & 1 deletion templates/chain/report-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</tr>
{% for b in bonus %}
{% if forloop.counter0|divisibleby:4 %}<tr>{% endif %}
<td style="text-align: center;"><b>Bonus #{{b.hit}}</b><br>{{b.name|playerURL:b.tId|safe}}</td>
<td style="text-align: center;"><b>Bonus #{{b.hit}}</b><br>{{b.name|playerURL:b.tId|safe}}{% if b.targetId %}<br>on {{b.targetName|playerURL:b.targetId|safe}}{% endif %}</td>
{% if forloop.counter|divisibleby:4 %}</tr>{% elif forloop.last %}</tr>{% endif %}
{% endfor %}
</tbody>
Expand Down

0 comments on commit 09f090c

Please sign in to comment.