Mercurial > repos > snowblizz-super-API-ideas
view api/Objects/UnitEquipmentItem.cs @ 67:e6200220ece3
Re #50 - Complete core loading of WarFoundry XML files
* Clean up stat loading for game systems and unit types
* Delete rogue character that stopped code compiling
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 25 Apr 2009 14:59:23 +0000 |
parents | 3a90f70dac73 |
children | 284ebe05158c |
line wrap: on
line source
// This file (UnitEquipmentItem.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. using System; using System.Xml; namespace IBBoard.WarFoundry.API.Objects { /// <summary> /// Summary description for UnitEquipmentItem. /// </summary> public class UnitEquipmentItem : WarFoundryObject { private EquipmentItem item; private bool required; private bool roundUp; private int minNum; private int maxNum; private double minPercentage; private double maxPercentage; private string mutexGroup; private UnitType unitType; protected UnitEquipmentItem(EquipmentItem equipmentItem, UnitType equipForType) { item = equipmentItem; EquipmentForUnit = equipForType; } public override string Name { get { return item.Name; } set { base.Name = value; } } public string EquipmentItemID { get { return item.ID; } } public double Cost { get { return item.Cost; } } public bool IsRequired { get { return required; } set { required = value; } } public bool RoundNumberUp { get { return roundUp; } set { roundUp = value; } } public string MutexGroup { get { return mutexGroup; } set { mutexGroup = (value == null ? "" : value.Trim()); } } public UnitType EquipmentForUnit { get { return unitType; } set { if (value != null) { unitType = value; } } } public bool IsRatioLimit { get { return minPercentage!=100 || maxPercentage!=100; } } public int MinNumber { get { return minNum; } set { if (value >=0 || value == WarFoundryCore.INFINITY) { minNum = value; } //TODO: Check Min<Max } } public int MaxNumber { get { return maxNum; } set { if (value >=0 || value == WarFoundryCore.INFINITY) { maxNum = value; } //TODO: Check Min<Max } } public double MinPercentage { get { return minPercentage; } set { if (value >=0 && value <= 100) { minPercentage = value; } //TODO: Check Min<Max } } public double MaxPercentage { get { return maxPercentage; } set { if (value >=0 && value <= 100) { maxPercentage = value; } //TODO: Check Min<Max } } public EquipmentItem EquipmentItem { get { return item; } } public override string ToString() { return EquipmentItem.Name+ " ("+EquipmentItem.Cost+"pts each)"; } public bool HasAlternatives() { if (MutexGroup=="") { return false; } else { //If the number of items in the MutEx group is greater than one then it must be this item plus another return EquipmentForUnit.GetEquipmentItemsByExclusionGroup(MutexGroup).Length > 1; } } public static string FormatEquipmentAmount(UnitEquipmentItem item, double amount) { if (item.IsRatioLimit) { return Math.Round(amount * 100) + "%"; } else { if (amount == WarFoundryCore.INFINITY) { return "all"; } else { return amount.ToString(); } } } } }