Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
Improve achievements
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Apr 11, 2016
1 parent c1ce98a commit b3e799e
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers;
namespace Domains\Bot;

use Domains\Room;
use Domains\Achieve;
use Illuminate\Support\Collection;
use Illuminate\Contracts\Support\Jsonable;
use Domains\Bot\Achievements\DocsAchieve;
use Domains\Bot\Achievements\Karma100Achieve;
use Domains\Bot\Achievements\Karma10Achieve;
use Domains\Bot\Achievements\Karma500Achieve;
use Domains\Bot\Achievements\Karma50Achieve;
use Domains\Bot\Achievements\Thanks100Achieve;
use Domains\Bot\Achievements\Thanks10Karma0Achieve;
use Domains\Bot\Achievements\Thanks20Achieve;
use Domains\Bot\Achievements\Thanks50Achieve;
use Domains\Room;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Collection;
use Interfaces\Gitter\Subscriber\SubscriberInterface;
use Core\Subscribers\Achievements\Karma10Achieve;
use Core\Subscribers\Achievements\Karma50Achieve;
use Core\Subscribers\Achievements\Karma100Achieve;
use Core\Subscribers\Achievements\Karma500Achieve;
use Core\Subscribers\Achievements\Thanks20Achieve;
use Core\Subscribers\Achievements\Thanks50Achieve;
use Core\Subscribers\Achievements\Thanks100Achieve;
use Core\Subscribers\Achievements\Thanks10Karma0Achieve;
use Core\Subscribers\Achievements\DocsAchieve;

/**
* Class AchieveSubscriber
Expand All @@ -46,7 +46,7 @@ class AchieveSubscriber implements
Thanks50Achieve::class,
Thanks100Achieve::class,
Thanks10Karma0Achieve::class,
DocsAchieve::class
DocsAchieve::class,
];

/**
Expand All @@ -65,14 +65,6 @@ public function __construct()
}
}

/**
* @return array
*/
public function getAchievementInstances(): array
{
return $this->instances;
}

/**
* Subscribe achievements
*/
Expand All @@ -93,11 +85,12 @@ public function handle()
}

/**
* @return Collection
* @param int $options
* @return string
*/
public function toCollection(): Collection
public function toJson($options = 0): string
{
return new Collection($this->getAchievementInstances());
return json_encode($this->toArray(), $options);
}

/**
Expand All @@ -111,11 +104,18 @@ public function toArray(): array
}

/**
* @param int $options
* @return string
* @return Collection
*/
public function toJson($options = 0): string
public function toCollection(): Collection
{
return json_encode($this->toArray(), $options);
return new Collection($this->getAchievementInstances());
}

/**
* @return array
*/
public function getAchievementInstances(): array
{
return $this->instances;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -40,4 +40,4 @@ public function handle()
{
// Only manual addition
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -46,4 +46,4 @@ public function handle()
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -47,4 +47,4 @@ public function handle()
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -46,4 +46,4 @@ public function handle()
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -46,4 +46,4 @@ public function handle()
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -46,4 +46,4 @@ public function handle()
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -46,4 +46,4 @@ public function handle()
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Core\Subscribers\Achievements;
namespace Domains\Bot\Achievements;

use Domains\Karma;
use Interfaces\Gitter\Achieve\AbstractAchieve;
Expand Down Expand Up @@ -46,4 +46,4 @@ public function handle()
}
});
}
}
}
4 changes: 2 additions & 2 deletions app/Interfaces/Gitter/Achieve/AbstractAchieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class AbstractAchieve implements
*/
public function __construct()
{
$this->name = static::class;
$this->name = basename(static::class);
}

/**
Expand Down Expand Up @@ -109,4 +109,4 @@ public function toJson($options = 0): string
{
return json_encode($this->toArray(), $options);
}
}
}
2 changes: 1 addition & 1 deletion config/gitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
// Subscribers
'subscribers' => [
// Подписывается на создание ачивки и отправляет сообщеньку в чат
Core\Subscribers\AchieveSubscriber::class,
Domains\Bot\AchieveSubscriber::class,
],
];

0 comments on commit b3e799e

Please sign in to comment.