Skip to content

Commit

Permalink
feat: prepare legends extension + increase played cards size again
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliboy50 committed Oct 22, 2022
1 parent ce8b3a3 commit ebace9a
Show file tree
Hide file tree
Showing 8 changed files with 554 additions and 146 deletions.
8 changes: 7 additions & 1 deletion dbmodel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ CREATE TABLE IF NOT EXISTS `card` (

ALTER TABLE `player`
ADD `rounds_ranking` VARCHAR(250) NOT NULL DEFAULT '',
ADD `is_wearing_jersey` TINYINT UNSIGNED NOT NULL DEFAULT 0;
ADD `has_card_jersey` TINYINT UNSIGNED NOT NULL DEFAULT 0,
ADD `has_card_legends_broom_wagon` TINYINT UNSIGNED NOT NULL DEFAULT 0,
ADD `has_card_legends_eagle` TINYINT UNSIGNED NOT NULL DEFAULT 0,
ADD `has_card_legends_panda` TINYINT UNSIGNED NOT NULL DEFAULT 0,
ADD `has_card_legends_shark` TINYINT UNSIGNED NOT NULL DEFAULT 0,
ADD `has_card_legends_badger` TINYINT UNSIGNED NOT NULL DEFAULT 0,
ADD `has_card_legends_elephant` TINYINT UNSIGNED NOT NULL DEFAULT 0;
10 changes: 10 additions & 0 deletions gameoptions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@
],
'default' => 5,
],
// 110 => [
// 'name' => totranslate('Extension "Legends"'),
// 'values' => [
// 0 => ['name' => totranslate('No')],
// 1 => ['name' => totranslate('Yes')],
// ],
// 'default' => 0,
// 'description' => totranslate('Add 6 special cards'),
// 'nobeginner' => true,
// ],
];
44 changes: 43 additions & 1 deletion modules/VelonimoPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class VelonimoPlayer
*/
private array $roundsRanking;
private bool $isWearingJersey;
private bool $hasCardLegendsBroomWagon;
private bool $hasCardLegendsEagle;
private bool $hasCardLegendsPanda;
private bool $hasCardLegendsShark;
private bool $hasCardLegendsBadger;
private bool $hasCardLegendsElephant;

public function __construct(
int $bgaId,
Expand All @@ -28,7 +34,13 @@ public function __construct(
int $score,
int $lastNumberOfPointsEarned,
array $roundsRanking,
bool $isWearingJersey
bool $isWearingJersey,
bool $hasCardLegendsBroomWagon,
bool $hasCardLegendsEagle,
bool $hasCardLegendsPanda,
bool $hasCardLegendsShark,
bool $hasCardLegendsBadger,
bool $hasCardLegendsElephant
) {
$this->bgaId = $bgaId;
$this->naturalOrderPosition = $naturalOrderPosition;
Expand All @@ -38,6 +50,12 @@ public function __construct(
$this->lastNumberOfPointsEarned = $lastNumberOfPointsEarned;
$this->roundsRanking = $roundsRanking;
$this->isWearingJersey = $isWearingJersey;
$this->hasCardLegendsBroomWagon = $hasCardLegendsBroomWagon;
$this->hasCardLegendsEagle = $hasCardLegendsEagle;
$this->hasCardLegendsPanda = $hasCardLegendsPanda;
$this->hasCardLegendsShark = $hasCardLegendsShark;
$this->hasCardLegendsBadger = $hasCardLegendsBadger;
$this->hasCardLegendsElephant = $hasCardLegendsElephant;
}

/*
Expand Down Expand Up @@ -113,6 +131,30 @@ public function isWearingJersey(): bool
{
return $this->isWearingJersey;
}
public function hasCardLegendsBroomWagon(): bool
{
return $this->hasCardLegendsBroomWagon;
}
public function hasCardLegendsEagle(): bool
{
return $this->hasCardLegendsEagle;
}
public function hasCardLegendsPanda(): bool
{
return $this->hasCardLegendsPanda;
}
public function hasCardLegendsShark(): bool
{
return $this->hasCardLegendsShark;
}
public function hasCardLegendsBadger(): bool
{
return $this->hasCardLegendsBadger;
}
public function hasCardLegendsElephant(): bool
{
return $this->hasCardLegendsElephant;
}
public function getRoundsRanking(): array
{
return $this->roundsRanking;
Expand Down
11 changes: 9 additions & 2 deletions modules/constants.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
define('ST_END_ROUND', 80);
define('ST_BGA_GAME_END', 99);

// Cards color ID
// Cards color
define('COLOR_BLUE', 10);
define('COLOR_BROWN', 20);
define('COLOR_GRAY', 30);
Expand All @@ -46,6 +46,13 @@
define('VALUE_45', 45);
define('VALUE_50', 50);
define('VALUE_JERSEY', 10);
define('VALUE_LEGENDS_BROOM_WAGON', 5);

// Special cards ID
define('CARD_ID_JERSEY', 0);
define('CARD_ID_JERSEY_PLUS_TEN', -2);
define('CARD_ID_LEGENDS_BROOM_WAGON_PLUS_FIVE', -3);
define('CARD_ID_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER', -4);
define('CARD_ID_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR', -5);
define('CARD_ID_LEGENDS_SHARK_ONE_RED_MULTIPLY_TEN', -6);
define('CARD_ID_LEGENDS_BADGER_ANY_NUMBER_OF_EACH_COLOR', -7);
define('CARD_ID_LEGENDS_ELEPHANT_STOP', -8);
20 changes: 18 additions & 2 deletions velonimo.action.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,24 @@ public function playCards()
$cardIds = explode(';', $cardsArg);

$withJerseyArg = (bool) self::getArg('withJersey', AT_bool, true);

$this->game->playCards(array_map(fn ($id) => (int) $id, $cardIds), $withJerseyArg);
$withLegendsBroomWagonArg = (bool) self::getArg('withLegendsBroomWagon', AT_bool, true);
$withLegendsEagleArg = (bool) self::getArg('withLegendsEagle', AT_bool, true);
$withLegendsPandaArg = (bool) self::getArg('withLegendsPanda', AT_bool, true);
$withLegendsSharkArg = (bool) self::getArg('withLegendsShark', AT_bool, true);
$withLegendsBadgerArg = (bool) self::getArg('withLegendsBadger', AT_bool, true);
$withLegendsElephantArg = (bool) self::getArg('withLegendsElephant', AT_bool, true);

// @TODO: support extension legends
$this->game->playCards(
array_map(fn ($id) => (int) $id, $cardIds),
$withJerseyArg,
$withLegendsBroomWagonArg,
$withLegendsEagleArg,
$withLegendsPandaArg,
$withLegendsSharkArg,
$withLegendsBadgerArg,
$withLegendsElephantArg
);

self::ajaxResponse();
}
Expand Down
19 changes: 10 additions & 9 deletions velonimo.css
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ Board cards
*/
#played-cards {
position: relative;
top: 166px; /* (containerHeight / 2) - (selfHeight / 2) */
top: 160px; /* (containerHeight / 2) - (selfHeight / 2) - 6px */
left: 235px; /* (containerWidth / 2) - (selfWidth / 2) */
display: flex;
align-items: center;
justify-content: center;
width: 270px; /* cardWidth + (6 * (cardWidth / 3)) */
height: 148px; /* cardHeight + (cardHeight / 6) */
height: 156px; /* cardHeight + (cardHeight / 6) + 8px */
z-index: 4;
}
#previous-last-played-cards {
Expand All @@ -372,7 +372,7 @@ Board cards
#last-played-cards .velonimo-card {
transition-property: all;
transition-duration: 0.5s;
transform: scale(1.2);
transform: scale(1.3);
}
/* /!\ 2P mode only */
#cards-deck {
Expand Down Expand Up @@ -423,7 +423,8 @@ Current player hand
display: inline-block;
margin: 0 0 0 10px;
}
#group-cards-button {
#group-cards-button,
#ungroup-cards-button {
display: inline-block;
margin: 0 0 0 10px;
}
Expand Down Expand Up @@ -486,12 +487,12 @@ Cards
opacity: 0.2;
}
.cards-stack .velonimo-card {
margin-right: -60px; /* 2/3 of card width */
margin-right: -50px; /* 2/3 of card width - 10px */
}
.cards-group-card::after {
content: "";
border-top: 4px solid black;
border-bottom: 4px solid black;
border-top: 3px solid black;
border-bottom: 3px solid black;
position: absolute;
top: -2px;
bottom: -2px;
Expand All @@ -500,15 +501,15 @@ Cards
}
.cards-group-card-left::before {
content: "";
border-left: 4px solid black;
border-left: 3px solid black;
position: absolute;
top: -2px;
bottom: -2px;
left: -3px;
}
.cards-group-card-right::before {
content: "";
border-right: 4px solid black;
border-right: 3px solid black;
position: absolute;
top: -2px;
bottom: -2px;
Expand Down
Loading

0 comments on commit ebace9a

Please sign in to comment.