samedi 28 mars 2020

Java function depended of another function implementation

I want to implement a function that "reacts" to another function.

I am implementing the card game Dominion, in this game there are attack cards and reaction cards. When an attack card is played a reaction card can be played in response, changing the outcome the attack card would cause. The Cards use a Consumer Object to achieve what they are out to do, at the moment I handle reaction cards in the attack cards (if this reaction-card played then this), which leads to a lot of redundant and ugly code. I want, ideally, to be able to implement the reaction card generically for all attack cards, without having to specifically tell them what to for each card but to derive it from the attack card itself.

In my implementation there are different "items" that are executed one after another to implement a card. Sometimes after user input, I could give the reaction card these items as input. But i would still not know what exactly they do since the main functionality is handled in Consumers, which I would have access to as objects.

I heard that tensorflow in python can track your computations to compile it to c++ code, so maybe something like this is also possible here? Or there is a pattern that would be applicable?

Aucun commentaire:

Enregistrer un commentaire