Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spectator fix bug #31

Merged
merged 5 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions calypso.game.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,26 @@ protected function getAllDatas()
}

$result['hand'] = $this->cards->getCardsInLocation( 'hand', $current_player_id );
$player_suit = self::getPlayerSuit($current_player_id);
$partner_suit = self::getPartnerSuit($player_suit);
// give suits in order: player suit, partner suit,
// same colour as player, same colour as partner
$result['suits_by_status'] = array(
+$player_suit,
$partner_suit,
self::getSameColourSuit($player_suit),
self::getSameColourSuit($partner_suit),
);
if (!self::isSpectator()){
$player_suit = self::getPlayerSuit($current_player_id);
$partner_suit = self::getPartnerSuit($player_suit);
// give suits in order: player suit, partner suit,
// same colour as player, same colour as partner
$result['suits_by_status'] = array(
+$player_suit,
$partner_suit,
self::getSameColourSuit($player_suit),
self::getSameColourSuit($partner_suit),
);
} else {
// dummy ranking to keep nice and smooth
$result['suits_by_status'] = array(
self::CLUBS,
self::DIAMONDS,
self::HEARTS,
self::SPADES,
);
}

$result['cardsontable'] = $this->cards->getCardsInLocation( 'cardsontable' );
$result['cardsincalypsos'] = $this->cards->getCardsInLocation( 'calypso' );
Expand Down Expand Up @@ -354,7 +364,7 @@ function getPartnerSuit($player_suit) {
self::CLUBS => self::DIAMONDS,
self::DIAMONDS => self::CLUBS,
self::HEARTS => self::SPADES,
self::SPADES => self::HEARTS
self::SPADES => self::HEARTS,
)[$player_suit];
}
// get suit the same colour as a given suit - feeds through to UI
Expand All @@ -363,7 +373,7 @@ function getSameColourSuit($player_suit) {
self::CLUBS => self::SPADES,
self::DIAMONDS => self::HEARTS,
self::HEARTS => self::DIAMONDS,
self::SPADES => self::CLUBS
self::SPADES => self::CLUBS,
)[$player_suit];
}

Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

- User preference to highlight playable cards (vs non-playable). Default is on

### Fixed

- Fixed spectator (silent) server errors by skipping problematic functions

## [beta-v01] - 2023-07-15

Entered beta on 15/7 - no changes
Expand Down