Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions C7/UIElements/MainMenu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ private void DisplayTitleScreen() {

// TODO: enable buttons are features are implemented
ButtonContainer.NewGame.Pressed += GoToWorldSetup;
ButtonContainer.QuickStart.Pressed += StartGame;
ButtonContainer.Tutorial.Pressed += StartGame;
ButtonContainer.QuickStart.Pressed += QuickStartGame;
ButtonContainer.Tutorial.Pressed += QuickStartGame;
ButtonContainer.Tutorial.Visible = false;
ButtonContainer.LoadGame.Pressed += LoadGame;
ButtonContainer.LoadScenario.Pressed += LoadScenario;
Expand Down Expand Up @@ -112,9 +112,10 @@ public void GoToWorldSetup() {
GetTree().ChangeSceneToFile("res://UIElements/NewGame/world_setup.tscn");
}

public void StartGame() {
public void QuickStartGame() {
log.Information("start game button pressed");
PlayButtonPressedSound();
QuickStartSetup.Init(Global);
GetTree().ChangeSceneToFile("res://C7Game.tscn");
}

Expand Down
49 changes: 49 additions & 0 deletions C7/UIElements/NewGame/QuickStartSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Godot;
using System;
using System.Linq;
using C7GameData;
using C7Engine;
using C7Engine.Lua;
using Serilog;

public partial class QuickStartSetup : Node {
private static ILogger log = LogManager.ForContext<ScenarioSetup>();

public static void Init(GlobalSingleton globalState) {
log.Information("Setting up a QuickStart game");

globalState.ResetLoadGameFields();

var save = GameModeLoader.Load(GamePaths.GameModesDir, GamePaths.GameMode);

globalState.WorldCharacteristics = new WorldCharacteristics(save) {
landform = WorldCharacteristics.Landform.Pangaea,
oceanCoverage = WorldCharacteristics.OceanCoverage.Percent_70,
age = WorldCharacteristics.Age.Billion_4,
climate = WorldCharacteristics.Climate.Normal,
temperature = WorldCharacteristics.Temperature.Temperate,
worldSize = WorldSize.Generic(),
mapSeed = new Random().Next(),
};

globalState.SaveGame = save;

Civilization player = save.Civilizations.FirstOrDefault(x => x.name == "Netherlands") ?? save.Civilizations[1];
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these strings ("Netherlands" and "Regent") are also used as default values in the PlayerSetup class, should we extract them into constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I considered constants, but actually, what we want to do is make Quick Start conform to the original.

I was reading the manual again and noticed that Quick Start is supposed to run a game with the same parameters as what was set by the user when a New Game was last creates. So this setup information should be stored in a file somewhere. This file can then be initially set with some defaults, which may or may not not match the New Game defaults.

I'll open a separate issue for this behaviour, I think it would be useful for testing.


Difficulty difficulty = save.Difficulties.FirstOrDefault(x => x.Name == "Regent") ?? save.Difficulties[0];

var opponents = save.Civilizations
.Select(x => new SelectedOpponent { isRandom = true })
.Take(globalState.WorldCharacteristics.worldSize.numberOfCivs - 1)
.ToList();

GameSetup gameSetup = new() {
playerCivilization = player,
difficulty = difficulty,
worldCharacteristics = globalState.WorldCharacteristics,
opponents = opponents
};

gameSetup.Populate(save);
}
}