X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tictac%2Ftictac.php;h=7a00349e4cd21613196036fe0523e11879b8435a;hb=c7c8934e2ce3ee76031d3257fac4d071b96a060d;hp=f928fd5e08ad6de002cecad0dde3371156c99cdb;hpb=c6e5bc3429c9c610895ba826d841cddd8c0f378b;p=friendica-addons.git diff --git a/tictac/tictac.php b/tictac/tictac.php index f928fd5e..7a00349e 100644 --- a/tictac/tictac.php +++ b/tictac/tictac.php @@ -4,63 +4,62 @@ * Description: The TicTacToe game application * Version: 1.0 * Author: Mike Macgirvin + * Status: unsupported */ -use Friendica\Core\Addon; -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'][] = '
' . t('Three Dimensional Tic-Tac-Toe') . '
'; -} - - -function tictac_module() { - return; +function tictac_app_menu(App $a, array &$b) +{ + $b['app_menu'][] = '
' . DI::l10n()->t('Three Dimensional Tic-Tac-Toe') . '
'; } +/** + * 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(App $a) { $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 .= '

' . t('3D Tic-Tac-Toe') . '


'; + $o .= '

' . DI::l10n()->t('3D Tic-Tac-Toe') . '


'; $t = new tictac($dimen,$handicap,$mefirst,$yours,$mine); $o .= $t->play(); - $o .= '' . t('New game') . '
'; - $o .= '' . t('New game with handicap') . '
'; - $o .= '

' . t('Three dimensional tic-tac-toe is just like the traditional game except that it is played on multiple levels simultaneously. '); - $o .= 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 .= '' . DI::l10n()->t('New game') . '
'; + $o .= '' . DI::l10n()->t('New game with handicap') . '
'; + $o .= '

' . 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 .= '

'; - $o .= 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 .= '

'; return $o; @@ -179,24 +178,24 @@ class tictac { if($this->first_move) { if(rand(0,1) == 1) { - $o .= '
' . t('You go first...') . '

'; + $o .= '
' . DI::l10n()->t('You go first...') . '

'; $this->mefirst = 0; $o .= $this->draw_board(); return $o; } - $o .= '
' . t('I\'m going first this time...') . '

'; + $o .= '
' . DI::l10n()->t('I\'m going first this time...') . '

'; $this->mefirst = 1; } if($this->check_youwin()) { - $o .= '
' . t('You won!') . '

'; + $o .= '
' . DI::l10n()->t('You won!') . '

'; $o .= $this->draw_board(); return $o; } if($this->fullboard()) - $o .= '
' . t('"Cat" game!') . '

'; + $o .= '
' . DI::l10n()->t('"Cat" game!') . '

'; $move = $this->winning_move(); if(strlen($move)) { @@ -219,9 +218,9 @@ class tictac { } if($this->check_iwon()) - $o .= '
' . t('I won!') . '

'; + $o .= '
' . DI::l10n()->t('I won!') . '

'; if($this->fullboard()) - $o .= '
' . t('"Cat" game!') . '

'; + $o .= '
' . DI::l10n()->t('"Cat" game!') . '

'; $o .= $this->draw_board(); return $o; }