Esempio n. 1
1
 public function recalculateTable()
 {
     $teamList = team::getAllTeams();
     foreach ($teamList as $team) {
         $this->teams[$team->id]['name'] = $team->name;
         $this->teams[$team->id]['point'] = 0;
         $this->teams[$team->id]['played'] = 0;
         $this->teams[$team->id]['win'] = 0;
         $this->teams[$team->id]['draw'] = 0;
         $this->teams[$team->id]['loose'] = 0;
         $this->teams[$team->id]['average'] = 0;
     }
     $matches = match::getAllMatchs();
     foreach ($matches as $match) {
         if ($match->score->firstTeam == null || $match->score->secondTeam == null) {
             continue;
         }
         $this->teams[$match->team1]['played']++;
         $this->teams[$match->team2]['played']++;
         if ($match->score->winner === 1) {
             $this->teams[$match->team1]['win']++;
             $this->teams[$match->team2]['loose']++;
             $this->teams[$match->team1]['point'] += 3;
         } else {
             if ($match->score->winner === 2) {
                 $this->teams[$match->team1]['loose']++;
                 $this->teams[$match->team2]['win']++;
                 $this->teams[$match->team2]['point'] += 3;
             } else {
                 $this->teams[$match->team1]['draw']++;
                 $this->teams[$match->team2]['draw']++;
                 $this->teams[$match->team1]['point']++;
                 $this->teams[$match->team2]['point']++;
             }
         }
         $average = $match->score->firstTeam - $match->score->secondTeam;
         $this->teams[$match->team1]['average'] += $average;
         $this->teams[$match->team2]['average'] -= $average;
     }
 }
 /**
  * @return array
  */
 public function load()
 {
     $request = new request(self::steam_matches_url, $this->_get_data_array());
     $xml = $request->send();
     if (is_null($xml)) {
         return null;
     }
     $matches = array();
     if (isset($xml->matches)) {
         $this->_total_results = $xml->total_results;
         foreach ($xml->matches as $m_matches) {
             foreach ($m_matches as $m) {
                 $match = new match();
                 $match->set_array((array) $m);
                 foreach ($m->players as $players) {
                     foreach ($players as $player) {
                         $slot = new slot();
                         $slot->set_array((array) $player);
                         $match->add_slot($slot);
                     }
                 }
                 $matches[$match->get('match_id')] = $match;
             }
         }
     }
     return $matches;
 }
 /**
  * Load match info by match_id
  */
 public function load()
 {
     $request = new request(self::steam_match_url, array('match_id' => $this->get_match_id()));
     $match_info = $request->send();
     if (is_null($match_info)) {
         return null;
     }
     $match = new match();
     $players = array();
     foreach ($match_info->players->player as $key => $player) {
         $players[] = $player;
     }
     $data = (array) $match_info;
     unset($data['players']);
     $data['start_time'] = date('Y-m-d H:i:s', $data['start_time']);
     $data['radiant_win'] = $data['radiant_win'] == 'true' ? '1' : '0';
     $match->set_array($data);
     // slots info
     foreach ($players as $player) {
         $data = (array) $player;
         $data['match_id'] = $this->get_match_id();
         $slot = new slot();
         $slot->set_array($data);
         // additional_units
         if (isset($data['additional_units'])) {
             $slot->set_additional_unit_items((array) $data['additional_units']->unit);
         }
         // abilities
         if (isset($data['ability_upgrades'])) {
             $d = (array) $data['ability_upgrades'];
             $abilities_upgrade = $d['ability'];
             if (!is_array($abilities_upgrade)) {
                 $abilities_upgrade = array($abilities_upgrade);
             }
             foreach ($abilities_upgrade as $k => $v) {
                 $abilities_upgrade[$k] = (array) $abilities_upgrade[$k];
             }
             $slot->set_abilities_upgrade($abilities_upgrade);
         }
         $match->add_slot($slot);
     }
     if (isset($match_info->picks_bans)) {
         $picks_bans = (array) $match_info->picks_bans;
         foreach ($picks_bans['pick_ban'] as $k => $v) {
             $picks_bans['pick_ban'][$k] = (array) $v;
             if ($picks_bans['pick_ban'][$k]['is_pick'] == 'false') {
                 $picks_bans['pick_ban'][$k]['is_pick'] = '0';
             } else {
                 $picks_bans['pick_ban'][$k]['is_pick'] = '1';
             }
         }
         $match->set_all_pick_bans($picks_bans['pick_ban']);
     }
     return $match;
 }
 /**
  * Load matches from db
  *
  * Possible filters: league_id, hero_id, account_id, start_at_match_id
  * Also matches_requested used as LIMIT
  * @return array
  */
 public function load()
 {
     $matches_info = $this->_get_matches_ids_from_matches();
     $matches_ids = array();
     foreach ($matches_info as $match_info) {
         array_push($matches_ids, $match_info['match_id']);
     }
     if (count($matches_ids) == 0) {
         return array();
     }
     $slots_info = $this->_load_slots_info($matches_ids);
     $picks_bans_formatted_info = $this->_load_picks_bans_info($matches_ids);
     $slots_ids = array();
     foreach ($slots_info as $slot_info) {
         array_push($slots_ids, $slot_info['id']);
     }
     $abilities_upgrade_formatted_info = $this->_load_ability_upgrades_info($slots_ids);
     $additional_units_formatted_info = $this->_load_additional_units_info($slots_ids);
     // we load all matches info and now need to make proper match objects
     $matches = array();
     foreach ($matches_info as $match_info) {
         $match = new match();
         $match->set_array($match_info);
         $slots_count = 0;
         foreach ($slots_info as $slot_info) {
             if ($slots_count > 9) {
                 // match can't has more than 10 slots
                 break;
             }
             if ($slot_info['match_id'] == $match->get('match_id')) {
                 $slot = new slot();
                 $slot->set_array($slot_info);
                 if (isset($abilities_upgrade_formatted_info[$slot->get('id')])) {
                     $slot->set_abilities_upgrade($abilities_upgrade_formatted_info[$slot->get('id')]);
                 }
                 if (isset($additional_units_formatted_info[$slot->get('id')])) {
                     $slot->set_additional_unit_items($additional_units_formatted_info[$slot->get('id')]);
                 }
                 $match->add_slot($slot);
                 $slots_count++;
             }
         }
         if (isset($picks_bans_formatted_info[$match->get('match_id')])) {
             $match->set_all_pick_bans($picks_bans_formatted_info[$match->get('match_id')]);
         }
         $matches[$match->get('match_id')] = $match;
     }
     return $matches;
 }
function read_matches($file_name)
{
    $db = new db_base();
    $handle = fopen($file_name, "r");
    if ($handle) {
        while (($line = fgets($handle)) !== false) {
            $result = json_decode($line);
            $match = new match();
            $match->insert_json($db, $result, null, null, null);
        }
        fclose($handle);
    } else {
        echo "cant open this f*****g file";
    }
}
Esempio n. 6
0
 public function cash()
 {
     $this->live_cash = 0;
     $this->played = 0;
     $this->cash = 0;
     $this->transactions = transaction::from_account($this->account_id);
     # här kommer transaktionerna
     foreach ($this->transactions as $transaction) {
         $transactions[] = $transaction;
         if ($transaction->type == "cash_in") {
             $this->cash += $transaction->amount;
         } elseif ($transaction->type == "bonus") {
             $this->cash += $transaction->amount;
         } elseif ($transaction->type == "cash_out") {
             $this->cash -= $transaction->amount;
         }
     }
     # här kommer betsen
     $this->bets = bet::from_account($this->account_id);
     foreach ($this->bets as $bet) {
         $bet->match = match::from_id($bet->match_id);
         $bet->account = account::from_id($bet->account_id);
         $bet->account->site = site::from_id($bet->account->site_id);
         $this->played += $bet->bet;
         if ($bet->match->result == "undecided") {
             $this->live_cash += $bet->bet;
             $this->cash -= $bet->bet;
         } else {
             $this->cash -= $bet->bet;
             $this->cash += $bet->result;
         }
     }
     return $this->cash;
 }
Esempio n. 7
0
 public function playWeek($week)
 {
     $matchs = match::getMatchsByWeek($week);
     foreach ($matchs as $match) {
         $match->calculateScore();
         $match->saveMatch();
     }
 }
Esempio n. 8
0
 function create()
 {
     $id = $_GET['user_id'];
     $user = user::from_id($id);
     $user->accounts = account::from_user($user->user_id);
     foreach ($user->accounts as $account) {
         $account->cash();
     }
     $matches = match::all_active();
     $data['matches'] = $matches;
     $data['accounts'] = $user->accounts;
     $this->view('bets/create_view.php', $data, 'main_template.php');
 }
Esempio n. 9
0
 public function selectByNumber($con, $compid, $number)
 {
     base::checkcon($con, __FUNCTION__);
     $sql = "select ID from matches where CompetitionID = {$compid} and Number = {$number}";
     $result = mysqli_query($con, $sql);
     if (!$result) {
         die('Error: ' . mysqli_error($con));
     }
     $row = mysqli_fetch_array($result);
     if ($row == null) {
         return null;
     } else {
         return match::select($con, $row['ID']);
     }
 }
Esempio n. 10
0
 function __construct($title)
 {
     global $site;
     global $config;
     global $tmpl;
     if (!isset($site)) {
         require_once dirname(dirname(dirname(__FILE__))) . '/site.php';
         $site = new site();
     }
     include dirname(__FILE__) . '/classes/match.php';
     $matchClass = new match();
     // accessible by public (show..)
     // find out which template should be used
     if (user::getCurrentUserId() < 0) {
         $matchClass->displayMatches();
         $tmpl->display();
         return;
     }
     // setup permissions for templates
     $tmpl->assign('canEnterMatch', $user->getPermission('allow_add_match'));
     $tmpl->assign('canEditMatch', $user->getPermission('allow_edit_match'));
     $tmpl->assign('canDeleteMatch', $user->getPermission('allow_delete_match'));
     if (isset($_GET['enter'])) {
         require_once dirname(__FILE__) . '/matchEnter.php';
         new matchEnter();
     } elseif (isset($_GET['edit'])) {
         require_once dirname(__FILE__) . '/matchEdit.php';
         new matchEdit();
     } elseif (isset($_GET['delete'])) {
         require_once dirname(__FILE__) . '/matchDelete.php';
         new matchDelete();
     } else {
         $matchClass->displayMatches();
     }
     $tmpl->display();
 }
Esempio n. 11
0
 function result()
 {
     $match_id = $_GET['match_id'];
     $match = match::from_id($match_id);
     $result = $_GET['result'];
     $match->result = $result;
     $match->update();
     $bets = bet::from_match($match_id);
     foreach ($bets as $bet) {
         $bet->account = account::from_id($bet->account_id);
         #$bet->account->site=site::from_id($bet->account->site_id);
         if ($bet->choice == $result) {
             $bet->result = $bet->bet * $bet->odds;
         } else {
             $bet->result = 0;
         }
         $bet->update();
     }
     header("location:index.php");
 }
Esempio n. 12
0
 function home()
 {
     $masters = master::all();
     $data['masters'] = $masters;
     $data['total'] = 0;
     foreach ($masters as $master) {
         $data['total'] += $master->cash;
     }
     $users = user::all();
     foreach ($users as $user) {
         $user->accounts = account::from_user($user->user_id);
         $bets = array();
         $user->calculation['cash_in'] = 0;
         $user->calculation['cash_out'] = 0;
         $user->calculation['bonus'] = 0;
         foreach ($user->accounts as $account) {
             # räkna ut alla pengar
             $account->transactions = transaction::from_account($account->account_id);
             foreach ($account->transactions as $transaction) {
                 $transactions[] = $transaction;
                 if ($transaction->type == "cash_in") {
                     $user->calculation['cash_in'] += $transaction->amount;
                 } elseif ($transaction->type == "bonus") {
                     $user->calculation['bonus'] += $transaction->amount;
                 } elseif ($transaction->type == "cash_out") {
                     $user->calculation['cash_out'] -= $transaction->amount;
                 }
             }
             $account->cash();
         }
     }
     $data['users'] = $users;
     $sites = site::all();
     $data['sites'] = $sites;
     $matches = match::all_active();
     $data['matches'] = $matches;
     $this->view('index_view.php', $data, 'main_template.php');
 }
Esempio n. 13
0
 function profile()
 {
     $id = $_GET['user_id'];
     $user = user::from_id($id);
     $user->accounts = account::from_user($user->user_id);
     $bets = array();
     $calculation['cash_in'] = 0;
     $calculation['cash_out'] = 0;
     $calculation['bonus'] = 0;
     foreach ($user->accounts as $account) {
         # räkna ut alla pengar
         $account->transactions = transaction::from_account($account->account_id);
         foreach ($account->transactions as $transaction) {
             $transactions[] = $transaction;
             if ($transaction->type == "cash_in") {
                 $calculation['cash_in'] += $transaction->amount;
             } elseif ($transaction->type == "bonus") {
                 $calculation['bonus'] += $transaction->amount;
             } elseif ($transaction->type == "cash_out") {
                 $calculation['cash_out'] -= $transaction->amount;
             }
         }
         $account->cash();
     }
     $bets = bet::from_user($id);
     foreach ($bets as $bet) {
         $bet->match = match::from_id($bet->match_id);
         $bet->account = account::from_id($bet->account_id);
         $bet->account->site = site::from_id($bet->account->site_id);
     }
     $data['calculation'] = $calculation;
     $data['user'] = $user;
     $data['bets'] = $bets;
     if (!empty($transactions)) {
         $data['transactions'] = $transactions;
     }
     $this->view('users/profile_view.php', $data, 'main_template.php');
 }
Esempio n. 14
0
        <td><input type="checkbox" name="didnotmove" <?php 
check($game->DidNotMove);
?>
  disabled /></td>
        <td>Did Not Move</td>
      </tr>
  </table>

  <label class="subject" title="Any other important information about robot to record">Comment</label><br/>
  <textarea rows="4" cols="60" name="Comment" disabled><?php 
echo $game->Comment;
?>
</textarea>
  <br/>

<?php 
$nmatch = match::selectByNumber($con, $compid, $game->MatchNumber + 1);
if ($nmatch != null) {
    if ($color == 'red') {
        $nteam = $nmatch->RedAlliance->{$slot};
    } else {
        $nteam = $nmatch->BlueAlliance->{$slot};
    }
    echo "<a href='score-game.php?match={$nmatch->ID}&team={$nteam}'>Continue</a>\n";
} else {
    include 'navbar.php';
}
include 'footer.php';
?>

Esempio n. 15
0
 protected function _getStatusString()
 {
     $str = match::statuses($this->status);
     if ($str == '') {
         return 'Unknown Status: ' . $this->status;
     }
     return $str;
 }
Esempio n. 16
0
<?
    //WEBSITE STARTUP
    include_once('../../includes/class.init.php');
    include_once('../../includes/class.match.php');

    $init = new init(1,0,0);
    $settings = new settings();

    $match = new match($settings, $init->errorClass, $init->notificationClass, $init->repository->get_data("matchId"));
    $match->getData();
?>

<div class="modal-dialog">
    <div class="modal-content">
        <form action="compPairing.php" method="post" role="form">
            <input type="hidden" name="seizoen" value="<?php 
echo $init->repository->get_data("seizoen");
?>
">
            <input type="hidden" name="competitie" value="<?php 
echo $init->repository->get_data("competitie");
?>
">
            <input type="hidden" name="ronde" value="<?php 
echo $init->repository->get_data("round");
?>
">
            <input type="hidden" name="matchId" value="<?php 
echo $init->repository->get_data("matchId");
?>
">
Esempio n. 17
0
                    print ", ";
                }
                print "{$property} = {$value}";
                $first = false;
            }
        }
        print "\n";
    }
}
function reportMatch($match)
{
    $red = $match->RedAlliance;
    $blue = $match->BlueAlliance;
    printf("{$match->ID}, {$match->Time}, {$match->Number}, {$red->TeamOne}, {$red->TeamTwo}, {$red->TeamThree}, " . "{$blue->TeamOne}, {$blue->TeamTwo}, {$blue->TeamThree}, {$red->Points}, {$blue->Points}\n");
}
$match = match::select($con, 42);
$team = team::selectTeam($con, 1425);
// reportMatch($match);
if ($match == null) {
    die("match not found.");
}
if ($team == null) {
    die("team not found.");
}
// reportMatch($match);
printf("match = %s, team = %s\n", $match->ID, $match->Number);
/*
$game = new game();
$game->MatchID = $match->ID;
$game->MatchNumber = $match->Number;
$game->TeamNumber = $team->Number;
Esempio n. 18
0
 protected function deleteTeam()
 {
     global $site;
     global $tmpl;
     // perform sanity checks
     if (($result = $this->sanityCheck()) !== true) {
         $tmpl->assign('error', $result === false ? 'An unknown error occurred while checking your request' : $result);
         return;
     }
     // notify team members using a private message first because later we won't have the membership info
     $pm = new pm();
     $pm->setSubject(\user::getCurrentUser()->getName() . ' deleted ' . $this->team->getName());
     $pm->setContent('Player ' . \user::getCurrentUser()->getName() . ' just deleted the team ' . $this->team->getName() . ' you were member of.');
     $pm->setTimestamp(date('Y-m-d H:i:s'));
     $pm->addTeamID($this->team->getID());
     // send it
     $pm->send();
     // remove the members from team
     $members = $this->team->getUsers();
     foreach ($members as $member) {
         $member->removeTeamMembership($this->team->getID());
         $member->update();
     }
     unset($members);
     unset($member);
     // if team never matched deleted it from database, otherwise just mark it as deleted
     require_once $site->installationPath() . '/CMS/classes/match.php';
     $matchCount = \match::getMatchCountForTeamId($this->team->getID());
     if ($matchCount > 0 || $matchCount === false) {
         // set the teams status to deleted
         $this->team->setStatus('deleted');
         $deletionTask = $this->team->update();
     } else {
         // actually delete team
         $deletionTask = $this->team->delete();
     }
     if (!$deletionTask) {
         $tmpl->assign('error', 'An unknown error occurred while deleting the team.');
     } else {
         // tell joined user that deletion was successful
         $tmpl->assign('teamDeleteSuccessful', true);
     }
 }
Esempio n. 19
0
 /**
  * Response when updating role succeed.
  *
  * @param  \Orchestra\Model\Role  $role
  *
  * @return mixed
  */
 public function destroySucceed(match $match)
 {
     $message = trans('orchestra/control::response.roles.delete', ['name' => $match->getAttribute('name')]);
     return $this->redirectWithMessage(handles('orchestra::match'), $message);
 }
Esempio n. 20
0
<?php 
require_once 'lib/db.php';
require_once 'lib/competition.php';
require_once 'lib/team.php';
require_once 'lib/game.php';
$con = DB::connect();
$matchid = $_GET["match"];
$match = match::select($con, $matchid);
$number = $match->Number;
session_start();
$compid = $_SESSION["competitionid"];
$comp = competition::select($con, $compid);
$prevmatch = match::selectByNumber($con, $compid, $number - 1);
$nextmatch = match::selectByNumber($con, $compid, $number + 1);
include 'header.php';
include 'navbar.php';
$red = $match->RedAlliance;
$blue = $match->BlueAlliance;
?>

<label class="heading">Match <?php 
echo $number;
?>
</label><br/>
<br/>
<table class='scout_table'>
  <tr>
    <td class='team red'><?php 
echo $red->TeamOne;
?>
</td>
Esempio n. 21
0
<?php

set_include_path("../src/");
require_once 'lib/db.php';
require_once 'lib/team.php';
require_once 'lib/match.php';
require_once 'lib/alliance.php';
require_once 'lib/competition.php';
//---------------------------------------------------------------------------//
$con = DB::connect();
$matchid = $argv[1];
printf("Match {$id}\n");
$match = match::select($con, $matchid);
$red = $match->RedAlliance;
$blue = $match->BlueAlliance;
printf("{$match->Time}, {$match->Number}, {$red->TeamOne}, {$red->TeamTwo}, {$red->TeamThree}, " . "{$blue->TeamOne}, {$blue->TeamTwo}, {$blue->TeamThree}, {$red->Points}, {$blue->Points}\n");
Esempio n. 22
0
if (is_array($compRounds)) {
    foreach ($compRounds as $round) {
        if ($round["ronde"] == $_GET["ronde"]) {
            $compData = date("d/m/Y", strtotime($round["datum"]));
        }
    }
}
//Processing PGN
if ($init->repository->get_data("pgnText") && $init->repository->get_data("matchId")) {
    include_once '../../includes/class.match.php';
    $pgnMatch = new match($settings, $init->errorClass, $init->notificationClass, $init->repository->get_data("matchId"));
    $pgnMatch->setPGN($init->repository->get_data("pgnText"), $init->repository->get_data("matchId"), $init->repository->get_data("pgnId"));
}
if ($init->repository->get_data("pgnRemove")) {
    include_once '../../includes/class.match.php';
    $pgnMatch = new match($settings, $init->errorClass, $init->notificationClass, $init->repository->get_data("matchId"));
    $pgnMatch->removePGN($init->repository->get_data("pgnRemove"));
}
?>
<link href="../css/select2.css" rel="stylesheet"/>
<script src="../js/select2.min.js"></script>
<script src="../js/jquery.maskedinput.js"></script>
<script>
    $(function() {
        $( "#date" ).datepicker({dateFormat: "dd/mm/yy" });
        $( "#date" ).mask("99/99/9999");
        $("#playerWhite,#playerBlack").select2({
            placeholder: "Selecteer een speler",
            allowClear: true});

Esempio n. 23
0
 /**
  * @param match $match
  * @param bool $lazy if true - update all data, if false - only possible updated data
  */
 public function update($match, $lazy = true)
 {
     $db = db::obtain();
     $slots = $match->get_all_slots();
     // update common match info
     $db->update_pdo(db::real_tablename('matches'), $match->get_data_array(), array('match_id' => $match->get('match_id')));
     foreach ($slots as $slot) {
         // update accounts
         $db->update_pdo(db::real_tablename('users'), array('account_id' => $slot->get('account_id'), 'steamid' => player::convert_id($slot->get('account_id'))), array('account_id' => $slot->get('account_id')));
         // update slots
         if (!$lazy) {
             $db->update_pdo(db::real_tablename('slots'), $slot->get_data_array(), array('match_id' => $slot->get('match_id'), 'player_slot' => $slot->get('player_slot')));
         }
     }
 }