Rangliste almost done
This commit is contained in:
parent
12651fc2e8
commit
43fd8c8cbf
579 changed files with 172489 additions and 127 deletions
|
|
@ -4,6 +4,8 @@ namespace App;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use DB;
|
||||
use Carbon;
|
||||
use Log;
|
||||
|
||||
class Tipp extends Model
|
||||
{
|
||||
|
|
@ -11,17 +13,98 @@ class Tipp extends Model
|
|||
'id', 'user_id', 'game_id','score1','score2','joker'
|
||||
];
|
||||
|
||||
public static function getTipp($game_id, $user_id) {
|
||||
// get tendency Color
|
||||
public static function getCol($user_id,$game_id) {
|
||||
$tipp=Tipp::getTipp($user_id,$game_id);
|
||||
$game = Game::where('id',$tipp->game_id)->first();
|
||||
|
||||
$tippTendenz = $tipp->score1 - $tipp->score2;
|
||||
if ($tippTendenz > 0) {$tippTendenz=1;}
|
||||
if ($tippTendenz < 0) {$tippTendenz=-1;}
|
||||
|
||||
$gameTendenz = $game->score1 - $game->score2;
|
||||
if ($gameTendenz<0) {$gameTendenz=-1;}
|
||||
if ($gameTendenz>0) {$gameTendenz=1;}
|
||||
|
||||
if ($tippTendenz!=$gameTendenz || $game->score1 ==-1 || $game->score2==-1 || $tipp->score1 == -1 || $tipp->score2==-1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$styling='background-color:grey;';
|
||||
|
||||
if ( ($tipp->score1 == $game->score1) && ($tipp->score2 == $game->score2) ) {
|
||||
$styling='background-color:orange;';
|
||||
if ($tipp->joker==true) {
|
||||
$styling='background-color:red';
|
||||
}
|
||||
}
|
||||
return $styling;
|
||||
|
||||
}
|
||||
|
||||
public static function getTipp( $user_id,$game_id) {
|
||||
//Log::info("getTipp for game_id, user_id = ".$game_id.",".$user_id);
|
||||
return DB::table('tipps')->where([
|
||||
['user_id','=',$user_id],
|
||||
['game_id','=',$game_id]
|
||||
])->first();
|
||||
}
|
||||
|
||||
public static function getScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker) {
|
||||
$score=0;
|
||||
$tippTendenz = $tipp1 - $tipp2;
|
||||
if ($tippTendenz > 0) {$tippTendenz=1;}
|
||||
if ($tippTendenz < 0) {$tippTendenz=-1;}
|
||||
|
||||
$gameTendenz = $goals1 - $goals2;
|
||||
if ($gameTendenz<0) {$gameTendenz=-1;}
|
||||
if ($gameTendenz>0) {$gameTendenz=1;}
|
||||
|
||||
if ($tippTendenz==$gameTendenz) { $score=1; }
|
||||
|
||||
|
||||
if ( ($tipp1 == $goals1) && ($tipp2 == $goals2) ) {
|
||||
$bonus = max(0,$goals1 + $goals2 - 3);
|
||||
$score= 2 + $bonus;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($joker==true) {
|
||||
$score = $score * 2;
|
||||
}
|
||||
|
||||
if ($tipp1==-1||$tipp2==-1||$goals1==-1||$goals2==-1) { $score=0; }
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function getTippScore($user_id,$game_id, $team=0) {
|
||||
//Log::info("Getting tippstring for game_id=". $game_id .", user_id=" . $user_id.", $team=".$team);
|
||||
|
||||
$tipp=Tipp::getTipp($user_id,$game_id);
|
||||
if (!$tipp) {
|
||||
//Log::info("not found !");
|
||||
return "x";
|
||||
}
|
||||
|
||||
$tippScore="";
|
||||
if ($team==0) { $tippScore= $tipp->score1;}
|
||||
else { $tippScore=$tipp->score2; }
|
||||
if ($tippScore==-1) { /*Log::info("untipped!");*/$tippScore="x";}
|
||||
|
||||
//Log::info("Returning: ". $tippScore);
|
||||
return $tippScore;
|
||||
}
|
||||
|
||||
public static function getScore($tipp_id) {
|
||||
$tipp = Tipp::where('id',$tipp_id)->first();
|
||||
$game = Game::where('id',$tipp->game_id)->first();
|
||||
|
||||
$bonus = max(0,$game->score1 + $game->score2 - 3);
|
||||
|
||||
$tippTendenz = $tipp->score1 - $tipp->score2;
|
||||
if ($tippTendenz > 0) {$tippTendenz=1;}
|
||||
if ($tippTendenz < 0) {$tippTendenz=-1;}
|
||||
|
|
@ -35,7 +118,7 @@ class Tipp extends Model
|
|||
if ($tippTendenz == $gameTendenz) { $score=1; }
|
||||
|
||||
if ( ($tipp->score1 == $game->score1) && ($tipp->score2 == $game->score2) ) {
|
||||
$score=2;
|
||||
$score=2 + $bonus;
|
||||
}
|
||||
|
||||
if ($tipp->joker==true) {
|
||||
|
|
@ -43,7 +126,16 @@ class Tipp extends Model
|
|||
}
|
||||
|
||||
if ($game->score1 == -1) { $score=0; }
|
||||
if ($tipp->score1==-1 || $tipp->score2==-1) {$score=0;}
|
||||
|
||||
return $score;
|
||||
}
|
||||
|
||||
public static function resultString($tipp_id) {
|
||||
$tipp = Tipp::where('id',$tipp_id)->first();
|
||||
$rStr="Ungetippt";
|
||||
if ($tipp->score1 > -1) $rStr= $tipp->score1 . " : " . $tipp->score2;
|
||||
|
||||
return $rStr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue