Skip to content

Commit

Permalink
feat(legends): support legends extension (#6)
Browse files Browse the repository at this point in the history
* feat(legends): support legends extension

* fix: card size in hand + global value must be INT

* fix: cards background position since cards sprite has changed

* fix: update cards sprite to put legends before adventurers

* fix: show legends coaches in logs and panel

* fix: show legends cards + support coach Elephant

* fix: all cards are supported

* fix: selected/unselected coach bugs + groups border color

* fix: special cards design on table + eagle highest value

* fix: highest values with coaches + hide coach when player wears the jersey

* fix: coach card not selectable after giving back cards + improve round results

* fix: new finish images + add stats for number of special cards played
  • Loading branch information
Oliboy50 authored Aug 9, 2023
1 parent 41cdd6c commit 6b7b6fc
Show file tree
Hide file tree
Showing 14 changed files with 2,007 additions and 486 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

- Create sprite from 180px wide PNG card images:
```shell
magick montage $(ls blue-*.png) $(ls brown-*.png) $(ls gray-*.png) $(ls green-*.png) $(ls pink-*.png) $(ls red-*.png) $(ls yellow-*.png) jersey.png $(ls adventurer-*.png) -geometry +0+0 -tile 7x8 -mode concatenate -background none cards.png
magick montage $(ls blue-*.png) $(ls brown-*.png) $(ls gray-*.png) $(ls green-*.png) $(ls pink-*.png) $(ls red-*.png) $(ls yellow-*.png) $(ls special-*.png) back-ext_legendes.png $(ls adventurer-*.png) -geometry +0+0 -tile 7x9 -mode concatenate -background none cards.png
```
- Create finish.png sprite from 150x150 finish images:
```shell
magick montage $(ls finish_*.png) -geometry +0+0 -tile 4x1 -mode concatenate -background none finish.png
```
- Reduce generated sprite size by ~90% (using https://tinypng.com or https://compresspng.com if the file is too large)

Expand Down
22 changes: 12 additions & 10 deletions gameoptions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@
],
'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,
// ],
110 => [
'name' => totranslate('With "Legend" cards'),
'values' => [
0 => ['name' => totranslate('No')],
1 => [
'name' => totranslate('Yes'),
'description' => totranslate('Permanently give a coach to each player. Also give the broom wagon to the loser of the previous round.'),
],
],
'default' => 0,
'nobeginner' => true,
],
];
Binary file modified img/cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/finish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/jersey.png
Binary file not shown.
Binary file removed img/jersey_player_panel.png
Binary file not shown.
18 changes: 18 additions & 0 deletions material.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@
*/

require_once('modules/constants.inc.php');

$this->legends_coaches = [
CARD_ID_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER => [
'name' => clienttranslate('Eagle'),
],
CARD_ID_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR => [
'name' => clienttranslate('Panda'),
],
CARD_ID_LEGENDS_SHARK_ONE_RED_MULTIPLY_TEN => [
'name' => clienttranslate('Shark'),
],
CARD_ID_LEGENDS_BADGER_ANY_NUMBER_OF_EACH_COLOR => [
'name' => clienttranslate('Badger'),
],
CARD_ID_LEGENDS_ELEPHANT_STOP => [
'name' => clienttranslate('Elephant'),
],
];
56 changes: 56 additions & 0 deletions modules/VelonimoPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,26 @@ public function isLastRoundWinner(): bool
{
return $this->getLastRoundRank() === 1;
}
public function isLastRoundLoser(int $numberOfPlayers): bool
{
return $this->getLastRoundRank() === $numberOfPlayers;
}
public function getCoachCardId(): ?int
{
if ($this->hasCardLegendsEagle) {
return CARD_ID_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER;
} elseif ($this->hasCardLegendsPanda) {
return CARD_ID_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR;
} elseif ($this->hasCardLegendsShark) {
return CARD_ID_LEGENDS_SHARK_ONE_RED_MULTIPLY_TEN;
} elseif ($this->hasCardLegendsBadger) {
return CARD_ID_LEGENDS_BADGER_ANY_NUMBER_OF_EACH_COLOR;
} elseif ($this->hasCardLegendsElephant) {
return CARD_ID_LEGENDS_ELEPHANT_STOP;
} else {
return null;
}
}

/*
* SETTERS
Expand All @@ -191,6 +211,42 @@ public function setIsWearingJersey(bool $isWearingJersey): self

return $this;
}
public function setHasCardLegendsBroomWagon(bool $hasCardLegendsBroomWagon): self
{
$this->hasCardLegendsBroomWagon = $hasCardLegendsBroomWagon;

return $this;
}
public function setHasCardLegendsEagle(bool $hasCardLegendsEagle): self
{
$this->hasCardLegendsEagle = $hasCardLegendsEagle;

return $this;
}
public function setHasCardLegendsPanda(bool $hasCardLegendsPanda): self
{
$this->hasCardLegendsPanda = $hasCardLegendsPanda;

return $this;
}
public function setHasCardLegendsShark(bool $hasCardLegendsShark): self
{
$this->hasCardLegendsShark = $hasCardLegendsShark;

return $this;
}
public function setHasCardLegendsBadger(bool $hasCardLegendsBadger): self
{
$this->hasCardLegendsBadger = $hasCardLegendsBadger;

return $this;
}
public function setHasCardLegendsElephant(bool $hasCardLegendsElephant): self
{
$this->hasCardLegendsElephant = $hasCardLegendsElephant;

return $this;
}
public function addRoundRanking(int $round, int $rank): self
{
if (isset($this->roundsRanking[$round])) {
Expand Down
11 changes: 8 additions & 3 deletions modules/constants.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
define('COLOR_RED', 60);
define('COLOR_YELLOW', 70);
define('COLOR_ADVENTURER', 80);
define('COLOR_JERSEY', 90);
define('COLOR_SPECIAL', 90);

// Cards value
define('VALUE_1', 1);
Expand All @@ -45,8 +45,13 @@
define('VALUE_40', 40);
define('VALUE_45', 45);
define('VALUE_50', 50);
define('VALUE_JERSEY', 10);
define('VALUE_LEGENDS_BROOM_WAGON', 5);
define('VALUE_JERSEY_PLUS_TEN', 10);
define('VALUE_LEGENDS_BROOM_WAGON_PLUS_FIVE', 5);
define('VALUE_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER', -4);
define('VALUE_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR', -5);
define('VALUE_LEGENDS_SHARK_ONE_RED_MULTIPLY_TEN', -6);
define('VALUE_LEGENDS_BADGER_ANY_NUMBER_OF_EACH_COLOR', -7);
define('VALUE_LEGENDS_ELEPHANT_STOP', -8);

// Special cards ID
define('CARD_ID_JERSEY_PLUS_TEN', -2);
Expand Down
91 changes: 86 additions & 5 deletions stats.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,63 @@
*/

$numberOfRoundsWonName = totranslate('Rounds won');
$minValueName = totranslate('Minimum value played');
$maxValueName = totranslate('Maximum value played');
$numberOfJerseyPlayedName = totranslate('Number of Jersey played');
$numberOfLegendsBroomWagonPlayedName = totranslate('Number of Broom Wagon played');
$numberOfLegendsEaglePlayedName = totranslate('Number of coach Eagle played');
$numberOfLegendsPandaPlayedName = totranslate('Number of coach Panda played');
$numberOfLegendsSharkPlayedName = totranslate('Number of coach Shark played');
$numberOfLegendsBadgerPlayedName = totranslate('Number of coach Badger played');
$numberOfLegendsElephantPlayedName = totranslate('Number of coach Elephant played');

$stats_type = [
// Statistics global to table
'table' => [
'minValue' => [
'id' => 13,
'name' => totranslate('Minimum value played'),
'name' => $minValueName,
'type' => 'int',
],
'maxValue' => [
'id' => 14,
'name' => totranslate('Maximum value played'),
'name' => $maxValueName,
'type' => 'int',
],
'numberOfJerseyPlayed' => [
'id' => 15,
'name' => $numberOfJerseyPlayedName,
'type' => 'int',
],
'numberOfLegendsBroomWagonPlayed' => [
'id' => 16,
'name' => $numberOfLegendsBroomWagonPlayedName,
'type' => 'int',
],
'numberOfLegendsEaglePlayed' => [
'id' => 17,
'name' => $numberOfLegendsEaglePlayedName,
'type' => 'int',
],
'numberOfLegendsPandaPlayed' => [
'id' => 18,
'name' => $numberOfLegendsPandaPlayedName,
'type' => 'int',
],
'numberOfLegendsSharkPlayed' => [
'id' => 19,
'name' => $numberOfLegendsSharkPlayedName,
'type' => 'int',
],
'numberOfLegendsBadgerPlayed' => [
'id' => 20,
'name' => $numberOfLegendsBadgerPlayedName,
'type' => 'int',
],
'numberOfLegendsElephantPlayed' => [
'id' => 21,
'name' => $numberOfLegendsElephantPlayedName,
'type' => 'int',
],
],
Expand All @@ -66,17 +112,52 @@
'player' => [
'numberOfRoundsWon' => [
'id' => 12,
'name' => totranslate('Rounds won'),
'name' => $numberOfRoundsWonName,
'type' => 'int',
],
'minValue' => [
'id' => 13,
'name' => totranslate('Minimum value played'),
'name' => $minValueName,
'type' => 'int',
],
'maxValue' => [
'id' => 14,
'name' => totranslate('Maximum value played'),
'name' => $maxValueName,
'type' => 'int',
],
'numberOfJerseyPlayed' => [
'id' => 15,
'name' => $numberOfJerseyPlayedName,
'type' => 'int',
],
'numberOfLegendsBroomWagonPlayed' => [
'id' => 16,
'name' => $numberOfLegendsBroomWagonPlayedName,
'type' => 'int',
],
'numberOfLegendsEaglePlayed' => [
'id' => 17,
'name' => $numberOfLegendsEaglePlayedName,
'type' => 'int',
],
'numberOfLegendsPandaPlayed' => [
'id' => 18,
'name' => $numberOfLegendsPandaPlayedName,
'type' => 'int',
],
'numberOfLegendsSharkPlayed' => [
'id' => 19,
'name' => $numberOfLegendsSharkPlayedName,
'type' => 'int',
],
'numberOfLegendsBadgerPlayed' => [
'id' => 20,
'name' => $numberOfLegendsBadgerPlayedName,
'type' => 'int',
],
'numberOfLegendsElephantPlayed' => [
'id' => 21,
'name' => $numberOfLegendsElephantPlayedName,
'type' => 'int',
],
],
Expand Down
1 change: 0 additions & 1 deletion velonimo.action.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function playCards()
$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,
Expand Down
Loading

0 comments on commit 6b7b6fc

Please sign in to comment.