rubberduck-vba / Battleship

An Object-Oriented VBA experiment
MIT License
85 stars 22 forks source link

Add a "Salvo" mode #8

Open retailcoder opened 6 years ago

retailcoder commented 6 years ago

Currently blocked by #7

Once there's an IGameMode interface, the game needs a SalvoMode implementation so that each turn consists of:

The GridState enum could have a MarkedPosition value that recycles the InvalidPosition member's value, which is currently only used in the deployment phase. Because of Worksheet UI limitations with the conditional formatting of the grid, no new enum values can be added.

ghost commented 5 years ago

Brilliant idea but a huge advantage for player 1. A larger grid would reduce the advantage.

I would still extend the GridState enum.

IGridViewCommands '@Description("Instructs the view to that all Players have are ready to go.") Public Sub OnPlayersComplete(Players as Dictionary) End Sub

Adding an OnPlayersComplete method to the IGridViewCommands interface would give you a clear point in which to switch from setup to battle mode (no matter what strategy is used). At this point it you could change the Conditional Formatting rules. Dropping (-1, 0, 1, 2) aka (Unknown, PreviewShipPosition, ShipPosition, InvalidPosition) and targeting (3, 4, 5, 6, 7) aka (PreviousMiss, PreviousHit, ?, ?, ?).

retailcoder commented 5 years ago

Adding an OnPlayersComplete method to the IGridViewCommands interface would give you a clear point in which to switch from setup to battle mode

It's the other way around: IGridViewEvents fires HumanPlayerReady from the view, when HideInformationBox is invoked and ViewMode is Player1 or Player2. TBH I don't really like this "ViewMode" state, there's gotta be a better way to do this.

This is part of why the prompt "needs" to pop for each ship 😒

ghost commented 5 years ago

Actually commenting out the deployment prompt has no effect on game play (other then not having to click it).

Public Sub ShowInfoBeginDeployShip(ByVal ShipName As String) Mode = FleetPosition ShowFleetStatus ' ShowInformation Replace(InfoBoxPlaceSHIPs, "%SHIP%", UCase$(ShipName)) End Sub

When I do my rewrite, I plan on moving the deployment message from the marquee to a passive information box over the opposing grid.

ghost commented 5 years ago

Just to clarify, I think the controller should fire a OnPlayersComplete(Players as Dictionary) event after the players are ready and before the battle begins. This would give the View a clear starting point to use to transition between modes.

I also think that passing both players to the View, during this event, would unlocks the View's potential to be customized. Say for instance you wanted to add a "Player 1 vs Player 2` transition (btw IPlayer should have a name field), or if you wanted to show all the ships in PlayAIvsAI or what every.

retailcoder commented 4 years ago

The IGameController interface introduced in v1.1 came with a renaming of GameController to StandardGameController; a SalvoModeGameController could be implemented without affecting the standard controller code, and the common logic could be extracted into a new GameControllerBase class.