grappfruit logo slice
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game)) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
if ($game->status == MGame::STATUS_CLOSED) {
	$turn = MTurn::getLatestForGid($game->gid);

	if (!is_null($turn) && $turn->turnType == MTurn::TYPE_RESIGN) {
		$this->r->setError(ERR_GAME_RESIGNED_BY_OPPONENT);
	} else {
		$this->r->setError(ERR_GAME_OVER);
	}

	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$turn = MTurn::getLatestForGid($game->gid);
if (!is_null($turn) && $turn->uid == $user->id) {
	$this->r->setError(ERR_NOT_YOUR_TURN);
	return;
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_TURN, $qp['word'], $qp['letter_state']);

if ( WORDFILTER && !$turn->isValidWord($game->language)) {
	$db = MyDatabase::getInstance();
	$mysqli = $db->getConnection();
	$stmt = $mysqli->prepare(''
		. 'INSERT IGNORE INTO `illegal_words` (`id`, `word`, `lang_id`) '
		. 'VALUES(NULL, ?, ?)'
	);
	$stmt->bind_param('si', $turn->word, $game->lang_id);
	$stmt->execute();

	$this->r->setError(ERR_INVALID_WORD);
	return;
}
if ($turn->wordAlreadyPlayed()) {
	$this->r->setError(ERR_WORD_ALREADY_PLAYED);
	return;
}
if ($turn->isPrefixWord()) {
	$this->r->setError(ERR_PREFIX_WORD);
	return;
}
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
$game_update = false;
$winner = '';
if (strpos($turn->letter_state, 'n') === false) {
	$game->winner = $game->getWinnerForLetterState($turn->letter_state);
	
	if ($game->winner == $user->id) {
		$winner = $user->username;
	} else {
		$otherUser = MUser::getByPrimaryKey($game->winner);
		$winner = $otherUser->username;
	}
	$game->status = MGame::STATUS_CLOSED;
	$game_update = true;
} else if ($game->status != MGame::STATUS_OPEN) {
	if ($game->status == MGame::STATUS_CREATED) {
		$game->status = MGame::STATUS_LOOKING;
		$game_update = true;
	} else if ($game->status == MGame::STATUS_LOOKING) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	} else if (
		$game->status == MGame::STATUS_CHALLENGE 
		&& $game->initiator != $user->id
	) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	}
}
if ($game_update) {
	$game->updated = date('Y-m-d H:i:s');
	if (!$game->update()) {
		// TODO: what to do here?
	}
}

$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', $turn->word);
$msg->addData('type', MTurn::TYPE_TURN);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();
$this->r->addResponse('success', 1);
$this->r->addResponse('tid', $tid);
$this->r->sendResponse();
}

public function pass($format = 'json') {
$qp = $this->ro->query_params;
if (array_key_exists('gid', $qp) === false ||
	array_key_exists('uid', $qp) === false ||
	array_key_exists('hash', $qp) === false
) {
	$this->r->setError(ERR_MISSING_PARAMETER);
	return;
}
if (hash('sha256', $qp['gid'] . $qp['uid'] . SALT_TURN) !== $qp['hash']) {
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game) || $game->status == MGame::STATUS_CLOSED) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$gameDraw = false;
$turn = MTurn::getLatestForGid($game->gid);
$letter_state = isset($qp['letter_state']) ? $qp['letter_state'] : '';
$winner = '';
if (!is_null($turn)) {
	if ($turn->uid == $user->id) {
		$this->r->setError(ERR_NOT_YOUR_TURN);
		return;
	}
	if ($turn->turnType == MTurn::TYPE_PASS) {
		$gameDraw = true;
		if ($letter_state != '') {
			$game->winner = $game->getWinnerForLetterState($letter_state);
	
			if ($game->winner != 0) {
				if ($game->winner == $user->id) {
					$winner = $user->username;
				} else {
					$otherUser = MUser::getByPrimaryKey($game->winner);
					$winner = $otherUser->username;
				}
			} else {
				$winner = 'draw';
			}
		}
	}
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_PASS);
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
if ($gameDraw) {
	$game->status = MGame::STATUS_CLOSED;
	if (!$game->update()) {
		$this->r->setError(ERR_SQL);
		return;
	}
}
$game_update = false;
if ($game->status != MGame::STATUS_OPEN) {
	if ($game->status == MGame::STATUS_CREATED) {
		$game->status = MGame::STATUS_LOOKING;
		$game_update = true;
	} else if ($game->status == MGame::STATUS_LOOKING) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	} else if (
		$game->status == MGame::STATUS_CHALLENGE 
		&& $game->initiator != $user->id
	) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	}
}
if ($game_update) {
	$game->updated = date('Y-m-d H:i:s');
	if (!$game->update()) {
		// TODO: what to do here?
	}
}
$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', '');
$msg->addData('type', MTurn::TYPE_PASS);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();
$this->r->addResponse('success', 1);
$this->r->addResponse('tid', $tid);
$this->r->sendResponse();
}

public function resign($format = 'json') {
$qp = $this->ro->query_params;
if (array_key_exists('gid', $qp) === false ||
	array_key_exists('uid', $qp) === false ||
	array_key_exists('hash', $qp) === false
) {
	$this->r->setError(ERR_MISSING_PARAMETER);
	return;
}
if (hash('sha256', $qp['gid'] . $qp['uid'] . SALT_TURN) !== $qp['hash']) {
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game)) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$turn = MTurn::getLatestForGid($game->gid);
if (!is_null($turn) && $turn->turnType == MTurn::TYPE_RESIGN) {
	if ($turn->uid != $user->id) {
		$this->r->setError(ERR_GAME_RESIGNED_BY_OPPONENT);
	}
	return;
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_RESIGN);
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
$winner = '';
if ($game->initiator == $user->id) {
	$game->winner = $game->opponent;
} else {
	$game->winner = $game->initiator;
}
$tmpUser = MUser::getByPrimaryKey($game->winner);
$winner = $tmpUser->username;
$game->status = MGame::STATUS_CLOSED;
if (!$game->update()) {
	$this->r->setError(ERR_SQL);
	return;
}
$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', '');
$msg->addData('type', MTurn::TYPE_RESIGN);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();

Was ich Ihnen biete

icon-android

App-Entwicklung

idee

Idee -> App

Apps: Diese sind aus der heutigen Zeit fast nicht mehr wegzudenken.
Sie haben eine Idee und wissen nicht, wie Sie sie umsetzen sollen?
Ich stehe Ihnen zur Seite – vom Konzept bis zur fertigen App.

native code

Nativer-Code

Jede App wird in nativem Code geschrieben.
Ich verwende keine App-Builder oder ähnliches.
Das garantiert die beste Performance für Ihre App.

support

Support

Sie haben bereits eine App und benötigen Support?
Oder Sie benötigen Unterstützung bei der Veröffentlichung?
Kein Problem, ich helfen Ihnen gerne weiter.

icon-globe

Web-Entwicklung

CMS WordPress

WordPress

WordPress ist das beliebteste CMS weltweit.
Ich entwickle Ihre Seite und passe sie ganz Ihren Wünschen an.
Danach können Sie die Inhalte Ihrer Webseite ganz einfach selbst verändern.

responsive design

Responsive

Heutzutage gibt es sehr viele unterschiedliche Geräte und Plattformen.
Ich gestalte Ihre Webseite flexibel.
Das ermöglicht Ihnen, die Inhalte Ihrer Webseite auf allen Geräten optimal darzustellen.

seo search engine optimization

SEO

Suchmaschinen spielen eine große Rolle, denn schließlich will man auch gefunden werden.
Ich optimiere Ihre Webseite, sodass auch Sie künftig ganz weit vorne sind.

super.onCreate( savedInstanceState );
setContentView( R.layout.game_list_activity );

registerWithGCM();

_self = GameListActivity.this;
mContext = this;
mScale = getResources().getDisplayMetrics().density;
mWebService = new WebService();

// Reading values from the Preferences
final SharedPreferences prefs = getSharedPreferences( MyApp.PREFS_FILE, MODE_PRIVATE );

mOldVer = prefs.getInt( MyApp.PREFS_VERSION, -1 );

// set username from prefs
MyApp.username = prefs.getString( MyApp.PREFS_USERNAME, "" );
MyApp.uid = prefs.getString( MyApp.PREFS_UID, "" );
MyApp.regId = prefs.getString( MyApp.PREFS_REG_ID, "" );

// set visual theme from prefs
final String savedVisualTheme = prefs.getString( MyApp.PREFS_VISUAL_THEME, "" );
if ( savedVisualTheme == null || savedVisualTheme.equals( "" ) ) {

	if ( MyApp.SHOW_LOG ) {
		Log.d( MyApp.TAG, "Setting grappfruit theme" );
	}

	MyApp.MY_VISUAL_THEME = new MyVisualThemes( null );

} else {
	try {
		// try setting theme from pref
		for ( final MyVisualTheme theme : MyVisualTheme.values() ) {
			if ( theme.getText().equals( savedVisualTheme ) ) {

				if ( MyApp.SHOW_LOG ) {
					Log.d( MyApp.TAG, "Visual-Theme '" + savedVisualTheme + "' set" );
				}

				MyApp.MY_VISUAL_THEME = new MyVisualThemes( theme );
				break;
			}
		}

	} catch ( final Exception e ) {

		if ( MyApp.SHOW_LOG ) {
			Log.e( MyApp.TAG, "error setting visual theme, fallback to grappfruit: " + e.toString() );
		}

		MyApp.MY_VISUAL_THEME = new MyVisualThemes( null );
	}
}

// set audio theme from prefs
final String savedAudioTheme = prefs.getString( MyApp.PREFS_AUDIO_THEME, "" );
if ( savedAudioTheme == null || savedAudioTheme.equals( "" ) ) {

	if ( MyApp.SHOW_LOG ) {
		Log.d( MyApp.TAG, "Setting default audio theme" );
	}

	MyApp.MY_AUDIO_THEME = new MyAudioThemes( null );

} else {
	try {
		// try setting theme from pref
		for ( final MyAudioTheme theme : MyAudioTheme.values() ) {
			if ( theme.getText().equals( savedAudioTheme ) ) {

				if ( MyApp.SHOW_LOG ) {
					Log.d( MyApp.TAG, "Audio-Theme '" + savedAudioTheme + "' set" );
				}

				MyApp.MY_AUDIO_THEME = new MyAudioThemes( theme );
				break;
			}
		}

	} catch ( final Exception e ) {

		if ( MyApp.SHOW_LOG ) {
			Log.e( MyApp.TAG, "error setting audio theme, fallback to default: " + e.toString() );
		}

		MyApp.MY_AUDIO_THEME = new MyAudioThemes( null );
	}
}

// set sound enabled from prefs
MyApp.soundOn = prefs.getBoolean( MyApp.PREFS_SOUND, true );
// set notifications enabled from prefs
MyApp.notificationsOn = prefs.getBoolean( MyApp.PREFS_NOTIFICATIONS, true );
MyApp.notificationSound = prefs.getBoolean( MyApp.PREFS_NOTIFICATION_SOUND, true );
MyApp.notificationVibrate = prefs.getBoolean( MyApp.PREFS_NOTIFICATION_VIBRATE, true );

// add listeners to refresh, new game and more buttons
final Button refresh = (Button)findViewById( R.id.btn_refresh );
refresh.setOnClickListener( new OnClickListener() {
	@Override
	public void onClick( final View v ) {
		refreshFromServer();
	}
} );
// make sure that the refresh button is the topmost button on the view!
refresh.bringToFront();

final LinearLayout newGame = (LinearLayout)findViewById( R.id.new_game );
newGame.setOnClickListener( new NewGameListener() );

final LinearLayout more = (LinearLayout)findViewById( R.id.more );
more.setOnClickListener( new OnClickListener() {
	@Override
	public void onClick( final View v ) {
		final Intent intent = new Intent( getContext(), MoreActivity.class );
		getContext().startActivity( intent );
	}
} );

if ( MyApp.uid == "" || MyApp.username == "" ) {
	promptUserName();
} else {
	refreshFromServer();
}

displayMessageOnVersionUpdate( false );

App-Projekte

WDR

Fehlerbehebung, Wartung und Erweiterung der bestehenden WDR App
Android SDK / Java / XML / Http / Json

zur App

CarUnity

Mitentwicklung der CarUnity App für Opel unter der Nebelhorn GmbH
Android SDK / Java / XML / Http / Json

zur App

ADAC Camping und Stellplatzführer 2013

App für europaweite Suche nach Camping- und Stellplätzen in der ADAC-Datenbank
Android SDK / Google Drive / Java / SQLite / MySQL / Python / XML

zur App

marktcom.de

Trödelmarkt-App für Deutschlands führendem Anbieter auf diesem Gebiet.
Android SDK / Java / XML / Http / Json

zur App

Auf ein Wort!

Eine Plattform-übergreifendes Wortsspiel komplett in 3D
Android SDK / Java / MySQL / Python / XML / Http / Json

zur App

die medienpartner .net

Augmented Reality Demo App auf Basis des metaioSDK
Android SDK / Java / XML

zur App

Sparkassen-Scan

Android Umsetzung der Augmented Reality App die Sparkasse
Android SDK / Java / XML / Http / Json

zur App

Tattoo 3D

Android Umsetzung der Augmented Reality App für das Magazin Tattoo Erotica
Android SDK / Java / XML / Json

zur App

Letterpress

Ein spannendes Wort-Spiel für kluge Köpfe
Android SDK / Java / SQLite / XML

zur App

MacroCraft

App Umsetzung des berühmten Starcraft 2 Spiels
Android SDK / Java / XML

zur App
width: 100%;
z-index: 999;
text-align: center;
background: -webkit-linear-gradient(#111111, #333333, #555555, #111111);
background: -moz-linear-gradient(#111111, #333333, #555555, #111111);
background: -o-linear-gradient(#111111, #333333, #555555, #111111);
background: linear-gradient(#111111, #333333, #555555, #111111);
/*
 * grappfruit image in nav
 * container to avoid wobble
 */ }
#mainnav li {
	display: inline-block;
	padding: 4px; }
#mainnav #menu-toggle {
	display: none; }
#mainnav :not(#grappfruit_home) a {
	color: #f7d117;
	display: inline-block;
	padding: 6px 10px;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	-o-border-radius: 4px;
	border-radius: 4px;
	-webkit-transition: all 0.1s ease-in-out 0s;
	-moz-transition: all 0.1s ease-in-out 0s;
	-o-transition: all 0.1s ease-in-out 0s;
	transition: all 0.1s ease-in-out 0s; }
	#mainnav :not(#grappfruit_home) a:link, #mainnav :not(#grappfruit_home) a:visited {
		text-decoration: none;
		font-weight: bold; }
	#mainnav :not(#grappfruit_home) a:focus, #mainnav :not(#grappfruit_home) a:hover, #mainnav :not(#grappfruit_home) a:active {
		color: #D9261C;
		background-color: #F7D117; }
#mainnav img {
	float: left;
	width: 144px;
	height: 30px;
	padding: 3px; }

/*
 * facebook like button
 * container to avoid wobble
 */
#fb-container {
	width: 101px;
	height: 20px;
	float: right;
	margin-right: 40px;
	margin-top: 8px; }

/*
 * Sections
 */
body {
	font-family: 'Raleway', sans-serif;
	/*
	 * footer
	 */ }
	body .title {
		padding-top: 10%;
		margin-top: -10%;
		background: transparent; }
	body section {
		padding: 1em 0;
		background-image: url("../img/background/grappfruit_title_image_bw.jpg"); }
		body section h2,
		body section h3,
		body section img,
		body section article,
		body section address {
			margin: 0;
			padding: 0; }
		body section h2 {
			font-size: 1.8em;
			letter-spacing: 1px;
			text-align: center; }
		body section h3 {
			padding-bottom: 0.5em; }
		body section p {
			margin: 0;
			line-height: 1.64; }
			body section p span {
				display: inline-block;
				min-width: 70px; }
		body section ul {
			list-style-type: circle; }
		body section img {
			max-width: 99%;
			padding: 0;
			margin: 0; }
	body #maps {
		background-color: #e6e6e6;
		height: 600px;
		max-height: 45%; }
	body footer {
		padding: 7px 0;
		text-align: center;
		color: #484848;
		background-color: #e6e6e6; }
		body footer span {
			display: inline-block;
			padding: 0 3px; }

/*
 * grappfruit logo impressum
 */
#grappfruit {
	text-shadow: 0 1px 0 #484848, 0 -1px 0 #484848, 1px 0 0 #484848, -1px 0 0 #484848;
	font-size: 1.2em;
	color: #F7D117;
	font-weight: bold; }
	#grappfruit span {
		text-transform: uppercase;
		color: #D9261C; }

/*
 * boxing of articles
 */
.box {
	padding: 1em;
	background: rgba(255, 255, 255, 0.4);
	border: 1px solid #777777;
	-moz-border-radius: 6px 6px 6px 6px;
	-webkit-border-radius: 6px 6px 6px 6px;
	border-radius: 6px 6px 6px 6px;
	-webkit-box-shadow: 0.3em 0.3em 0.75em 0.1em rgba(0, 0, 0, 0.5);
	-moz-box-shadow: 0.3em 0.3em 0.75em 0.1em rgba(0, 0, 0, 0.5);
	-o-box-shadow: 0.3em 0.3em 0.75em 0.1em rgba(0, 0, 0, 0.5);
	box-shadow: 0.3em 0.3em 0.75em 0.1em rgba(0, 0, 0, 0.5);
	margin: 0 auto;
	width: 96%;
	max-width: 720px; }
	.box:not(:first-of-type) {
		margin-top: 1em; }

/*
 * Fullscreen background
 */
.fullscreen-background {
	background-attachment: fixed;
	background-repeat: no-repeat;
	background-size: auto auto;
	height: 100%; }
	.fullscreen-background .background-logo {

Web-Projekte

Düsen Görgen

Webkatalog eines Anbieters für Hochdruckdüsen auf Wordpress-Basis.
HTML5 / CSS3 / PHP / JavaScript / jQuery / WordPress

zur Webseite

Coaching Verändert

Infoportal des Vita-Coaches Silke Gummersbach auf Wordpress-Basis.
HTML5 / CSS3 / PHP / JavaScript / jQuery / WordPress

zur Webseite

Zahnheilkunde Düsseldorf

Webseite der Zahnheilkundepraxis Düsseldorf auf Wordpress-Basis.
HTML5 / CSS3 / PHP / JavaScript / jQuery / WordPress

zur Webseite

Tanztheater Image

Infoportal des Tanzensembles Image auf Wordpress-Basis.
HTML5 / CSS3 / PHP / JavaScript / jQuery / WordPress

zur Webseite

Westside-Werbung

WordPress Webseite eines Werbetechnik-Unternehmens.
HTML5 / CSS3 / PHP / JavaScript / jQuery / WordPress

zur Webseite

Christoph Kauerz

Eine Fullscreen Onepage im responsive Design.
HTML5 / CSS3 / PHP / JavaScript / jQuery

zur Webseite

SubZero Trockeneisstrahlen

Produktbeschreibungs-Webseite auf WordPress Basis im responsive Design.
HTML5 / CSS3 / PHP / JavaScript / jQuery / WordPress

Projekt offline

	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game)) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
if ($game->status == MGame::STATUS_CLOSED) {
	$turn = MTurn::getLatestForGid($game->gid);

	if (!is_null($turn) && $turn->turnType == MTurn::TYPE_RESIGN) {
		$this->r->setError(ERR_GAME_RESIGNED_BY_OPPONENT);
	} else {
		$this->r->setError(ERR_GAME_OVER);
	}

	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$turn = MTurn::getLatestForGid($game->gid);
if (!is_null($turn) && $turn->uid == $user->id) {
	$this->r->setError(ERR_NOT_YOUR_TURN);
	return;
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_TURN, $qp['word'], $qp['letter_state']);

if ( WORDFILTER && !$turn->isValidWord($game->language)) {
	$db = MyDatabase::getInstance();
	$mysqli = $db->getConnection();
	$stmt = $mysqli->prepare(''
		. 'INSERT IGNORE INTO `illegal_words` (`id`, `word`, `lang_id`) '
		. 'VALUES(NULL, ?, ?)'
	);
	$stmt->bind_param('si', $turn->word, $game->lang_id);
	$stmt->execute();

	$this->r->setError(ERR_INVALID_WORD);
	return;
}
if ($turn->wordAlreadyPlayed()) {
	$this->r->setError(ERR_WORD_ALREADY_PLAYED);
	return;
}
if ($turn->isPrefixWord()) {
	$this->r->setError(ERR_PREFIX_WORD);
	return;
}
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
$game_update = false;
$winner = '';
if (strpos($turn->letter_state, 'n') === false) {
	$game->winner = $game->getWinnerForLetterState($turn->letter_state);
	
	if ($game->winner == $user->id) {
		$winner = $user->username;
	} else {
		$otherUser = MUser::getByPrimaryKey($game->winner);
		$winner = $otherUser->username;
	}
	$game->status = MGame::STATUS_CLOSED;
	$game_update = true;
} else if ($game->status != MGame::STATUS_OPEN) {
	if ($game->status == MGame::STATUS_CREATED) {
		$game->status = MGame::STATUS_LOOKING;
		$game_update = true;
	} else if ($game->status == MGame::STATUS_LOOKING) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	} else if (
		$game->status == MGame::STATUS_CHALLENGE 
		&& $game->initiator != $user->id
	) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	}
}
if ($game_update) {
	$game->updated = date('Y-m-d H:i:s');
	if (!$game->update()) {
		// TODO: what to do here?
	}
}

$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', $turn->word);
$msg->addData('type', MTurn::TYPE_TURN);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();
$this->r->addResponse('success', 1);
$this->r->addResponse('tid', $tid);
$this->r->sendResponse();
}

public function pass($format = 'json') {
$qp = $this->ro->query_params;
if (array_key_exists('gid', $qp) === false ||
	array_key_exists('uid', $qp) === false ||
	array_key_exists('hash', $qp) === false
) {
	$this->r->setError(ERR_MISSING_PARAMETER);
	return;
}
if (hash('sha256', $qp['gid'] . $qp['uid'] . SALT_TURN) !== $qp['hash']) {
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game) || $game->status == MGame::STATUS_CLOSED) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$gameDraw = false;
$turn = MTurn::getLatestForGid($game->gid);
$letter_state = isset($qp['letter_state']) ? $qp['letter_state'] : '';
$winner = '';
if (!is_null($turn)) {
	if ($turn->uid == $user->id) {
		$this->r->setError(ERR_NOT_YOUR_TURN);
		return;
	}
	if ($turn->turnType == MTurn::TYPE_PASS) {
		$gameDraw = true;
		if ($letter_state != '') {
			$game->winner = $game->getWinnerForLetterState($letter_state);
	
			if ($game->winner != 0) {
				if ($game->winner == $user->id) {
					$winner = $user->username;
				} else {
					$otherUser = MUser::getByPrimaryKey($game->winner);
					$winner = $otherUser->username;
				}
			} else {
				$winner = 'draw';
			}
		}
	}
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_PASS);
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
if ($gameDraw) {
	$game->status = MGame::STATUS_CLOSED;
	if (!$game->update()) {
		$this->r->setError(ERR_SQL);
		return;
	}
}
$game_update = false;
if ($game->status != MGame::STATUS_OPEN) {
	if ($game->status == MGame::STATUS_CREATED) {
		$game->status = MGame::STATUS_LOOKING;
		$game_update = true;
	} else if ($game->status == MGame::STATUS_LOOKING) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	} else if (
		$game->status == MGame::STATUS_CHALLENGE 
		&& $game->initiator != $user->id
	) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	}
}
if ($game_update) {
	$game->updated = date('Y-m-d H:i:s');
	if (!$game->update()) {
		// TODO: what to do here?
	}
}
$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', '');
$msg->addData('type', MTurn::TYPE_PASS);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();
$this->r->addResponse('success', 1);
$this->r->addResponse('tid', $tid);
$this->r->sendResponse();
}

public function resign($format = 'json') {
$qp = $this->ro->query_params;
if (array_key_exists('gid', $qp) === false ||
	array_key_exists('uid', $qp) === false ||
	array_key_exists('hash', $qp) === false
) {
	$this->r->setError(ERR_MISSING_PARAMETER);
	return;
}
if (hash('sha256', $qp['gid'] . $qp['uid'] . SALT_TURN) !== $qp['hash']) {
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game)) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$turn = MTurn::getLatestForGid($game->gid);
if (!is_null($turn) && $turn->turnType == MTurn::TYPE_RESIGN) {
	if ($turn->uid != $user->id) {
		$this->r->setError(ERR_GAME_RESIGNED_BY_OPPONENT);
	}
	return;
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_RESIGN);
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
$winner = '';
if ($game->initiator == $user->id) {
	$game->winner = $game->opponent;
} else {
	$game->winner = $game->initiator;
}
$tmpUser = MUser::getByPrimaryKey($game->winner);
$winner = $tmpUser->username;
$game->status = MGame::STATUS_CLOSED;
if (!$game->update()) {
	$this->r->setError(ERR_SQL);
	return;
}
$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', '');
$msg->addData('type', MTurn::TYPE_RESIGN);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();

Partner

zusammen bieten wir Ihnen …

… ein neues Konzept

Logo Westside-Werbung

Westside-Werbung

Die in Grevenbroich ansässige Firma Westside-Werbung ist seit Jahren ein zuverlässiger Dienstleister rund um das Gebiet Werbetechnik. Das Angebot reicht von Beschriftungen, Schilder, Druck und Textilien über Werbeartikel bis hin zu Cardesign. Zusammen bieten wir Ihnen ein Komplettpaket bis hin zum neuen CI-Konzept mit passender Webseite, Visitenkarte, Briefpapier, Werbeartikeln,… und sogar einer eigenen App. Apropos App …

… Android und iOS

iOS Entwickler Max Opitz

maxopitz.de

Der seit 2010 selbständige iOS Entwickler Max Opitz, maxopitz.de, ist mein Partner, wenn es um das Thema iOS Entwicklung geht. Gemeinsam haben wir Projekte wie zum Beispiel den Camping- und Stellplatzführer 2013 für den ADAC oder die Trödelmarkt-App für marktcom.de, Deutschlands führendem Anbieter auf diesem Gebiet, umgesetzt. Mit unserem gebündelten Know-How helfen wir Ihnen, Millionen Kunden mit Ihrer ganz persönlichen App zu erreichen.
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game)) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
if ($game->status == MGame::STATUS_CLOSED) {
	$turn = MTurn::getLatestForGid($game->gid);

	if (!is_null($turn) && $turn->turnType == MTurn::TYPE_RESIGN) {
		$this->r->setError(ERR_GAME_RESIGNED_BY_OPPONENT);
	} else {
		$this->r->setError(ERR_GAME_OVER);
	}

	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$turn = MTurn::getLatestForGid($game->gid);
if (!is_null($turn) && $turn->uid == $user->id) {
	$this->r->setError(ERR_NOT_YOUR_TURN);
	return;
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_TURN, $qp['word'], $qp['letter_state']);

if ( WORDFILTER && !$turn->isValidWord($game->language)) {
	$db = MyDatabase::getInstance();
	$mysqli = $db->getConnection();
	$stmt = $mysqli->prepare(''
		. 'INSERT IGNORE INTO `illegal_words` (`id`, `word`, `lang_id`) '
		. 'VALUES(NULL, ?, ?)'
	);
	$stmt->bind_param('si', $turn->word, $game->lang_id);
	$stmt->execute();

	$this->r->setError(ERR_INVALID_WORD);
	return;
}
if ($turn->wordAlreadyPlayed()) {
	$this->r->setError(ERR_WORD_ALREADY_PLAYED);
	return;
}
if ($turn->isPrefixWord()) {
	$this->r->setError(ERR_PREFIX_WORD);
	return;
}
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
$game_update = false;
$winner = '';
if (strpos($turn->letter_state, 'n') === false) {
	$game->winner = $game->getWinnerForLetterState($turn->letter_state);
	
	if ($game->winner == $user->id) {
		$winner = $user->username;
	} else {
		$otherUser = MUser::getByPrimaryKey($game->winner);
		$winner = $otherUser->username;
	}
	$game->status = MGame::STATUS_CLOSED;
	$game_update = true;
} else if ($game->status != MGame::STATUS_OPEN) {
	if ($game->status == MGame::STATUS_CREATED) {
		$game->status = MGame::STATUS_LOOKING;
		$game_update = true;
	} else if ($game->status == MGame::STATUS_LOOKING) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	} else if (
		$game->status == MGame::STATUS_CHALLENGE 
		&& $game->initiator != $user->id
	) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	}
}
if ($game_update) {
	$game->updated = date('Y-m-d H:i:s');
	if (!$game->update()) {
		// TODO: what to do here?
	}
}

$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', $turn->word);
$msg->addData('type', MTurn::TYPE_TURN);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();
$this->r->addResponse('success', 1);
$this->r->addResponse('tid', $tid);
$this->r->sendResponse();
}

public function pass($format = 'json') {
$qp = $this->ro->query_params;
if (array_key_exists('gid', $qp) === false ||
	array_key_exists('uid', $qp) === false ||
	array_key_exists('hash', $qp) === false
) {
	$this->r->setError(ERR_MISSING_PARAMETER);
	return;
}
if (hash('sha256', $qp['gid'] . $qp['uid'] . SALT_TURN) !== $qp['hash']) {
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game) || $game->status == MGame::STATUS_CLOSED) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$gameDraw = false;
$turn = MTurn::getLatestForGid($game->gid);
$letter_state = isset($qp['letter_state']) ? $qp['letter_state'] : '';
$winner = '';
if (!is_null($turn)) {
	if ($turn->uid == $user->id) {
		$this->r->setError(ERR_NOT_YOUR_TURN);
		return;
	}
	if ($turn->turnType == MTurn::TYPE_PASS) {
		$gameDraw = true;
		if ($letter_state != '') {
			$game->winner = $game->getWinnerForLetterState($letter_state);
	
			if ($game->winner != 0) {
				if ($game->winner == $user->id) {
					$winner = $user->username;
				} else {
					$otherUser = MUser::getByPrimaryKey($game->winner);
					$winner = $otherUser->username;
				}
			} else {
				$winner = 'draw';
			}
		}
	}
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_PASS);
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
if ($gameDraw) {
	$game->status = MGame::STATUS_CLOSED;
	if (!$game->update()) {
		$this->r->setError(ERR_SQL);
		return;
	}
}
$game_update = false;
if ($game->status != MGame::STATUS_OPEN) {
	if ($game->status == MGame::STATUS_CREATED) {
		$game->status = MGame::STATUS_LOOKING;
		$game_update = true;
	} else if ($game->status == MGame::STATUS_LOOKING) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	} else if (
		$game->status == MGame::STATUS_CHALLENGE 
		&& $game->initiator != $user->id
	) {
		$game->status = MGame::STATUS_OPEN;
		$game_update = true;
	}
}
if ($game_update) {
	$game->updated = date('Y-m-d H:i:s');
	if (!$game->update()) {
		// TODO: what to do here?
	}
}
$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', '');
$msg->addData('type', MTurn::TYPE_PASS);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();
$this->r->addResponse('success', 1);
$this->r->addResponse('tid', $tid);
$this->r->sendResponse();
}

public function resign($format = 'json') {
$qp = $this->ro->query_params;
if (array_key_exists('gid', $qp) === false ||
	array_key_exists('uid', $qp) === false ||
	array_key_exists('hash', $qp) === false
) {
	$this->r->setError(ERR_MISSING_PARAMETER);
	return;
}
if (hash('sha256', $qp['gid'] . $qp['uid'] . SALT_TURN) !== $qp['hash']) {
	$this->r->setError(ERR_INVALID_HASH);
	return;
}
$game = MGame::getByUniqueField('gid', $qp['gid']);
if (is_null($game)) {
	$this->r->setError(ERR_GAME_NOT_FOUND);
	return;
}
$user = MUser::getByPrimaryKey($qp['uid']);
if (is_null($user)) {
	$this->r->setError(ERR_USER_NOT_FOUND);
	return;
}
$turn = MTurn::getLatestForGid($game->gid);
if (!is_null($turn) && $turn->turnType == MTurn::TYPE_RESIGN) {
	if ($turn->uid != $user->id) {
		$this->r->setError(ERR_GAME_RESIGNED_BY_OPPONENT);
	}
	return;
}
$turn = new MTurn();
$turn->init($qp['gid'], $qp['uid'], MTurn::TYPE_RESIGN);
$tid = $turn->save();
if ($tid === false) {
	$this->r->setError(ERR_SQL);
	return;
}
$winner = '';
if ($game->initiator == $user->id) {
	$game->winner = $game->opponent;
} else {
	$game->winner = $game->initiator;
}
$tmpUser = MUser::getByPrimaryKey($game->winner);
$winner = $tmpUser->username;
$game->status = MGame::STATUS_CLOSED;
if (!$game->update()) {
	$this->r->setError(ERR_SQL);
	return;
}
$msg = new MMessage();
$msg->addData('gid', $game->gid);
$msg->addData('username', $user->username);
$msg->addData('word', '');
$msg->addData('type', MTurn::TYPE_RESIGN);
$msg->addData('status', $game->status);
$msg->addData('winner', $winner);
$msg->addRegistrationId($game->getRegIdOfOtherPlayer($user->id));
$msg->send();

Kontakt

und so erreichen Sie mich …

Roland Wimmer
Roland Wimmer
Adresse:
Otto-Hahn-Straße 35
40591 Düsseldorf
Mobil:
01525 / 616 86 61
E-Mail:

… mit dem Auto

… oder direkt

Bitte Sicherheitsabfage beantworten *