Esempio n. 1
0
 public function create_object($data)
 {
     $data = \Core\Dict::create($data);
     $assassin = Agent::mapper()->create_object(array('id' => $data->assassin, 'alias' => $data->assassin_agent_alias));
     $target = Agent::mapper()->create_object(array('id' => $data->target, 'alias' => $data->target_agent_alias));
     $weapon = Weapon::mapper()->create_object(array('id' => $data->weapon_id, 'name' => $data->weapon_name));
     return Kill::create(array('id' => $data->id, 'description' => $data->description, 'assassin' => $assassin, 'target' => $target, 'weapon' => $weapon, 'game' => $game, 'when_happened' => new \DateTime($data->when_happened)), True);
 }
Esempio n. 2
0
 public function create_object($data)
 {
     if (empty($data['victor'])) {
         $data['victor'] = 0;
     } else {
         $data['victor'] = Agent::mapper()->create_object(array('id' => $data['victor'], 'alias' => $data['victor_agent_alias']));
         unset($data['victor_alias']);
     }
     $game = Game::create($data, True);
     $game->attach_mapper('Kill', Kill::mapper()->attach_storage(\Core\Storage::container()->get_storage('Kill')));
     $game->attach_mapper('Agent', Agent::mapper()->attach_storage(\Core\Storage::container()->get_storage('Agent')));
     foreach (array('start_date', 'end_date') as $f) {
         $game[$f] = new \DateTime($game[$f]);
     }
     $game->invite_only = (int) $data['invite_only'];
     $now = new \DateTime();
     if ($game->start_date > $now) {
         $game['joinable'] = True;
         $game['active'] = False;
         $game['state'] = 0;
     } else {
         if ($game->start_date < $now && $now < $game->end_date) {
             $game['joinable'] = False;
             $game['active'] = True;
             $game['state'] = 1;
         } else {
             $game['joinable'] = False;
             $game['active'] = False;
             $game['state'] = 2;
         }
     }
     return $game;
 }
Esempio n. 3
0
 public function create_object($data)
 {
     $agent = Agent::mapper()->create_object(array('id' => $data['agent'], 'alias' => $data['agent_alias'], 'avatar' => $data['agent_avatar']));
     return Player::create(array('id' => $data['id'], 'agent' => $agent, 'target' => $data['target'], 'credits' => $data['credits'], 'pkn' => $data['pkn'], 'status' => $data['status']));
 }