// STITCHME It might be valuable to eventually have InGameState be able to say which nodes are reachable?

        // STITCHME It could be nice to keep track of all canResets in the room and evaluate them as you move around?
        // Another option would be to have something in an initialization phase that converts canResets into just names,
        // and adds information on nodes and strats that they invalidate the canReset.
        // We'll see when we get to the step of reducing logical elements *shrug*

        /// <summary>
        /// Creates a new InGameState
        /// </summary>
        /// <param name="model">A SuperMetroidModel. Its rooms must have both been set and initialized.
        /// Its items and game flags must also have been set.</param>
        /// <param name="itemContainer">The result of reading the items.json file.</param>
        public InGameState(SuperMetroidModel model, ItemContainer itemContainer)
        {
            IEnumerable <ResourceCapacity> startingResources = itemContainer.StartingResources;

            Inventory = new ItemInventory(startingResources);

            Resources = new ResourceCount();

            // Start the player at full
            foreach (ResourceCapacity capacity in startingResources)
            {
                Resources.ApplyAmountIncrease(capacity.Resource, capacity.MaxAmount);
            }

            // Initialize starting game flags
            foreach (string gameFlagName in itemContainer.StartingGameFlagNames)
            {
                ApplyAddGameFlag(model.GameFlags[gameFlagName]);
            }

            // Initialize starting items
            foreach (string itemName in itemContainer.StartingItemNames)
            {
                ApplyAddItem(model.Items[itemName]);
            }

            RoomNode startingNode = model.Rooms[itemContainer.StartingRoomName].Nodes[itemContainer.StartingNodeId];

            InRoomState = new InRoomState(startingNode);
        }
Beispiel #2
0
        /// <summary>
        /// Creates and returns a copy of this ResourceCount, with positive and negative values flipped.
        /// </summary>
        /// <returns></returns>
        public ResourceCount CloneNegative()
        {
            ResourceCount clone = Clone();

            foreach (RechargeableResourceEnum currentResource in Enum.GetValues(typeof(RechargeableResourceEnum)))
            {
                clone.ApplyAmount(currentResource, clone.GetAmount(currentResource) * -1);
            }

            return(clone);
        }
Beispiel #3
0
        /// <summary>
        /// A constructor that receives an enumeration of ResourceCapacity to express the base resource maximums.
        /// </summary>
        /// <param name="baseResourceMaximums">The base maximum for all resources</param>
        public ItemInventory(IEnumerable <ResourceCapacity> baseResourceMaximums)
        {
            ResourceCapacityChanges = new ResourceCount();

            // Apply startingResources to base maximums
            BaseResourceMaximums = new ResourceCount();
            foreach (ResourceCapacity capacity in baseResourceMaximums)
            {
                BaseResourceMaximums.ApplyAmountIncrease(capacity.Resource, capacity.MaxAmount);
            }
        }
        /// <summary>
        /// Creates and returns a ResourceCount that expresses how many rechargeable resources this in-game state has,
        /// relative to the provided in-game state. Negative values mean this state has less.
        /// </summary>
        /// <param name="other">The other in-game state to compare with.</param>
        /// <returns></returns>
        public ResourceCount GetResourceVariationWith(InGameState other)
        {
            ResourceCount returnValue = new ResourceCount();

            foreach (RechargeableResourceEnum currentResource in Enum.GetValues(typeof(RechargeableResourceEnum)))
            {
                returnValue.ApplyAmount(currentResource, GetCurrentAmount(currentResource) - other.GetCurrentAmount(currentResource));
            }

            return(returnValue);
        }
Beispiel #5
0
 public ResourceCount(ResourceCount other)
 {
     ApplyAmounts(other);
 }
Beispiel #6
0
 /// <summary>
 /// Sets in this container the resource amount found in the provided other container for the provided resource.
 /// </summary>
 /// <param name="resource">The resource to apply an amount for</param>
 /// <param name="other">The ResourceCount to use the amount from</param>
 public void ApplyAmount(RechargeableResourceEnum resource, ResourceCount other)
 {
     Amounts[resource] = other.Amounts[resource];
 }
Beispiel #7
0
 /// <summary>
 /// Sets in this container the resource amounts found in the provided other container
 /// </summary>
 /// <param name="other">The ResourceCount to use amounts from</param>
 public void ApplyAmounts(ResourceCount other)
 {
     Amounts = new Dictionary <RechargeableResourceEnum, int>(other.Amounts);
 }
Beispiel #8
0
 /// <summary>
 /// A constructor that receives a ResourceCount to express the base resource maximums.
 /// </summary>
 /// <param name="baseResourceMaximums">A ResourceCount containing the base maximums.
 /// This instance will be cloned and will never be modified as a result of being passed here.</param>
 public ItemInventory(ResourceCount baseResourceMaximums)
 {
     BaseResourceMaximums    = baseResourceMaximums.Clone();
     ResourceCapacityChanges = new ResourceCount();
 }