using System.Collections.Generic;
using System.Linq;
using Cthangover.Core.Battle;
using Cthangover.Core.Factories.Impls;
using Cthangover.Core.Quests;
using Cthangover.Core.Characters;
using Godot;
namespace Cthangover.Core.Settings
{
///
/// Immutable descriptor for a battle encounter, constructed via the
/// static factory overloads. Holds the
/// background texture, enemy roster, quest reference, card order side,
/// and the scene to return to when the battle ends. The private
/// constructor forces creation through the factories so that all
/// required data is supplied upfront.
///
public class BattleData
{
/// The quest that triggered this battle; may be null
/// for non-quest skirmishes.
public QuestBase Quest { get; set; }
/// Auxiliary tag set on new characters acquired via recruitment
/// after this battle.
public string NewTag { get; set; }
/// List of enemy instances spawned from
/// the provided IDs or default templates.
public List EnemiesCards { get; private set; }
/// Battle background texture (full-resolution).
public Texture2D Background { get; private set; }
/// Depth map texture for the parallax post-process effect.
public Texture2D DepthMap { get; set; }
/// Albedo/colour map texture for the parallax post-process effect.
public Texture2D AlbedoMap { get; set; }
/// Which side of the screen the player's cards are drawn on.
public BattleSide BattleSide { get; private set; } = BattleSide.Player;
/// Identifier for the active battle core logic module.
public string ActiveBattleCore { get; set; }
/// Scene name to transition to when the battle finishes or is
/// fled. Stored as a string to avoid type coupling.
public string ReturnScene { get; private set; }
private BattleData()
{ }
///
/// Convenience overload that defaults to
/// BattleSide.Player. Constructs enemies from their string IDs
/// via ,
/// falling back to a level-1 template when the ID is unknown.
///
public static BattleData InitBattle(Texture2D background, string returnScene, params string[] enemies)
{
return InitBattle(background, returnScene, BattleSide.Player, enemies);
}
///
/// Creates a battle with a specified and
/// enemy IDs. Each ID is resolved through
/// .
/// Unknown IDs produce a fallback with 20 HP
/// and 3 action points.
///
public static BattleData InitBattle(Texture2D background, string returnScene, BattleSide cardOrder = BattleSide.Player, params string[] enemies)
{
var list = enemies.Select(o => CharacterFactory.Instance.Get(o) ?? new Character
{
ID = o,
Attributes = new CharacterAttributes
{
Health = new Attribute { Value = 20, BaseValue = 20 },
Point = new Attribute { Value = 3, BaseValue = 3 },
},
Level = 1,
Exp = 10,
}).ToList();
return InitBattle(background, returnScene, list, cardOrder);
}
///
/// Core factory that directly accepts a pre-built
/// for the enemy roster. This is the
/// overload that all other InitBattle variants delegate to.
///
public static BattleData InitBattle(Texture2D background, string returnScene, List enemiesCards, BattleSide cardOrder = BattleSide.Player)
{
return new BattleData
{
Background = background,
ReturnScene = returnScene,
EnemiesCards = enemiesCards,
BattleSide = cardOrder,
};
}
}
}