예제 #1
0
 /**
  * Displays the contact page
  */
 public function actionRun()
 {
     require __DIR__ . '/../../../vendor/autoload.php';
     $evm = new EventManager();
     $data = array();
     $collect = function ($info) use(&$data) {
         $data[] = $info;
     };
     $evm->on('game.run', $collect);
     $evm->on('game.addplayer', $collect);
     $evm->on('game.start', $collect);
     $evm->on('game.turn', $collect);
     $evm->on('game.end', $collect);
     $evm->on('player.start', $collect);
     $evm->on('player.attack', $collect);
     $evm->on('player.defense', $collect);
     $evm->on('player.damage', $collect);
     $game = new Game($evm);
     foreach (Player::model()->findAll() as $player) {
         $game->addPlayer(new EPlayer($player->name, (int) $player->life, (int) $player->strong, (int) $player->speed, new EResource($player->resource->name, (int) $player->resource->attack, (int) $player->resource->defense, new Dice((int) $player->resource->dice)), $game));
     }
     $game->run(new Dice(20));
     $this->render('run', array('data' => $data));
 }
예제 #2
0
파일: main.php 프로젝트: rafaelang/rpg
<?php

require 'vendor/autoload.php';
use Engine\Game;
use Engine\Player;
use Engine\Resource;
use Engine\Dice;
use Engine\EventManager;
$evm = new EventManager();
$evm->on('game.run', '\\Engine\\Game::info');
$evm->on('game.addplayer', '\\Engine\\Game::info');
$evm->on('game.start', '\\Engine\\Game::info');
$evm->on('game.turn', '\\Engine\\Game::info');
$evm->on('game.end', '\\Engine\\Game::info');
$evm->on('player.start', '\\Engine\\Game::info');
$evm->on('player.attack', '\\Engine\\Game::info');
$evm->on('player.defense', '\\Engine\\Game::info');
$evm->on('player.damage', '\\Engine\\Game::info');
$game = new Game($evm);
$game->addPlayers(array(new Player('Humam', 12, 1, 2, new Resource('Espada longa', 1, 2, new Dice(6)), $game), new Player('Orc', 20, 2, 0, new Resource('Clava de madeira', 1, 0, new Dice(8)), $game)));
$game->run(new Dice(20));