$this->save();
}
+ public function getGuessingSetting($name, $default = null) {
+ if (empty($this->guessing_settings) ||
+ empty($this->guessing_type) ||
+ !array_key_exists($this->guessing_type, $this->guessing_settings) ||
+ !array_key_exists($name, $this->guessing_settings[$this->guessing_type])
+ ) {
+ return $default;
+ }
+ return $this->guessing_settings[$this->guessing_type][$name];
+ }
+
public function solveGuessing($solution) {
$start = $this->guessing_start;
$end = is_null($this->guessing_end) ? now() : $this->guessing_end;
}
public function scoreGuessing($solution, $guess, $first) {
- return 1;
+ if ($guess == $solution) {
+ if ($first) {
+ return $this->getGuessingSetting('points_exact_first', 1);
+ }
+ return $this->getGuessingSetting('points_exact_other', 1);
+ }
+ $distance = abs(intval($guess) - intval($solution));
+ if ($distance <= $this->getGuessingSetting('points_close_max', 3)) {
+ if ($first) {
+ return $this->getGuessingSetting('points_close_first', 1);
+ }
+ return $this->getGuessingSetting('points_close_other', 1);
+ }
+ return 0;
}
public function isValidGuess($solution) {
'chat' => 'boolean',
'chat_commands' => 'array',
'chat_settings' => 'array',
+ 'guessing_settings' => 'array',
'guessing_start' => 'datetime',
'guessing_end' => 'datetime',
'languages' => 'array',