fn div_game_status_and_player_actions<'a, 'bump>(
            root_rendering_component: &'a RootRenderingComponent,
            bump: &'bump Bump,
        ) -> Node<'bump>
        where
            'a: 'bump,
        {
            if let GameState::Start = root_rendering_component.game_data.game_state {
                // 1S Ask Player2 to play!
                console::log_1(&"GameState::Start".into());
                //return Ask Player2 to play!
                ask_to_play(root_rendering_component, bump, "Invite")
            } else if let GameState::EndGame = root_rendering_component.game_data.game_state {
                //end game ,Play again?
                h3(bump)
                    .attr("id", "ws_elem")
                    .attr("style", "color:green;")
                    .children([text(
                        //Play again?
                        bumpalo::format!(in bump, "Play again{}?", "").into_bump_str(),
                    )])
                    .on("click", move |root, vdom, _event| {
                        let root_rendering_component = root.unwrap_mut::<RootRenderingComponent>();
                        root_rendering_component.reset();
                        vdom.schedule_render();
                    })
                    .finish()
            } else if let GameState::Asking = root_rendering_component.game_data.game_state {
                //return wait for the other player
                div(bump)
                    .children([
                        div_wait_for_other_player(bump),
                        ask_to_play(root_rendering_component, bump, "Reinvite"),
                    ])
                    .finish()
            } else if let GameState::Asked = root_rendering_component.game_data.game_state {
                // 2S Click here to Accept play!
                console::log_1(&"GameState::Asked".into());
                //return Click here to Accept play
                h3(bump)
                    .attr("id", "ws_elem")
                    .attr("style", "color:green;")
                    .children([text(
                        //show Ask Player2 to Play!
                        bumpalo::format!(in bump, "Click here to Accept {}!", root_rendering_component.game_data.content_folder_name)
                            .into_bump_str(),
                    )])
                    .on("click", move |root, vdom, _event| {
                        let mut root_rendering_component =
                            root.unwrap_mut::<RootRenderingComponent>();
                        //region: send WsMessage over websocket
                        root_rendering_component.game_data.prepare_random_data();
                        root_rendering_component
                            .game_data
                            .this_machine_player_number = 2;
                        root_rendering_component.game_data.player_turn=1;
                        root_rendering_component.game_data.game_state = GameState::Play;

                        //send request to Websocket server for spellings
                        root_rendering_component
                            .game_data
                            .ws
                            .send_with_str(
                                &serde_json::to_string(&WsMessage::RequestSpelling {
                                    filename: format!(
                                        "content/{}/text.json",
                                        root_rendering_component.game_data.content_folder_name
                                    ),
                                })
                                .expect("error sending RequestSpelling"),
                            )
                            .expect("Failed to send RequestSpelling");

                        root_rendering_component
                            .game_data
                            .ws
                            .send_with_str(
                                &serde_json::to_string(&WsMessage::AcceptPlay {
                                    my_ws_uid: root_rendering_component.game_data.my_ws_uid,
                                    other_ws_uid: root_rendering_component.game_data.other_ws_uid,
                                    //send the vector of cards because both players need cards in the same location.
                                    card_grid_data: serde_json::to_string(
                                        &root_rendering_component.game_data.vec_cards,
                                    )
                                    .expect("error serde_json"),
                                })
                                .expect("error sending test"),
                            )
                            .expect("Failed to send");
                        //endregion
                        vdom.schedule_render();
                    })
                    .finish()
            } else if root_rendering_component
                .game_data
                .count_click_inside_one_turn
                >= 2
            {
                if root_rendering_component
                    .game_data
                    .this_machine_player_number
                    == root_rendering_component.game_data.player_turn
                {
                    //return wait for the other player
                    div_wait_for_other_player(bump)
                } else {
                    //return Click here to take your turn
                    h3(bump)
                        .attr("id", "ws_elem")
                        .attr("style", "color:green;")
                        .children([text(
                            bumpalo::format!(in bump, "Click here to take your turn !{}", "")
                                .into_bump_str(),
                        )])
                        .on("click", move |root, vdom, _event| {
                            let root_rendering_component =
                                root.unwrap_mut::<RootRenderingComponent>();
                            //this game_data mutable reference is dropped on the end of the function
                            //clippy is wrong about dropping the mut. I need it.
                            let game_data = &root_rendering_component.game_data;
                            //region: send WsMessage over websocket
                            game_data
                                .ws
                                .send_with_str(
                                    &serde_json::to_string(&WsMessage::PlayerChange {
                                        my_ws_uid: game_data.my_ws_uid,
                                        other_ws_uid: game_data.other_ws_uid,
                                    })
                                    .expect("error sending PlayerChange"),
                                )
                                .expect("Failed to send PlayerChange");
                            //endregion
                            root_rendering_component.take_turn();
                            // Finally, re-render the component on the next animation frame.
                            vdom.schedule_render();
                        })
                        .finish()
                }
            } else if root_rendering_component
                .game_data
                .count_click_inside_one_turn
                < 2
            {
                if root_rendering_component
                    .game_data
                    .this_machine_player_number
                    == root_rendering_component.game_data.player_turn
                {
                    h3(bump)
                        .attr("id", "ws_elem")
                        .attr("style", "color:orange;")
                        .children([text(
                            bumpalo::format!(in bump, "Play !{}", "").into_bump_str(),
                        )])
                        .finish()
                } else {
                    //return wait for the other player
                    div_wait_for_other_player(bump)
                }
            } else {
                //unpredictable situation
                //return
                h3(bump)
                    .attr("id", "ws_elem")
                    .children([text(
                        bumpalo::format!(in bump, "gamestate: {} player {}", root_rendering_component.game_data.game_state.as_ref(),root_rendering_component.game_data.this_machine_player_number)
                            .into_bump_str(),
                    )])
                    .finish()
            }
        }
///html element to inform player what to do and get a click action from user
html element to inform player what to do and get a click action from user
html element to inform player what to do and get a click action from user
fn div_game_status_and_player_actions<'a, 'bump>(
            root_rendering_component: &'a RootRenderingComponent,
            bump: &'bump Bump,
        ) -> Node<'bump>
        where
            'a: 'bump,
        {
            if let GameState::Start = root_rendering_component.game_data.game_state {
                // 1S Ask Player2 to play!
                console::log_1(&"GameState::Start".into());
                //return Ask Player2 to play!
                ask_to_play(root_rendering_component, bump, "Invite")
            } else if let GameState::EndGame = root_rendering_component.game_data.game_state {
                //end game ,Play again?
                h3(bump)
                    .attr("id", "ws_elem")
                    .attr("style", "color:green;")
                    .children([text(
                        //Play again?
                        bumpalo::format!(in bump, "Play again{}?", "").into_bump_str(),
                    )])
                    .on("click", move |root, vdom, _event| {
                        let root_rendering_component = root.unwrap_mut::<RootRenderingComponent>();
                        root_rendering_component.reset();
                        vdom.schedule_render();
                    })
                    .finish()
            } else if let GameState::Asking = root_rendering_component.game_data.game_state {
                //return wait for the other player
                div(bump)
                    .children([
                        div_wait_for_other_player(bump),
                        ask_to_play(root_rendering_component, bump, "Reinvite"),
                    ])
                    .finish()
            } else if let GameState::Asked = root_rendering_component.game_data.game_state {
                // 2S Click here to Accept play!
                console::log_1(&"GameState::Asked".into());
                //return Click here to Accept play
                h3(bump)
                    .attr("id", "ws_elem")
                    .attr("style", "color:green;")
                    .children([text(
                        //show Ask Player2 to Play!
                        bumpalo::format!(in bump, "Click here to Accept {}!", root_rendering_component.game_data.content_folder_name)
                            .into_bump_str(),
                    )])
                    .on("click", move |root, vdom, _event| {
                        let mut root_rendering_component =
                            root.unwrap_mut::<RootRenderingComponent>();
                        //region: send WsMessage over websocket
                        root_rendering_component.game_data.prepare_random_data();
                        root_rendering_component
                            .game_data
                            .this_machine_player_number = 2;
                        root_rendering_component.game_data.player_turn=1;
                        root_rendering_component.game_data.game_state = GameState::Play;
                        //send request to Websocket server for spellings
                        root_rendering_component
                            .game_data
                            .ws
                            .send_with_str(
                                &serde_json::to_string(&WsMessage::RequestSpelling {
                                    filename: format!(
                                        "content/{}/text.json",
                                        root_rendering_component.game_data.content_folder_name
                                    ),
                                })
                                .expect("error sending RequestSpelling"),
                            )
                            .expect("Failed to send RequestSpelling");
                        root_rendering_component
                            .game_data
                            .ws
                            .send_with_str(
                                &serde_json::to_string(&WsMessage::AcceptPlay {
                                    my_ws_uid: root_rendering_component.game_data.my_ws_uid,
                                    other_ws_uid: root_rendering_component.game_data.other_ws_uid,
                                    //send the vector of cards because both players need cards in the same location.
                                    card_grid_data: serde_json::to_string(
                                        &root_rendering_component.game_data.vec_cards,
                                    )
                                    .expect("error serde_json"),
                                })
                                .expect("error sending test"),
                            )
                            .expect("Failed to send");
                        //endregion
                        vdom.schedule_render();
                    })
                    .finish()
            } else if root_rendering_component
                .game_data
                .count_click_inside_one_turn
                >= 2
            {
                if root_rendering_component
                    .game_data
                    .this_machine_player_number
                    == root_rendering_component.game_data.player_turn
                {
                    //return wait for the other player
                    div_wait_for_other_player(bump)
                } else {
                    //return Click here to take your turn
                    h3(bump)
                        .attr("id", "ws_elem")
                        .attr("style", "color:green;")
                        .children([text(
                            bumpalo::format!(in bump, "Click here to take your turn !{}", "")
                                .into_bump_str(),
                        )])
                        .on("click", move |root, vdom, _event| {
                            let root_rendering_component =
                                root.unwrap_mut::<RootRenderingComponent>();
                            //this game_data mutable reference is dropped on the end of the function
                            //clippy is wrong about dropping the mut. I need it.
                            let game_data = &root_rendering_component.game_data;
                            //region: send WsMessage over websocket
                            game_data
                                .ws
                                .send_with_str(
                                    &serde_json::to_string(&WsMessage::PlayerChange {
                                        my_ws_uid: game_data.my_ws_uid,
                                        other_ws_uid: game_data.other_ws_uid,
                                    })
                                    .expect("error sending PlayerChange"),
                                )
                                .expect("Failed to send PlayerChange");
                            //endregion
                            root_rendering_component.take_turn();
                            // Finally, re-render the component on the next animation frame.
                            vdom.schedule_render();
                        })
                        .finish()
                }
            } else if root_rendering_component
                .game_data
                .count_click_inside_one_turn
                < 2
            {
                if root_rendering_component
                    .game_data
                    .this_machine_player_number
                    == root_rendering_component.game_data.player_turn
                {
                    h3(bump)
                        .attr("id", "ws_elem")
                        .attr("style", "color:orange;")
                        .children([text(
                            bumpalo::format!(in bump, "Play !{}", "").into_bump_str(),
                        )])
                        .finish()
                } else {
                    //return wait for the other player
                    div_wait_for_other_player(bump)
                }
            } else {
                //unpredictable situation
                //return
                h3(bump)
                    .attr("id", "ws_elem")
                    .children([text(
                        bumpalo::format!(in bump, "gamestate: {} player {}", root_rendering_component.game_data.game_state.as_ref(),root_rendering_component.game_data.this_machine_player_number)
                            .into_bump_str(),
                    )])
                    .finish()
            }
        }
fn div_game_status_and_player_actions < ' a , ' bump > ( root_rendering_component : & ' a RootRenderingComponent , bump : & ' bump Bump , ) -> Node < ' bump > where ' a : ' bump , { if let GameState :: Start = root_rendering_component . game_data . game_state { // 1S Ask Player2 to play! console :: log_1 ( & " " . into ( ) ) ; //return Ask Player2 to play! ask_to_play ( root_rendering_component , bump , " " ) } else if let GameState :: EndGame = root_rendering_component . game_data . game_state { //end game ,Play again? h3 ( bump ) . attr ( " " , " " ) . attr ( " " , " " ) . children ( [ text ( //Play again? bumpalo :: format ! ( in bump " " " " ) . into_bump_str ( ) , ) ] ) . on ( " " , move | root , vdom , _event | { let root_rendering_component = root . unwrap_mut :: < RootRenderingComponent > ( ) ; root_rendering_component . reset ( ) ; vdom . schedule_render ( ) ; } ) . finish ( ) } else if let GameState :: Asking = root_rendering_component . game_data . game_state { //return wait for the other player div ( bump ) . children ( [ div_wait_for_other_player ( bump ) , ask_to_play ( root_rendering_component , bump , " " ) , ] ) . finish ( ) } else if let GameState :: Asked = root_rendering_component . game_data . game_state { // 2S Click here to Accept play! console :: log_1 ( & " " . into ( ) ) ; //return Click here to Accept play h3 ( bump ) . attr ( " " , " " ) . attr ( " " , " " ) . children ( [ text ( //show Ask Player2 to Play! bumpalo :: format ! ( in bump " " root_rendering_component game_data content_folder_name ) . into_bump_str ( ) , ) ] ) . on ( " " , move | root , vdom , _event | { let mut root_rendering_component = root . unwrap_mut :: < RootRenderingComponent > ( ) ; //region: send WsMessage over websocket root_rendering_component . game_data . prepare_random_data ( ) ; root_rendering_component . game_data . this_machine_player_number = 2 ; root_rendering_component . game_data . player_turn = 1 ; root_rendering_component . game_data . game_state = GameState :: Play ; //send request to Websocket server for spellings root_rendering_component . game_data . ws . send_with_str ( & serde_json :: to_string ( & WsMessage :: RequestSpelling { filename : format ! ( " " root_rendering_component game_data content_folder_name ) , } ) . expect ( " " ) , ) . expect ( " " ) ; root_rendering_component . game_data . ws . send_with_str ( & serde_json :: to_string ( & WsMessage :: AcceptPlay { my_ws_uid : root_rendering_component . game_data . my_ws_uid , other_ws_uid : root_rendering_component . game_data . other_ws_uid , //send the vector of cards because both players need cards in the same location. card_grid_data : serde_json :: to_string ( & root_rendering_component . game_data . vec_cards , ) . expect ( " " ) , } ) . expect ( " " ) , ) . expect ( " " ) ; //endregion vdom . schedule_render ( ) ; } ) . finish ( ) } else if root_rendering_component . game_data . count_click_inside_one_turn >= 2 { if root_rendering_component . game_data . this_machine_player_number == root_rendering_component . game_data . player_turn { //return wait for the other player div_wait_for_other_player ( bump ) } else { //return Click here to take your turn h3 ( bump ) . attr ( " " , " " ) . attr ( " " , " " ) . children ( [ text ( bumpalo :: format ! ( in bump " " " " ) . into_bump_str ( ) , ) ] ) . on ( " " , move | root , vdom , _event | { let root_rendering_component = root . unwrap_mut :: < RootRenderingComponent > ( ) ; //this game_data mutable reference is dropped on the end of the function //clippy is wrong about dropping the mut. I need it. let game_data = & root_rendering_component . game_data ; //region: send WsMessage over websocket game_data . ws . send_with_str ( & serde_json :: to_string ( & WsMessage :: PlayerChange { my_ws_uid : game_data . my_ws_uid , other_ws_uid : game_data . other_ws_uid , } ) . expect ( " " ) , ) . expect ( " " ) ; //endregion root_rendering_component . take_turn ( ) ; // Finally, re-render the component on the next animation frame. vdom . schedule_render ( ) ; } ) . finish ( ) } } else if root_rendering_component . game_data . count_click_inside_one_turn < 2 { if root_rendering_component . game_data . this_machine_player_number == root_rendering_component . game_data . player_turn { h3 ( bump ) . attr ( " " , " " ) . attr ( " " , " " ) . children ( [ text ( bumpalo :: format ! ( in bump " " " " ) . into_bump_str ( ) , ) ] ) . finish ( ) } else { //return wait for the other player div_wait_for_other_player ( bump ) } } else { //unpredictable situation //return h3 ( bump ) . attr ( " " , " " ) . children ( [ text ( bumpalo :: format ! ( in bump " " root_rendering_component game_data game_state as_ref ( ) root_rendering_component game_data this_machine_player_number ) . into_bump_str ( ) , ) ] ) . finish ( ) } }
html element to inform player what to do and get a click action from user
html element to inform player what to do and get a click action from user
root_rendering_component
&'a RootRenderingComponent
bump
&'bump Bump
root_rendering_component
&'a RootRenderingComponent
bump
&'bump Bump