Skip to content

Commit

Permalink
* Fix asterisks algoritm
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Kholodilin committed Nov 7, 2016
1 parent a021a5b commit 5bf4c07
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Chrl/AppBundle/Service/GameService.php
Expand Up @@ -145,12 +145,15 @@ public function checkAnswer($message)
if (mb_substr_count($hint,'*','UTF-8') >= mb_strlen($hint,'UTF-8')/2) {
//tell hint

$tPos = rand(0,mb_strlen($question->a1,'UTF-8'));

while($game->hint == $hint) {
$hint = mb_substr($hint,0,$tPos,'UTF-8').
mb_substr($question->a1,$tPos,1,'UTF-8').
mb_substr($hint,$tPos+1,200,'UTF-8');
for($t = 0; $t< mb_strlen($hint);$t++) {
if (mb_substr($hint,$t,1,'UTF-8') == '*') {
if (rand(0,1)==1) {
$hint = mb_substr($hint,0,$t,'UTF-8')
.mb_substr($question->a1,$t,1)
.mb_substr($hint,$t+1);
break;
}
}
}

$game->hint = $hint;
Expand Down

0 comments on commit 5bf4c07

Please sign in to comment.