DeckStacker v1.0
A card manager plugin for Unity games.
 
Loading...
Searching...
No Matches
DeckStacker.DSItemDistributor Class Reference

Static Public Member Functions

static List< List< DSCard > > DistributeCardsIntoLists (List< DSCard > originalCardList_, int preferredCardsPerList_, int maxNumberOfLists_, DSItemDistribution cardDistribution_, DSDistributionWeight distributionWeight_)
 
static List< List< T > > DistributeItemsIntoLists< T > (List< T > originalList_, int preferredItemsPerList_, int maxNumberOfLists_, DSItemDistribution itemDistribution_, DSDistributionWeight distributionWeight_)
 

Detailed Description

This script generically distributes a specified list of items between a number of new lists.

For example: If you want to evenly split a collection of 11 Transforms between 3 new parents, where:

  • The Transforms have been collected into a list, transformList
  • The preferred maximum number of objects per parent will be 5
  • The excess items should be weighted toward the bottom half of the parent list ...then you will call this command:

DSItemDistributor.DistributeItemsIntoLists<Transform>(transformList, 5, 3, DSItemDistribution.Even, DSDistributionWeight.End);

The return will be a List of Lists, containing a distribution of the Transforms between them.
This can be used to determine what parents the objects should be assigned to.

The primary way this is used in DeckStacker is for distributing several cards between multiple stacks.


This script was originally concieved as part of a Multi-Stack system that dynamically distributes cards between multiple stacks, but that idea turned out to conflict with some fundamentals of DeckStacker, and the implementation was kind of ugly, anyway.

Multi-Stack was pulled back to a smaller scope, resulting in this script.

Member Function Documentation

◆ DistributeCardsIntoLists()

static List< List< DSCard > > DeckStacker.DSItemDistributor.DistributeCardsIntoLists ( List< DSCard > originalCardList_,
int preferredCardsPerList_,
int maxNumberOfLists_,
DSItemDistribution cardDistribution_,
DSDistributionWeight distributionWeight_ )
inlinestatic

A wrapper function for DistributeItemsIntoLists, because DSCards are going to be the main use case for this script.

◆ DistributeItemsIntoLists< T >()

static List< List< T > > DeckStacker.DSItemDistributor.DistributeItemsIntoLists< T > ( List< T > originalList_,
int preferredItemsPerList_,
int maxNumberOfLists_,
DSItemDistribution itemDistribution_,
DSDistributionWeight distributionWeight_ )
inlinestatic

Takes a list of items and other parameters, and breaks that list into several lists.
This was originally made for distributing cards into several stacks, and you want those cards distributed evenly.

This was then made generic for more versatility.


The documentation for this class was generated from the following file: