/// Context / Background reading /// ---------------------------- /// You must understand the following before understanding this function /// + What the HedgeEmHandStageInfo class is and what its purpose is. /// /// History /// ----------- /// Original Author: Simon Hewins Jul 2014 /// Last edit: Simon Hewins Aug 2014 /// /// Description /// ----------- /// /// Gets a LIST of HedgeEmHandStageInfo objects for any given hand (index) at any given stage. /// </summary> /// <param name="a_enum_game_state"></param> /// <param name="a_hand_index"></param> /// <returns></returns> public HedgeEmBet f_get_previous_bets_for_stage_and_hand_player(enum_betting_stage a_enum_betting_stage, int a_hand_index, int a_player_id) { /// xxx hack until Bet contains player id a_player_id = 0; List<HedgeEmBet> my_previous_bets_list = new List<HedgeEmBet>(); HedgeEmBet myHedgeEmBet = null; try { my_previous_bets_list = (from handsstage_objects in _global_game_state_object.p_recorded_bets where handsstage_objects.p_enum_betting_stage == a_enum_betting_stage && handsstage_objects.p_hand_index == a_hand_index && handsstage_objects.p_seat_index == a_player_id select handsstage_objects).ToList(); if (my_previous_bets_list.Count > 1) { String my_err_msg = String.Format("Expected only one 'Bet' for state [{0}], hand [{1}] object got [{1}] ", a_enum_betting_stage.ToString(), a_hand_index, my_previous_bets_list.Count); throw new Exception(my_err_msg); } myHedgeEmBet = my_previous_bets_list[0]; } catch (Exception ex) { string my_error_popup = "alert('Error in f_get_previous_bets_for_stage_and_hand" + ex.Message.ToString() + "');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true); HedgeEmLogEvent my_log = new HedgeEmLogEvent(); my_log.p_message = "Exception caught in f_get_hand_stage_info_object_for_stage_and_hand function " + ex.Message; my_log.p_method_name = "f_get_hand_stage_info_object_for_stage_and_hand"; my_log.p_player_id = f_get_player_id(); my_log.p_game_id = game_id; my_log.p_table_id = _table_id; log.Error(my_log.ToString()); } return myHedgeEmBet; }
/// Context / Background reading /// ---------------------------- /// You must understand the following before understanding this function /// + What the HedgeEmHandStageInfo class is and what its purpose is. /// /// History /// ----------- /// Original Author: Simon Hewins Jul 2014 /// Last edit: Simon Hewins Aug 2014 /// /// Description /// ----------- /// /// Gets a LIST of HedgeEmHandStageInfo objects for any given hand (index) at any given stage. /// </summary> /// <param name="a_enum_game_state"></param> /// <param name="a_hand_index"></param> /// <returns></returns> public HedgeEmBet f_get_previous_bets_for_stage_and_hand_player(enum_betting_stage a_enum_betting_stage, int a_hand_index, int a_player_id) { // Create a 'log event' object to audit execution HedgeEmLogEvent my_log_event = new HedgeEmLogEvent(); my_log_event.p_method_name = System.Reflection.MethodBase.GetCurrentMethod().ToString(); my_log_event.p_message = "Method Entered."; my_log_event.p_player_id = p_session_player_id; my_log_event.p_table_id = p_session_personal_table_id; log.Debug(my_log_event.ToString()); /// xxx hack until Bet contains player id //a_player_id = 0; List<HedgeEmBet> my_previous_bets_list = new List<HedgeEmBet>(); HedgeEmBet myHedgeEmBet = null; try { my_previous_bets_list = (from handsstage_objects in _global_game_state_object.p_recorded_bets where handsstage_objects.p_enum_betting_stage == a_enum_betting_stage && handsstage_objects.p_hand_index == a_hand_index && handsstage_objects.p_seat_index == a_player_id select handsstage_objects).ToList(); if (my_previous_bets_list.Count > 1) { String my_err_msg = String.Format("Expected only one 'Bet' for state [{0}], hand [{1}] object got [{1}] ", a_enum_betting_stage.ToString(), a_hand_index, my_previous_bets_list.Count); throw new Exception(my_err_msg); } myHedgeEmBet = my_previous_bets_list[0]; } catch (Exception ex) { string my_error_popup = "Error in f_get_previous_bets_for_stage_and_hand" + ex.Message.ToString(); // ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true); HedgeEmLogEvent my_log = new HedgeEmLogEvent(); my_log_event.p_message = String.Format("Exception caught [{0}] ", ex.Message); my_log.p_player_id = Convert.ToInt32(Session["p_session_player_id"]); my_log.p_game_id = game_id; my_log.p_table_id = p_session_personal_table_id; log.Error(my_log.ToString()); HedgeemerrorPopup my_popup_message = new HedgeemerrorPopup(); my_popup_message.p_detailed_message_str = ""; my_popup_message.p_is_visible = false; //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true); my_popup_message.p_detailed_message_str = my_error_popup; my_popup_message.p_is_visible = true; Place_Holder_Popup_Message.Controls.Add(my_popup_message); } return myHedgeEmBet; }
DC_bet_acknowledgement f_place_bet(enum_betting_stage a_betting_stage, int a_hand_index, double a_amount) { // Create a 'log event' object to audit execution HedgeEmLogEvent my_log = new HedgeEmLogEvent(); my_log.p_message = ""; my_log.p_method_name = "f_place_bet"; my_log.p_player_id = f_get_player_id(); my_log.p_game_id = game_id; my_log.p_table_id = _table_id; // Create a new 'Bet Acknowledgement' object that will be used to Ackknowledge the success (ACK) or failure (NACK) of the placed bet. DC_bet_acknowledgement my_ack = null; try { // Log the entry to this method my_log.p_message = String.Format("f_place_bet called. Args Stage[{0}], Hand [{1}], Amount[{2}]", a_betting_stage.ToString(), a_hand_index, a_amount); log.Debug(my_log.p_message); // Call the Hedge'Em Webservices (via helper function) to place the bet. string place_bet_endpoint = String.Format("ws_place_bet/{0},{1},{2},{3},{4}", _table_id.ToString(), a_hand_index.ToString(), a_amount.ToString(), a_betting_stage.ToString(), f_get_player_id().ToString()); my_ack = (DC_bet_acknowledgement)f_get_object_from_json_call_to_server(place_bet_endpoint, typeof(DC_bet_acknowledgement)); // Return the Acknowledgement message to the caller to indicate success or failure. return my_ack; } catch (Exception e) { string strScript = "alert('Unable to place bet. Reason..." + e.Message.ToString() + "');"; ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", strScript, true); my_log.p_message = "Exception caught in f_place_bet function " + e.Message; log.Error(my_log.ToString()); return my_ack; } }
DC_bet_acknowledgement f_place_bet(enum_betting_stage a_betting_stage, int a_hand_index, double a_amount) { // Create a 'log event' object to audit execution HedgeEmLogEvent my_log_event = new HedgeEmLogEvent(); my_log_event.p_method_name = System.Reflection.MethodBase.GetCurrentMethod().ToString(); my_log_event.p_message = "Method Entered."; my_log_event.p_player_id = p_session_player_id; my_log_event.p_table_id = p_session_personal_table_id; log.Debug(my_log_event.ToString()); my_log_event.p_game_id = game_id; // Create a new 'Bet Acknowledgement' object that will be used to Ackknowledge the success (ACK) or failure (NACK) of the placed bet. DC_bet_acknowledgement my_ack = null; try { // Log the entry to this method my_log_event.p_message = String.Format("f_place_bet called. Args Stage[{0}], Hand [{1}], Amount[{2}]", a_betting_stage.ToString(), a_hand_index, a_amount); log.Debug(my_log_event.p_message); // Call the Hedge'Em Webservices (via helper function) to place the bet. string place_bet_endpoint = String.Format("ws_place_bet/{0},{1},{2},{3},{4}", p_session_personal_table_id.ToString(), a_hand_index.ToString(), a_amount.ToString(), a_betting_stage.ToString(), Convert.ToInt32(Session["p_session_player_id"]).ToString()); my_ack = (DC_bet_acknowledgement)f_get_object_from_json_call_to_server(place_bet_endpoint, typeof(DC_bet_acknowledgement)); // Return the Acknowledgement message to the caller to indicate success or failure. return my_ack; } catch (Exception e) { string strScript = "Unable to place bet. Reason..." + e.Message.ToString(); // ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", strScript, true); HedgeemerrorPopup my_popup_message = new HedgeemerrorPopup(); my_popup_message.p_detailed_message_str = ""; my_popup_message.p_is_visible = false; //ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true); my_popup_message.p_detailed_message_str = strScript; my_popup_message.p_is_visible = true; Place_Holder_Popup_Message.Controls.Add(my_popup_message); my_log_event.p_message = "Exception caught in f_place_bet function " + e.Message; log.Error(my_log_event.ToString()); return my_ack; } }