Skip to content

Conversation

github-classroom[bot]
Copy link
Contributor

@github-classroom github-classroom bot commented Nov 10, 2022

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to main since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to main since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @rog1gor


## Libraries
- Bevy
- Serde (for serialization)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nie jestem pewien, czy łączenie Bevy z Nannou to dobry pomysł: obydwa raczej działają z założeniem, że zarządzają własnym oknem i grafiką. Chyba lepiej byłoby do bevy użyć egui albo bevy_prototype_lyon (do rysowania prostych kształtów jak svg)

@rog1gor rog1gor force-pushed the main branch 2 times, most recently from da55829 to 0d445aa Compare December 22, 2022 16:33
Copy link

@agluszak agluszak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bardzo kiepski error handling (unwrapy).
Typy są w niektórych miejscach, a w innych nie ma (np. let connection_established: bool = false - wiadomo przecież, że to bool, ani nie polepsza to czytelności, ani nie pomaga kompilatorowi w inferencji typów...)
Problemy ze współbieżnością.
Kod niepoformatowany.

Trochę się obawiam, czy nawet jak kolega @obukaj wrzuci swoją część kodu, to czy uda się Wam zrobić drugą część (GUI).

Zamiast dwóch osobnych projektów proponuję zrobić jeden projekt (tzn. jeden plik Cargo.toml) z podfolderami i dwoma binarkami (w katalogu bin).

Kod w tym momencie oceniłbym na 3/5, ale ponieważ mieliście dwa dni spóźnienia, to zgodnie z tym co ustaliliśmy, mnożę to razy 0.8. Czyli ostatecznie wychodzi 2.4/5


use p2p_client::Client;

// Sending a message that should explain what kind of message is expected

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raczej w dokumentacji się pisze, że funkcja coś robi, a nie że funkcja to jest robienie czegoś. Cf. https://doc.rust-lang.org/std/primitive.bool.html#implementations

}

// Sending a message that we're expecting a socket address of a server
// reading that socket addres from stdin and parsing it into SocketAddress

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// reading that socket addres from stdin and parsing it into SocketAddress
// reading that socket address from stdin and parsing it into SocketAddress

// reading that socket addres from stdin and parsing it into SocketAddress
// If the address is incorrect, then returns a default socket address
fn provide_server() -> SocketAddr {
let input = provide_input("Provide a socket that the server will be binded to");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let input = provide_input("Provide a socket that the server will be binded to");
let input = provide_input("Provide a socket that the server will be bound to");


// Sending a message that should explain what kind of message is expected
// and reading that message from stdin
fn provide_input(msg: &str) -> String {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chyba lepsza byłaby nazwa ask_for_input

socket_addr
}

// Sending a message that we're expecting a socket address of a TcpListener

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tak w ogóle to to przecież nie jest żadne wysyłanie, tylko wypisywanie (print, a nie send)


// Function that provides steps for the player who received Send message from the server
pub fn received_send(&self, addr: SocketAddr, password: String) -> Option<TcpStream> {
self.going_first.store(true, Ordering::Relaxed); // This player goes first

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dlaczego ta zmienna jest atomowa? Nie musi być, bo i tak dotykamy jej tylko z jednego wątku

Comment on lines 160 to 164
let mut buffer = [0; 1024];
let mut num_bytes = 0;
while num_bytes == 0 {
num_bytes = opponent_stream.read(&mut buffer).unwrap();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

powtórzony kod

}

s.spawn(|| {
match Self::handle_connection(&mut players.lock().unwrap(), stream) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to niedobrze dawać wnętrze zablokowanego muteksa do funkcji, bo blokuje to inne wątki

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to jest bardzo poważny błąd z dziedziny programowania współbieżnego

fn handle_connection(players: &mut Vec<ClientsAddr>, mut stream: TcpStream) -> io::Result<()> {
println!("Handling connection...");
let mut buffer = [0; 1024];
let num_bytes = stream.read(&mut buffer)?;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

na tym wywołaniu funkcja może się zablokować na dowolnie długo, ale przecież nie potrzeba jej w tym miejscu jeszcze do niczego referencji do players

pub fn port(&self) -> u16 {
self.tcp_listener.local_addr().unwrap().port()
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kod nie był formatowany

Copy link

@agluszak agluszak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W porządku wyszła gra, 5/5

Action::PlayCard(n1, n2) => is_legal_to_play(n1, n2, game_state),
Action::EndTurn => true,
Action::Help => true,
_ => panic!("Unknown or not ingame action"), // this should never be reached
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do tego jest unreachable!()

rand_int: i32, // used for deck shuffling
}

impl Ord for Minion {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raczej nie powinno się rącznie nadpisywać Ord i Cmp, lepiej opakować ten typ w NewType używany do sortowania, a w strukturze Minion zostawić naturalne sortowanie/porównywanie

struct SortedMinion(i32, Minion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants