100 lines
2.8 KiB
PHP
100 lines
2.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Websocket\Controllers;
|
||
|
|
|
||
|
|
use App\Actions\Tribes;
|
||
|
|
use App\Websocket\GameController;
|
||
|
|
use Closure;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* tribe.show|list|found|invite|cancelInvite|join|refuse|leave|kick|role|describe|disband|propose|accept|end|enemy,
|
||
|
|
* each with world_id. All but list answer with the tribe page (Tribes::show).
|
||
|
|
*/
|
||
|
|
class TribeController extends GameController
|
||
|
|
{
|
||
|
|
public function show()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->show($u, $w));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function list()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->list($u, $w));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function found()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->found($u, $w, (string) request('name'), (string) request('tag')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function invite()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->invite($u, $w, (string) request('player')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function cancelInvite()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->cancelInvite($u, $w, (int) request('player_id')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function join()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->join($u, $w, (int) request('tribe_id')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function refuse()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->refuse($u, $w, (int) request('tribe_id')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function leave()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->leave($u, $w));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function kick()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->kick($u, $w, (int) request('player_id')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function role()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->role($u, $w, (int) request('player_id'), (string) request('role')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function describe()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->describe($u, $w, (string) request('description')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function disband()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->disband($u, $w));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function propose()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->propose($u, $w, (string) request('tag'), (string) request('state')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function accept()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->accept($u, $w, (int) request('tribe_id')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function end()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->end($u, $w, (int) request('tribe_id')));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function enemy()
|
||
|
|
{
|
||
|
|
return $this->tribes(fn (Tribes $t, $u, $w) => $t->enemy($u, $w, (string) request('tag')));
|
||
|
|
}
|
||
|
|
|
||
|
|
private function tribes(Closure $intent)
|
||
|
|
{
|
||
|
|
return $this->play(fn () => $intent(app(Tribes::class), auth()->user(), (int) request('world_id')));
|
||
|
|
}
|
||
|
|
}
|