Пример #1
0
 public function add()
 {
     // Sets encrypted password
     $this->salt = rand(10000, 99999);
     $this->password = $this->encryptPassword($this->password);
     parent::add();
     // Sets first game
     $playerStructure = new PlayerHasStructure();
     $playerStructure->player_id = $this->id;
     $playerStructure->structure_id = OsteoFactory::getElement('Structure', null, 'structure_category_id=7')->id;
     $playerStructure->add();
 }
Пример #2
0
    foreach ($relatedStructureList as $relatedStructure) {
        $structure = OsteoFactory::getElement('Structure', $relatedStructure->structure_id);
        $requiredStructureList = OsteoFactory::getElementList('StructureRequiredStructure', 'structure_id=' . $structure->id . ' AND required_structure_id !=' . $quizz['structureId']);
        $isUnlocked = true;
        foreach ($requiredStructureList as $requiredStructure) {
            try {
                OsteoFactory::getElement('PlayerHasStructure', null, 'player_id=' . $player->id . ' AND structure_id=' . $requiredStructure->required_structure_id);
            } catch (ElementNoResultException $e) {
                LogTool::getInstance()->logWarning('no unlock');
                $isUnlocked = false;
                break;
            }
        }
        if ($isUnlocked) {
            try {
                $newPlayerStructure = new PlayerHasStructure();
                $newPlayerStructure->player_id = $player->id;
                $newPlayerStructure->structure_id = $relatedStructure->structure_id;
                $newPlayerStructure->add();
            } catch (DatabaseDuplicateEntryException $e) {
                // Already in database
            }
        }
    }
}
if (!$quizz['isCraft']) {
    $questionDataList = array();
    foreach ($quizz['questionList'] as $questionData) {
        $question = OsteoFactory::getElement('Question', $questionData['questionId']);
        $questionDataList[] = $question->toArray(Question::FORMAT_RESULT, $questionData['answer']);
    }