Guest User

Untitled

a guest
Jan 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. > Выберите действие:
  2. 1. Добавить фигуру
  3. 2. Удалить фигуру
  4. 3. Переместить фигуру
  5.  
  6. $config = [
  7. 'figures' => [
  8. 'pawn' => ['ico' => 'o', 'title' => "пешка"],
  9. 'rook' => ['ico' => 'X', 'title' => "ладья"],
  10. ],
  11. ];
  12.  
  13. $game = new GameField(['size' => 12]);
  14.  
  15. $game->onAddFigure = function($item){
  16. print "пользовательский обработчик добавления фигуры";
  17. });
  18.  
  19. public function addFigure($f){
  20. ....
  21. if(is_callable($this->onAddFigure)){
  22. ($(this)->onAddFigure)($f);
  23. }
  24. ....
  25. }
  26.  
  27. interface IGameLoader {
  28. public function save($state);
  29. public function load();
  30. }
  31.  
  32. class JsonLoader implements IGameLoader(){
  33. public function save($state){
  34. .....
  35. file_put_contents("...", json_encode($state));
  36. }
  37.  
  38. public function load(){
  39. }
  40. }
  41.  
  42. $game->save('json', "./data.json");
Add Comment
Please, Sign In to add comment