Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > Выберите действие:
- 1. Добавить фигуру
- 2. Удалить фигуру
- 3. Переместить фигуру
- $config = [
- 'figures' => [
- 'pawn' => ['ico' => 'o', 'title' => "пешка"],
- 'rook' => ['ico' => 'X', 'title' => "ладья"],
- ],
- ];
- $game = new GameField(['size' => 12]);
- $game->onAddFigure = function($item){
- print "пользовательский обработчик добавления фигуры";
- });
- public function addFigure($f){
- ....
- if(is_callable($this->onAddFigure)){
- ($(this)->onAddFigure)($f);
- }
- ....
- }
- interface IGameLoader {
- public function save($state);
- public function load();
- }
- class JsonLoader implements IGameLoader(){
- public function save($state){
- .....
- file_put_contents("...", json_encode($state));
- }
- public function load(){
- }
- }
- $game->save('json', "./data.json");
Add Comment
Please, Sign In to add comment