take_action(user_action) {
this.chatroom.take_action(user_action);
switch (user_action.action.action) {
+ case "Message":
+ break;
case "Join":
this.seats.set(user_action.username, user_action.action.seat);
this.stacks.set(user_action.username, user_action.action.chips);
take_action(user_action) {
this.chatroom.take_action(user_action);
switch (user_action.action.action) {
+ case "Message":
+ break;
case "Join":
this.seats.set(user_action.username, user_action.action.seat);
this.hands.set(user_action.username, []);
fn validate_action(&self, UserAction { timestamp, username, action }: UserAction) -> Result<ValidatedUserAction, ActionError> {
match (self.state, action) {
(_, Action::PlayCard { .. }) | (_, Action::ChooseTrumps { .. }) => Err(ActionError::InvalidActionForGameType),
+ (_, Action::Message {message}) => Ok(ValidatedUserAction(UserAction { timestamp, username, action: Action::Message {message}})),
(State::NotStarted, Action::Join { seat, chips }) => {
if self.seats.contains_player(username) {
Err(ActionError::AlreadyJoined)
fn take_action(&mut self, ValidatedUserAction(UserAction { timestamp, username, action }): ValidatedUserAction) -> Result<(), ActionError> {
self.actions_len += 1;
+ if matches!(action, Action::Message {..}) {
+ return Ok(());
+ }
self.last_action_time = Some(timestamp);
self.rng.advance();
match (self.state, action) {
(_, Action::AddOn { .. }) | (_, Action::RevealCard { .. }) | (_, Action::Fold) | (_, Action::TimeoutFold) | (_, Action::Bet { .. }) => {
Err(ActionError::InvalidActionForGameType)
}
+ (_, Action::Message {message}) => Ok(ValidatedUserAction(UserAction { timestamp, username, action: Action::Message {message}})),
(State::NotStarted, Action::Join { seat, .. }) => {
if self.seats.contains_player(username) {
Err(ActionError::AlreadyJoined)
fn take_action(&mut self, ValidatedUserAction(UserAction { username, action, .. }): ValidatedUserAction) -> Result<(), ActionError> {
self.actions_len += 1;
+ if matches!(action, Action::Message {..}) {
+ return Ok(());
+ }
self.rng.advance();
match (self.state, action) {
(_, Action::AddOn { .. }) | (_, Action::Fold) | (_, Action::TimeoutFold) | (_, Action::Bet { .. }) => Err(ActionError::InvalidActionForGameType),