예제 #1
0
 private function procesarListaPartidos($postJugadorApi, $postJugadorLocal, $postTorneo, &$listaPartidos)
 {
     $selectTorneos = Torneo::model()->selectTorneos();
     $peticionPartidos = ApiChallonge::getPartidoTorneo($postTorneo['idTorneo']);
     $lengthJugadores = count($postJugadorApi);
     for ($i = 0; $i < $lengthJugadores; $i++) {
         $jugadorApi = $postJugadorApi[$i];
         $jugadorLocal = $postJugadorLocal['jugadorId'][$i];
         $idTorneoLocal = $postJugadorLocal['idTorneoVzla'];
         $posicionJugadorLocal = $postJugadorLocal['posicionJugador'][$i];
         $peticionPartidos = str_replace($jugadorApi, $jugadorLocal, $peticionPartidos);
         $posicionJugador = new JugadorPosicionTorneo();
         $posicionJugador->id_jugador = $jugadorLocal;
         $posicionJugador->id_torneo = $idTorneoLocal;
         $posicionJugador->posicion = $posicionJugadorLocal;
         $posicionJugador->save();
     }
     $jsonPartidos = json_decode($peticionPartidos, true);
     $i = 0;
     foreach ($jsonPartidos as $key => $value) {
         $match = $value['match'];
         $player1Id = $match['player1_id'];
         $player2Id = $match['player2_id'];
         $winnerId = $match['winner_id'];
         $ronda = $match['identifier'];
         $numeroRonda = $match['round'];
         $jugadorVzla1 = Jugador::model()->findByPk($player1Id);
         $jugadorVzla2 = Jugador::model()->findByPk($player2Id);
         $ganadorVzla = Jugador::model()->findByPk($winnerId);
         $listaPartidos .= $this->renderPartial('_listaPartidos', array('jsonPartidos' => $jsonPartidos, 'player1Id' => $player1Id, 'player2Id' => $player2Id, 'winnerId' => $winnerId, 'ronda' => $ronda, 'numeroRonda' => $numeroRonda, 'jugadorVzla1' => $jugadorVzla1, 'jugadorVzla2' => $jugadorVzla2, 'ganadorVzla' => $ganadorVzla, 'i' => $i), true, false);
         $i++;
     }
     $listaPartidos .= Chtml::label('ID Torneo SSBMVZLA', 'ResultadoPvP_idTorneoVzla') . '<br/>' . CHtml::dropDownList('ResultadoPvP[idTorneoVzla]', '', $selectTorneos, array('empty' => '')) . '<br/>';
 }
예제 #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Comment the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Jugador::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #3
0
 /**
 * Updates a particular model.
 * If update is successful, the browser will be redirected to the 'view' page.
 * @param integer $id the ID of the model to be updated
 */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $user = Yii::app()->user;
     $selectJugadores = Jugador::model()->selectJugadores();
     $selectTorneos = Torneo::model()->selectTorneos();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['PvpSet'])) {
         $model->attributes = $_POST['PvpSet'];
         if ($model->save()) {
             $user->setFlash('success', "Datos han sido modificados <strong>satisfactoriamente</strong>.");
             $this->redirect(array('admin'));
         }
     }
     $this->render('update', array('model' => $model, 'selectJugadores' => $selectJugadores, 'selectTorneos' => $selectTorneos));
 }
예제 #4
0
파일: PvpSet.php 프로젝트: ednjv/SSBMVZLA
 private function getInactivePlayers($jugadorLastSet, $dias)
 {
     //, $diasRango
     $inactivePlayers = array();
     foreach ($jugadorLastSet as $key => $value) {
         $nick = Jugador::model()->findByPk($key)->nick;
         $lastDate = date('Y-m-d', $value);
         $diff = date_diff(date_create(date('Y-m-d')), date_create($lastDate));
         $diasDiff = intval($diff->format("%a"));
         if ($diasDiff > $dias) {
             // && $diasDiff < $diasRango
             $inactivePlayers[$key] = $value;
         }
     }
     return $inactivePlayers;
 }
예제 #5
0
 protected function verificar_sesion()
 {
     //1. Verifico la sesión para inicializar el juego
     if (!isset(Yii::app()->session['ronda']) || Yii::app()->session['ronda'] == 0) {
         if ($this->_jugador_id == 0) {
             //2. Obtengo el id del jugador
             $jugador = Jugador::model()->find('usuario_id = ' . Yii::app()->user->id);
             $jugador_id = $jugador->id;
             Yii::app()->session['jugador_id'] = $this->_jugador_id = $jugador_id;
         }
         //3. Verifico el  número de rondas que ha jugado hoy para que no juegue más de la cuenta
         $rondasdia = Ronda::model()->getRondasDia($this->_jugador_id);
         $n_rondasdia = count($rondasdia);
         if ($n_rondasdia >= Yii::app()->params['rondasxdia']) {
             Yii::app()->user->setFlash('error', "Ya has jugado " . Yii::app()->params['rondasxdia'] . ' veces el día de hoy, vuelve mañana para que sigas acumulando puntos.');
             $this->redirect('puntajes');
             Yii::app()->end();
         }
         //Verifico el nivel para actualizar el tiempo de cada pregunta
         $pt = Jugador::model()->getPuntos($this->_jugador_id);
         $ronda = new Ronda();
         Yii::app()->session['ronda'] = $this->_ronda = $ronda->iniciarRonda($this->_jugador_id);
         Yii::app()->session['preguntas'] = $this->_preguntas = array();
         Yii::app()->session['ayudas'] = $this->_ayudas = AyudaXRonda::model()->getAyudasDia($rondasdia);
         Yii::app()->session['preguntan'] = $this->_preguntan = 0;
         Yii::app()->session['preguntaid'] = $this->_preguntaid = 0;
         Yii::app()->session['nivel'] = $this->_nivel = 1;
         Yii::app()->session['puntosr'] = $this->_puntosr = 0;
         Yii::app()->session['puntost'] = $this->_puntost = $pt;
         Yii::app()->session['situacion'] = $this->_situacion = 1;
         //1. inicio
         $nivel = Nivel::model()->findByPk($this->_nivel);
         Yii::app()->session['tiempo'] = $this->_tiempo = $nivel->tiempo;
     } else {
         $this->_ronda = Yii::app()->session['ronda'];
         $this->_jugador_id = Yii::app()->session['jugador_id'];
         $this->_preguntas = Yii::app()->session['preguntas'];
         $this->_preguntan = Yii::app()->session['preguntan'];
         $this->_preguntaid = Yii::app()->session['preguntaid'];
         $this->_nivel = Yii::app()->session['nivel'];
         $this->_tiempo = Yii::app()->session['tiempo'];
         $this->_puntosr = Yii::app()->session['puntosr'];
         $this->_puntost = Yii::app()->session['puntost'];
         $this->_situacion = Yii::app()->session['situacion'];
         $this->_ayudas = Yii::app()->session['ayudas'];
     }
 }
예제 #6
0
?>
	<br/>
	<?php 
echo CHtml::dropDownList('ListaJugadorLocal[idTorneoVzla]', '', $selectTorneos);
?>
</div>
<b>Lista de participantes</b>
<?php 
$i = 0;
foreach ($jsonParticipantes as $key => $value) {
    $participant = $value['participant'];
    $idParticipante = $participant['id'];
    $nickParticipante = $participant['name'];
    $rankParticipante = $participant['final_rank'];
    $jugadorLocal = '';
    $busqJugadorVzla = Jugador::model()->find('nick LIKE :nick', array(':nick' => $nickParticipante));
    if ($busqJugadorVzla != null) {
        $jugadorLocal = $busqJugadorVzla->id;
    }
    $arrayJugadorApi = array($idParticipante => $nickParticipante);
    ?>
<div class="row-fluid">
	<div class="col-md-1">
		<div class="form-group">
			<?php 
    echo $rankParticipante;
    ?>
)
		</div>
	</div>
	<div class="col-md-3">
예제 #7
0
 private function validarCuentas()
 {
     if (isset(Yii::app()->session['jugador_id']) && !empty(Yii::app()->session['jugador_id'])) {
         $rj = RespuestaXJugador::model()->find("( TIMESTAMPDIFF(MINUTE,fecha,?) <= ? AND jugador_id <> ? ) AND RTRIM( SUBSTR(ip, 1, (INSTR(ip, ':')-1)) ) = ? ", array(0 => date('Y-m-d G:i:s'), 1 => Yii::app()->params['bloqueo'], 2 => Yii::app()->session['jugador_id'], 3 => $_SERVER['REMOTE_ADDR']));
         if ($rj === null) {
             return true;
         } else {
             return false;
         }
     } else {
         if (Yii::app()->user->id) {
             $jugador = Jugador::model()->find('usuario_id = ' . Yii::app()->user->id);
             if ($jugador != null) {
                 $jugador_id = $jugador->id;
                 Yii::app()->session['jugador_id'] = $jugador_id;
                 if (!empty(Yii::app()->session['jugador_id'])) {
                     $rj = RespuestaXJugador::model()->find("( TIMESTAMPDIFF(MINUTE,fecha,?) <= ? AND jugador_id <> ? ) AND RTRIM( SUBSTR(ip, 1, (INSTR(ip, ':')-1)) ) = ? ", array(0 => date('Y-m-d G:i:s'), 1 => Yii::app()->params['bloqueo'], 2 => Yii::app()->session['jugador_id'], 3 => $_SERVER['REMOTE_ADDR']));
                     if ($rj === null) {
                         return true;
                     } else {
                         return false;
                     }
                 }
             }
         }
         return false;
     }
 }
예제 #8
0
 public function actionGetChart()
 {
     $id = $_POST['id'];
     if ($id != "") {
         $rankJugId = JugadorRanking::model()->findByPk($id);
         $jugador = Jugador::model()->findByPk($rankJugId->id_jugador);
         $sets = PvpSet::model()->chartSets($rankJugId->id_jugador);
         $vsJugador = PvpSet::model()->chartVsJugadores($sets, $jugador->id);
         $ptsVs = PvpSet::model()->chartPtsVs($sets, $jugador->id);
         $this->renderPartial('_chartJug', array('sets' => $sets, 'jugador' => $jugador, 'vsJugador' => $vsJugador, 'ptsVs' => $ptsVs), false, true);
     }
 }
예제 #9
0
 public function actionCompararJugador()
 {
     $jugadorActual = $_GET['jugadorActual'];
     $jugadorComparar = $_GET['jugadorComparar'];
     $modelJugadorVs = Jugador::model()->findByPk($jugadorComparar);
     $personajePrimario = JugadorPersonaje::model()->find(array('condition' => 'id_jugador=:jugadorComparar AND primario=1', 'params' => array(':jugadorComparar' => $jugadorComparar)));
     if ($jugadorActual != $jugadorComparar) {
         $recordVs = Jugador::model()->getRecordVs($jugadorActual, $jugadorComparar);
     } else {
         $recordVs = "0 G - 0 P";
     }
     $allSets = PvpSet::model()->historiaVs($jugadorActual, $jugadorComparar);
     return $this->renderPartial('_vsJugador', array('personajePrimario' => $personajePrimario, 'modelJugadorVs' => $modelJugadorVs, 'recordVs' => $recordVs, 'allSets' => $allSets, 'jugadorActual' => $jugadorActual), false, true);
 }
예제 #10
-1
파일: Jugador.php 프로젝트: ednjv/SSBMVZLA
 public function selectJugadores()
 {
     $model = Jugador::model()->findAll(array('with' => array('idEstado' => array('with' => array('idPais'))), 'select' => array('CONCAT(nick, " (", primer_nombre, " ", primer_apellido, " - ", idEstado.nombre, ", ", idPais.nombre, ")") as primer_nombre', 'id'), 'order' => 'primer_nombre'));
     $lista = CHtml::listdata($model, 'id', 'primer_nombre');
     return $lista;
 }