Example #1
0
 function post_register()
 {
     // set validation rules for new user content.
     $rules = array('name' => 'required|min:3|max:75', 'email' => 'required|unique:users|email', 'password' => 'required|min:5|max:64');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::to('user/new')->with_input('except', array('password'))->with_errors($v);
     }
     $nameArr = explode(' ', Input::get('name'), 2);
     $player = new Player();
     $player->first_name = $nameArr[0];
     $player->last_name = isset($nameArr[1]) ? $nameArr[1] : '';
     $player->save();
     if ($player->save()) {
         $user = new User();
         $user->password = Hash::make(Input::get('password'));
         $user->email = Input::get('email');
         $user->player_id = $player->id;
         if ($user->save()) {
             // log the user in the session
             Auth::login($user->id);
             return Redirect::to('user')->with('welcomeMsg', true);
         } else {
             // oh shit. roll back the player and return an error
             $player->delete();
             return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'Nah fool... something went real wrong.');
         }
     } else {
         return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'This user could not be created.');
     }
 }
Example #2
0
 public function post_create_player()
 {
     if (!Request::ajax()) {
         return;
     }
     $failUri = 'bracket/players';
     // Bracket to add to.
     $bracket = Bracket::find(Session::get('bracketId'));
     // fail if bracket does not exist.
     if (!$bracket) {
         return Redirect::home();
     }
     // Make sure they gave us a player name
     $name = Input::get('playerName');
     if (!$name) {
         return Redirect::to($failUri);
     }
     // Create the new player.
     $name = explode(' ', $name);
     $player = new Player();
     $player->first_name = $name[0];
     $player->last_name = isset($name[1]) ? $name[1] : false;
     // save the player
     if ($player->save()) {
         // associate this new person with the bracket
         $bracket->players()->attach($player);
         return json_encode($player);
     } else {
         return json_encode(array());
     }
 }
 public static function handle_register()
 {
     $firstname = $_POST['firstname'];
     $username = $_POST['username'];
     $password = $_POST['password'];
     $password2 = $_POST['password2'];
     $errors = array();
     if ($firstname == null) {
         $errors[] = "Syötä nimesi.";
     }
     if ($username == null) {
         $errors[] = "Syötä uusi käyttäjätunnus.";
     }
     if (Player::username_exists($username)) {
         $errors[] = "Käyttäjätunnus on jo käytössä. Valitse toinen käyttäjätunnus.";
     }
     if ($password == null || $password2 == null) {
         $errors[] = "Syötä uusi salasana.";
     }
     if ($password != $password2) {
         $errors[] = "Annetut salasanat eivät täsmänneet.";
     }
     if ($errors != null) {
         View::make('user/register.html', array('errors' => $errors, 'username' => $username, 'firstname' => $firstname));
     } else {
         // Register user/player and login
         $player = new Player(array('firstname' => $firstname, 'username' => $username, 'password' => crypt($password)));
         $player->save();
         // POST params for signing in are the same in register.html and login.html
         self::handle_login();
     }
 }
Example #4
0
 public function addPlayer($args)
 {
     $model = new Player();
     $model->setAttributes($args);
     $model->token = StringHelper::generateToken(20, 30);
     $model->created_at = new CDbExpression('NOW()');
     if ($model->save(FALSE)) {
         return $model->id;
     }
     return FALSE;
 }
Example #5
0
 protected function createBookedPlayer($email, $nick, $tournament)
 {
     $player = new Player();
     $player->setFirstname("-");
     $player->setLastname("-");
     $player->setNickname($nick);
     $player->setEmail($email);
     $player->setTournament($tournament);
     $player->save();
     return $player;
 }
 public static function store()
 {
     $params = $_POST;
     $Player = new Player(array('name' => $params['name'], 'password' => $params['password']));
     $errors = $Player->errors();
     if (count($errors) != 0) {
         View::make('/Player/new.html', array('errors' => $errors, 'player' => $Player));
     } else {
         $Player->save();
         Redirect::to('/login', array('message' => 'Pelaaja luotu! Kirjaudu nyt sisään'));
     }
 }
Example #7
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Player();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Player'])) {
         $model->attributes = $_POST['Player'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->playerId));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Player();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Player'])) {
         $model->attributes = $_POST['Player'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'Player created');
             $this->redirect(array('index'));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #9
0
 public function actionReg()
 {
     $email = trim(Yii::app()->request->getParam('email'));
     $nick = trim(Yii::app()->request->getParam('nickname'));
     $password = trim(Yii::app()->request->getParam('passwd'));
     $password2 = trim(Yii::app()->request->getParam('passwd2'));
     $refer = trim(Yii::app()->request->getParam('refer', '/'));
     if (!preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $email)) {
         $this->json_return(false, '请输入一个格式正确的Email地址');
     }
     if (!$password || $password != $password2) {
         $this->json_return(false, '2次输入的密码不一致');
     }
     if (!$nick) {
         $this->json_return(false, '请填写昵称');
     }
     if (mb_strlen($nick, 'UTF-8') > 9) {
         $this->json_return(false, '昵称长度请限制在9个字之内');
     }
     if (Player::model()->find('email=:email', array(':email' => $email))) {
         $this->json_return(false, '这个Email已经被注册了,您是否已经注册过了呢?');
     }
     if (Player::model()->find('nickname=:nick', array(':nick' => $nick))) {
         $this->json_return(false, '这个昵称已经被注册了,换一个吧');
     }
     $player = new Player();
     $player->email = $email;
     $player->nickname = $nick;
     $player->password = MyUserIdentity::hashpwd($password);
     $player->login_times = 0;
     $player->b_win = 0;
     $player->b_lose = 0;
     $player->w_win = 0;
     $player->w_lose = 0;
     $player->draw = 0;
     $player->reg_time = date('Y-m-d H:i:s');
     $player->reg_ip = MyController::getUserHostAddress();
     $player->last_login_time = date('Y-m-d H:i:s');
     $player->last_login_ip = MyController::getUserHostAddress();
     $player->score = Yii::app()->params['init_score'];
     if ($player->save()) {
         $identity = new MyUserIdentity($email, $password);
         if ($identity->authenticate()) {
             Yii::app()->user->login($identity, 3600);
             $this->json_return(true, '恭喜您注册成功!', $refer);
         }
     }
     $this->json_return(false, '注册失败啦,请与管理员联系。');
 }
 public function load()
 {
     $this->clear();
     // Alfredo Rodriguez (Maryland)
     $player = new Player();
     $player->setFirstName('Alfredo');
     $player->setLastName('Rodriguez');
     $player->setHeight(72);
     $player->setWeight(180);
     $player->setBats('R');
     $player->setThrows('R');
     $player->setHometown('Oak Hill, Va.');
     $player->setCstvId(395839);
     $player->setNcaaId(993788);
     $player->save();
     print_r(sprintf("Created Player: %s (%s)\n", $player->getName(), $player->getId()));
 }
Example #11
0
function test_player_obj()
{
    // in: player_id, out: valid db save
    DatabaseConnection::getInstance();
    $player_id_sel = DatabaseConnection::$pdo->query("SELECT player_id FROM players WHERE uname = 'glassbox'");
    $player_id = $player_id_sel->fetchColumn();
    $player = new Player($player_id);
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player uname, out: valid db save
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player status check, out: no errors
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player, out: vo of player data
    $player = new Player('glassbox');
    $vo = $player->as_vo();
    assert($vo instanceof PlayerVO);
    // in: player, out: array of player data
    $player = new Player('glassbox');
    $arr = $player->as_array();
    assert(count($arr) > 0);
    var_dump($arr);
}
Example #12
0
function test_player_obj()
{
    // in: player_id, out: valid db save
    $player_id_sel = "select player_id from players where uname = 'glassbox'";
    $db = new DBAccess();
    $player_id = $db->QueryItem($player_id_sel);
    $player = new Player($player_id);
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player uname, out: valid db save
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player status check, out: no errors
    $player = new Player('glassbox');
    assert($player->vo->player_id == $player_id);
    $orig_clan = $player->vo->clan_long_name;
    $player->vo->clan_long_name = 'Testingz';
    $player->save();
    $changed_player = new Player($player_id);
    $changed_clan = $changed_player->vo->clan_long_name;
    $changed_player->vo->clan_long_name = $orig_clan;
    assert($changed_clan == 'Testingz');
    // in: player, out: vo of player data
    $player = new Player('glassbox');
    $vo = $player->as_vo();
    assert($vo instanceof PlayerVO);
    // in: player, out: array of player data
    $player = new Player('glassbox');
    $arr = $player->as_array();
    assert(count($arr) > 0);
    var_dump($arr);
}
Example #13
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Player();
     $document = new DocumentPlayer();
     $document->ID_DOCUMENT = 1;
     $document->ID_PLAYER = 1;
     $document->NAME = 'Acta de Juanito Perez';
     $document->PATH = 'En case la verga';
     $document->SIZE = 2;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Player'])) {
         $model->attributes = $_POST['Player'];
         //$document->save();
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->ID));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rand = 'GSP' . rand(100, 100000);
     $data = Input::all();
     $validator = Validator::make($data, Player::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // Helper: File Upload in Player Model
     $check = Player::all()->count();
     if ($check >= 11) {
         return View::make('players.index')->with('message', 'You have reached the maximum number allowed');
     } else {
         $data['id_copy'] = Player::uploadFile(Input::file('id_copy'), 'id_copy');
         $data['photo'] = Player::uploadFile(Input::file('photo'), 'photo');
         $players = new Player($data);
         $players->rand_num = $rand;
         $players->save();
         return View::make('players.index')->with('message', 'file upload was successful');
     }
 }
Example #15
0
 protected function run()
 {
     if ($this->check == self::OK) {
         $colorRepository = new ColorRepository();
         $count = $colorRepository->getCountAll();
         $randomColor = mt_rand(1, $count);
         $userParams = array('username' => 'AI-' . str_pad(mt_rand(0, 999), 3, 0, STR_PAD_LEFT), 'color' => $randomColor);
         $userRepository = new UserRepository();
         $newUser = $userRepository->getOneByUsername($userParams['username']);
         if (!$newUser) {
             $newUser = new User($userParams);
             $newUser = $newUser->save(TRUE);
         }
         $playersCount = GameUtils::getPosition($this->game);
         $strategyRepository = new AiStrategyRepository();
         $strategyRepository->addOrderBy(array('RAND()' => ''));
         $strategy = $strategyRepository->getOneBy();
         $params = array('game' => $this->game['id'], 'user' => $newUser['id'], 'seat' => GameUtils::getSeatOnPosition($playersCount), 'ai_strategy' => $strategy['id']);
         $player = new Player($params);
         $player->save();
     }
 }
 /**
  * Store a newly created resource in storage.
  * POST /player
  *
  * @return Response
  */
 public function store()
 {
     $user = Auth::user();
     $validator = Validator::make(Input::all(), Player::$rules);
     $uuid = Uuid::generate();
     if ($validator->passes()) {
         $player = new Player();
         $player->id = $uuid;
         $player->firstname = Input::get('firstname');
         $player->lastname = Input::get('lastname');
         $player->position = Input::get('position');
         $player->relation = Input::get('relation');
         $player->dob = Input::get('dob');
         $player->gender = Input::get('gender');
         $player->year = Input::get('year');
         $player->avatar = Input::get('avatar');
         $player->email = Input::get('email');
         $player->mobile = Input::get('mobile');
         $player->school = Input::get('school');
         $player->laxid = Input::get('laxid');
         $player->laxid_exp = Input::get('laxid_exp');
         $player->uniform = Input::get('uniform');
         $player->address = Input::get('address');
         $player->city = Input::get('city');
         $player->state = Input::get('state');
         $player->zip = Input::get('zip');
         $player->user_id = $user->id;
         $status = $player->save();
         if ($status) {
             return Redirect::action('PlayerController@index')->with('messages', 'Player created successfully');
         } else {
             $error = $player->errors()->all(':message');
             return Redirect::back()->withErrors($error);
         }
     }
     return Redirect::back()->withErrors($validator)->withInput();
 }
Example #17
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aPlayer !== null) {
             if ($this->aPlayer->isModified() || $this->aPlayer->isNew()) {
                 $affectedRows += $this->aPlayer->save($con);
             }
             $this->setPlayer($this->aPlayer);
         }
         if ($this->aCourt !== null) {
             if ($this->aCourt->isModified() || $this->aCourt->isNew()) {
                 $affectedRows += $this->aCourt->save($con);
             }
             $this->setCourt($this->aCourt);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Example #18
0
            }
        }
    }
    if ($_POST['p2weapon'] == "rock") {
        $player2 = new Player($_POST['p2name'], $_POST['p2age'], $rock);
    } else {
        if ($_POST['p2weapon'] == "paper") {
            $player2 = new Player($_POST['p2name'], $_POST['p2age'], $paper);
        } else {
            if ($_POST['p2weapon'] == "scissors") {
                $player2 = new Player($_POST['p2name'], $_POST['p2age'], $scissors);
            }
        }
    }
    $player1->save();
    $player2->save();
    var_dump($_SESSION['player_stats']);
    $player1_spot = $_SESSION['player_stats'][1];
    $player2_spot = $_SESSION['player_stats'][2];
    $turn = Player::whoseTurn();
    return $app['twig']->render('play.html.twig', array('player1' => $player1_spot, 'player2' => $player2_spot, 'turn' => $turn));
});
$app->post("/delete", function () use($app) {
    Player::deleteAll();
    return $app['twig']->render('home.html.twig');
});
$app->post("/attack", function () use($app) {
    print_r($_SESSION['player_stats']);
    $whoseturn = Player::whoseTurn();
    $player = Player::decidePlayer();
    $attack = Player::attack();
Example #19
0
            if ($check_name_in_database->isLoaded()) {
                $newchar_errors[] = 'This name is already used. Please choose another name!';
            }
            $charToEdit = new Player($_REQUEST['player_id']);
            if (!$charToEdit->isLoaded()) {
                $newchar_errors[] = 'This player does not exist.';
            }
            if ($charToEdit->isOnline()) {
                $newchar_errors[] = 'This player is ONLINE. Logout first.';
            } elseif ($account_logged->getID() != $charToEdit->getAccountID()) {
                $newchar_errors[] = 'This player is not on your account.';
            }
            if (empty($newchar_errors)) {
                echo 'Name of character <b>' . htmlspecialchars($charToEdit->getName()) . '</b> changed to <b>' . htmlspecialchars($newchar_name) . '</b>';
                $charToEdit->setName($newchar_name);
                $charToEdit->save();
                $account_logged->setCustomField('premium_points', $account_logged->getCustomField('premium_points') - $changeNameCost);
            } else {
                echo 'Some errors occured:<br />';
                foreach ($newchar_errors as $e) {
                    echo '<li>' . $e . '</li>';
                }
                echo '<br /><a href="?subtopic=changename"><b>BACK</b></a>';
            }
        }
    } else {
        echo 'You don\'t have premium points. You need ' . $changeNameCost . '.';
    }
} else {
    echo 'You must login first.';
}
 protected function saveTeamSeasonForPlayers($players, $team)
 {
     $list = array();
     $this->CI->load->model('playerRepository', '_player');
     foreach ($players as $ncaaId => $stats) {
         $player = $this->CI->_player->findOneByNcaaId($ncaaId);
         $name = explode(',', $stats[0]);
         if (!$player) {
             $player = new Player();
             $player->setNcaaId($ncaaId);
             $player->setFirstName(trim($name[1]));
             $player->setLastName(trim($name[0]));
             $player->save();
         }
         if (!$player->getFirstName()) {
             $player->setFirstName(trim($name[1]));
         }
         if (!$player->getLastName()) {
             $player->setLastName(trim($name[0]));
         }
         $year = explode('-', $stats[2]);
         $year = date('Y', strtotime("january 1, " . $year[1]));
         if ($this->output) {
             print_r("Checking for Player Season with Year: " . $year . "\n");
         }
         $season = $player->getSeason($year);
         if (!$season) {
             if ($this->output) {
                 print_r("No Season for Player, Creating New Season\n");
             }
             $season = new Season();
         }
         $season->setYear($year);
         $season->setClass($stats[1]);
         $season->setPosition($stats[3]);
         $season->setTeam($team);
         $season->setGames($stats[4]);
         $season->setAtBats($stats[5]);
         $season->setRuns($stats[6]);
         $season->setHits($stats[7]);
         $season->setDoubles($stats[9]);
         $season->setTriples($stats[10]);
         $season->setHomeRuns($stats[11]);
         $season->setTotalBases($stats[12]);
         $season->setRunsBattedIn($stats[14]);
         $season->setStolenBases($stats[15]);
         $season->setStolenBaseAttempts($stats[16]);
         $season->setWalks($stats[17]);
         $season->setStrikeouts($stats[18]);
         $season->setHitByPitch($stats[19]);
         $season->setSacrificeHits($stats[20]);
         $season->setSacrificeFlies($stats[21]);
         $season->setAppearances($stats[22]);
         $season->setGamesStarted($stats[23]);
         $season->setCompleteGames($stats[24]);
         $season->setWins($stats[25]);
         $season->setLosses($stats[26]);
         $season->setSaves($stats[27]);
         $season->setShutouts($stats[28]);
         $season->setInningsPitched($stats[29]);
         $season->setHitsAllowed($stats[30]);
         $season->setRunsAllowed($stats[31]);
         $season->setEarnedRuns($stats[32]);
         $season->setWalksAllowed($stats[33]);
         $season->setStrikeoutsPitched($stats[34]);
         $player->addSeason($season);
         //print_r($player);
         //print_r('<br /><br />');
         $player->save();
         if ($this->output) {
             print_r("Player with Season:\n");
         }
         if ($this->output) {
             print_r($player);
         }
         $list[] = $player;
     }
     if ($this->output) {
         print_r("List of Players:\n");
     }
     if ($this->output) {
         print_r($list);
     }
     return $list;
 }
Example #21
0
 protected function runSuzyLafayetteAction()
 {
     if (!in_array($this->commandName, array('create', 'join', 'add_ai_player', 'init', 'choose_character', 'start'))) {
         if ($this->actualPlayer && $this->actualPlayer->getIsSuzyLafayette($this->game)) {
             if (!in_array($this->commandName, array('throw', 'draw', 'choose_cards'))) {
                 $handCards = unserialize($this->actualPlayer['hand_cards']);
                 if (count($handCards) == 0) {
                     $drawnCards = GameUtils::drawCards($this->game, 1);
                     $handCards = array_merge($handCards, $drawnCards);
                     $this->actualPlayer['hand_cards'] = serialize($handCards);
                     $this->actualPlayer = $this->actualPlayer->save(TRUE);
                 }
             }
         } elseif ($this->enemyPlayer && $this->enemyPlayer->getIsSuzyLafayette($this->game)) {
             $handCards = unserialize($this->enemyPlayer['hand_cards']);
             if (count($handCards) == 0) {
                 $drawnCards = GameUtils::drawCards($this->game, 1);
                 $handCards = array_merge($handCards, $drawnCards);
                 $this->enemyPlayer['hand_cards'] = serialize($handCards);
                 $this->enemyPlayer = $this->enemyPlayer->save(TRUE);
             }
         }
     }
 }
     $char_to_copy->setLastIP(0);
     $char_to_copy->setLastLogin(0);
     $char_to_copy->setLastLogout(0);
     $char_to_copy->setName($newchar_name);
     $char_to_copy->setAccount($account_logged);
     $char_to_copy->setSex($newchar_sex);
     $char_to_copy->setTown($newchar_town);
     $char_to_copy->setPosX(0);
     $char_to_copy->setPosY(0);
     $char_to_copy->setPosZ(0);
     $char_to_copy->setWorldID((int) $world_id);
     $char_to_copy->setCreateIP(Visitor::getIP());
     $char_to_copy->setCreateDate(time());
     $char_to_copy->setSave();
     // make character saveable
     $char_to_copy->save();
     // now it will load 'id' of new player
     if ($char_to_copy->isLoaded()) {
         $char_to_copy->saveItems();
         $char_to_copy->saveSkills();
         $main_content .= '<div class="TableContainer" >  <table class="Table1" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" >        <span class="CaptionEdgeLeftTop" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url(' . $layout_name . '/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url(' . $layout_name . '/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Character Created</div>        <span class="CaptionVerticalRight" style="background-image:url(' . $layout_name . '/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url(' . $layout_name . '/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td>The character <b>' . htmlspecialchars($newchar_name) . '</b> has been created.<br/>Please select the outfit when you log in for the first time.<br/><br/><b>See you on ' . $config['server']['servername'] . '!</b></td></tr>          </table>        </div>  </table></div></td></tr><br/><center><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url(' . $layout_name . '/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url(' . $layout_name . '/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="' . $layout_name . '/images/buttons/_sbutton_back.gif" ></div></div></td></tr></form></table></center>';
     } else {
         echo "Error. Can\\'t create character. Probably problem with database. Try again or contact with admin.";
         exit;
     }
 } else {
     $main_content .= '<div class="SmallBox" >  <div class="MessageContainer" >    <div class="BoxFrameHorizontal" style="background-image:url(' . $layout_name . '/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeLeftTop" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeRightTop" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></div>    <div class="ErrorMessage" >      <div class="BoxFrameVerticalLeft" style="background-image:url(' . $layout_name . '/images/content/box-frame-vertical.gif);" /></div>      <div class="BoxFrameVerticalRight" style="background-image:url(' . $layout_name . '/images/content/box-frame-vertical.gif);" /></div>      <div class="AttentionSign" style="background-image:url(' . $layout_name . '/images/content/attentionsign.gif);" /></div><b>The Following Errors Have Occurred:</b><br/>';
     foreach ($newchar_errors as $newchar_error) {
         $main_content .= '<li>' . $newchar_error;
     }
     $main_content .= '</div>    <div class="BoxFrameHorizontal" style="background-image:url(' . $layout_name . '/images/content/box-frame-horizontal.gif);" /></div>    <div class="BoxFrameEdgeRightBottom" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></div>    <div class="BoxFrameEdgeLeftBottom" style="background-image:url(' . $layout_name . '/images/content/box-frame-edge.gif);" /></div>  </div></div><br/>';
Example #23
0
     $new_nick = $_REQUEST['nick'];
     $player = new Player();
     $player->find($player_n);
     $player_from_account = FALSE;
     if (strlen($new_nick) <= 30) {
         if ($player->isLoaded()) {
             $account_players = $account_logged->getPlayersList();
             if (count($account_players)) {
                 foreach ($account_players as $acc_player) {
                     if ($acc_player->getId() == $player->getId()) {
                         $player_from_account = TRUE;
                     }
                 }
                 if ($player_from_account) {
                     $player->setGuildNick($new_nick);
                     $player->save();
                     $main_content .= 'Guild nick of player <b>' . htmlspecialchars($player->getName()) . '</b> changed to <b>' . htmlspecialchars($new_nick) . '</b>.';
                     $addtolink = '&action=show&guild=' . $player->getRank()->getGuildId();
                 } else {
                     $main_content .= 'This player is not from your account.';
                 }
             } else {
                 $main_content .= 'This player is not from your account.';
             }
         } else {
             $main_content .= 'Unknow error occured.';
         }
     } else {
         $main_content .= 'Too long guild nick. Max. 30 chars, your: ' . strlen($new_nick);
     }
 } else {
Example #24
0
 function harmonize_chakra(Player $char)
 {
     // Heal at most 100 or ki available or hurt by AND at least 0
     $heal_for = (int) max(0, min(100, $char->is_hurt_by(), $char->ki()));
     if ($heal_for > 0) {
         // If there's anything to heal, try.
         // Subtract the ki used for healing.
         $char->heal($heal_for);
         $char->set_ki($char->ki() - $heal_for);
         $char->save();
     }
     return $char;
 }
Example #25
0
 public function kickPlayer($playerId)
 {
     if ($playerId == $this->getOwnerID()) {
         $this->delete();
     } else {
         $player = new Player($playerId);
         if ($player->isLoaded()) {
             $player->setRankID(0);
             $player->save();
         }
     }
 }
Example #26
0
 /**
  * Persist
  *
  * @param Player $player
  * @return mixed
  */
 public function save(Player $player)
 {
     return $player->save();
 }
 public function importPitchers($real = false, $year = 0)
 {
     if ($real) {
         $file = "./web/utilities/bw-pitching.csv";
     } else {
         $file = "./web/utilities/bw-pitching-test.csv";
     }
     $row = 0;
     if (($handle = fopen($file, "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
             if ($row) {
                 if ($data[0] >= $year) {
                     $player = utf8_encode($data[2]);
                     $slug = $this->CI->slugify->simple($player);
                     $player = $this->CI->_player->findOneBySlug($slug);
                     $team = utf8_encode($data[1]);
                     $slug = $this->CI->slugify->simple($team);
                     $team = $this->CI->_team->findOneBySlug($slug);
                     $year = $data[0];
                     if ($team) {
                         if ($player) {
                             $season = $this->CI->_season->findOneBySourceAndPlayerAndYear('Boydsworld', $player, $year);
                             $official = $this->CI->_season->findOneBySourceAndPlayerAndYear('Smallball', $player, $year);
                         }
                         if (!$season) {
                             $season = new Season();
                         }
                         $num = count($data);
                         for ($c = 0; $c < $num; $c++) {
                             $method = 'set' . ucwords($this->pitcher[$c]);
                             if (method_exists($season, $method)) {
                                 $season->{$method}($data[$c]);
                                 if ($official) {
                                     $official->{$method}($data[$c]);
                                 }
                             }
                         }
                         //print_r($season);
                         $season->setPlayer(utf8_encode($season->getPlayer()));
                         $season->setLevel('College');
                         $season->setLeague('NCAA');
                         $season->setDivision('D1');
                         /* Save Player */
                         if (!$player) {
                             $player = new Player();
                             $name = $season->getPlayer();
                             $name = explode(' ', $name);
                             if (isset($name[count($name) - 1])) {
                                 $player->setLastName(utf8_encode($name[count($name) - 1]));
                             }
                             $name = array_splice($name, 0, count($name) - 1);
                             $name = implode(' ', $name);
                             if (isset($name)) {
                                 $player->setFirstName(utf8_encode($name));
                             }
                             print_r("Adding Player: " . $team->getName() . ", " . $player->getName() . ", " . $season->getYear() . "\n");
                             $player->save();
                         } else {
                             print_r("Existing Player: " . $team->getName() . ", " . $player->getName() . ", " . $season->getYear() . "\n");
                         }
                         $season->setPlayer($player);
                         $season->setTeam($team);
                         $season->setSource('Boydsworld');
                         $season->save();
                         if (!$official) {
                             $official = clone $season;
                             $official->setSource('Smallball');
                         }
                         $official->setPlayer($player);
                         $official->setTeam($team);
                         $official->save();
                         $teamOfficial = $this->CI->_season->findOneOfficialByTeamAndYear($team, $season->getYear());
                         if ($teamOfficial) {
                             $teamOfficial->addPlayer($player);
                             $teamOfficial->save();
                         }
                     }
                     // end team
                 }
                 // end year
             }
             //row
             $row++;
         }
         fclose($handle);
     }
 }
 function test_Player_One_Turn()
 {
     //Arrange
     $rock = new Rock();
     $paper = new Paper();
     $scissors = new Scissors();
     $player1 = new Player('Marika', 25, $rock);
     $player2 = new Player('Jason', 25, $paper);
     $player1->save();
     $player2->save();
     //Act
     $_SESSION['player_stats'][0] += 1;
     $result = Player::playerTurn();
     //Assert
     $this->assertEquals("It's Marika's turn", $result);
 }
Example #29
0
         $newPlayer->setSkillCount(5, 0);
         $newPlayer->setSkillCount(6, 0);
         $newPlayer->save();
     }
     if ($newPlayer->isLoaded()) {
         foreach ($samplePlayers as $vocationID => $name) {
             $samplePlayer = new Player($name, Player::LOADTYPE_NAME);
             if (!$samplePlayer->isLoaded()) {
                 $samplePlayer = new Player('Account Manager', Player::LOADTYPE_NAME);
                 $samplePlayer->setID(null);
                 // save as new player, not edited
                 $samplePlayer->setName($name);
                 $samplePlayer->setVocation($vocationID);
                 $samplePlayer->setGroupID(1);
                 $samplePlayer->setLookType(128);
                 $samplePlayer->save();
                 echo '<span style="color:green">Added sample character: </span><span style="color:green;font-weight:bold">' . $name . '</span><br/>';
             } else {
                 echo 'Sample character: <span style="font-weight:bold">' . $name . '</span> already exist in database<br/>';
             }
         }
     } else {
         new Error_Critic('', 'Character <i>Account Manager</i> does not exist. Cannot install sample characters!');
     }
 } elseif ($step == 5) {
     echo '<h1>STEP ' . $step . '</h1>Set Admin Account<br>';
     if (empty($_REQUEST['saveaccpassword'])) {
         echo 'Admin account login is: <b>1</b><br/>Set new password to this account.<br>';
         echo 'New password: <form action="install.php" method=POST><input type="text" name="newpass" size="35">(Don\'t give it password to anyone!)';
         echo '<input type="hidden" name="saveaccpassword" value="yes"><input type="hidden" name="page" value="step"><input type="hidden" name="step" value="5"><input type="submit" value="SET"></form><br>If account with login 1 doesn\'t exist installator will create it and set your password.';
     } else {
 public function actionAddPlayerToDbAndTournament()
 {
     // This is garbage
     // Refactor
     if (Yii::app()->request->isPostRequest) {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
     if (isset($_GET['data'])) {
         $data = $_GET['data'];
         $tournament_id = $data['tournament_id'];
         $player = $data['player'];
         $_player = new Player();
         $_player->name = $player['name'];
         $_player->nickname = $player['nickname'];
         $_player->female = $player['female'] == 'true' ? 1 : 0;
         if ($_player->save()) {
             $player['id'] = Yii::app()->db->getLastInsertId();
             $_player->name = $_player->getFullName(true);
             list($message, $Tplayer) = $this->addToTournament($tournament_id, $player);
         } else {
             $message = 'There was a problem saving the player';
             $_player->id = null;
         }
         echo CJSON::encode(array('status' => $message, 'id' => $Tplayer->id, 'player' => $_player));
     }
 }