1
0
Fork 0

Formatting fixes and cleanup.

This commit is contained in:
Henrik Hautakoski 2023-01-31 07:34:02 +01:00
parent a1e14a3e60
commit 51fb71e469
41 changed files with 394 additions and 392 deletions

View file

@ -34,7 +34,7 @@ class CardExport extends Command
public function handle() public function handle()
{ {
$data = collect(); $data = collect();
foreach(Card::with(['character', 'raid'])->get() as $card) { foreach (Card::with(['character', 'raid'])->get() as $card) {
$row = collect([ $row = collect([
'message' => $card->body, 'message' => $card->body,

View file

@ -39,12 +39,12 @@ class CardImport extends Command
try { try {
$json = json_decode($data, false, 8, JSON_THROW_ON_ERROR); $json = json_decode($data, false, 8, JSON_THROW_ON_ERROR);
} catch(\JsonException $ex) { } catch (\JsonException $ex) {
$this->error("Json: " . $ex->getMessage()); $this->error("Json: " . $ex->getMessage());
return; return;
} }
foreach($json as $item) { foreach ($json as $item) {
$data = [ $data = [
'body' => $item->message, 'body' => $item->message,

View file

@ -34,4 +34,4 @@ class InstallLogo extends Command
Storage::disk('resources')->copy('logos/' . $filename, 'images/logo.png'); Storage::disk('resources')->copy('logos/' . $filename, 'images/logo.png');
} }
} }

View file

@ -28,7 +28,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
{ {
// Prune old game settings. // Prune old game settings.
$schedule->command('model:prune', [ '--model' => [ \App\Models\Setting::class ] ]) $schedule->command('model:prune', ['--model' => [\App\Models\Setting::class]])
->description("Prune expired settings") ->description("Prune expired settings")
->twiceDaily(2, 8); ->twiceDaily(2, 8);
} }
@ -40,7 +40,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function commands() protected function commands()
{ {
$this->load(__DIR__.'/Commands'); $this->load(__DIR__ . '/Commands');
require base_path('routes/console.php'); require base_path('routes/console.php');
} }

View file

@ -39,7 +39,7 @@ class GameBoard
/** /**
* Return the state * Return the state
*/ */
public function getState() : GameBoardState public function getState(): GameBoardState
{ {
return $this->state; return $this->state;
} }
@ -47,7 +47,7 @@ class GameBoard
/** /**
* Get the size of the board. * Get the size of the board.
*/ */
public function getSize() : int public function getSize(): int
{ {
return $this->state->getSize(); return $this->state->getSize();
} }
@ -55,7 +55,7 @@ class GameBoard
/** /**
* Clear the game board. * Clear the game board.
*/ */
public function clear() : void public function clear(): void
{ {
$this->state->clear(); $this->state->clear();
} }
@ -64,7 +64,7 @@ class GameBoard
* Check if the board is in an ended state. * Check if the board is in an ended state.
* E.g: all cards is in a winning state. * E.g: all cards is in a winning state.
*/ */
public function hasGameEnded() : bool public function hasGameEnded(): bool
{ {
return $this->state->isFull(GameBoardState::STATE_WIN); return $this->state->isFull(GameBoardState::STATE_WIN);
} }
@ -74,7 +74,7 @@ class GameBoard
* *
* @throw NotEnoughCardsException * @throw NotEnoughCardsException
*/ */
public function regenerate(GameSettings $settings) : self public function regenerate(GameSettings $settings): self
{ {
$num_cards = $this->getSize(); $num_cards = $this->getSize();
$cards = Card::getBySettings($settings, $num_cards); $cards = Card::getBySettings($settings, $num_cards);

View file

@ -42,7 +42,7 @@ class GameBoardState
/** /**
* Set the state of a cell. * Set the state of a cell.
*/ */
public function set(int $pos, bool $pressed = true) : self public function set(int $pos, bool $pressed = true): self
{ {
if ($this->hasGameEnded()) { if ($this->hasGameEnded()) {
return $this; return $this;
@ -62,7 +62,7 @@ class GameBoardState
/** /**
* Toggle pressed state of a cell. * Toggle pressed state of a cell.
*/ */
public function toggle(int $pos) : self public function toggle(int $pos): self
{ {
return $this->set($pos, !$this->isPressed($pos)); return $this->set($pos, !$this->isPressed($pos));
} }
@ -70,7 +70,7 @@ class GameBoardState
/** /**
* Check if a cell is pressed or not. * Check if a cell is pressed or not.
*/ */
public function isPressed(int $pos) : bool public function isPressed(int $pos): bool
{ {
return isset($this->state[$pos]); return isset($this->state[$pos]);
} }
@ -78,7 +78,7 @@ class GameBoardState
/** /**
* Check if a cell is part of a winning row/column. * Check if a cell is part of a winning row/column.
*/ */
public function isWin(int $pos) : bool public function isWin(int $pos): bool
{ {
return isset($this->state[$pos]) && $this->state[$pos] == self::STATE_WIN; return isset($this->state[$pos]) && $this->state[$pos] == self::STATE_WIN;
} }
@ -86,7 +86,7 @@ class GameBoardState
/** /**
* Get the sate of the cells. * Get the sate of the cells.
*/ */
public function getState() : array public function getState(): array
{ {
return $this->state; return $this->state;
} }
@ -94,7 +94,7 @@ class GameBoardState
/** /**
* Get the size of the board. * Get the size of the board.
*/ */
public function getSize() : int public function getSize(): int
{ {
return $this->width * $this->height; return $this->width * $this->height;
} }
@ -102,7 +102,7 @@ class GameBoardState
/** /**
* Clear the board. * Clear the board.
*/ */
public function clear() : self public function clear(): self
{ {
$this->state = []; $this->state = [];
$this->winning = 0; $this->winning = 0;
@ -110,7 +110,7 @@ class GameBoardState
} }
// TODO: Rename // TODO: Rename
public function getNumWinRows() : int public function getNumWinRows(): int
{ {
return $this->winning; return $this->winning;
} }
@ -118,13 +118,13 @@ class GameBoardState
/** /**
* Check if the board only has winning cards * Check if the board only has winning cards
*/ */
public function hasGameEnded() : bool public function hasGameEnded(): bool
{ {
if (count($this->state) < $this->width * $this->height) { if (count($this->state) < $this->width * $this->height) {
return false; return false;
} }
foreach($this->state as $pos) { foreach ($this->state as $pos) {
if ($pos !== self::STATE_WIN) { if ($pos !== self::STATE_WIN) {
return false; return false;
} }
@ -135,14 +135,14 @@ class GameBoardState
/** /**
* Check if the board is full and all positions is in a given state. * Check if the board is full and all positions is in a given state.
*/ */
public function isFull($state) : bool public function isFull($state): bool
{ {
// Board not filled, impossible to have all positions set. // Board not filled, impossible to have all positions set.
if (count($this->state) < $this->width * $this->height) { if (count($this->state) < $this->width * $this->height) {
return false; return false;
} }
foreach($this->state as $pos) { foreach ($this->state as $pos) {
if ($pos !== $state) { if ($pos !== $state) {
return false; return false;
} }
@ -153,15 +153,15 @@ class GameBoardState
/** /**
* *
*/ */
protected function update() : void protected function update(): void
{ {
foreach($this->state as $pos => $_) { foreach ($this->state as $pos => $_) {
$this->state[$pos] = self::STATE_PRESSED; $this->state[$pos] = self::STATE_PRESSED;
} }
$patterns = $this->checkWinningState(); $patterns = $this->checkWinningState();
foreach($patterns as $cards) { foreach ($patterns as $cards) {
foreach($cards as $pos) { foreach ($cards as $pos) {
$this->state[$pos] = self::STATE_WIN; $this->state[$pos] = self::STATE_WIN;
} }
} }
@ -171,12 +171,12 @@ class GameBoardState
/** /**
* Check if the board is in a winning state. * Check if the board is in a winning state.
*/ */
protected function checkWinningState() : array protected function checkWinningState(): array
{ {
$win = []; $win = [];
// Rows // Rows
for($y=0; $y < $this->height; $y++) { for ($y = 0; $y < $this->height; $y++) {
$c = $this->checkRow($y); $c = $this->checkRow($y);
if (count($c)) { if (count($c)) {
$win[] = $c; $win[] = $c;
@ -184,7 +184,7 @@ class GameBoardState
} }
// Columns // Columns
for($x=0; $x < $this->width; $x++) { for ($x = 0; $x < $this->width; $x++) {
$c = $this->checkCol($x); $c = $this->checkCol($x);
if (count($c)) { if (count($c)) {
$win[] = $c; $win[] = $c;
@ -197,12 +197,12 @@ class GameBoardState
/** /**
* Check if a row is in a winning state (all cells pressed) * Check if a row is in a winning state (all cells pressed)
*/ */
protected function checkRow($y) : array protected function checkRow($y): array
{ {
$cards = []; $cards = [];
$y = $y * $this->width; $y = $y * $this->width;
for($x = 0; $x < $this->width; $x++) { for ($x = 0; $x < $this->width; $x++) {
$pos = $x + $y; $pos = $x + $y;
if (!$this->isPressed($pos)) { if (!$this->isPressed($pos)) {
return []; return [];
@ -216,11 +216,11 @@ class GameBoardState
/** /**
* Check if a column is in a winning state (all cells pressed) * Check if a column is in a winning state (all cells pressed)
*/ */
protected function checkCol($x) : array protected function checkCol($x): array
{ {
$cards = []; $cards = [];
for($y = 0; $y < $this->height; $y++) { for ($y = 0; $y < $this->height; $y++) {
$pos = $x + ($y * $this->width); $pos = $x + ($y * $this->width);
if (!$this->isPressed($pos)) { if (!$this->isPressed($pos)) {
return []; return [];

View file

@ -20,7 +20,7 @@ class GameService
/** /**
* Get the current session * Get the current session
*/ */
public function session() : GameSession public function session(): GameSession
{ {
return $this->session; return $this->session;
} }
@ -28,7 +28,7 @@ class GameService
/** /**
* Generate a new Game session * Generate a new Game session
*/ */
public function newSession(?GameSettings $settings = null) : self public function newSession(?GameSettings $settings = null): self
{ {
if (!$settings) { if (!$settings) {
$settings = $this->session()->getSettings(); $settings = $this->session()->getSettings();

View file

@ -28,7 +28,7 @@ class GameSession
/** /**
* Get the board * Get the board
*/ */
public function getBoard() : GameBoard public function getBoard(): GameBoard
{ {
return $this->board; return $this->board;
} }
@ -36,7 +36,7 @@ class GameSession
/** /**
* Get the board state * Get the board state
*/ */
public function getBoardState() : GameBoardState public function getBoardState(): GameBoardState
{ {
return $this->getBoard()->getState(); return $this->getBoard()->getState();
} }
@ -44,7 +44,7 @@ class GameSession
/** /**
* Get Cards * Get Cards
*/ */
public function getCards() : Collection public function getCards(): Collection
{ {
return $this->getBoard()->getCards(); return $this->getBoard()->getCards();
} }
@ -52,7 +52,7 @@ class GameSession
/** /**
* Get Settings * Get Settings
*/ */
public function getSettings() : GameSettings public function getSettings(): GameSettings
{ {
return $this->settings; return $this->settings;
} }
@ -60,7 +60,7 @@ class GameSession
/** /**
* Set new settings * Set new settings
*/ */
public function setSettings(GameSettings $settings) : self public function setSettings(GameSettings $settings): self
{ {
$this->settings = $settings; $this->settings = $settings;
return $this; return $this;

View file

@ -44,7 +44,7 @@ class GameSettings
} }
} }
public function toArray() : array public function toArray(): array
{ {
return [ return [
'classes' => $this->classes->toArray(), 'classes' => $this->classes->toArray(),
@ -54,7 +54,7 @@ class GameSettings
]; ];
} }
public function all() : Collection public function all(): Collection
{ {
return collect([ return collect([
'classes' => $this->classes->all()->toArray(), 'classes' => $this->classes->all()->toArray(),

View file

@ -7,7 +7,7 @@ use App\Http\Livewire\Form\CardForm;
class CardController extends BaseController class CardController extends BaseController
{ {
protected $_datatable = [ protected $_datatable = [
'model' => Card::class, 'model' => Card::class,
'default_sort' => 'id', 'default_sort' => 'id',
'route_create' => 'admin.card.create', 'route_create' => 'admin.card.create',
@ -16,21 +16,21 @@ class CardController extends BaseController
'restore_enabled' => true, 'restore_enabled' => true,
'columns' => [ 'columns' => [
'id' => '#', 'id' => '#',
'body' => 'Body', 'body' => 'Body',
'subject' => 'Subject', 'subject' => 'Subject',
'subject_type' => 'Subject Type', 'subject_type' => 'Subject Type',
'raid.name' => 'Raid', 'raid.name' => 'Raid',
], ],
'sort_columns' => [ 'sort_columns' => [
'id' => 'id', 'id' => 'id',
'body' => 'body', 'body' => 'body',
'subject' => ['character.name', 'class', 'role'], 'subject' => ['character.name', 'class', 'role'],
'raid.name' => 'raid.name', 'raid.name' => 'raid.name',
] ]
]; ];
static public function getForm() : string static public function getForm(): string
{ {
return CardForm::class; return CardForm::class;
} }
} }

View file

@ -9,13 +9,13 @@ use App\Http\Controllers\Controller;
class AuthController extends Controller class AuthController extends Controller
{ {
/** /**
* Show login page * Show login page
*/ */
public function create() public function create()
{ {
return view('auth.login'); return view('auth.login');
} }
/** /**
* Destroy an authenticated session. * Destroy an authenticated session.

View file

@ -31,18 +31,18 @@ class Kernel extends HttpKernel
protected $middlewareGroups = [ protected $middlewareGroups = [
'web' => [ 'web' => [
\Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class,
] ]
]; ];
/** /**
* The application's route middleware. * The application's route middleware.
* *
* These middleware may be assigned to groups or used individually. * These middleware may be assigned to groups or used individually.
* *
* @var array * @var array
*/ */
protected $routeMiddleware = [ protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class 'auth' => \App\Http\Middleware\Authenticate::class
]; ];
} }

View file

@ -7,45 +7,45 @@ use Livewire\Component;
class AlertContainer extends Component class AlertContainer extends Component
{ {
/** /**
* List of alert types. * List of alert types.
*/ */
protected array $_types = [ protected array $_types = [
'info', 'info',
'success', 'success',
'warning', 'warning',
'danger' 'danger'
]; ];
/** /**
* Event listeners * Event listeners
*/ */
protected $listeners = [ protected $listeners = [
// Add message when "alert" event is fired. // Add message when "alert" event is fired.
'alert' => 'addMessage' 'alert' => 'addMessage'
]; ];
/** /**
* Alert messages. * Alert messages.
*/ */
public array $messages = []; public array $messages = [];
public function mount() public function mount()
{ {
// Load messages from session // Load messages from session
foreach($this->_types as $type) { foreach ($this->_types as $type) {
if (Session::has($type)) { if (Session::has($type)) {
$this->addMessage($type, Session::get($type)); $this->addMessage($type, Session::get($type));
} }
} }
} }
/** /**
* Add a message to the container. * Add a message to the container.
*/ */
public function addMessage(string $type, string $message) public function addMessage(string $type, string $message)
{ {
$this->messages[] = [ $type, $message ]; $this->messages[] = [$type, $message];
} }
/** /**

View file

@ -5,197 +5,202 @@ namespace App\Http\Livewire;
use Livewire\Component; use Livewire\Component;
use Livewire\WithPagination; use Livewire\WithPagination;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class Datatable extends Component class Datatable extends Component
{ {
use WithPagination, Traits\WithSort, Traits\Alert; use WithPagination, Traits\WithSort, Traits\Alert;
/** /**
* Query string settings. * Query string settings.
*/ */
protected $queryString = [ protected $queryString = [
'sort' => ['except' => 'id'], 'sort' => ['except' => 'id'],
'dir' => ['except' => 'asc'], 'dir' => ['except' => 'asc'],
'page' => ['except' => 1], 'page' => ['except' => 1],
'trashed' => ['except' => false] 'trashed' => ['except' => false]
]; ];
/** /**
* Model to get data from. * Model to get data from.
*/ */
public $model; public $model;
/** /**
* Array of columns to show * Array of columns to show
*/ */
public array $columns; public array $columns;
/** /**
* What colums are sortable * What colums are sortable
*/ */
public array $sort_columns; public array $sort_columns;
/** /**
* Default sorting column * Default sorting column
*/ */
public string $default_sort; public string $default_sort;
/** /**
* If only trashed records should be shown. * If only trashed records should be shown.
*/ */
public bool $trashed = false; public bool $trashed = false;
/** /**
* Route for creating a record (if null, link is omitted) * Route for creating a record (if null, link is omitted)
*/ */
public $route_create; public $route_create;
/** /**
* Route for editing a record (if null, link is omitted) * Route for editing a record (if null, link is omitted)
*/ */
public $route_edit; public $route_edit;
/** /**
* True if delete functionality is enabled. * True if delete functionality is enabled.
*/ */
public $delete_enabled; public $delete_enabled;
/** /**
* True if restore functionality is enabled. * True if restore functionality is enabled.
*/ */
public $restore_enabled; public $restore_enabled;
/** /**
* How many records should be displayed on one page. * How many records should be displayed on one page.
*/ */
public int $itemsPerPage = 30; public int $itemsPerPage = 30;
public function mount(string $model, array $columns, public function mount(
array $sort_columns = [], $default_sort = '', string $model,
$route_create = null, $route_edit = null, $delete_enabled = false, $restore_enabled = false) array $columns,
{ array $sort_columns = [],
$this->model = app()->make($model); $default_sort = '',
$this->default_sort = $default_sort; $route_create = null,
$this->sort = $this->default_sort; $route_edit = null,
$this->sort_columns = $sort_columns; $delete_enabled = false,
$this->route_create = $route_create; $restore_enabled = false
$this->route_edit = $route_edit; ) {
$this->delete_enabled = (bool) $delete_enabled; $this->model = app()->make($model);
$this->restore_enabled = (bool) $restore_enabled; $this->default_sort = $default_sort;
$this->columns = $columns;
$this->sort = $this->default_sort;
$this->sort_columns = $sort_columns;
$this->route_create = $route_create;
$this->route_edit = $route_edit;
$this->delete_enabled = (bool) $delete_enabled;
$this->restore_enabled = (bool) $restore_enabled;
$this->setTrashed(false); $this->setTrashed(false);
} }
/** /**
* Get the model name. * Get the model name.
*/ */
public function getModelName() : string public function getModelName(): string
{ {
return class_basename($this->model); return class_basename($this->model);
} }
/** /**
* Set trashed flag. * Set trashed flag.
*/ */
public function setTrashed($value) public function setTrashed($value)
{ {
$this->trashed = (bool) $value; $this->trashed = (bool) $value;
if ($this->trashed) { if ($this->trashed) {
// Add deleted_at columns. // Add deleted_at columns.
$this->columns['deleted_at'] = 'Deleted at'; $this->columns['deleted_at'] = 'Deleted at';
$this->sort_columns['deleted_at'] = 'deleted_at'; $this->sort_columns['deleted_at'] = 'deleted_at';
} else { } else {
// Unset deleted_at columns. // Unset deleted_at columns.
unset($this->columns['deleted_at']); unset($this->columns['deleted_at']);
unset($this->sort_columns['deleted_at']); unset($this->sort_columns['deleted_at']);
// if delete_at was the sorting column // if delete_at was the sorting column
// revert back to default sorting. // revert back to default sorting.
if ($this->sort == 'deleted_at') { if ($this->sort == 'deleted_at') {
$this->sort = $this->default_sort; $this->sort = $this->default_sort;
} }
} }
} }
/** /**
* Toggle trashed flag * Toggle trashed flag
*/ */
public function toggleTrashed() public function toggleTrashed()
{ {
$this->setTrashed(!$this->trashed); $this->setTrashed(!$this->trashed);
} }
/** /**
* Delete an record * Delete an record
*/ */
public function delete($id) public function delete($id)
{ {
if (!$this->delete_enabled) { if (!$this->delete_enabled) {
return; return;
} }
$record = $this->model->find($id); $record = $this->model->find($id);
if (!$record) { if (!$record) {
$this->danger('Record not found'); $this->danger('Record not found');
return; return;
} }
$record->delete(); $record->delete();
$this->info(__($this->getModelName() . " #:id was deleted.", [ 'id' => $record->id ])); $this->info(__($this->getModelName() . " #:id was deleted.", ['id' => $record->id]));
} }
/** /**
* Restore a delted record * Restore a delted record
*/ */
public function restore($id) public function restore($id)
{ {
if (!$this->restore_enabled) { if (!$this->restore_enabled) {
return; return;
} }
$record = $this->model->withTrashed()->find($id); $record = $this->model->withTrashed()->find($id);
if (!$record) { if (!$record) {
$this->danger('Record not found'); $this->danger('Record not found');
return; return;
} }
$record->restore(); $record->restore();
$this->info(__($this->getModelName() . " #:id was restored.", [ 'id' => $record->id ])); $this->info(__($this->getModelName() . " #:id was restored.", ['id' => $record->id]));
} }
/** /**
* Render the datatable * Render the datatable
*/ */
public function render() public function render()
{ {
$query = $this->model->query(); $query = $this->model->query();
// Only include trashed if asked to. // Only include trashed if asked to.
if ($this->trashed) { if ($this->trashed) {
$query->onlyTrashed(); $query->onlyTrashed();
} }
// Check colums for "dot-notated" strings. // Check colums for "dot-notated" strings.
// as we want to eager load those relationships // as we want to eager load those relationships
foreach ($this->columns as $col => $_) { foreach ($this->columns as $col => $_) {
$p = strrpos($col, '.'); $p = strrpos($col, '.');
if ($p !== false) { if ($p !== false) {
$rel = substr($col, 0, $p); $rel = substr($col, 0, $p);
$query->with($rel); $query->with($rel);
} }
} }
// Apply sorting. // Apply sorting.
$this->sortApply($query); $this->sortApply($query);
$items = $query->paginate($this->itemsPerPage); $items = $query->paginate($this->itemsPerPage);
return view('livewire.datatable', ['items' => $items]); return view('livewire.datatable', ['items' => $items]);
} }

View file

@ -14,7 +14,7 @@ class Authenticate extends Middleware
*/ */
protected function redirectTo($request) protected function redirectTo($request)
{ {
if (! $request->expectsJson()) { if (!$request->expectsJson()) {
return route('login'); return route('login');
} }
} }

View file

@ -59,7 +59,7 @@ class Card extends Model
return "Somebody"; return "Somebody";
} }
/** /**
* Who, Where or What this card belongs to. * Who, Where or What this card belongs to.
*/ */
public function getSubjectTypeAttribute() public function getSubjectTypeAttribute()
@ -91,7 +91,7 @@ class Card extends Model
->inRandomOrder(); ->inRandomOrder();
// Run through all settings and apply filter. // Run through all settings and apply filter.
foreach($settings->all() as $type => $values) { foreach ($settings->all() as $type => $values) {
$column = $type_map[$type]; $column = $type_map[$type];

View file

@ -29,14 +29,14 @@ class Setting extends Model
]; ];
/** /**
* Get the prunable model query. * Get the prunable model query.
* *
* @return \Illuminate\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
*/ */
public function prunable() public function prunable()
{ {
return static::where('created_at', '<', now()->subDay(1)); return static::where('created_at', '<', now()->subDay(1));
} }
public function getHashAttribute() public function getHashAttribute()
{ {

View file

@ -4,19 +4,19 @@ namespace App\Models;
class Wow class Wow
{ {
/** /**
* Enum for classes. * Enum for classes.
*/ */
static public $classes = [ static public $classes = [
'warrior' => 'Warrior', 'warrior' => 'Warrior',
'rogue' => 'Rogue', 'rogue' => 'Rogue',
'paladin' => 'Paladin', 'paladin' => 'Paladin',
'hunter' => 'Hunter', 'hunter' => 'Hunter',
'mage' => 'Mage', 'mage' => 'Mage',
'warlock' => 'Warlock', 'warlock' => 'Warlock',
'shaman' => 'Shaman', 'shaman' => 'Shaman',
'druid' => 'Druid', 'druid' => 'Druid',
'priest' => 'Priest', 'priest' => 'Priest',
'dk' => 'Death Knight' 'dk' => 'Death Knight'
]; ];
} }

View file

@ -2,7 +2,6 @@
namespace App\Providers; namespace App\Providers;
use App\Game\GameBuilder;
use App\Game\GameBoardState; use App\Game\GameBoardState;
use App\Game\GameService; use App\Game\GameService;
use App\Game\GameSession; use App\Game\GameSession;
@ -20,7 +19,7 @@ class GameServiceProvider extends ServiceProvider implements DeferrableProvider
*/ */
public function register() public function register()
{ {
$this->app->bind(GameBoardState::class, function($app) { $this->app->bind(GameBoardState::class, function ($app) {
$width = (int) config('app.game.board.width', 4); $width = (int) config('app.game.board.width', 4);
$height = (int) config('app.game.board.height', 4); $height = (int) config('app.game.board.height', 4);
return new GameBoardState($width, $height); return new GameBoardState($width, $height);
@ -50,6 +49,6 @@ class GameServiceProvider extends ServiceProvider implements DeferrableProvider
*/ */
public function provides() public function provides()
{ {
return [ 'game', GameService::class, GameBoardState::class ]; return ['game', GameService::class, GameBoardState::class];
} }
} }

View file

@ -4,10 +4,7 @@ namespace App\Providers;
use App\Models\Setting; use App\Models\Setting;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider

View file

@ -13,12 +13,12 @@ class Set implements \Countable
public function __construct($items = []) public function __construct($items = [])
{ {
foreach($items as $k => $v) { foreach ($items as $k => $v) {
$this->set($k, $v); $this->set($k, $v);
} }
} }
public function set($key, bool $value = true) : self public function set($key, bool $value = true): self
{ {
if ($value) { if ($value) {
$this->items[$key] = true; $this->items[$key] = true;
@ -29,40 +29,40 @@ class Set implements \Countable
return $this; return $this;
} }
public function fill($array) : self public function fill($array): self
{ {
$this->clear(); $this->clear();
foreach($array as $k => $v) { foreach ($array as $k => $v) {
$this->set($k, $v); $this->set($k, $v);
} }
return $this; return $this;
} }
public function has($key) : bool public function has($key): bool
{ {
return isset($this->items[$key]); return isset($this->items[$key]);
} }
public function toggle($key) : self public function toggle($key): self
{ {
$this->set($key, !$this->has($key)); $this->set($key, !$this->has($key));
return $this; return $this;
} }
public function clear() : self public function clear(): self
{ {
$this->items = []; $this->items = [];
return $this; return $this;
} }
public function all() : Collection public function all(): Collection
{ {
return collect($this->items)->keys(); return collect($this->items)->keys();
} }
public function count() : int public function count(): int
{ {
return count($this->items); return count($this->items);
} }

View file

@ -10,7 +10,7 @@ class CardText extends Component
{ {
protected Card $card; protected Card $card;
protected string $subject; protected string $subject;
/** /**
* Create a new component instance. * Create a new component instance.
@ -20,7 +20,7 @@ class CardText extends Component
public function __construct(Card $card, $subject = '') public function __construct(Card $card, $subject = '')
{ {
$this->card = $card; $this->card = $card;
$this->subject = strlen($subject) ? $subject : $card->subject; $this->subject = strlen($subject) ? $subject : $card->subject;
} }
/** /**
@ -34,9 +34,10 @@ class CardText extends Component
// Replace non escaped '?' with subject and also Unescape escaped '?' // Replace non escaped '?' with subject and also Unescape escaped '?'
$text = preg_replace( $text = preg_replace(
['/(?<!\\\\)\?/u', '/\\\\\\?/u'] , ['/(?<!\\\\)\?/u', '/\\\\\\?/u'],
["<strong>$subject</strong>", '?'], ["<strong>$subject</strong>", '?'],
$this->card->body); $this->card->body
);
return $text; return $text;
} }

View file

@ -15,9 +15,9 @@ define('LARAVEL_START', microtime(true));
| |
*/ */
require __DIR__.'/vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php'; $app = require_once __DIR__ . '/bootstrap/app.php';
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View file

@ -105,6 +105,6 @@ return [
| |
*/ */
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'Bingo'), '_').'_cache'), 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'Bingo'), '_') . '_cache'),
]; ];

View file

@ -123,7 +123,7 @@ return [
'options' => [ 'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'), 'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
], ],
'default' => [ 'default' => [

View file

@ -43,7 +43,7 @@ return [
'public' => [ 'public' => [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('app/public'), 'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage', 'url' => env('APP_URL') . '/storage',
'visibility' => 'public', 'visibility' => 'public',
], ],

View file

@ -2,8 +2,8 @@
return [ return [
'select' => [ 'select' => [
'icon' => 'heroicon-s-chevron-down', 'icon' => 'heroicon-s-chevron-down',
] ]
]; ];

View file

@ -16,7 +16,7 @@ return [
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s', '%s%s',
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '' env('APP_URL') ? ',' . parse_url(env('APP_URL'), PHP_URL_HOST) : ''
))), ))),
/* /*

View file

@ -128,7 +128,7 @@ return [
'cookie' => env( 'cookie' => env(
'SESSION_COOKIE', 'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'bingo'), '_').'_session' Str::slug(env('APP_NAME', 'bingo'), '_') . '_session'
), ),
/* /*

View file

@ -2,4 +2,4 @@
return [ return [
'proxies' => env('HTTP_TRUSTED_PROXIES', []), 'proxies' => env('HTTP_TRUSTED_PROXIES', []),
]; ];

View file

@ -14,10 +14,10 @@ class TBCRaidSeeder extends Seeder
*/ */
public function run() public function run()
{ {
$raids = [ 'Karazhan', 'Grul\'s Lair', 'Magtheridon', 'SSC', 'TK' ]; $raids = ['Karazhan', 'Grul\'s Lair', 'Magtheridon', 'SSC', 'TK'];
foreach($raids as $name) { foreach ($raids as $name) {
Raid::insert(['name' => $name ]); Raid::insert(['name' => $name]);
} }
} }
} }

View file

@ -14,10 +14,10 @@ class WrathRaidSeeder extends Seeder
*/ */
public function run() public function run()
{ {
$raids = [ 'Naxramas', 'Obsidian Sanctum', 'Malygos', 'Ulduar', 'Icecrown Citadel' ]; $raids = ['Naxramas', 'Obsidian Sanctum', 'Malygos', 'Ulduar', 'Icecrown Citadel'];
foreach($raids as $name) { foreach ($raids as $name) {
Raid::insert(['name' => $name ]); Raid::insert(['name' => $name]);
} }
} }
} }

View file

@ -4,25 +4,25 @@
<form class="space-y-4" wire:submit.prevent="submit"> <form class="space-y-4" wire:submit.prevent="submit">
<div> <div>
<x-ignite-label for="username">{{ __('Username') }}</x-ignite-label> <x-ignite-label for="username">{{ __('Username') }}</x-ignite-label>
<x-ignite-input name="username" value="{{ $username }}" disabled /> <x-ignite-input name="username" value="{{ $username }}" disabled />
</div> </div>
<div> <div>
<x-ignite-label for="password_current">{{ __('Current Password') }}</x-ignite-label> <x-ignite-label for="password_current">{{ __('Current Password') }}</x-ignite-label>
<x-ignite-password name="password_current" wire:model="password_current" /> <x-ignite-password name="password_current" wire:model="password_current" />
</div> </div>
<div> <div>
<x-ignite-label for="password">{{ __('New Password') }}</x-ignite-label> <x-ignite-label for="password">{{ __('New Password') }}</x-ignite-label>
<x-ignite-password name="password" wire:model="password" /> <x-ignite-password name="password" wire:model="password" />
</div> </div>
<div> <div>
<x-ignite-label for="password_confirmation">{{ __('Confirm Password') }}</x-ignite-label> <x-ignite-label for="password_confirmation">{{ __('Confirm Password') }}</x-ignite-label>
<x-ignite-password name="password_confirmation" wire:model="password_confirmation" /> <x-ignite-password name="password_confirmation" wire:model="password_confirmation" />
</div> </div>
<x-button type="info">{{ __('Save') }}</x-button> <x-button type="info">{{ __('Save') }}</x-button>
<x-button href="{{ route('admin') }}" type="warning">{{ __('Back') }}</x-button> <x-button href="{{ route('admin') }}" type="warning">{{ __('Back') }}</x-button>

View file

@ -9,7 +9,7 @@
<ul class="py-4 space-y-2 text-white"> <ul class="py-4 space-y-2 text-white">
<li><a class="{{ $item_classes }}" href="{{ url('/admin/account') }}"><x-heroicon-o-user class="h-8 mr-2"/> {{ __('Account') }}</a></li> <li><a class="{{ $item_classes }}" href="{{ url('/admin/account') }}"><x-heroicon-o-user class="h-8 mr-2"/> {{ __('Account') }}</a></li>
<li><a class="{{ $item_classes }}" href="{{ url('/admin') }}"><x-heroicon-o-user-group class="h-8 mr-2"/> {{ __('Admins') }}</a></li> <li><a class="{{ $item_classes }}" href="{{ url('/admin') }}"><x-heroicon-o-user-group class="h-8 mr-2"/> {{ __('Admins') }}</a></li>
</ul> </ul>
<ul class="py-4 space-y-2 text-white"> <ul class="py-4 space-y-2 text-white">

View file

@ -47,7 +47,7 @@ Artisan::command('character:edit {id} {name}', function ($id, $name) {
})->purpose('Edit a character'); })->purpose('Edit a character');
Artisan::command('character:list {--trashed}', function ($trashed) { Artisan::command('character:list {--trashed}', function ($trashed) {
$cols = ['id', 'name' ]; $cols = ['id', 'name'];
if ($trashed) { if ($trashed) {
$cols[] = 'deleted_at'; $cols[] = 'deleted_at';
$q = Character::onlyTrashed(); $q = Character::onlyTrashed();
@ -83,7 +83,7 @@ Artisan::command('raid:add {name}', function ($name) {
Artisan::command('raid:edit {id} {name}', function ($id, $name) { Artisan::command('raid:edit {id} {name}', function ($id, $name) {
$raid = Raid::find($id); $raid = Raid::find($id);
if (!$raid ) { if (!$raid) {
$this->warn("Could not find raid."); $this->warn("Could not find raid.");
return; return;
} }
@ -95,7 +95,7 @@ Artisan::command('raid:edit {id} {name}', function ($id, $name) {
})->purpose('Edit a raid'); })->purpose('Edit a raid');
Artisan::command('raid:list {--trashed}', function ($trashed) { Artisan::command('raid:list {--trashed}', function ($trashed) {
$cols = ['id', 'name' ]; $cols = ['id', 'name'];
if ($trashed) { if ($trashed) {
$cols[] = 'deleted_at'; $cols[] = 'deleted_at';
$q = Raid::onlyTrashed(); $q = Raid::onlyTrashed();
@ -120,9 +120,9 @@ Artisan::command('raid:delete {id}', function ($id) {
// Cards // Cards
// -------------------------- // --------------------------
Artisan::command('card:add {body} {--column=} {--value=}', function ($body, $column=null, $value=null) { Artisan::command('card:add {body} {--column=} {--value=}', function ($body, $column = null, $value = null) {
$data = [ 'body' => $body ]; $data = ['body' => $body];
if ($value && !in_array($column, ['character_id', 'raid_id', 'class', 'role'])) { if ($value && !in_array($column, ['character_id', 'raid_id', 'class', 'role'])) {
$this->warn(sprintf("Invalid column '%s'", $column)); $this->warn(sprintf("Invalid column '%s'", $column));
@ -137,7 +137,7 @@ Artisan::command('card:add {body} {--column=} {--value=}', function ($body, $col
$this->info("Created card"); $this->info("Created card");
})->purpose('Create a new card'); })->purpose('Create a new card');
Artisan::command('card:edit {id} {--body=} {--column=} {--value=}', function ($id, $body=null, $column=null, $value=null) { Artisan::command('card:edit {id} {--body=} {--column=} {--value=}', function ($id, $body = null, $column = null, $value = null) {
$card = Card::find($id); $card = Card::find($id);
@ -164,7 +164,7 @@ Artisan::command('card:edit {id} {--body=} {--column=} {--value=}', function ($i
})->purpose('Update a card'); })->purpose('Update a card');
Artisan::command('card:list {--trashed}', function ($trashed) { Artisan::command('card:list {--trashed}', function ($trashed) {
$cols = [ 'id', 'character_id', 'raid_id', 'role', 'class', 'body' ]; $cols = ['id', 'character_id', 'raid_id', 'role', 'class', 'body'];
$q = Card::query(); $q = Card::query();
if ($trashed) { if ($trashed) {
$cols[] = 'deleted_at'; $cols[] = 'deleted_at';
@ -197,7 +197,7 @@ Artisan::command('admin:add {username} {password}', function ($username, $passwo
$this->info("Created admin user"); $this->info("Created admin user");
})->purpose('Add a admin user'); })->purpose('Add a admin user');
Artisan::command('admin:edit {id} {--username=} {--password=}', function ($id, $username=null, $password=null) { Artisan::command('admin:edit {id} {--username=} {--password=}', function ($id, $username = null, $password = null) {
$admin = Admin::find($id); $admin = Admin::find($id);
if (!$admin) { if (!$admin) {
@ -228,8 +228,8 @@ Artisan::command('admin:delete {id}', function ($id) {
})->purpose('Delete a admin user'); })->purpose('Delete a admin user');
Artisan::command('admin:list', function () { Artisan::command('admin:list', function () {
$cols = ['id', 'username', 'password', 'created_at', 'updated_at' ]; $cols = ['id', 'username', 'password', 'created_at', 'updated_at'];
$q = Admin::query(); $q = Admin::query();
$data = $q->select($cols)->get()->makeVisible('password'); $data = $q->select($cols)->get()->makeVisible('password');
$this->table($cols, $data); $this->table($cols, $data);
})->purpose('list admin users'); })->purpose('list admin users');

View file

@ -26,41 +26,41 @@ use Illuminate\Support\Facades\Session;
| |
*/ */
Route::get('/', function() { Route::get('/', function () {
return redirect()->route('setup'); return redirect()->route('setup');
}); });
Route::get('/setup', Setup::class)->name('setup'); Route::get('/setup', Setup::class)->name('setup');
route::get('/setup/{setting}', [ SettingController::class, "hash" ])->name('setup-hash'); route::get('/setup/{setting}', [SettingController::class, "hash"])->name('setup-hash');
Route::get('/game', Game::class)->name('game'); Route::get('/game', Game::class)->name('game');
// Admin section // Admin section
Route::prefix('admin')->group(function() { Route::prefix('admin')->group(function () {
// Auth // Auth
Route::get('/login', [AuthController::class, 'create'])->name('login'); Route::get('/login', [AuthController::class, 'create'])->name('login');
Route::post('/login', [AuthController::class, 'store']); Route::post('/login', [AuthController::class, 'store']);
Route::middleware(['auth'])->group(function() { Route::middleware(['auth'])->group(function () {
Route::get('/', [AdminController::class, 'index'])->name('admin'); Route::get('/', [AdminController::class, 'index'])->name('admin');
Route::get('/account', AccountForm::class); Route::get('/account', AccountForm::class);
Route::get('/cards', [CardController::class, 'index'])->name('admin.card.index'); Route::get('/cards', [CardController::class, 'index'])->name('admin.card.index');
Route::get('/cards/new', CardController::getForm())->name('admin.card.create'); Route::get('/cards/new', CardController::getForm())->name('admin.card.create');
Route::get('/cards/{card}', CardController::getForm())->name('admin.card.edit'); Route::get('/cards/{card}', CardController::getForm())->name('admin.card.edit');
Route::get('/characters', [CharacterController::class, 'index'])->name('admin.character.index'); Route::get('/characters', [CharacterController::class, 'index'])->name('admin.character.index');
Route::get('/characters/new', CharacterController::getForm())->name('admin.character.create'); Route::get('/characters/new', CharacterController::getForm())->name('admin.character.create');
Route::get('/characters/{character}', CharacterController::getForm())->name('admin.character.edit'); Route::get('/characters/{character}', CharacterController::getForm())->name('admin.character.edit');
Route::get('/raids', [RaidController::class, 'index'])->name('admin.raid.index'); Route::get('/raids', [RaidController::class, 'index'])->name('admin.raid.index');
Route::get('/raids/new', RaidController::getForm())->name('admin.raid.create'); Route::get('/raids/new', RaidController::getForm())->name('admin.raid.create');
Route::get('/raids/{raid}', RaidController::getForm())->name('admin.raid.edit'); Route::get('/raids/{raid}', RaidController::getForm())->name('admin.raid.edit');
Route::post('/logout', [AuthController::class, 'destroy'])->name('logout'); Route::post('/logout', [AuthController::class, 'destroy'])->name('logout');
}); });
}); });

View file

@ -14,8 +14,8 @@ $uri = urldecode(
// This file allows us to emulate Apache's "mod_rewrite" functionality from the // This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel // built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here. // application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
return false; return false;
} }
require_once __DIR__.'/public/index.php'; require_once __DIR__ . '/public/index.php';

View file

@ -13,7 +13,7 @@ trait CreatesApplication
*/ */
public function createApplication() public function createApplication()
{ {
$app = require __DIR__.'/../bootstrap/app.php'; $app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap(); $app->make(Kernel::class)->bootstrap();

View file

@ -19,7 +19,7 @@ class CardTest extends TestCase
protected $characters; protected $characters;
public function setUp() : void public function setUp(): void
{ {
parent::setUp(); parent::setUp();
@ -47,24 +47,24 @@ class CardTest extends TestCase
public function provider(): array public function provider(): array
{ {
return [ return [
[ [ 0 ], 16 ], [[0], 16],
[ [ 0, 1 ], 18 ], [[0, 1], 18],
]; ];
} }
public function providerClasses(): array public function providerClasses(): array
{ {
return [ return [
[ [ 'priest' ], 16 ], [['priest'], 16],
[ [ 'priest', 'warrior' ], 18 ], [['priest', 'warrior'], 18],
]; ];
} }
public function providerRoles(): array public function providerRoles(): array
{ {
return [ return [
[ [ 'dps' ], 16 ], [['dps'], 16],
[ [ 'dps', 'tank' ], 18 ], [['dps', 'tank'], 18],
]; ];
} }
@ -74,7 +74,7 @@ class CardTest extends TestCase
public function test_get_with_character_settings($characters, $count) public function test_get_with_character_settings($characters, $count)
{ {
$settings = new GameSettings(); $settings = new GameSettings();
foreach($characters as $i) { foreach ($characters as $i) {
$settings->characters->set($this->characters[$i]); $settings->characters->set($this->characters[$i]);
} }
@ -82,11 +82,11 @@ class CardTest extends TestCase
$this->assertSame($count, count($cards)); $this->assertSame($count, count($cards));
$expected = collect($characters)->map(function($i) { $expected = collect($characters)->map(function ($i) {
return $this->characters[$i]; return $this->characters[$i];
})->push(null); })->push(null);
foreach($cards as $card) { foreach ($cards as $card) {
$this->assertContains($card->character_id, $expected, $cards->pluck('character_id')); $this->assertContains($card->character_id, $expected, $cards->pluck('character_id'));
} }
} }
@ -97,7 +97,7 @@ class CardTest extends TestCase
public function test_get_with_raid_settings($raids, $count) public function test_get_with_raid_settings($raids, $count)
{ {
$settings = new GameSettings(); $settings = new GameSettings();
foreach($raids as $i) { foreach ($raids as $i) {
$settings->raids->set($this->raids[$i]); $settings->raids->set($this->raids[$i]);
} }
@ -105,11 +105,11 @@ class CardTest extends TestCase
$this->assertSame($count, count($cards)); $this->assertSame($count, count($cards));
$expected = collect($raids)->map(function($item) { $expected = collect($raids)->map(function ($item) {
return $this->raids[$item]; return $this->raids[$item];
})->push(null); })->push(null);
foreach($cards as $card) { foreach ($cards as $card) {
$this->assertContains($card->raid_id, $expected); $this->assertContains($card->raid_id, $expected);
} }
} }
@ -120,7 +120,7 @@ class CardTest extends TestCase
public function test_get_with_class_settings($classes, $count) public function test_get_with_class_settings($classes, $count)
{ {
$settings = new GameSettings(); $settings = new GameSettings();
foreach($classes as $class) { foreach ($classes as $class) {
$settings->classes->set($class); $settings->classes->set($class);
} }
@ -130,7 +130,7 @@ class CardTest extends TestCase
$expected = collect($classes)->push(null); $expected = collect($classes)->push(null);
foreach($cards as $card) { foreach ($cards as $card) {
$this->assertContains($card->class, $expected); $this->assertContains($card->class, $expected);
} }
} }
@ -141,7 +141,7 @@ class CardTest extends TestCase
public function test_get_with_role_settings($roles, $count) public function test_get_with_role_settings($roles, $count)
{ {
$settings = new GameSettings(); $settings = new GameSettings();
foreach($roles as $role) { foreach ($roles as $role) {
$settings->roles->set($role); $settings->roles->set($role);
} }
@ -151,7 +151,7 @@ class CardTest extends TestCase
$expected = collect($roles)->push(null); $expected = collect($roles)->push(null);
foreach($cards as $card) { foreach ($cards as $card) {
$this->assertContains($card->role, $expected); $this->assertContains($card->role, $expected);
} }
} }

View file

@ -19,9 +19,9 @@ class GameBoardStateTest extends TestCase
// 8, 9, 10, 11 // 8, 9, 10, 11
// 12, 13, 14, 15 // 12, 13, 14, 15
[ 4, 4, [], [ 1, 5, 8 ], 0 ], [4, 4, [], [1, 5, 8], 0],
[ 4, 4, [ 4, 5, 6, 7 ], [2, 3], 1 ], [4, 4, [4, 5, 6, 7], [2, 3], 1],
[ 4, 4, [ 8, 9, 10, 11, 2, 6, 14 ], [ 15 ], 2 ], [4, 4, [8, 9, 10, 11, 2, 6, 14], [15], 2],
// 5x3 board // 5x3 board
// --------------- // ---------------
@ -29,9 +29,9 @@ class GameBoardStateTest extends TestCase
// 5, 6, 7, 8, 9 // 5, 6, 7, 8, 9
// 10, 11, 12, 13, 14 // 10, 11, 12, 13, 14
[ 5, 3, [], [ 2, 4, 5, 8, 13 ], 0 ], [5, 3, [], [2, 4, 5, 8, 13], 0],
[ 5, 3, [ 5, 6, 7, 8, 9 ], [ 0, 3, 4, 10], 1 ], [5, 3, [5, 6, 7, 8, 9], [0, 3, 4, 10], 1],
[ 5, 3, [ 0, 5, 10, 3, 8, 13, 4, 9, 14 ], [ 6, 12 ], 3 ], [5, 3, [0, 5, 10, 3, 8, 13, 4, 9, 14], [6, 12], 3],
// 10x10 board // 10x10 board
// -------------------------------------- // --------------------------------------
@ -46,9 +46,9 @@ class GameBoardStateTest extends TestCase
// 80, 81, 82, 83, 84, 85, 86, 87, 88, 89 // 80, 81, 82, 83, 84, 85, 86, 87, 88, 89
// 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 // 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
[ 10, 10, [], [ 59, 31, 52 ], 0 ], [10, 10, [], [59, 31, 52], 0],
[ 10, 10, [ 3, 13, 23, 33, 43, 53, 63, 73, 83, 93 ], [7, 11, 24, 25, 31, 32, 57, 66, 90, 91 ], 1 ], [10, 10, [3, 13, 23, 33, 43, 53, 63, 73, 83, 93], [7, 11, 24, 25, 31, 32, 57, 66, 90, 91], 1],
[ 10, 10, [ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 4, 14, 34, 44, 54, 64, 74, 84, 94 ], [ 0, 32, 61, 78, 98 ], 2 ] [10, 10, [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 4, 14, 34, 44, 54, 64, 74, 84, 94], [0, 32, 61, 78, 98], 2]
]; ];
} }
@ -59,15 +59,15 @@ class GameBoardStateTest extends TestCase
{ {
$board = new GameBoardState($w, $h); $board = new GameBoardState($w, $h);
foreach($state_win + $state_press as $pos) { foreach ($state_win + $state_press as $pos) {
$board->set($pos); $board->set($pos);
} }
foreach($state_win as $pos) { foreach ($state_win as $pos) {
$this->assertTrue($board->isWin($pos)); $this->assertTrue($board->isWin($pos));
} }
foreach($state_press as $pos) { foreach ($state_press as $pos) {
$this->assertFalse($board->isWin($pos)); $this->assertFalse($board->isWin($pos));
} }
} }
@ -79,11 +79,11 @@ class GameBoardStateTest extends TestCase
{ {
$board = new GameBoardState($w, $h); $board = new GameBoardState($w, $h);
foreach($state_win + $state_press as $pos) { foreach ($state_win + $state_press as $pos) {
$board->set($pos); $board->set($pos);
} }
foreach($state_win + $state_press as $pos) { foreach ($state_win + $state_press as $pos) {
$this->assertTrue($board->isPressed($pos)); $this->assertTrue($board->isPressed($pos));
} }
} }
@ -95,7 +95,7 @@ class GameBoardStateTest extends TestCase
{ {
$board = new GameBoardState($w, $h); $board = new GameBoardState($w, $h);
foreach($state_win + $state_press as $pos) { foreach ($state_win + $state_press as $pos) {
$board->set($pos); $board->set($pos);
} }

View file

@ -32,7 +32,7 @@ class SetTest extends TestCase
{ {
$set = new Set(['one' => true, 'two' => true, 'three' => true]); $set = new Set(['one' => true, 'two' => true, 'three' => true]);
$set->fill(["five" => true, "six" => true, "seven" => false ]); $set->fill(["five" => true, "six" => true, "seven" => false]);
$this->assertSame(['five', 'six'], $set->all()->toArray()); $this->assertSame(['five', 'six'], $set->all()->toArray());
} }