Skip to content

Commit

Permalink
Merge pull request #36 from sebastianluczak/feature/dungeons-dlc
Browse files Browse the repository at this point in the history
Feature/dungeons dlc
  • Loading branch information
sebastianluczak authored Nov 15, 2021
2 parents c150486 + ba79b54 commit 0961acd
Show file tree
Hide file tree
Showing 20 changed files with 307 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Worst game on the planet.

#### Prerequisites:
- Docker with Docker Compose
- Terminal Emulator capable of dosplaying rich text and XTERM256 support
- Terminal Emulator capable of displaying rich text and XTERM256 support

```shell
cd ~
Expand Down
1 change: 0 additions & 1 deletion config/packages/messenger.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
framework:
messenger:
transports:
redis: "%env(MESSENGER_TRANSPORT_DSN)%"
sync: 'sync://'
3 changes: 3 additions & 0 deletions docs/images/screenshot — kopia.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
LastWriterPackageFamilyName=Microsoft.ScreenSketch_8wekyb3d8bbwe
ZoneId=3
Binary file modified docs/images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/images/screenshot.png:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
LastWriterPackageFamilyName=Microsoft.ScreenSketch_8wekyb3d8bbwe
ZoneId=3
38 changes: 38 additions & 0 deletions src/Command/GameTestCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Command;

use App\Service\GameService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class GameTestCommand extends Command
{
protected static $defaultName = 'game:test';
protected GameService $gameService;

public function __construct(GameService $gameService, string $name = null)
{
parent::__construct($name);
$this->gameService = $gameService;
}

protected function configure(): void
{
$this->setHelp('Test of Game');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<fg=#00ff00;bg=#00f>... contents ...</>');

return Command::SUCCESS;
}

private function clearScreen()
{
echo chr(27).chr(91).'H'.chr(27).chr(91).'J'; //^[H^[J
}
}
2 changes: 2 additions & 0 deletions src/Enum/GameIconEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @method static STATS()
* @method static INVENTORY()
* @method static SKULL()
* @method static GEM()
*/
class GameIconEnum extends Enum
{
Expand All @@ -35,4 +36,5 @@ class GameIconEnum extends Enum
private const INVENTORY = '🧳';

private const SKULL = '💀';
private const GEM = '💎';
}
7 changes: 1 addition & 6 deletions src/Model/Loot/AbstractLoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ public function getLootPickupMessage(): string

public function isBetterThan(LootInterface $otherLoot): bool
{
if ($this->getLootClass()->getValue() == $otherLoot->getLootClass()->getValue()) {
if ($this->getAverageRoll() > $otherLoot->getAverageRoll()) {
return true; // current loot ($self) IS better than $otherLoot
}
}
if ($this->getLootClass()->getValue() < $otherLoot->getLootClass()->getValue()) {
if ($this->getAverageRoll() > $otherLoot->getAverageRoll()) {
return true; // current loot ($self) IS better than $otherLoot
}

Expand Down
36 changes: 36 additions & 0 deletions src/Model/Loot/Keystone/AbstractKeystone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Model\Loot\Keystone;

use App\Enum\GameIconEnum;
use App\Enum\Loot\LootTypeEnum;
use App\Model\Loot\AbstractLoot;

abstract class AbstractKeystone extends AbstractLoot
{
public function __construct()
{
parent::__construct();

$this->lootType = LootTypeEnum::KEYSTONE();
}

public function isWeapon(): bool
{
return false;
}

public function isArmor(): bool
{
return false;
}

public function __toString(): string
{
return sprintf(
"%s %s",
GameIconEnum::GEM(),
$this->getName()
);
}
}
19 changes: 19 additions & 0 deletions src/Model/Loot/Keystone/BrokenKeystone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Model\Loot\Keystone;

use App\Enum\GameIconEnum;
use App\Model\Stats\Stats;

class BrokenKeystone extends AbstractKeystone
{
protected string $name = "Broken keystone";

public function __construct(Stats $stats)
{
parent::__construct();

$this->lootPickupMessage = "You've picked up " . GameIconEnum::GEM() . " " . $this->getName();
$this->dice = '1d1';
}
}
20 changes: 20 additions & 0 deletions src/Model/Loot/Keystone/ChromaticKeystone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Model\Loot\Keystone;

use App\Enum\GameIconEnum;
use App\Model\Stats\Stats;

class ChromaticKeystone extends AbstractKeystone
{
protected string $name = "Chromatic keystone";

public function __construct(Stats $stats)
{
parent::__construct();

$this->lootPickupMessage = "You've picked up " . GameIconEnum::GEM() . " " . $this->getName();

$this->dice = '2d' . random_int(1, $stats->getIntelligence() + 1) . '+' . $stats->getLuck();
}
}
20 changes: 20 additions & 0 deletions src/Model/Loot/Keystone/ColorlessKeystone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Model\Loot\Keystone;

use App\Enum\GameIconEnum;
use App\Model\Stats\Stats;

class ColorlessKeystone extends AbstractKeystone
{
protected string $name = "Colorless keystone";

public function __construct(Stats $stats)
{
parent::__construct();

$this->lootPickupMessage = "You've picked up " . GameIconEnum::GEM() . " " . $this->getName();

$this->dice = '5d' . random_int(1, $stats->getIntelligence() + 8) . '+' . $stats->getLuck();
}
}
20 changes: 20 additions & 0 deletions src/Model/Loot/Keystone/PrismaticKeystone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Model\Loot\Keystone;

use App\Enum\GameIconEnum;
use App\Model\Stats\Stats;

class PrismaticKeystone extends AbstractKeystone
{
protected string $name = "Prismatic keystone";

public function __construct(Stats $stats)
{
parent::__construct();

$this->lootPickupMessage = "You've picked up " . GameIconEnum::GEM() . " " . $this->getName();

$this->dice = '1d' . random_int(1, $stats->getIntelligence()) . '+' . $stats->getLuck();
}
}
7 changes: 6 additions & 1 deletion src/Model/Player/Inventory/PlayerInventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Enum\Loot\LootTypeEnum;
use App\Model\Loot\Armor\Shield;
use App\Model\Loot\Keystone\BrokenKeystone;
use App\Model\Loot\LootInterface;
use App\Model\Loot\Weapon\Sword;
use App\Model\Stats\Stats;
Expand All @@ -21,6 +22,7 @@ public function __construct(Stats $stats)
$this->weaponSlot = new Sword($stats);
// todo luckModifier from stats, do it other way, factory?
$this->armorSlot = new Shield($stats);
$this->keyStone = new BrokenKeystone($stats);
}

public function getWeaponSlot(): LootInterface
Expand Down Expand Up @@ -55,7 +57,10 @@ public function handleLoot(LootInterface $loot): PlayerInventoryInterface
}
break;
case LootTypeEnum::KEYSTONE():
$this->keyStone = $loot;
if (!$this->keyStone->isBetterThan($loot)) {
$this->keyStone = $loot;
$this->hasChanged = true;
}
break;
}

Expand Down
40 changes: 40 additions & 0 deletions src/Model/Tile/BossRoomTile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Model\Tile;

use App\Model\Stats\StatsInterface;
use App\Model\Tile\TileLogic\BossRoomTileLogic;
use App\Model\Tile\TileLogic\TileLogicInterface;

class BossRoomTile extends AbstractTile
{
public function isInteractable(): bool
{
return false;
}

public function isPassable(): bool
{
return true;
}

public function isSpawn(): bool
{
return false;
}

public function hasLogic(): bool
{
return true;
}

public function handleLogic(int $scale, StatsInterface $stats): TileLogicInterface
{
return new BossRoomTileLogic($scale);
}

public function draw(): string
{
return "<fg=bright-red>*</>";
}
}
2 changes: 1 addition & 1 deletion src/Model/Tile/ChestTile.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public function handleLogic(int $scale, StatsInterface $stats): TileLogicInterfa

public function draw(): string
{
return "#";
return "<fg=bright-white>#</>";
}
}
70 changes: 70 additions & 0 deletions src/Model/Tile/TileLogic/BossRoomTileLogic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace App\Model\Tile\TileLogic;

use App\Enum\MessageClassEnum;
use App\Model\Creature\CreatureInterface;
use App\Model\Creature\Dragon;
use App\Model\Player\PlayerInterface;
use App\Model\RandomEvent\RandomEventInterface;
use App\Model\RandomEvent\ThiefArrivedGameEvent;

class BossRoomTileLogic implements TileLogicInterface
{
protected int $scale;
protected string $rawMessage;
protected string $messageClass;
protected CreatureInterface $creature;
protected RandomEventInterface $event;

public function __construct(int $scale)
{
$this->scale = $scale;
$this->rawMessage = "You've entered a dark room...";
$this->messageClass = MessageClassEnum::IMPORTANT();
}

public function process(PlayerInterface $player)
{
if ($player->getInventory()->getKeystone()->getAverageRoll() > 3) {
$this->creature = new Dragon($this->scale * 1.8);
} else {
$this->event = new ThiefArrivedGameEvent($player);
}
}

public function hasAdventureLogMessage(): bool
{
return !empty($this->rawMessage);
}

public function getAdventureLogMessage(): string
{
return $this->rawMessage;
}

public function getAdventureLogMessageClass(): string
{
return $this->messageClass;
}

public function hasEncounter(): bool
{
return !empty($this->creature);
}

public function getEncounteredCreature(): ?CreatureInterface
{
return $this->creature;
}

public function getEvent(): RandomEventInterface
{
return $this->event;
}

public function hasEvent(): bool
{
return !empty($this->event);
}
}
Loading

0 comments on commit 0961acd

Please sign in to comment.