Пример #1
0
 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);
 }
Пример #2
0
 public function generateRollURL($diffDie)
 {
     $difficultyCollection = new DiceCollection();
     $difficultyCollection->createPoolFromSerializedDiceAmount($diffDie);
     $roll = new RollTable();
     if (count($difficultyCollection->getDiceArray()) > 0) {
         // Difficutly Set
         $roll->setAgainstDiceSerial($difficultyCollection->getDiceAmountSerialized());
         $roll->setAgainstIncluded(RollTable::Yes);
     }
     $roll->setGenDate(time());
     $roll->save();
     $this->renderArray['RollURL'] = "http://reztek.net/rr/roll/" . $roll->getId();
 }
Пример #3
0
 public function generateRoll($diffDie)
 {
     $difficultyCollection = new DiceCollection();
     $difficultyCollection->createPoolFromSerializedDiceAmount($diffDie);
     $roll = new RollTable();
     if (count($difficultyCollection->getDiceArray()) > 0) {
         // Difficutly Set
         $roll->setAgainstDiceSerial($difficultyCollection->getDiceAmountSerialized());
         $roll->setAgainstIncluded(RollTable::Yes);
     }
     $roll->setGenDate(time());
     $roll->save();
     return $roll->getId();
 }