Skip to content

Commit

Permalink
Merge pull request #265 from lanedirt/233-implement-attack-mission-an…
Browse files Browse the repository at this point in the history
…d-battle-system-logic

Add attack mission and battle report logic
  • Loading branch information
lanedirt authored Aug 19, 2024
2 parents e890977 + 2c7295c commit a0b1566
Show file tree
Hide file tree
Showing 75 changed files with 5,376 additions and 327 deletions.
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ $ php artisan test:race-condition-unitqueue
$ php artisan test:race-condition-game-mission
```

### 5. Keep it simple
If your PR is too big, it will be hard to review. Try to keep it simple and small. If you want to do more than one thing, send multiple pull requests.
### 5. Run CSS and JS build
OGameX uses Laravel Mix to compile the CSS and JS assets. Before submitting a PR, make sure to run the following command to compile the assets.
This command can be run in watch mode to automatically recompile the assets when changes are made which is useful during development.

### 6. Keep it clean
Please remove any unrelated changes from your PR. If you have changes in your branch that are not related to the PR, please create a new branch for them.

If you have any questions, feel free to reach out to the maintainer(s). Thank you in advance for your contributions! 🎉
```
$ npm run dev watch
```
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,25 @@ OGameX is under active development with several core features already implemente
- Planet switching
- Highscore system
- Basic messages system
- Battle system
- Fleet dispatch missions
- Transport
- Deployment
- Colonisation
- Espionage
- Attack
- Basic admin panel

### <a name="upcoming-features"></a> a) Upcoming Features

New features are continuously being added. Upcoming features:
- Remaining fleet dispatch missions (recycling, attack, ACS)
- Battlesystem
- Support for Moons
- Moon destruction fleet dispatch mission
New features are continuously being added. Upcoming major features:
- Recycle fleet dispatch mission
- Support for Moons
- Moon creation through debris field after battle
- Moon buildings
- Phalanx
- Moon destruction fleet dispatch mission
- ACS fleet dispatch missions
- Alliance system
- Improve galaxy overview
- Improve message system
Expand Down
8 changes: 7 additions & 1 deletion app/Console/Commands/Tests/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ protected function setup(): void
// Delete user if it already exists.
$user = User::where('email', '=', $this->email)->first();
if ($user) {
$playerServiceFactory->make($user->id)->delete();
try {
$playerServiceFactory->make($user->id)->delete();
} catch (Exception $e) {
$this->error("Failed to delete existing user: " . $e->getMessage());
// Try to delete the user directly from the database.
$user->delete();
}
}

// Create a test user
Expand Down
2 changes: 2 additions & 0 deletions app/Factories/GameMessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Contracts\Container\BindingResolutionException;
use OGame\GameMessages\Abstracts\GameMessage;
use OGame\GameMessages\BattleReport;
use OGame\GameMessages\ColonyEstablished;
use OGame\GameMessages\ColonyEstablishFailAstrophysics;
use OGame\GameMessages\EspionageReport;
Expand Down Expand Up @@ -37,6 +38,7 @@ class GameMessageFactory
'fleet_deployment' => FleetDeployment::class,
'fleet_deployment_with_resources' => FleetDeploymentWithResources::class,
'espionage_report' => EspionageReport::class,
'battle_report' => BattleReport::class,
];

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Factories/GameMissionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Contracts\Container\BindingResolutionException;
use OGame\GameMissions\Abstracts\GameMission;
use OGame\GameMissions\AttackMission;
use OGame\GameMissions\ColonisationMission;
use OGame\GameMissions\DeploymentMission;
use OGame\GameMissions\EspionageMission;
Expand Down Expand Up @@ -33,6 +34,7 @@ public static function getAllMissions(): array
*/
try {
return [
1 => app()->make(AttackMission::class),
3 => app()->make(TransportMission::class),
4 => app()->make(DeploymentMission::class),
6 => app()->make(EspionageMission::class),
Expand All @@ -53,6 +55,8 @@ public static function getMissionById(int $missionId, array $dependencies): Game
{
try {
switch ($missionId) {
case 1:
return app()->make(AttackMission::class, $dependencies);
case 3:
return app()->make(TransportMission::class, $dependencies);
case 4:
Expand Down
9 changes: 7 additions & 2 deletions app/GameMessages/Abstracts/GameMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OGame\Factories\PlayerServiceFactory;
use OGame\Models\Message;
use OGame\Models\Planet\Coordinate;
use OGame\Services\ObjectService;

/**
* GameMessage class which contains unique parsing logic for a specific message type.
Expand Down Expand Up @@ -42,21 +43,25 @@ abstract class GameMessage

protected PlayerServiceFactory $playerServiceFactory;

protected ObjectService $objects;

/**
* GameMessage constructor.
*
* @param Message $message
* @param PlanetServiceFactory $planetServiceFactory
* @param PlayerServiceFactory $playerServiceFactory
* @param Message $message
* @param ObjectService $objectService
*/
public function __construct(Message $message, PlanetServiceFactory $planetServiceFactory, PlayerServiceFactory $playerServiceFactory)
public function __construct(Message $message, PlanetServiceFactory $planetServiceFactory, PlayerServiceFactory $playerServiceFactory, ObjectService $objectService)
{
// Clone the message to prevent any changes to the original message affecting this object.
// This is important because otherwise mutations such as setting the viewed flag after loading this object
// would affect this object's state as well.
$this->message = clone $message;
$this->planetServiceFactory = $planetServiceFactory;
$this->playerServiceFactory = $playerServiceFactory;
$this->objects = $objectService;
$this->initialize();
}

Expand Down
Loading

0 comments on commit a0b1566

Please sign in to comment.