コード例 #1
0
ファイル: clues.php プロジェクト: rjwalsh88/BawkApp
function displayClueEditForm(Clue $clue)
{
    $dateSelect = ui_select('date', Date::getAllDates(), $clue->getFormDate());
    $defaultStateSelect = ui_select('defaultState', State::getAllStates(), $clue->getDefaultState());
    $startDateSelect = ui_select("startDate", Date::getAllDatesNullable(), $clue->getStartFormDate());
    $hintDateSelect = ui_select("hintDate", Date::getAllDatesNullable(), $clue->getHintFormDate());
    $answerDateSelect = ui_select("answerDate", Date::getAllDatesNullable(), $clue->getAnswerFormDate());
    $startCitySelect = ui_select("startCity", City::getAllCityNames(), $clue->getStartCityID());
    $hintCitySelect = ui_select("hintCity", City::getAllCityNames(), $clue->getHintCityID());
    $answerCitySelect = ui_select("answerCity", City::getAllCityNames(), $clue->getAnswerCityID());
    $startDirectionSelect = ui_select("startDirection", Direction::getAllDirections(), $clue->getStartDirection());
    $hintDirectionSelect = ui_select("hintDirection", Direction::getAllDirections(), $clue->getHintDirection());
    $answerDirectionSelect = ui_select("answerDirection", Direction::getAllDirections(), $clue->getAnswerDirection());
    return <<<EOT
<form method="POST" action="clues.php">
Name (admin use only): <input type="hidden" name="id" value="{$clue->getID()}" />
<input type="text" name="name" value="{$clue->getName()}" />
<br />
Date (for sorting): {$dateSelect}
<input type="text" size="8" name="time" value="{$clue->getFormTime()}" />
<br />
Default state: {$defaultStateSelect}
<br />
Question: <br />
<textarea name="question" cols="45" rows="8">{$clue->getQuestion()}</textarea><br />
Hint: <br />
<textarea name="hint" cols="45" rows="4">{$clue->getHint()}</textarea><br />
Answers (1 per line, * for wildcard): <br />
<textarea name="answer" cols="45" rows="4">{$clue->getAnswerText()}</textarea><br />
<br /><br />

Answering prerequisites:<br />
<input type="text" size="4" name="startDistance" value="{$clue->getStartDistance()}" />
miles {$startDirectionSelect} {$startCitySelect} or after time
{$startDateSelect} <input type="text" size="8" name="startTime" value="{$clue->getStartFormTime()}" />.<br /><br />

Hint conditions:<br />
<input type="text" size="4" name="hintDistance" value="{$clue->getHintDistance()}" />
miles {$hintDirectionSelect} {$hintCitySelect} or after time
{$hintDateSelect} <input type="text" size="8" name="hintTime" value="{$clue->getHintFormTime()}" />.<br /><br />

Auto-answering conditions:<br />
<input type="text" size="4" name="answerDistance" value="{$clue->getAnswerDistance()}" />
miles {$answerDirectionSelect} {$answerCitySelect} or after time
{$answerDateSelect} <input type="text" size="8" name="answerTime" value="{$clue->getAnswerFormTime()}" />.<br /><br />


<input type="submit" name="edit" value="Edit Clue" />
<br /><br />
Delete clue: <input type="submit" name="delete" value="Delete Clue" />
</form>
EOT;
}
コード例 #2
0
ファイル: Team.php プロジェクト: rjwalsh88/BawkApp
 public function doGuessAnswer(Clue $clue, $guess)
 {
     $clueState = $clue->getClueState($this);
     $currentState = $clue->calculateClueState($this);
     if ($currentState >= STATE_ANSWERED) {
         add_notification('This clue has already been answered.');
         return false;
     } else {
         if ($currentState < STATE_ANSWERABLE) {
             add_notification('This clue cannot be answered yet. Try waiting or changing your location as indicated.');
             return false;
         }
     }
     if ($clue->isGuessCorrect($guess)) {
         add_notification('Correct answer!');
         if ($clueState == null) {
             $clueState = new ClueState(array('team' => $this->id, 'clue' => $clue->getID()));
             $clueState->doAdd();
             $clue->setClueState($this, $clueState);
         }
         $clueState->makeChanges(array('state' => STATE_ANSWERED, 'answer' => $guess));
         $clueState->doUpdate();
         return true;
     } else {
         add_notification('Incorrect guess!');
         return false;
     }
 }