Skip to content

Commit

Permalink
Final finishes and release candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianluczak committed Dec 10, 2021
1 parent d50419d commit e6ec990
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 3 deletions.
14 changes: 14 additions & 0 deletions resources/levels/Rivermouth_city.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,31 @@ places:
size: [ 9, 9 ]
starting_point: [ 3, 6 ]

# TBD of scope and shape and purpose
stables:
generation_class: App\Generator\Level\DefaultBoxRoomGenerator
size: [ 9, 9 ]
starting_point: [ 2, 49 ]

# TBD of scope and shape and purpose
# - buy health potions?
# - take quests? <---- I LIKE IT
tavern:
generation_class: App\Generator\Level\DefaultBoxRoomGenerator
size: [ 9, 9 ]
starting_point: [ 21, 12 ]

# TBD of scope and shape and purpose
# - Change allignment ?
# - get rid of curses <--- I LIKE IT
cathedral:
generation_class: App\Generator\Level\DefaultBoxRoomGenerator
size: [ 9, 9 ]
starting_point: [ 11, 82 ]

# Just an idea, could be good
#river:
# generation_class: App\Generator\Level\RiverGenerator
# size: 10
# starting_point: [ 0, 60 ]
# fluctuation: 4
24 changes: 24 additions & 0 deletions src/Message/PrayAtTheAltarMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

namespace App\Message;

use App\Model\Player\PlayerInterface;

class PrayAtTheAltarMessage implements MessageInterface
{
protected PlayerInterface $player;

public function getPlayer(): PlayerInterface
{
return $this->player;
}

public function setPlayer(PlayerInterface $player): PrayAtTheAltarMessage
{
$this->player = $player;

return $this;
}
}
31 changes: 31 additions & 0 deletions src/MessageHandler/PrayAtTheAltarHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App\MessageHandler;

use App\Message\GameEffectMessage;
use App\Message\PrayAtTheAltarMessage;
use App\Model\RandomEvent\AltarPrayerGameEvent;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
use Symfony\Component\Messenger\MessageBusInterface;

class PrayAtTheAltarHandler implements MessageHandlerInterface
{
protected MessageBusInterface $messageBus;

public function __construct(MessageBusInterface $messageBus)
{
$this->messageBus = $messageBus;
}

public function __invoke(PrayAtTheAltarMessage $message): void
{
// TODO add multiple events based on luck of player
// do this as a strategy, because this service is 100% DI ready
$player = $message->getPlayer();
// FIXME this is just an example how to fire a event in event loop ("tick's" in ClockService)
$event = new AltarPrayerGameEvent($player);
$this->messageBus->dispatch(new GameEffectMessage($event));
}
}
47 changes: 47 additions & 0 deletions src/Model/Dialogue/City/AltarDialogue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace App\Model\Dialogue\City;

use App\Message\MessageInterface;
use App\Message\PrayAtTheAltarMessage;
use App\Message\WrongDialogueOptionMessage;
use App\Model\Dialogue\DialogueInterface;

class AltarDialogue implements DialogueInterface
{
public const DIALOGUE_ENTITY = '𝕲𝖔𝖉𝖘';
public const DIALOGUE_TEXT = '𝕯𝖔 𝖞𝖔𝖚 𝖜𝖆𝖓𝖙 𝖙𝖔 𝖕𝖗𝖆𝖞 𝖆𝖙 𝖙𝖍𝖊 𝖆𝖑𝖙𝖆𝖗?';
public const DIALOGUE_OPTIONS = ['YES', 'no'];

public function getEntity(): string
{
return self::DIALOGUE_ENTITY;
}

public function getText(): string
{
return self::DIALOGUE_TEXT;
}

public function getOptions(): array
{
return self::DIALOGUE_OPTIONS;
}

public function print(): string
{
return sprintf('[%s] %s [%s | %s]', self::DIALOGUE_ENTITY, self::DIALOGUE_TEXT, self::DIALOGUE_OPTIONS[0], self::DIALOGUE_OPTIONS[1]);
}

public function handleButtonPress(string $buttonPressed): ?MessageInterface
{
switch ($buttonPressed) {
case '1':
return new PrayAtTheAltarMessage();
default:
return new WrongDialogueOptionMessage();
}
}
}
4 changes: 2 additions & 2 deletions src/Model/Tile/City/AltarTile.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Model\Player\PlayerInterface;
use App\Model\Stats\StatsInterface;
use App\Model\Tile\AbstractTile;
use App\Model\Tile\TileInteraction\EmptyTileInteraction;
use App\Model\Tile\TileInteraction\AltarTileInteraction;
use App\Model\Tile\TileInteraction\TileInteractionInterface;
use App\Model\Tile\TileLogic\NoLogic;
use App\Model\Tile\TileLogic\TileLogicInterface;
Expand Down Expand Up @@ -42,7 +42,7 @@ public function handleLogic(int $scale, StatsInterface $stats): TileLogicInterfa

public function handleInteraction(PlayerInterface $player): TileInteractionInterface
{
return new EmptyTileInteraction();
return new AltarTileInteraction();
}

public function draw(): string
Expand Down
21 changes: 21 additions & 0 deletions src/Model/Tile/TileInteraction/AltarTileInteraction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Model\Tile\TileInteraction;

use App\Model\Dialogue\City\AltarDialogue;
use App\Model\Dialogue\DialogueInterface;

class AltarTileInteraction implements TileInteractionInterface
{
protected DialogueInterface $dialogue;

public function __construct()
{
$this->dialogue = new AltarDialogue();
}

public function getDialogue(): DialogueInterface
{
return $this->dialogue;
}
}
2 changes: 1 addition & 1 deletion src/Model/Tile/TileLogic/BossRoomTileLogic.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function process(PlayerInterface $player): void
// FIXME scale is not fine, maybe should be higher or affected by something more?
/* @var CreatureInterface $boss */
$boss = new $bossRolled(ScaleHelper::bossEncounterScale($this->scale, 1.2));
if ($boss instanceof CreatureInterface && $boss instanceof AbstractBossCreature) {
if ($boss instanceof AbstractBossCreature) {
$this->creature = $boss;
} else {
throw new \LogicException('BossRoomTileLogic can spawn only Boss creatures');
Expand Down

0 comments on commit e6ec990

Please sign in to comment.