-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DISCUSSION] Code architecture #7
Comments
So, the
So what I suggest: since we rely on user input for updating the game state, let's just put input processing into |
These are good points, was something I was wondering about (sort of) myself), but you have outlined the issue well. However, not sure if I like the idea of combining the update and input functions, as the two functions have are suppose to have different purposes and that. That being said, it does seem to look like it works fine, but I'll have to think about it. I do like the use of slice pattern matching, I didn't know you could do that 😄 |
Also, not all input will be for updating the game. For example, when the player opens their bag, it will rather push a state to the game struct for the player too look on their bag. (This example would return a 'PushState(Box::new(BagMenuState::new()))' for the return result). In this case, I guess skipping update when this happens is probably a good idea. |
@Hopson97 No, the idea is that game can't do anything before the user inputs a command, so And also, here's how I would do opening the bag: impl ExploreState {
// bla-bla-bla
fn update(&mut self, input_args: &[&str]) -> ReturnResult {
match input_args {
["bag"] => {
PushState(Box::new(BagMenuState::new()))
}
// bla-bla-bla
}
}
}
impl BagMenuState {
// bla-bla-bla
fn update(&mut self, input_args: &[&str]) -> ReturnResult {
match input_args {
["close"] => {
PushState(Box::new(ExploreState::new()))
}
// bla-bla-bla
}
}
} |
Good points. This is the sort of thing that would be interesting a video :p The only issue I have now is the function is called update() when it does more than just update, so we just need a better name I guess |
@Hopson97 Well, well, well... Maybe, BTW, here's a PR with these changes. |
@Hopson97 Just a small request (i don't want to open an issue): could you format the code with |
Done |
Thanks |
This is a thread for discussing general things about code architecture in Asciimon. Code architecture means usage of structs and traits, relationships between structs, patterns etc.
THIS IS A DISCUSSION, DO NOT CLOSE!!!
The text was updated successfully, but these errors were encountered: