jeudi 4 juillet 2019

Abstract Factory Pattern Object Creation With Different Logic

I am an adult video game developer and am working on a project where a large set of girls are created for the player to use and the player is also able to create more of their own girl designs to add to the game.

Our team has decided to use abstract factory to hide the underlying implementation of factories and girls as we plan to update the collection as the time progresses. However, the issue is that girls are to be initialized with toys and our team is having a very big debate about who should be picking out toys for the girls, the girls themselves in their initialization or the factory as it builds the girls.

IList<IGirl> GetGirls(Race race, Nationality nationality, Vector3 girlSizes, int numberOfGirls, bool hardcore = false)
{
    PimpLord pl = new PimpLord(hardcore);
    Pimp p = pl.CreatePimp(race, nationality, girlSizes);
    return p.CreateGirls(numberOfGirls);
}

void Fun(Player player, FunType funType)
{
    // Overload of above 'GetGirls' function that uses above function.
    IList<IGirl> girls = GetGirls(funType, player.Race, player.Location, player.Attributes);

    player.Use(girls, funType);
}

Interface IToy
{
    bool Use(IGirl g);
    Vector4 InhibitionLevels { get; }
    float BatteryLeft { get; }
    void ReplaceBattery(IBattery b);
    int Cleanliness { get; }
    void Clean();
    int UsesLeft { get; }
    bool CanPerforateHymen { get; }
}

The 'PimpLord' is the abstract factory, the 'Pimp' is the concrete factory, and the 'Girl' is the object the concrete factory produces. Girls come with different Toys according to their features; however, player designed girls come with exactly what the player orders them to have. The number of girls we've made by default should far exceed the player designed girls.

If we have the Girl pick out concrete toys, the problem is coupling the girls with the Toy class and making all the girls knowledgeable of what toys they need (random toys but available ones depends on girlSizes and other info). If we have the Pimp pick out the toys for the girls, the pimp will do fine with everything, except they would need to know exactly what toys the player-designed girls are supposed to come with.

Any suggestions are very much appreciated.

Aucun commentaire:

Enregistrer un commentaire