Unrolling database transaction

Game development with Board Game Arena Studio
Post Reply
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Unrolling database transaction

Post by Victoria_La »

I have a very complected game where action can result in cascading effects, some of which may not resolve at the end
because of rule violation, the easiest way to check that would have been it implement the effect in database, check the rule,
if it does not validate unroll, then check the other effect, etc.

But currently unrolling happens for the whole sequence of game states up to first user state. Is there a way to declare
a subtransation without breaking the original unroll? Psudo code:

Code: Select all


function action_playMove() {
    ...
    $this->gamestate->nextState('gameTurnConflicts');
}

function st_gameTurnConflicts() {
     $data = $this->getConflictData();
     if ($data) {
         $trans = startSubTransaction();
         applyConflicResolutionToDb($data);
         if (anyRulesViolated()) {
             unrollSubTransaction($trans);
             clearConflict($data);
         }
     } else {
       $this->gamestate->nextState('palyerTurnMain');
        return;
     }
     $this->gamestate->nextState('gameTurnConflicts');
}
Post Reply

Return to “Developers”