mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 15:16:33 -08:00
Simplify Combat (C#) folder structure
This commit is contained in:
31
28_Combat/csharp/Program.cs
Normal file
31
28_Combat/csharp/Program.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace Game
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
View.ShowBanner();
|
||||
View.ShowInstructions();
|
||||
|
||||
var computerForces = new ArmedForces { Army = 30000, Navy = 20000, AirForce = 22000 };
|
||||
var playerForces = Controller.GetInitialForces(computerForces);
|
||||
|
||||
var state = (WarState) new InitialCampaign(computerForces, playerForces);
|
||||
var isFirstTurn = true;
|
||||
|
||||
while (!state.FinalOutcome.HasValue)
|
||||
{
|
||||
var branch = Controller.GetAttackBranch(state, isFirstTurn);
|
||||
var attackSize = Controller.GetAttackSize(state.PlayerForces[branch]);
|
||||
|
||||
var (nextState, message) = state.LaunchAttack(branch, attackSize);
|
||||
View.ShowMessage(message);
|
||||
|
||||
state = nextState;
|
||||
isFirstTurn = false;
|
||||
}
|
||||
|
||||
View.ShowResult(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user