Skip to content

Commit

Permalink
feat: finalize two-players mode (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliboy50 authored Jul 13, 2022
1 parent 75613bb commit b098f14
Show file tree
Hide file tree
Showing 7 changed files with 422 additions and 129 deletions.
4 changes: 2 additions & 2 deletions gameinfos.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
// Board game geek ID of the game
'bgg_id' => 323262,

// Players configuration that can be played (ex: 2 to 4 players)
'players' => [3, 4, 5],
// Players configuration that can be played (2 to 5 players)
'players' => [2, 3, 4, 5],

// Suggest players to play with this number of players. Must be null if there is no such advice, or if there is only one possible player configuration.
'suggest_player_number' => null,
Expand Down
1 change: 1 addition & 0 deletions modules/constants.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
define('ST_ACTIVATE_NEXT_PLAYER', 22);
define('ST_PLAYER_SELECT_NEXT_PLAYER', 30);
define('ST_APPLY_SELECTED_NEXT_PLAYER', 31);
define('ST_PLAYER_SELECT_WHO_TAKE_ATTACK_REWARD', 38);
define('ST_PLAYER_PICK_CARDS_FROM_PLAYER', 40);
define('ST_PLAYER_GIVE_CARDS_BACK_TO_PLAYER_AFTER_PICKING', 41);
define('ST_END_ROUND', 80);
Expand Down
23 changes: 22 additions & 1 deletion states.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@
'description' => '',
'type' => 'game',
'action' => 'stActivateNextPlayer',
'transitions' => ['firstPlayerTurn' => ST_FIRST_PLAYER_TURN, 'playerTurn' => ST_PLAYER_TURN, 'playerSelectNextPlayer' => ST_PLAYER_SELECT_NEXT_PLAYER],
'transitions' => [
'firstPlayerTurn' => ST_FIRST_PLAYER_TURN,
'playerTurn' => ST_PLAYER_TURN,
'playerSelectNextPlayer' => ST_PLAYER_SELECT_NEXT_PLAYER,
'playerSelectWhoTakeAttackReward' => ST_PLAYER_SELECT_WHO_TAKE_ATTACK_REWARD,
],
],

// The "natural" next player don't have cards anymore,
Expand All @@ -136,6 +141,22 @@
'transitions' => ['firstPlayerTurn' => ST_FIRST_PLAYER_TURN],
],

// /!\ 2P mode only
// When a player wins an attack,
// he has to choose if it takes the reward or if he gives it to its opponent
ST_PLAYER_SELECT_WHO_TAKE_ATTACK_REWARD => [
'name' => 'playerSelectWhoTakeAttackReward',
'description' => clienttranslate('${actplayer} must choose who will take the attacker reward'),
'descriptionmyturn' => clienttranslate('${you} must choose who will take the attacker reward'),
'type' => 'activeplayer',
'args' => 'argPlayerSelectWhoTakeAttackReward',
'possibleactions' => ['selectWhoTakeAttackReward'],
'transitions' => [
'firstPlayerTurn' => ST_FIRST_PLAYER_TURN,
'zombiePass' => ST_ACTIVATE_NEXT_PLAYER,
],
],

// When someone plays one or more cards of value "1",
// this player has to pick one or more cards from another player of its choice
ST_PLAYER_PICK_CARDS_FROM_PLAYER => [
Expand Down
14 changes: 14 additions & 0 deletions velonimo.action.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ public function selectNextPlayer()
self::ajaxResponse();
}

/**
* /!\ 2P mode only
*/
public function selectWhoTakeAttackReward()
{
self::setAjaxMode();

$selectedPlayerId = trim(self::getArg('selectedPlayerId', AT_int, true));

$this->game->selectWhoTakeAttackReward((int) $selectedPlayerId);

self::ajaxResponse();
}

public function selectPlayerToPickCards()
{
self::setAjaxMode();
Expand Down
38 changes: 29 additions & 9 deletions velonimo.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,6 @@ Board
.player-table.is-wearing-jersey .player-table-hand {
margin: 5px 0 0 -6px;
}
.player-table-hand .number-of-cards {
position: absolute;
left: 8px;
top: 20px;
font-size: 2em;
text-align: center;
width: 1em;
pointer-events: none;
}
.player-table-speech-bubble {
position: absolute;
top: 0;
Expand Down Expand Up @@ -235,6 +226,26 @@ Board cards
height: 126px; /* cardHeight */
z-index: 8;
}
/* /!\ 2P mode only */
#cards-deck {
position: absolute;
display: inline-block;
top: 177px; /* (containerHeight / 2) - (selfHeight / 2) */
left: 10px; /* boardMargin */
width: 90px; /* cardWidth */
height: 126px; /* cardHeight */
background-image: url('img/remaining_cards.png');
background-size: 90px 126px;
}
/* /!\ 2P mode only */
#attack-reward-card {
position: absolute;
display: inline-block;
top: 177px; /* (containerHeight / 2) - (selfHeight / 2) */
left: 110px; /* cardWidth + (2 * boardMargin) */
width: 90px; /* cardWidth */
height: 126px; /* cardHeight */
}
/**
END Board cards
*/
Expand Down Expand Up @@ -313,6 +324,15 @@ Cards
.cards-stack .velonimo-card {
margin-right: -60px; /* 2/3 of card width */
}
.text-on-cards {
position: absolute;
left: 8px;
top: 20px;
font-size: 2em;
text-align: center;
width: 1em;
pointer-events: none;
}
/**
END Cards
*/
Expand Down
Loading

0 comments on commit b098f14

Please sign in to comment.