예제 #1
0
 public function showRoll($rollId)
 {
     $rt = new RollTable();
     $rt->load($rollId);
     if ($rt->getId() == 0) {
         // roll does not exist
         $this->showError("These are not the rolls you are looking for...");
         return;
     }
     $this->renderArray['RollTable'] = $rt;
     if ($rt->getAgainstIncluded() == RollTable::Yes) {
         $againstCollection = new DiceCollection();
         $againstCollection->createPoolFromSerializedDiceAmount($rt->getAgainstDiceSerial());
         $this->renderArray['AgainstDiceArray'] = $againstCollection->getDiceArray();
     }
     if ($rt->getRollComplete() == RollTable::Yes) {
         $againstRoll = new DiceCollection();
         $myRoll = new DiceCollection();
         $againstRoll->createPoolFromSerializedDiceRolled($rt->getAgainstRollSerial());
         $myRoll->createPoolFromSerializedDiceRolled($rt->getRollSerial());
         $this->renderArray['AgainstRollArray'] = $againstRoll->getDiceArray();
         $this->renderArray['MyRollArray'] = $myRoll->getDiceArray();
     }
     $this->renderTemplate = $this->twigObj->loadTemplate('showRoll.html');
 }
예제 #2
0
파일: RRRest.php 프로젝트: ChaseHQ/RegRoll
 public function getRoll($rollId)
 {
     $rt = new RollTable();
     $result = new RESTResult();
     $rt->load($rollId);
     if ($rt->getId() == 0) {
         $result->Result = "Roll Cannot be found";
         $result->ResultCode = -1;
     } else {
         $result->Data['Roll']['GeneratedDate'] = $rt->getGenDate();
         $result->Data['Roll']['Complete'] = $rt->getRollComplete();
         $result->Data['Roll']['AgainstIncluded'] = $rt->getAgainstIncluded();
         if ($rt->getRollComplete() == 'N') {
             if ($rt->getAgainstIncluded() == 'Y') {
                 // Populate the against die even though roll not complete
                 $result->Data['Roll']['AgainstDice']['DiceTypeSerial'] = $rt->getAgainstDiceSerial();
                 $adc = new DiceCollection();
                 $adc->createPoolFromSerializedDiceAmount($rt->getAgainstDiceSerial());
                 foreach ($adc->getDiceArray() as $die) {
                     $result->Data['Roll']['AgainstDice'][] = $die->getJsonArray();
                 }
             }
         } else {
             // Roll is completed - show all info
             $result->Data['Roll']['RollDate'] = $rt->getRollDate();
             if ($rt->getAgainstRollSerial()) {
                 // There is an Against Roll
                 $againstColl = new DiceCollection();
                 $againstColl->createPoolFromSerializedDiceRolled($rt->getAgainstRollSerial());
                 $result->Data['Roll']['AgainstDice']['DiceTypeSerial'] = $againstColl->getDiceAmountSerialized();
                 $result->Data['Roll']['AgainstDice']['DiceRollSerial'] = $againstColl->getDiceRollsSerialzed();
                 foreach ($againstColl->getDiceArray() as $die) {
                     $result->Data['Roll']['AgainstDice'][] = $die->getJsonArray();
                 }
             }
             if ($rt->getRollSerial()) {
                 $rollColl = new DiceCollection();
                 $rollColl->createPoolFromSerializedDiceRolled($rt->getRollSerial());
                 $result->Data['Roll']['PlayerDice']['DiceTypeSerial'] = $rollColl->getDiceAmountSerialized();
                 $result->Data['Roll']['PlayerDice']['DiceRollSerial'] = $rollColl->getDiceRollsSerialzed();
                 foreach ($rollColl->getDiceArray() as $die) {
                     $result->Data['Roll']['PlayerDice'][] = $die->getJsonArray();
                 }
             }
         }
     }
     echo json_encode($result, JSON_PRETTY_PRINT);
 }