Ejemplo n.º 1
0
 function setHeatStatus($status)
 {
     if ($status >= $GLOBALS['cfgHeatStatus']['open']) {
         $this->update("\r\n\t\t\t\tUPDATE serie SET\r\n\t\t\t\t\tStatus = {$status}\r\n\t\t\t\t\tWHERE xSerie = " . $this->heatID);
         // change this round's speaker status
         // (class Round will determine correct speaker status)
         $round = new Round($this->roundID);
         $round->setSpeakerStatus($GLOBALS['cfgSpeakerStatus']['open']);
     }
     // ET valid heat status
 }
Ejemplo n.º 2
0
 public function postCreate($tournament)
 {
     if ($tournament->user() != Auth::user()) {
         return Redirect::to('tournaments');
     }
     $round = new Round();
     $round->number = Input::get('number');
     $round->tournament = $tournament->id;
     $round->save();
     App::make('GamesController')->createMultiple($round);
     return Redirect::to('rounds/' . $round->id . '/update');
 }
 function process()
 {
     require './lib/common.lib.php';
     require './lib/utils.lib.php';
     if (empty($_POST['checked'])) {
         //
         $status = $GLOBALS['cfgSpeakerStatus']['open'];
     } else {
         $status = $_POST['status'];
     }
     $round = new Round($_POST['round']);
     $round->setSpeakerStatus($status);
     if (!empty($GLOBALS['AA_ERROR'])) {
         return;
     }
     $this->ok_out['msg'] = $GLOBALS['strOKUpdate'] . ": " . $GLOBALS['strSpeakerStatus'] . " (xRunde = " . $_POST['round'] . ")";
 }
Ejemplo n.º 4
0
 public function __construct($node, $parent)
 {
     parent::__construct($node, $parent);
     self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes);
     self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes);
     self::$possible_children = array_merge(parent::$possible_children, self::$possible_children);
     self::$required_children = array_merge(parent::$required_children, self::$required_children);
 }
Ejemplo n.º 5
0
 /**
  * Battle::startBattle()
  * 
  * @return null
  */
 public function startBattle($debug = false)
 {
     if (!$debug) {
         ob_start();
     }
     $this->battleStarted = true;
     //only for initial fleets presentation
     log_var('attackers', $this->attackers);
     log_var('defenders', $this->defenders);
     $round = new Round($this->attackers, $this->defenders, 0);
     $this->report->addRound($round);
     for ($i = 1; $i <= ROUNDS; $i++) {
         $att_lose = $this->attackers->isEmpty();
         $deff_lose = $this->defenders->isEmpty();
         //if one of they are empty then battle is ended, so update the status
         if ($att_lose || $deff_lose) {
             $this->checkWhoWon($att_lose, $deff_lose);
             $this->report->setBattleResult($this->attackers->battleResult, $this->defenders->battleResult);
             if (!$debug) {
                 ob_get_clean();
             }
             return;
         }
         //initialize the round
         $round = new Round($this->attackers, $this->defenders, $i);
         $round->startRound();
         //add the round to the combatReport
         $this->report->addRound($round);
         //if($i==2) die('Round: '.$this->report->getRound(0)->getNumber()); // ERRORE
         //update the attackers and defenders after round
         $this->attackers = $round->getAfterBattleAttackers();
         $this->defenders = $round->getAfterBattleDefenders();
     }
     //check status after all rounds
     $this->checkWhoWon($this->attackers->isEmpty(), $this->defenders->isEmpty());
     if (!$debug) {
         ob_get_clean();
     }
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Displays a listing of a user's list of all played rounds.
  *
  * @param int $id Id of player to be displayed.
  */
 public static function show($id)
 {
     $player = Player::find($id);
     $moderatorOf = Course::find_by_moderator($id);
     $course = Course::find($player->course);
     $scores = Score::find_by_player($player->id);
     foreach ($scores as $score) {
         $score->round = Round::find($score->roundId);
     }
     // $rounds = Round::find_by_player($player->id);
     // Kint::dump($rounds);
     View::make('player/show.html', array('player' => $player, 'scores' => $scores, 'moderatorOf' => $moderatorOf, 'course' => $course));
 }
Ejemplo n.º 7
0
 /**
  * Calculates average score for course.
  *
  * @return int Returns average score for course.
  */
 public function average()
 {
     $count = 0;
     $sum = 0;
     $rounds = Round::find_by_course($this->id);
     if (count($rounds) > 0) {
         foreach ($rounds as $round) {
             $scores = $round->getScores();
             if (count($scores) > 0) {
                 foreach ($scores as $score) {
                     $count++;
                     $sum += $score->throws;
                 }
             }
         }
     }
     $return = 0;
     if ($count != 0) {
         $return = $sum / $count;
     }
     return $return;
 }
Ejemplo n.º 8
0
 /**
  * Returns a key identifying where in $this->data table to find
  * group data for the given step and repetition.
  * 
  * @see Step::stepLabel()
  * @param Step $step
  * @param int $repetition
  * @return string
  */
 protected static function groupKey(Round $round)
 {
     return $round->label() . '_group';
 }
Ejemplo n.º 9
0
 /** 
  * Returns a label identifying this step and (if applicable) repetition.
  * 
  * @deprecated Use Round::label() instead.
  */
 public function stepLabel($repetition = NULL)
 {
     $round = new Round($this, $repetition);
     return $round->label();
 }
Ejemplo n.º 10
0
 /**
  * @covers pgn\tags\Round::getName
  */
 public function testGetName()
 {
     $expected = 'Round';
     $result = $this->object->getName();
     $this->assertEquals($expected, $result);
 }
Ejemplo n.º 11
0
 /** Returns a key, unique to this round, under which we will save the StepVariables in Session->data. */
 protected static function makeKey(Round $round)
 {
     return $round->label() . '_uservariables';
 }
Ejemplo n.º 12
0
                $gt++;
                break;
            }
            if (count($players[0]->opponents($tournament)->where('players.id', '=', $players[$pt])->get()) == 0) {
                $games[$gt]->players = array($players[0], $players[$pt]);
                $gt++;
                unset($players[$pt]);
                unset($players[0]);
                $players = array_values($players);
                $pt = 0;
                continue;
            }
        }
        return $games;
    }
}
Round::deleting(function ($round) {
    $games = $round->games()->get();
    $gamesToDelete = array();
    foreach ($games as $game) {
        $gamesToDelete[] = $game->id;
    }
    Report::whereIn('game', $gamesToDelete)->delete();
    Game::whereIn('id', $gamesToDelete)->delete();
    $tournament = $round->tournament();
    $players = $tournament->players()->get();
    foreach ($players as $player) {
        $player->updateScore($tournament);
        $player->updateSos($tournament);
    }
});
Ejemplo n.º 13
0
 /**
  * change round status
  * -------------------
  */
 function AA_utils_changeRoundStatus($round, $status)
 {
     require './lib/cl_round.lib.php';
     $GLOBALS['AA_ERROR'] = '';
     $mergedRounds = AA_getMergedRounds($round);
     if ($mergedRounds != '') {
         $sqlRounds = "IN " . $mergedRounds;
         $arrRound = split('[,]', substr($mergedRounds, 1, -1));
         foreach ($arrRound as $round) {
             $rnd = new Round($round);
             $rnd->setStatus($status);
         }
     } else {
         $rnd = new Round($round);
         $rnd->setStatus($status);
     }
 }
Ejemplo n.º 14
0
 /**
  * nextRound 
  * Returns false if there is no next round (you're in the championship round.)
  * Get the round that is one index higher than the current round.
  * 
  * @param Round $round Current round.
  * @return Round
  */
 public function nextRound(Round $round)
 {
     return Round::where('bracket_id', '=', $round->bracket()->first()->id)->where('index', '=', $round->index + 1)->first();
 }
Ejemplo n.º 15
0
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::bind('tournament', function ($key, $route) {
    $tournament = Tournament::find($key);
    if ($tournament == null) {
        App::abort(404);
    } else {
        return $tournament;
    }
});
Route::bind('round', function ($key, $route) {
    $round = Round::find($key);
    if ($round == null) {
        App::abort(404);
    } else {
        return $round;
    }
});
Route::bind('map', function ($key, $route) {
    $round = Map::find($key);
    if ($round == null) {
        App::abort(404);
    } else {
        return $round;
    }
});
Route::bind('scenario', function ($key, $route) {
Ejemplo n.º 16
0
 public static function saveWinners($db)
 {
     if (is_array($_POST['winners'])) {
         $sql = "UPDATE winners SET winners.price = :price, leftToPay = :price WHERE winners.id = :id";
         $stmt = $db->prepare($sql);
         $stmt->bindParam(":price", $price, PDO::PARAM_INT);
         $stmt->bindParam(":id", $id, PDO::PARAM_INT);
         foreach ($_POST['winners'] as $winner) {
             $price = $winner['price'];
             $id = $winner['id'];
             $stmt->execute();
         }
     }
     $sql = "SELECT players.id, places.place FROM players INNER JOIN places ON " . "places.id = players.place WHERE players.name = :name LIMIT 1";
     $stmt = $db->prepare($sql);
     $stmt->bindValue(":name", $_POST['winner']['name'], PDO::PARAM_STR);
     $stmt->execute();
     $winner = $stmt->fetch(PDO::FETCH_ASSOC);
     $sql = "SELECT places.id FROM places WHERE place = :place";
     $stmt = $db->prepare($sql);
     $stmt->bindValue(":place", $_POST['winner']['place'], PDO::PARAM_STR);
     $stmt->execute();
     $place = $stmt->fetchColumn(0);
     if ($place == false) {
         // place doesn't exist
         $sql = "INSERT INTO places (place) VALUES(:place)";
         $stmt = $db->prepare($sql);
         $stmt->bindValue(":place", $_POST['winner']['place'], PDO::PARAM_STR);
         $stmt->execute();
         $place = $db->lastInsertId();
     }
     if ($winner['place'] != $_POST['winner']['place']) {
         // update the place
         $sql = "UPDATE players SET place = :place WHERE id = :id";
         $stmt = $db->prepare($sql);
         $stmt->bindValue(":place", $place, PDO::PARAM_INT);
         $stmt->bindValue(":id", $winner['id'], PDO::PARAM_INT);
         $stmt->execute();
     }
     if ($winner === false) {
         // winner doesn't exist
         $sql = "INSERT INTO winners (name, place) VALUES(:name, :place)";
         $stmt = $db->prepare(':name', $_POST['winner']['name'], PDO::PARAM_STR);
         $stmt->prepare(':place', $place, PDO::PARAM_INT);
         $stmt->execute();
         $winner = $db->lastInsertId();
     }
     $round = new Round($db);
     $rows = $round->getRows();
     $sql = "INSERT INTO winners (player, ticket, date, round, leftToPay, price, status, row) " . "VALUES(:player, :ticket, NOW(), :round, :price, :price, 5, :row)";
     $stmt = $db->prepare($sql);
     $stmt->bindValue(":player", $winner['id'], PDO::PARAM_INT);
     $stmt->bindValue(":ticket", $_POST['winner']['verification'], PDO::PARAM_INT);
     $stmt->bindValue(":round", $round->getId(), PDO::PARAM_INT);
     $stmt->bindValue(":price", $_POST['winner']['price'], PDO::PARAM_INT);
     $stmt->bindValue(":row", $rows, PDO::PARAM_INT);
     $stmt->execute();
     return json_encode(['status' => true]);
 }
Ejemplo n.º 17
0
 public function run()
 {
     Eloquent::unguard();
     $rounds = Round::get();
     $games = array();
     foreach ($rounds as $round) {
         for ($gt = 1; $gt <= $round->tournament()->players()->count() / 2; $gt++) {
             $games[] = array('round' => $round->id, 'slug' => 'T ' . $gt);
         }
     }
     DB::table('games')->truncate();
     DB::table('games')->insert($games);
 }
Ejemplo n.º 18
0
        if (empty($station)) {
            return Response::error('404');
        }
        $teams = Team::all();
        $stationRounds = Round::where('station_id', '=', $station->id)->get();
        $teamsAdded = array();
        $teamslist = array();
        foreach ($stationRounds as $sr) {
            $teamsAdded[] = $sr->team->id;
        }
        foreach ($teams as $team) {
            if (!in_array($team->id, $teamsAdded)) {
                $teamslist[$team->id] = $team->name;
            }
        }
        $rounds = Round::where('station_id', '=', $station->id)->get();
        return View::make('station', array('station' => $station, 'rounds' => $rounds, 'teamslist' => $teamslist));
    });
});
/*
|--------------------------------------------------------------------------
| Application 404 & 500 Error Handlers
|--------------------------------------------------------------------------
|
| To centralize and simplify 404 handling, Laravel uses an awesome event
| system to retrieve the response. Feel free to modify this function to
| your tastes and the needs of your application.
|
| Similarly, we use an event to handle the display of 500 level errors
| within the application. These errors are fired when there is an
| uncaught exception thrown in the application.
Ejemplo n.º 19
0
 /**
  * Attempts to destroy selected round.
  *
  * @param int $id Id of round to be deleted.
  */
 public static function destroy($id)
 {
     $round = new Round(array('id' => $id));
     $round->destroy();
     Redirect::to('/round', array('message' => 'Kierros poistettu.'));
 }
Ejemplo n.º 20
0
 /**
  * Deletes orphaned rows from score_hole table.
  */
 public function clean()
 {
     $courseId = Round::find($this->roundId)->courseId;
     $query = DB::connection()->prepare('DELETE FROM score_hole WHERE holeid IN (SELECT sh.holeid FROM score_hole sh JOIN score s ON s.id = sh.scoreid JOIN hole h ON h.id = sh.holeid WHERE s.id = 1 AND NOT h.courseid = :courseid) AND scoreid IN (SELECT sh.scoreid FROM score_hole sh JOIN score s ON s.id = sh.scoreid JOIN hole h ON h.id = sh.holeid WHERE s.id = 1 AND NOT h.courseid = :courseid)');
     $query->execute(array('courseid' => $courseId));
 }