summaryrefslogtreecommitdiff
path: root/protocol/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocol/src')
-rw-r--r--protocol/src/bridge_engine.rs19
-rw-r--r--protocol/src/simple_bots.rs2
2 files changed, 15 insertions, 6 deletions
diff --git a/protocol/src/bridge_engine.rs b/protocol/src/bridge_engine.rs
index 6b3cf7d..fa5c995 100644
--- a/protocol/src/bridge_engine.rs
+++ b/protocol/src/bridge_engine.rs
@@ -426,6 +426,10 @@ impl Bidding {
self.dealer.many_next(self.bids.len() - 4)
}
+ pub fn current_bidder(&self) -> Player {
+ self.dealer.many_next(self.bids.len())
+ }
+
pub fn highest_bid(&self) -> Option<Raise> {
for bid in self.bids.iter().rev() {
if let Some(raise) = bid.as_raise() {
@@ -526,11 +530,11 @@ impl BiddingStatePlayerView {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct PlayState {
- dealer: Player,
- deal: Deal,
- contract: Contract,
- bidding: Bidding,
- playing_deal: DealInPlay,
+ pub dealer: Player,
+ pub deal: Deal,
+ pub contract: Contract,
+ pub bidding: Bidding,
+ pub playing_deal: DealInPlay,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
@@ -696,10 +700,15 @@ mod tests {
fn bidding() {
crate::tests::test_setup();
let bidding = Bidding::new(Player::South);
+ assert_eq!(bidding.current_bidder(), Player::South);
let bidding = as_bidding(bidding.bid(Bid::Pass).unwrap());
+ assert_eq!(bidding.current_bidder(), Player::West);
let bidding = as_bidding(bidding.bid(Bid::Raise("1♦".parse().unwrap())).unwrap());
+ assert_eq!(bidding.current_bidder(), Player::North);
let bidding = as_bidding(bidding.bid(Bid::Pass).unwrap());
+ assert_eq!(bidding.current_bidder(), Player::East);
let bidding = as_bidding(bidding.bid(Bid::Pass).unwrap());
+ assert_eq!(bidding.current_bidder(), Player::South);
let contract = as_contract(bidding.bid(Bid::Pass).unwrap());
assert_eq!(
Some(Contract {
diff --git a/protocol/src/simple_bots.rs b/protocol/src/simple_bots.rs
index ffa1be2..7997418 100644
--- a/protocol/src/simple_bots.rs
+++ b/protocol/src/simple_bots.rs
@@ -6,7 +6,7 @@ struct AlwaysPassBiddingBot {}
#[async_trait]
impl BiddingBot for AlwaysPassBiddingBot {
- async fn bid(&self, bidding: &BiddingStatePlayerView) -> Bid {
+ async fn bid(&self, _bidding: &BiddingStatePlayerView) -> Bid {
Bid::Pass
}
}