* Description: The TicTacToe game application
* Version: 1.0
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
+ * Status: unsupported
*/
-use Friendica\Core\Addon;
-use Friendica\Core\L10n;
-function tictac_install() {
- Addon::registerHook('app_menu', 'addon/tictac/tictac.php', 'tictac_app_menu');
-}
-
-function tictac_uninstall() {
- Addon::unregisterHook('app_menu', 'addon/tictac/tictac.php', 'tictac_app_menu');
+use Friendica\App;
+use Friendica\Core\Hook;
+use Friendica\DI;
+function tictac_install()
+{
+ Hook::register('app_menu', 'addon/tictac/tictac.php', 'tictac_app_menu');
}
-function tictac_app_menu($a,&$b) {
- $b['app_menu'][] = '<div class="app-title"><a href="tictac">' . L10n::t('Three Dimensional Tic-Tac-Toe') . '</a></div>';
-}
-
-
-function tictac_module() {
- return;
+function tictac_app_menu(array &$b)
+{
+ $b['app_menu'][] = '<div class="app-title"><a href="tictac">' . DI::l10n()->t('Three Dimensional Tic-Tac-Toe') . '</a></div>';
}
+/**
+ * This is a statement rather than an actual function definition. The simple
+ * existence of this method is checked to figure out if the addon offers a
+ * module.
+ */
+function tictac_module() {}
-
-
-
-function tictac_content(&$a) {
+function tictac_content() {
$o = '';
if($_POST['move']) {
- $handicap = $a->argv[1];
- $mefirst = $a->argv[2];
- $dimen = $a->argv[3];
- $yours = $a->argv[4];
- $mine = $a->argv[5];
+ $handicap = DI::args()->get(1);
+ $mefirst = DI::args()->get(2);
+ $dimen = DI::args()->get(3);
+ $yours = DI::args()->get(4);
+ $mine = DI::args()->get(5);
$yours .= $_POST['move'];
}
- elseif($a->argc > 1) {
- $handicap = $a->argv[1];
+ elseif(DI::args()->getArgc() > 1) {
+ $handicap = DI::args()->get(1);
$dimen = 3;
}
else {
$dimen = 3;
}
- $o .= '<h3>' . L10n::t('3D Tic-Tac-Toe') . '</h3><br />';
+ $o .= '<h3>' . DI::l10n()->t('3D Tic-Tac-Toe') . '</h3><br />';
$t = new tictac($dimen,$handicap,$mefirst,$yours,$mine);
$o .= $t->play();
- $o .= '<a href="tictac">' . L10n::t('New game') . '</a><br />';
- $o .= '<a href="tictac/1">' . L10n::t('New game with handicap') . '</a><br />';
- $o .= '<p>' . L10n::t('Three dimensional tic-tac-toe is just like the traditional game except that it is played on multiple levels simultaneously. ');
- $o .= L10n::t('In this case there are three levels. You win by getting three in a row on any level, as well as up, down, and diagonally across the different levels.');
+ $o .= '<a href="tictac">' . DI::l10n()->t('New game') . '</a><br />';
+ $o .= '<a href="tictac/1">' . DI::l10n()->t('New game with handicap') . '</a><br />';
+ $o .= '<p>' . DI::l10n()->t('Three dimensional tic-tac-toe is just like the traditional game except that it is played on multiple levels simultaneously. ');
+ $o .= DI::l10n()->t('In this case there are three levels. You win by getting three in a row on any level, as well as up, down, and diagonally across the different levels.');
$o .= '</p><p>';
- $o .= L10n::t('The handicap game disables the center position on the middle level because the player claiming this square often has an unfair advantage.');
+ $o .= DI::l10n()->t('The handicap game disables the center position on the middle level because the player claiming this square often has an unfair advantage.');
$o .= '</p>';
return $o;
if($this->first_move) {
if(rand(0,1) == 1) {
- $o .= '<div class="error-message">' . L10n::t('You go first...') . '</div><br />';
+ $o .= '<div class="error-message">' . DI::l10n()->t('You go first...') . '</div><br />';
$this->mefirst = 0;
$o .= $this->draw_board();
return $o;
}
- $o .= '<div class="error-message">' . L10n::t('I\'m going first this time...') . ' </div><br />';
+ $o .= '<div class="error-message">' . DI::l10n()->t('I\'m going first this time...') . ' </div><br />';
$this->mefirst = 1;
}
if($this->check_youwin()) {
- $o .= '<div class="error-message">' . L10n::t('You won!') . '</div><br />';
+ $o .= '<div class="error-message">' . DI::l10n()->t('You won!') . '</div><br />';
$o .= $this->draw_board();
return $o;
}
if($this->fullboard())
- $o .= '<div class="error-message">' . L10n::t('"Cat" game!') . '</div><br />';
+ $o .= '<div class="error-message">' . DI::l10n()->t('"Cat" game!') . '</div><br />';
$move = $this->winning_move();
if(strlen($move)) {
}
if($this->check_iwon())
- $o .= '<div class="error-message">' . L10n::t('I won!') . '</div><br />';
+ $o .= '<div class="error-message">' . DI::l10n()->t('I won!') . '</div><br />';
if($this->fullboard())
- $o .= '<div class="error-message">' . L10n::t('"Cat" game!') . '</div><br />';
+ $o .= '<div class="error-message">' . DI::l10n()->t('"Cat" game!') . '</div><br />';
$o .= $this->draw_board();
return $o;
}