/*
* ColonySimStatusInformation.cs
* Authors: Bradley R. Blankenship
* Copyright (c) 2007-2008 Cornell University
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System.Collections.Generic;
using Microsoft.Xna.Framework;
namespace ColonySim
{
///
/// Represents the status information for the Colony, which is displayed on the GUI
/// and used in for deciding to build buildings, etc.
///
public class ColonySimStatusInformation
{
#region Fields
// The current population of the colony
private int mCurrentPopulation;
// The current amount of money for the colony
private int mCurrentMoney;
// The current resources that we have avaialable, and their quantities
private Dictionary mResources = new Dictionary();
// The current numbers and types of mini game tokens
private Dictionary mTokens = new Dictionary();
// The current GOP of the colony
private float mGOP;
// The current Tier of buildings and resources we have access to
private Tier mTier;
// The number of mini-games we've played
private int mMiniGamesCompleted;
#endregion
#region Properties
///
/// Allow outside access to view and set the population.
///
public int Population
{
get { return mCurrentPopulation; }
set { mCurrentPopulation = value; }
}
///
/// Allows outside access to view and set the money for the player.
///
public int Money
{
get { return mCurrentMoney; }
set { mCurrentMoney = value; }
}
///
/// Allows access to the currently accessible resources in the Colony.
///
public Dictionary Resources
{
get { return mResources; }
set { mResources = value; }
}
///
/// Allows access to the currently accessible tokens for the Colony.
///
public Dictionary Tokens
{
get { return mTokens; }
}
///
/// Allows outside access to view and set the GOP of the colony.
///
public float Happiness
{
get { return mGOP; }
set { mGOP = value; }
}
///
/// Allows access to the current tier the player has unlocked in the
/// Colony Simulation.
///
internal Tier Tier
{
get { return mTier; }
set { mTier = value; }
}
///
/// Allows access to the number of mini-games that were completed.
///
public int MiniGamesCompleted
{
get { return mMiniGamesCompleted; }
set { mMiniGamesCompleted = value; }
}
#endregion
#region Behavior
///
/// Tells if there are enough resources.
///
/// The resource costs to compare.
/// Whether there are enough resources to mee the cost.
public bool EnoughResources(Dictionary pResourceCosts)
{
// The return value
bool retVal = true;
// Go through the resource costs
foreach (ResourceCode resource in pResourceCosts.Keys)
{
// If the it contains it
if (!mResources.ContainsKey(resource) ||
mResources[resource] < pResourceCosts[resource])
{
// Set the return value to false
retVal = false;
// Break
break;
}
}
// Return
return retVal;
}
///
/// Spends resources for the given amounts.
///
/// The resources costs.
public void SpendResources(Dictionary pResourceCosts)
{
// Go through the resource costs
foreach (ResourceCode resource in pResourceCosts.Keys)
{
// If the it contains it
if (mResources.ContainsKey(resource))
{
// Spend the resource
mResources[resource] =
(int)MathHelper.Max(0, mResources[resource] - pResourceCosts[resource]);
}
}
}
#endregion
}
}