Compare commits

..

No commits in common. "7be04f128acf5233cda39e720c2cafa91f0416ef" and "751a86c8231b961eb6ce68081f83ca34506e30eb" have entirely different histories.

5 changed files with 28 additions and 23 deletions

4
Jenkinsfile vendored
View File

@ -37,7 +37,7 @@ pipeline {
sh 'vendor/bin/phpunit --log-junit unit_test_results.xml --testdox tests'
}
post {
always {
success {
archiveArtifacts 'unit_test_results.xml'
}
}
@ -56,7 +56,7 @@ pipeline {
sh 'php -d memory_limit=1G vendor/bin/phpstan analyse -c phpstan.neon --error-format=prettyJson > static_code_analysis_results.json'
}
post {
always {
success {
archiveArtifacts 'static_code_analysis_results.json'
}
}

View File

@ -231,6 +231,17 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
prepare: function () {
var data = new FormData();
var userNames;
if (roomId) {
var userNames = localStorage.userNames ? JSON.parse(localStorage.userNames) : {};
if (!userNames.hasOwnProperty(roomId)) {
userNames[roomId] = prompt('Your name: ');
localStorage.userNames = JSON.stringify(userNames);
}
data.append('userName', userNames[roomId]);
}
document.getElementById('loading').style.visibility = 'visible';
var url = Game.getGameIdentifier() + '/prepare.json';
@ -607,7 +618,7 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
break;
case 'anonymous_user':
MapGuesser.showModalWithContent('Error', 'You have to login to join this game!');
MapGuesser.showModalWithContent('Error', 'You have to login to join a challenge!');
break;
default:

View File

@ -131,13 +131,11 @@
}, formData);
};
if (document.getElementById('multiButton')) {
document.getElementById('multiButton').onclick = function () {
MapGuesser.showModal('multi');
document.getElementById('createNewRoomButton').href = '/multiGame/new/' + this.dataset.mapId;
document.getElementById('multiForm').elements.roomId.select();
document.getElementById('playMode').style.visibility = 'hidden';
}
document.getElementById('multiButton').onclick = function () {
MapGuesser.showModal('multi');
document.getElementById('createNewRoomButton').href = '/multiGame/new/' + this.dataset.mapId;
document.getElementById('multiForm').elements.roomId.select();
document.getElementById('playMode').style.visibility = 'hidden';
}
if (document.getElementById('challengeButton')) {

View File

@ -1,6 +1,7 @@
<?php namespace MapGuesser\Controller;
use DateTime;
use Faker\Factory;
use SokoWeb\Interfaces\Authentication\IAuthenticationRequired;
use SokoWeb\Response\HtmlContent;
use SokoWeb\Response\JsonContent;
@ -11,7 +12,6 @@ use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\MultiRoom;
use MapGuesser\PersistentData\Model\PlaceInChallenge;
use MapGuesser\PersistentData\Model\UserInChallenge;
use MapGuesser\PersistentData\Model\User;
use MapGuesser\Repository\ChallengeRepository;
use MapGuesser\Repository\MapRepository;
use MapGuesser\Repository\MultiRoomRepository;
@ -190,16 +190,12 @@ class GameController implements IAuthenticationRequired
public function prepareMultiGame(): IContent
{
/**
* @var User|null $user
*/
$user = \Container::$request->user();
if ($user === null)
{
return new JsonContent(['error' => 'anonymous_user']);
}
$roomId = \Container::$request->query('roomId');
$userName = \Container::$request->post('userName');
if (empty($userName)) {
$faker = Factory::create();
$userName = $faker->userName;
}
$room = $this->multiRoomRepository->getByRoomId($roomId);
@ -229,7 +225,7 @@ class GameController implements IAuthenticationRequired
$this->multiConnector->sendMessage('join_room', [
'roomId' => $roomId,
'token' => $token,
'userName' => $user->getDisplayName()
'userName' => $userName
]);
return new JsonContent([

View File

@ -9,9 +9,9 @@ TODO: condition!
<div id="playMode" class="modal">
<h2>Play map</h2>
<a id="singleButton" class="button fullWidth marginTop" href="" title="Single player">Single player</a>
<p class="bold center marginTop marginBottom">OR</p>
<button id="multiButton" class="fullWidth green" data-map-id="">Multiplayer (beta)</button>
<?php if ($isLoggedIn): ?>
<p class="bold center marginTop marginBottom">OR</p>
<button id="multiButton" class="fullWidth green" data-map-id="">Multiplayer (beta)</button>
<p class="bold center marginTop marginBottom">OR</p>
<button id="challengeButton" class="fullWidth yellow" data-map-id="" data-timer="">Challenge (gamma)</button>
<?php endif; ?>