Ejemplo n.º 1
0
def start(request):
    context = user_menu(request)

    try:
        if context['userprofile'].clan_stream == 'news':
            context['news'] = AllianceNews.objects.filter(alliance=context['my_alliance'])[:5]
    except Exception:
        pass

#    TODO: get territories
    territories = Territory.objects.all()

    context['locations'] = Location.objects.all()

    try:
        territories = territories.exclude(owner = context['userprofile'])
    except Exception:
        pass

    context['territories'] = territories
    try:
        context['my_territory'] = Territory.objects.filter(owner = context['userprofile'])
    except Exception:
        pass
    try:
        context['war'] = Battle.objects.get(Q(attacker=context['userprofile']) | Q(defender=context['userprofile']), active=True)
    except Exception:
        pass

    return render_to_response('game.html',
                              context,
                              context_instance=RequestContext(request))
Ejemplo n.º 2
0
def ranks(request):
    users = UserProfile.objects.all().order_by('-lvl', '-money', 'user__username')[:10]
    context = user_menu(request)
    context['users'] = users
    return render_to_response('ranks.html',
                              context,
                              context_instance=RequestContext(request))
Ejemplo n.º 3
0
def my_clan(request):
    context = user_menu(request)
    
    my_clan = context['my_alliance']

    context['clan_members'] = AllianceMembership.objects.filter(alliance=my_clan)
    context['avatar_form'] = UploadAvatar()
    context['clan_stream'] = AllianceNews.objects.filter(alliance=Alliance.objects.get(members=context['userprofile']))
    context['boss'] = context['clan_members'].get(rank=1).profile
    context['rank'] = context['userprofile'].alliancemembership_set.all()[0].rank
    
    last_lvl_exp = (my_clan.lvl-1)*(my_clan.lvl-1)*10
    exp_needed = ((my_clan.lvl*my_clan.lvl)*10)- last_lvl_exp

    context['exp'] = ((my_clan.exp-last_lvl_exp)*100)/exp_needed
    
    return render_to_response('my_clan2.html',
                              context,
                              context_instance=RequestContext(request))
Ejemplo n.º 4
0
def start(request):
    context = user_menu(request)

    try:
        if context['userprofile'].clan_stream == 'news':
            context['news'] = AllianceNews.objects.filter(
                alliance=context['my_alliance'])[:5]
    except Exception:
        pass

#    TODO: get territories
    territories = Territory.objects.all()

    context['locations'] = Location.objects.all()

    try:
        territories = territories.exclude(owner=context['userprofile'])
    except Exception:
        pass

    context['territories'] = territories
    try:
        context['my_territory'] = Territory.objects.filter(
            owner=context['userprofile'])
    except Exception:
        pass
    try:
        context['war'] = Battle.objects.get(
            Q(attacker=context['userprofile'])
            | Q(defender=context['userprofile']),
            active=True)
    except Exception:
        pass

    return render_to_response('game.html',
                              context,
                              context_instance=RequestContext(request))