Game Portal

Development Progress

helpwanted

(Adam Hopkins) #1

Here is a little update with where we are so far.

The API for the backend is coming along VERY nicely. I am pleased with how flexible and modular it is coming out which really should make the whole build process more simple. A little extra elbow grease up front will go a long way.

For the frontend, I have been also building some modular components, and a good way through that. I have the Character page mostly together.

Here is a sneak peak:

Next up will be the following pages:

  • Realms
  • Military
  • Map
  • Finance
  • Authority
  • Clergy

Once I have that together I will probably start asking for volunteers to begin bug testing. If you are interested in helping out, let me know.


(Adam Hopkins) #2

Things are coming along well. As you can see, I am working to create a set of consistent views so that each game element (characters, realms, units, etc) has a familiar looking UI.

Military Unit

Realm

Province (on map view)


With the main data display views complete, I am working on the player controls: all the knobs and buttons that the player will use to play the game.


(Adam Hopkins) #3

Awesome awesome progress.

I know this does not look like much yet. But, what is shown here is actually quite a bit of complex things going on.

Permissions

This is a bit of a quandry. The permissions rules are VERY complex. Players have many characters, who themselves have a tangling web of loyalty. And, because all characters are MUCH more autonomous than they have been in the past, Every single relationship matters. But, more importantly, If one character is the liege over another, he gets to see some of that information!

Example.

In the data shown above, the logged in player is the House of Arichis. One of its nobles is Frangan. One of his vassals is Agilulf from the House of Urfai. So, that means that Frangan will get to see the balance sheets.

The code to calculate that is a bit more complex than I thought it would need to be initially.

def get_queryset(self):
    Character = apps.get_app_config('characters').get_model('Character')
    House = apps.get_app_config('houses').get_model('House')
    user = get_current_user()
    game = get_current_game()
    try:
        house = House.objects.get(user=user, game=game)
    except House.DoesNotExist:
        return None

    player_nobles = Character.objects.nobles().filter(house=house)
    subject_ids = [x.get_all_subjects(True).values_list('pk', flat=True) for x in player_nobles]
    subject_ids = [x for y in subject_ids for x in y]
    all_nobles_ids = Character.objects.nobles().filter(pk__in=subject_ids).values_list('pk', flat=True)

    kwargs = {
        'treasury__noble__pk__in': all_nobles_ids,
    }

    year = self.request.parser_context.get('kwargs', {}).get('year', None)

    if year is None:
        year = get_current_game().year

    kwargs.update({
        'year': year
    })

    queryset = models.BalanceSheet.objects.filter(**kwargs)
    return queryset

Most of that code is actually pretty simple stuff. the magic is this line here:

subject_ids = [x.get_all_subjects(True).values_list('pk', flat=True) for x in player_nobles]

The query get_all_subjects itself runs a modified preorder tree traversal query to grab all the possible subjects in a single SQL query. I’m pretty happy with this solution because it really opened a potential bottleneck for games to grow in size and complexity.

Abstraction

There is a pretty cool thing going on here as well. Besides that query I just showed you, the rest of the code to generate that data up top is this:

class AllBalanceSheets(generics.ListAPIView):
    serializer_class = serializers.PublicBasicBalanceSheetSerializer

That’s it. It is beautiful in its simplicity.

Granted, there are a lot more complicated things going on in the background. But, I have a good set of tools, and spent a good set of time building out my toolchain that the development process is really moving along at a clip now.

With any luck, this time next week I might even be talking about building the adjudicator!