Skip to content
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

Rivers and Bridges map refactor #103

Merged
merged 8 commits into from
Aug 19, 2022
Merged

Rivers and Bridges map refactor #103

merged 8 commits into from
Aug 19, 2022

Conversation

chris-bsnake
Copy link
Contributor

Breaking the river and bridges map into three maps, each focusing on a single map size

@chris-bsnake chris-bsnake removed the request for review from bvanvugt August 18, 2022 16:12
Copy link
Contributor

@robbles robbles left a comment

Choose a reason for hiding this comment

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

Looks good, and works for me locally. Just have a couple of optional suggestions.

globalRegistry.RegisterMap("hz_rivers_bridges_xl", RiverAndBridgesExtraLargeHazardsMap{})
}

func getUnoccupiedPoints(lastBoardState *rules.BoardState) []rules.Point {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a little confusing having two similarly named functions in the rules and maps packages, where one actually wraps the other. Maybe either:

  • rename to getUnoccupiedPointsWithHazards
  • add a boolean param to rules.GetUnoccupiedPoints that makes it exclude hazards as well, and use that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to either option. Feels like we may want to do this more often so maybe #2 makes the most sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to move towards providing more reusable utilities for maps to do common operations like this, so 2 is probably better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i'll take a swing at this and see if I can figure out how rules.GetUnoccupiedPoints() works

}
}

func (m RiverAndBridgesMediumHazardsMap) SetupBoard(lastBoardState *rules.BoardState, settings rules.Settings, editor Editor) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to have these return an error if the board size isn't the supported one. Otherwise it draws the map regardless of whether it fits on the board.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering about this, i didn't know if the map system had that built in or if we need to do standard checks at the start of SetupBoard() on every map

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not built in currently. Right now it's sort of the maps choice whether to enforce the supported sizes and validate settings.
I think if it's going to produce "wrong" behaviour like off-grid hazards vs. just "funny-looking" games, that might be the reason to enforce it in the map. Unless something's changed, the error message should be passed back to the play UI, so you can at least see why a game wasn't created.

Copy link
Contributor

@robbles robbles left a comment

Choose a reason for hiding this comment

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

Looks good!

maps/game_map.go Outdated
}

for _, size := range d {
if size.Width == Width && size.Height == Height {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a little nicer to cast to uint internally here so that most calls to IsAllowable don't need to cast int -> uint.

@robbles robbles merged commit f82cfe5 into main Aug 19, 2022
@robbles robbles deleted the rivers-bridges-refactor branch August 19, 2022 17:09
bcambl added a commit to bcambl/rules that referenced this pull request Aug 24, 2022
@bcambl bcambl mentioned this pull request Aug 24, 2022
robbles pushed a commit that referenced this pull request Aug 26, 2022
* castle_wall map

Wall of hazards around the board with dangerous bridges.

- add support for all standard board sizes
- hazard placement for all board sizes

* passage food placement for all board sizes

* 4 snake starting positions for all maps

* only one food can spawn on a bridge

* support 8 snakes for all board sizes

support 12 snakes on XLarge and XXLarge board sizes

* max 2 food sm/med/lg and max 4 food on xlg/xxlg

no food in the first 10 turns

* sort generated hazard positions

* remove 'uninteresting' castle wall map board sizes

* refactor castle wall map to align with #103

* align map castle wall meta Name with ID

* set MinPlayers to 1 for castle wall map

* pass max snake/food and startPosition to priv func

* fix castle wall food placement and refactor tests

* avoid food spawn by snake heads on castle wall map

- fixes forced food spawning infront of snake issue on large & xlarge maps with double walls
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.

2 participants