Page 1 of 1

Unrolling database transaction

Posted: 03 December 2017, 16:21
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');
}