|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* rmarchiv.tk |
|
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace App\Http\Controllers\Api\v1; |
|
9
|
|
|
|
|
10
|
|
|
use Carbon\Carbon; |
|
11
|
|
|
use App\Models\Game; |
|
12
|
|
|
use App\Models\GamesFile; |
|
13
|
|
|
use App\Models\GamesDeveloper; |
|
14
|
|
|
use App\Models\PlayerFileHash; |
|
15
|
|
|
use App\Http\Controllers\Controller; |
|
16
|
|
|
use App\Models\PlayerFileGamefileRel; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class EasyRPGController |
|
20
|
|
|
* @package App\Http\Controllers\Api\v1 |
|
21
|
|
|
* |
|
22
|
|
|
* Class for EasyRPG related stuff |
|
23
|
|
|
*/ |
|
24
|
|
|
class EasyRPGController extends Controller |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* return index of all gamefile_ids with filehash |
|
28
|
|
|
* @return array |
|
29
|
|
|
*/ |
|
30
|
|
|
public function index() |
|
31
|
|
|
{ |
|
32
|
|
|
$hashes = PlayerFileGamefileRel::where('orig_filename', 'like', '%rpg_rt.ldb%') |
|
33
|
|
|
->join('player_file_hashes', 'player_file_hashes.id', 'player_file_gamefile_rel.file_hash_id') |
|
34
|
|
|
->select([ |
|
35
|
|
|
'player_file_gamefile_rel.gamefile_id', |
|
36
|
|
|
'player_file_hashes.filehash', |
|
37
|
|
|
]) |
|
38
|
|
|
->get(); |
|
39
|
|
|
|
|
40
|
|
|
$array = [ |
|
41
|
|
|
'type' => 'hashlist', |
|
42
|
|
|
'count' => $hashes->count(), |
|
43
|
|
|
'data' => $hashes->toArray(), |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
|
|
return $array; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param $ldbhash |
|
51
|
|
|
* @return array |
|
52
|
|
|
*/ |
|
53
|
|
|
public function show($ldbhash) |
|
54
|
|
|
{ |
|
55
|
|
|
$hashid = PlayerFileHash::whereFilehash($ldbhash)->first()->id; |
|
|
|
|
|
|
56
|
|
|
$gamefileid = PlayerFileGamefileRel::whereFileHashId($hashid)->first()->gamefile_id; |
|
57
|
|
|
$gamefile = GamesFile::whereId($gamefileid)->first(); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
//Lade Spielinformationen |
|
60
|
|
|
$game = Game::whereId($gamefile->game_id)->first(); |
|
61
|
|
|
|
|
62
|
|
|
//Fülle Array |
|
63
|
|
|
$array = [ |
|
64
|
|
|
'type' => 'RpgGame', |
|
65
|
|
|
'version' => 'rmapi_v1', |
|
66
|
|
|
'data_date' => Carbon::now()->toDateTimeString(), |
|
67
|
|
|
'data' => [ |
|
68
|
|
|
'identifier' => $ldbhash, |
|
69
|
|
|
'title' => $game->title, |
|
70
|
|
|
'subtitle' => $game->subtitle, |
|
71
|
|
|
'release_date' => Carbon::create($gamefile->release_year, $gamefile->release_month, $gamefile->release_day)->toDateString(), |
|
72
|
|
|
'developers' => '', |
|
73
|
|
|
'language' => $game->language->short, |
|
74
|
|
|
'engine' => $game->maker->short, |
|
75
|
|
|
'release_type' => $gamefile->gamefiletype->short, |
|
76
|
|
|
'files' => '', |
|
77
|
|
|
], |
|
78
|
|
|
]; |
|
79
|
|
|
|
|
80
|
|
|
//Lade Entwickler |
|
81
|
|
|
$developer = GamesDeveloper::whereGameId($game->id)->get(); |
|
|
|
|
|
|
82
|
|
|
$t = []; |
|
|
|
|
|
|
83
|
|
|
foreach ($developer as $dev) { |
|
84
|
|
|
$t[] = $dev->developer->name; |
|
85
|
|
|
} |
|
86
|
|
|
$array['data']['developers'] = $t; |
|
87
|
|
|
|
|
88
|
|
|
//Lade Dateien |
|
89
|
|
|
$files = PlayerFileGamefileRel::whereGamefileId($gamefileid)->get(); |
|
|
|
|
|
|
90
|
|
|
$t = []; |
|
|
|
|
|
|
91
|
|
|
foreach ($files as $f) { |
|
92
|
|
|
$t[$f->orig_filename] = $f->filehash->filehash; |
|
93
|
|
|
} |
|
94
|
|
|
$array['data']['files'] = $t; |
|
95
|
|
|
|
|
96
|
|
|
return $array; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.