Skip to content

Commit e6fcdb2

Browse files
authored
Merge pull request #1533 from Lan2Play/feature/3-3-0
Milestone 3.3.0
2 parents 1630ccb + 27b1a4a commit e6fcdb2

File tree

67 files changed

+7115
-5553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+7115
-5553
lines changed

src/.phpstorm.meta.php

Lines changed: 447 additions & 373 deletions
Large diffs are not rendered by default.

src/_ide_helper.php

Lines changed: 4428 additions & 4361 deletions
Large diffs are not rendered by default.

src/app/Event.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class Event extends Model
4242
'private_participants',
4343
'matchmaking_enabled',
4444
'tournaments_freebies',
45-
'tournaments_staff'
45+
'tournaments_staff',
46+
'tickettype_hide_policy'
4647
];
4748

4849
public const STATUS_PUBLISHED = 'PUBLISHED';

src/app/GameMatchApiHandler.php

Lines changed: 238 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace App;
44

5-
use Exception;
6-
use Illuminate\Http\Request;
7-
use App\MatchMaking;
85
use App\EventTournament;
6+
use App\MatchMaking;
97
use App\MatchReplay;
8+
use Exception;
9+
use Illuminate\Http\Request;
1010
use Illuminate\Support\Facades\Storage;
1111
use Auth;
1212

@@ -18,6 +18,7 @@ public static function getGameMatchApiHandlerSelectArray()
1818
"0" => "None",
1919
"1" => "Get5",
2020
"2" => "PugSharp",
21+
"3" => "PugSharp 2v2",
2122
);
2223
return $return;
2324
}
@@ -29,6 +30,8 @@ public function getGameMatchApiHandler($matchApiHandlerId): IGameMatchApiHandler
2930
return new Get5MatchApiHandler();
3031
case "2":
3132
return new PugSharpMatchApiHandler();
33+
case "3":
34+
return new PugSharpMatchApiHandler2v2();
3235
default:
3336
throw new Exception("MatchApiHandler \"" . GameMatchApiHandler::getGameMatchApiHandlerSelectArray()[$matchApiHandlerId] . "\" is not able to execute commands.");
3437
}
@@ -534,3 +537,235 @@ public function uploaddemo(Request $request, MatchMaking $match = null, EventTou
534537
return false;
535538
}
536539
}
540+
541+
542+
class PugSharpMatchApiHandler2v2 implements IGameMatchApiHandler
543+
{
544+
private $result;
545+
546+
public function __construct()
547+
{
548+
$this->result = new \stdClass();
549+
$this->result->maplist = array(
550+
"de_rooftop",
551+
"de_overpass",
552+
"de_vertigo",
553+
"de_nuke",
554+
"de_inferno"
555+
);
556+
$this->result->max_rounds = 16;
557+
$this->result->max_overtime_rounds = 6;
558+
}
559+
560+
public function getuserthirdpartyrequirements()
561+
{
562+
$return = array(
563+
"thirdpartyid" => "steamid",
564+
"thirdpartyname" => "steamname",
565+
);
566+
return $return;
567+
}
568+
569+
public function addteam($name)
570+
{
571+
if (!isset($this->result->team1)) {
572+
$this->result->team1 = new \stdClass();
573+
$this->result->team1->name = $name;
574+
$this->result->team1->tag = $name;
575+
} elseif (!isset($this->result->team2)) {
576+
$this->result->team2 = new \stdClass();
577+
$this->result->team2->name = $name;
578+
$this->result->team2->tag = $name;
579+
} else {
580+
throw new Exception("MatchApiHandler for PugSharp does not support more than 2 Teams!");
581+
}
582+
}
583+
584+
public function addplayer($teamName, $thirdpartyid, $thirdpartyname, $userid, $username)
585+
{
586+
$team = null;
587+
588+
if ($teamName == $this->result->team1->name) {
589+
$team = $this->result->team1;
590+
} elseif ($teamName == $this->result->team2->name) {
591+
$team = $this->result->team2;
592+
}
593+
594+
if (!isset($team->players)) {
595+
$team->players = new \stdClass();
596+
}
597+
598+
$team->players->{$thirdpartyid} = $thirdpartyname;
599+
}
600+
601+
public function getconfig($matchid, $nummaps, $players_per_team, $apiurl, $apikey)
602+
{
603+
$this->result->matchid = "$matchid";
604+
$this->result->num_maps = intval($nummaps);
605+
$this->result->players_per_team = intval($players_per_team);
606+
$this->result->min_players_to_ready = intval($players_per_team);
607+
608+
if ($apikey != null && $apiurl != null) {
609+
$this->result->eventula_apistats_url = $apiurl;
610+
$this->result->eventula_demo_upload_url = $apiurl . "demo";
611+
}
612+
613+
return $this->result;
614+
}
615+
616+
617+
public function authorizeserver(Request $request, GameServer $gameserver)
618+
{
619+
if (auth('sanctum')->user()->id != $gameserver->id) {
620+
return false;
621+
} else {
622+
return true;
623+
}
624+
}
625+
626+
627+
628+
629+
public function golive(Request $request, MatchMaking $match = null, EventTournament $tournament = null, ?int $challongematchid, int $mapnumber)
630+
{
631+
if ($match != null && $tournament == null) {
632+
if (!$match->setStatus('LIVE')) {
633+
return false;
634+
}
635+
return true;
636+
}
637+
if ($match == null && $tournament != null && $challongematchid != null) {
638+
//tournament stuff
639+
return true;
640+
}
641+
return false;
642+
}
643+
644+
public function updateround(Request $request, MatchMaking $match = null, EventTournament $tournament = null, ?int $challongematchid, int $mapnumber)
645+
{
646+
647+
if ($match != null && $tournament == null) {
648+
$loop = 1;
649+
foreach ($match->teams as $team) {
650+
$team->team_score = $request->{"team" . $loop . "score"};
651+
if (!$team->save()) {
652+
return false;
653+
}
654+
$loop++;
655+
}
656+
return true;
657+
}
658+
if ($match == null && $tournament != null && $challongematchid != null) {
659+
$tournament->updateMatchScores($challongematchid, $request->{"team1score"}, $request->{"team2score"});
660+
return true;
661+
}
662+
return false;
663+
}
664+
public function updateplayer(Request $request, MatchMaking $match = null, EventTournament $tournament = null, ?int $challongematchid, int $mapnumber, string $player)
665+
{
666+
if ($match != null && $tournament == null) {
667+
//matchmaking stuff
668+
return true;
669+
}
670+
if ($match == null && $tournament != null && $challongematchid != null) {
671+
//tournament stuff
672+
return true;
673+
}
674+
return false;
675+
}
676+
677+
public function finalizemap(Request $request, MatchMaking $match = null, EventTournament $tournament = null, ?int $challongematchid, int $mapnumber)
678+
{
679+
if ($match != null && $tournament == null) {
680+
if (!$this->updateround($request, $match, null, null, $mapnumber)) {
681+
return false;
682+
}
683+
return true;
684+
}
685+
if ($match == null && $tournament != null && $challongematchid != null) {
686+
if (($mapnumber + 1) == $tournament->getnummaps($challongematchid)) {
687+
$tournament->updateMatch($challongematchid, $request->{"team1score"}, $request->{"team2score"});
688+
return true;
689+
}
690+
if (!$this->updateround($request, null, $tournament, $challongematchid, $mapnumber)) {
691+
return false;
692+
}
693+
return true;
694+
}
695+
return false;
696+
}
697+
public function finalize(Request $request, MatchMaking $match = null, EventTournament $tournament = null, ?int $challongematchid)
698+
{
699+
if ($match != null && $tournament == null) {
700+
if (!$match->setStatus('COMPLETE')) {
701+
return false;
702+
}
703+
return true;
704+
}
705+
if ($match == null && $tournament != null && $challongematchid != null) {
706+
//tournament stuff
707+
708+
}
709+
return false;
710+
}
711+
712+
public function freeserver(Request $request, MatchMaking $match = null, EventTournament $tournament = null, ?int $challongematchid)
713+
{
714+
if ($match != null && $tournament == null) {
715+
716+
if (!$match->matchMakingServer->delete()) {
717+
return false;
718+
}
719+
return true;
720+
}
721+
if ($match == null && $tournament != null && $challongematchid != null) {
722+
723+
$evtms = EventTournamentMatchServer::where(['challonge_match_id' => $challongematchid])->first();
724+
725+
if (isset($evtms)) {
726+
if (!$evtms->delete()) {
727+
return false;
728+
}
729+
}
730+
return true;
731+
}
732+
return false;
733+
}
734+
735+
public function uploaddemo(Request $request, MatchMaking $match = null, EventTournament $tournament = null, ?int $challongematchid)
736+
{
737+
$demoname = str_replace(' ', '_', $request->headers->get('PugSharp-DemoName'));
738+
739+
if ($match != null && $tournament == null) {
740+
$destinationPathDemo = MatchReplay::createReplayPath($match->game, $demoname);
741+
742+
if (Storage::disk('public')->put($destinationPathDemo, $request->getContent()) == false) {
743+
return false;
744+
}
745+
746+
$replay = new MatchReplay();
747+
$replay->name = $demoname;
748+
$replay->matchmaking_id = $match->id;
749+
if (!$replay->save()) {
750+
return false;
751+
}
752+
return true;
753+
}
754+
if ($match == null && $tournament != null && $challongematchid != null) {
755+
$destinationPathDemo = MatchReplay::createReplayPath($tournament->game, $demoname);
756+
757+
if (Storage::disk('public')->put($destinationPathDemo, $request->getContent()) == false) {
758+
return false;
759+
}
760+
761+
$replay = new MatchReplay();
762+
$replay->name = $demoname;
763+
$replay->challonge_match_id = $challongematchid;
764+
if (!$replay->save()) {
765+
return false;
766+
}
767+
return true;
768+
}
769+
return false;
770+
}
771+
}

src/app/Http/Controllers/Admin/Events/EventsController.php

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function store(Request $request)
5757
'desc_short' => 'required',
5858
'desc_long' => 'required',
5959
'end_date' => 'required|date_format:m/d/Y',
60-
'end_time' => 'required|date_format:H:i',
60+
'end_time' => 'required|date_format:H:i,G:i',
6161
'start_date' => 'required|date_format:m/d/Y',
62-
'start_time' => 'required|date_format:H:i',
62+
'start_time' => 'required|date_format:H:i,G:i',
6363
'capacity' => 'required|integer',
6464
'venue' => 'exists:event_venues,id',
6565
];
@@ -70,9 +70,9 @@ public function store(Request $request)
7070
'end_date.required' => 'End date is required',
7171
'end_time.required' => 'End date is required',
7272
'end_date.date_format' => 'End Date must be m/d/Y format',
73-
'end_time.date_format' => 'End Time must be H:i format',
73+
'end_time.date_format' => 'End Time must be H:i or G:i format (e.g., 07:00 or 7:00)',
7474
'start_date.date_format' => 'Start Date must be m/d/Y format',
75-
'start_time.date_format' => 'Start Time must be H:i format',
75+
'start_time.date_format' => 'Start Time must be H:i or G:i format (e.g., 07:00 or 7:00)',
7676
'desc_short.required' => 'Short Description is required',
7777
'desc_long.required' => 'Long Description is required',
7878
'capacity.required' => 'Capacity is required',
@@ -99,6 +99,7 @@ public function store(Request $request)
9999
$event->matchmaking_enabled = (bool)$request->matchmaking_enabled;
100100
$event->tournaments_freebies = (bool)$request->tournaments_freebies;
101101
$event->tournaments_staff = (bool)$request->tournaments_staff;
102+
$event->ticket_hide_policy = (int)$request->ticket_hide_policy;
102103
if (!$event->save()) {
103104
Session::flash('alert-danger', 'Cannot Save Event!');
104105
return Redirect::to('admin/events/' . $event->slug);
@@ -121,9 +122,9 @@ public function update(Event $event, Request $request)
121122
$rules = [
122123
'event_name' => 'filled',
123124
'end_date' => 'filled|date_format:m/d/Y',
124-
'end_time' => 'filled|date_format:H:i',
125+
'end_time' => 'filled|date_format:H:i,G:i',
125126
'start_date' => 'filled|date_format:m/d/Y',
126-
'start_time' => 'filled|date_format:H:i',
127+
'start_time' => 'filled|date_format:H:i,G:i',
127128
'status' => 'in:draft,preview,published,private,registeredonly',
128129
'capacity' => 'filled|integer',
129130
'venue' => 'exists:event_venues,id',
@@ -133,11 +134,11 @@ public function update(Event $event, Request $request)
133134
'end_date.filled' => 'A End Date cannot be empty',
134135
'end_date.date_format' => 'A End Date must be m/d/Y format',
135136
'end_time.filled' => 'A End Time cannot be empty',
136-
'end_time.date_format' => 'A End Time must be H:i formate',
137+
'end_time.date_format' => 'A End Time must be H:i or G:i format (e.g., 07:00 or 7:00)',
137138
'start_date.filled' => 'A Start Date cannot be empty',
138-
'end_date.date_format' => 'A Start Date must be m/d/Y format',
139+
'start_date.date_format' => 'A Start Date must be m/d/Y format',
139140
'start_time.filled' => 'A Start Time cannot be empty',
140-
'end_time.date_format' => 'A Start Time must be H:i format',
141+
'start_time.date_format' => 'A Start Time must be H:i or G:i format (e.g., 07:00 or 7:00)',
141142
'status.in' => 'Status must be draft, preview, published or private',
142143
'capacity.filled' => 'Capacity is required',
143144
'capacity.integer' => 'Capacity must be a integer',
@@ -205,6 +206,10 @@ public function update(Event $event, Request $request)
205206
$event->event_venue_id = @$request->venue;
206207
}
207208

209+
if (isset($request->ticket_hide_policy)) {
210+
$event->ticket_hide_policy = $request->ticket_hide_policy;
211+
}
212+
208213
if (!$event->save()) {
209214
Session::flash('alert-danger', 'Cannot update Event!');
210215
return Redirect::to('admin/events/' . $event->slug);
@@ -314,4 +319,25 @@ public function freeStaff(Request $request, Event $event)
314319
Session::flash('alert-success', 'Successfully added Staff!');
315320
return Redirect::to('admin/events/' . $event->slug . '/tickets');
316321
}
322+
323+
/**
324+
* Seperate method for updating the ticket hide policy because this is not called from the event show page.
325+
* @param Event $event to update the ticket Policy for
326+
* @param Request $request containing the ticket_hide_policy to set
327+
* @return RedirectResponse
328+
* @throws \Illuminate\Validation\ValidationException
329+
*/
330+
public function updateTicketHidePolicy(Event $event, Request $request) {
331+
$rules = [
332+
'ticket_hide_policy' => 'required|integer|min:-1|max:15'
333+
];
334+
335+
$this->validate($request, $rules);
336+
337+
$event->tickettype_hide_policy = $request->ticket_hide_policy;
338+
if (!$event->save()) {
339+
Session::flash('alert-danger', 'Cannot update Ticket Hide Policy!');
340+
}
341+
return Redirect::back();
342+
}
317343
}

0 commit comments

Comments
 (0)