Good code architecture for this problem?

architecture, c#, oop

Solution

What about the Builder pattern? You could have a static `FillDefaults` method on your ShipInfo class and then assign each property of the ShipInfo via an instance method that returns the instance that you're working with, like this:

ShipInfo.FillDefaults().CalculateSomething(50).AssignName("Testing...").RelativeFiringPower(10).ApplyTo(myShip);

Within ShipInfo, this would look something like:

public static ShipInfo FillDefaults()
{
    ShipInfo newInstance = ...;
    // Do some default setup here
    return newInstance;
}

public ShipInfo CalculateSomething(int basis)
{
    // Do some calculation
    // Assign some values internally
    return this;
}

// Keep following this pattern of methods
public void ApplyTo(SpaceObject obj)
{
    // Some checks here if you want
    obj.ShipInfo = this;
}

Problem

I am developing a space shooter game with customizable ships. You can increase the strength of any number of properties of the ship via a pair of radar charts*. Internally, i represent each ship as a subclassed `SpaceObject` class, which holds a `ShipInfo` that describes various properties of that ship. I want to develop a relatively simple API that lets me feed in a block of relative strengths (from minimum to maximum of what the radar chart allows) for all of the ship properties (some of which are simplifications of the underlying actual set of properties) and get back a ShipInfo class i can give to a `PlayerShip` class (that is the object that is instantiated to be a player ship). I can develop the code to do the transformations between simplified and actual properties myself, but i would like some recommendations as to what sort of architecture to provide to minimize the pain of interacting with this translator code (i.e. no methods with 5+ arguments or somesuch other nonsense). Does anyone have any ideas? *=not actually implemented yet, but that's the plan.

Original source