public function restarPuntosInactividad() { $lastDateJugador1 = PvpSet::getPlayersLastDate('id_jugador_1', 'idJugador1'); $lastDateJugador2 = PvpSet::getPlayersLastDate('id_jugador_2', 'idJugador2'); $jugadoresLastSet = PvpSet::filtrarJugadores($lastDateJugador1, $lastDateJugador2); $inactivePlayers = PvpSet::getInactivePlayers($jugadoresLastSet, 250); // $i = 1; foreach ($inactivePlayers as $key => $value) { $rank = JugadorRankTemp::model()->find(array('condition' => 'id_jugador=:idJugador and status=0', 'params' => array(':idJugador' => $key), 'order' => 'fecha desc')); if ($rank != null) { $puntosPorInactividad = $rank->puntos - 100; echo $i . ") Jugador: " . $rank->idJugador->nick; echo ", Posicion: " . $rank->posicion; echo ", Puntos: " . $rank->puntos; echo ", Puntos por inactividad: " . $puntosPorInactividad; echo "<br>"; $i++; // $rank->status = 0; // $rank->puntos = $puntosPorInactividad; // $rank->save(); } } }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = JugadorRankTemp::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Función para importar los jugadores del ranking temporal al ranking * Todos aquellos jugadores que tengan como status de su ranking 1 (activo) * Pasaran de forma automatica al ranking principal */ public function actionImportRank() { $user = Yii::app()->user; $busqRankTemp = JugadorRankTemp::model()->findAll(array('condition' => 'status=1')); foreach ($busqRankTemp as $rnkTmp) { $newRank = new JugadorRanking(); $newRank->id_jugador = $rnkTmp->id_jugador; $newRank->puntos = $rnkTmp->puntos; $newRank->fecha = date("Y-m-d h:i:s"); $newRank->status = $rnkTmp->status; $newRank->posicion = $rnkTmp->posicion; $newRank->save(); } $user->setFlash('success', "Datos han sido modificados <strong>satisfactoriamente</strong>."); $this->redirect(array('admin')); }
public function calcularPosiciones() { $busqAll = JugadorRankTemp::model()->findAll(array('condition' => 'status=1', 'order' => 'puntos desc')); $i = 1; foreach ($busqAll as $rankJug) { $rankJug->isNewRecord = false; $rankJug->saveAttributes(array('posicion' => $i)); $i++; } }