Esempio n. 1
0
 /**
  * executePsubmit
  *
  * @param sfWebRequest $request
  * @return void
  */
 public function executePsubmit(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     $zoneList = array('strike', 'ball');
     $pitching = $request->getParameter('pitching');
     $zone = $zoneList[$pitching['zone']];
     $pitcher = new Pitcher();
     $pitcher->setAction($zone);
     $batter = new Batter();
     $batter->setAction('swing');
     $game = new Game();
     $game->setPlayer($pitcher, $batter);
     $game->judgement();
     $pitcher = $game->getPitcher();
     $params = array('result' => $pitcher->getResult());
     $this->redirect('match/result?' . http_build_query($params));
 }
Esempio n. 2
0
$pitcher->setAction('strike');
$batter = new Batter();
$batter->setAction('swing');
$game = new Game();
$game->setPlayer($pitcher, $batter);
$game->judgement();
$t->is($game->isFinished(), true, '決着がついたこと');
$t->is($pitcher->isWin(), false, '投手が敗北したこと');
$t->is($pitcher->fluctuateYen(), -1, '投手に-1円ついたこと');
$t->diag('ボール-見逃しの場合');
$pitcher = new Pitcher();
$pitcher->setAction('ball');
$batter = new Batter();
$batter->setAction('watch');
$game = new Game();
$game->setPlayer($pitcher, $batter);
$game->judgement();
$t->is($game->isFinished(), true, '決着がついたこと');
$t->is($pitcher->isWin(), false, '投手が敗北したこと');
$t->is($pitcher->fluctuateYen(), -2, '投手に-2円ついたこと');
$t->diag('ボール-スイングの場合');
$pitcher = new Pitcher();
$pitcher->setAction('ball');
$batter = new Batter();
$batter->setAction('swing');
$game = new Game();
$game->setPlayer($pitcher, $batter);
$game->judgement();
$t->is($game->isFinished(), true, '決着がついたこと');
$t->is($pitcher->isWin(), true, '投手が勝利したこと');
$t->is($pitcher->fluctuateYen(), 2, '投手に2円ついたこと');