Beispiel #1
0
        public static Dictionary <string, beans.beanLocalType> beans_byId(this beans _beans)
        {
            var beans_byID = new Dictionary <string, beans.beanLocalType>();

            foreach (var bean in _beans.bean)
            {
                beans_byID.Add(bean.id ?? bean.name.str(), bean);
            }
            return(beans_byID);
        }
Beispiel #2
0
 public static string GetImageUrl(beans.ResourcesType resource)
 {
     switch (resource)
     {
         case ResourcesType.Clay:
             return "<img src=\"images/resources/clay.png\" title=\"Clay\" alt=\"\" />";
         case ResourcesType.Wood:
             return "<img src=\"images/resources/wood.png\" title=\"Wood\" alt=\"\" />";
         case ResourcesType.Iron:
             return "<img src=\"images/resources/iron.png\" title=\"iron\" alt=\"\" />";
         default:
             return "";
     }
 }
 private string BuildableStatusToString(beans.BuildingType type, ISession session)
 {
     BuildableStatus enumCanBuild = this.Village.VillageBuildingMethods.CanBuild(type, session);
     string strResult = "";
     if (enumCanBuild == BuildableStatus.JustDoIt)
     {
         int level = 0;
         BuildPrice price = null;
         switch (type)
         {
             case BuildingType.Headquarter:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopHeadquarterLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopHeadquarterLevel + 1;
                 break;
             case BuildingType.Barracks:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopBarrackLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopBarrackLevel + 1;
                 break;
             case BuildingType.Stable:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopStableLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopStableLevel + 1;
                 break;
             case BuildingType.Workshop:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopWorkshopLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopWorkshopLevel + 1;
                 break;
             case BuildingType.Academy:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopAcademyLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopAcademyLevel + 1;
                 break;
             case BuildingType.Smithy:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopSmithyLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopSmithyLevel + 1;
                 break;
             case BuildingType.Rally:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopRallyPointLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopRallyPointLevel + 1;
                 break;
             case BuildingType.Market:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopMarketLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopMarketLevel + 1;
                 break;
             case BuildingType.TimberCamp:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopTimberCampLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopTimberCampLevel + 1;
                 break;
             case BuildingType.ClayPit:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopClayPitLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopClayPitLevel + 1;
                 break;
             case BuildingType.IronMine:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopIronMineLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopIronMineLevel + 1;
                 break;
             case BuildingType.Farm:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopFarmLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopFarmLevel + 1;
                 break;
             case BuildingType.Warehouse:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopWarehouseLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopWarehouseLevel + 1;
                 break;
             case BuildingType.HidingPlace:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopHiddenPlaceLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopHiddenPlaceLevel + 1;
                 break;
             case BuildingType.Wall:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopWallLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 level = this.Village.VillageBuildingMethods.TopWallLevel + 1;
                 break;
             default:
                 break;
         }
         
         strResult += "<td><img src=\"images/holz.png\" title=\"Wood\" alt=\"\" />" + price.Wood + "</td>";
         strResult += "<td><img src=\"images/lehm.png\" title=\"Clay\" alt=\"\" />" + price.Clay + "</td>";
         strResult += "<td><img src=\"images/eisen.png\" title=\"Iron\" alt=\"\" />" + price.Iron + "</td>";
         strResult += "<td><img src=\"images/face.png\" title=\"Villagers\" alt=\"\" />" + Math.Round(price.Population, MidpointRounding.AwayFromZero) + "</td>";
         strResult += "<td>" + Functions.FormatTime(price.BuildTime) + "</td>";
         strResult += "<td align=\"center\"><a href=\"headquarters.aspx?id=" + this.Village.ID + "&action=build&building=" + (int)type + "\">Nâng cấp lên level " + level.ToString("00") + "</td>";
     }
     else if (enumCanBuild == BuildableStatus.BuildingLevelExceed)
     {
         strResult += "<td colspan=\"6\" align=\"center\"><span class=\"inactive\">" + beans.BuildableStatusFactory.ToString(BuildableStatus.BuildingLevelExceed) + "</span></td>";
     }
     else
     {
         BuildPrice price = null;
         switch (type)
         {
             case BuildingType.Headquarter:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopHeadquarterLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Barracks:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopBarrackLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Stable:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopStableLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Workshop:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopWorkshopLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Academy:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopAcademyLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Smithy:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopSmithyLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Rally:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopRallyPointLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Market:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopMarketLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.TimberCamp:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopTimberCampLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.ClayPit:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopClayPitLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.IronMine:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopIronMineLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Farm:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopFarmLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Warehouse:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopWarehouseLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.HidingPlace:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopHiddenPlaceLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             case BuildingType.Wall:
                 price = beans.Build.GetPrice(type, this.Village.VillageBuildingMethods.TopWallLevel + 1, this.Village[beans.BuildingType.Headquarter]);
                 break;
             default:
                 break;
         }
         strResult += "<td><img src=\"images/holz.png\" title=\"Wood\" alt=\"\" />" + price.Wood + "</td>";
         strResult += "<td><img src=\"images/lehm.png\" title=\"Clay\" alt=\"\" />" + price.Clay + "</td>";
         strResult += "<td><img src=\"images/eisen.png\" title=\"Iron\" alt=\"\" />" + price.Iron + "</td>";
         strResult += "<td><img src=\"images/face.png\" title=\"Villagers\" alt=\"\" />" + Math.Round(price.Population, MidpointRounding.AwayFromZero) + "</td>";
         strResult += "<td>" + Functions.FormatTime(price.BuildTime) + "</td>";
         strResult += "<td align=\"center\"><span class=\"inactive\">" + beans.BuildableStatusFactory.ToString(enumCanBuild) + "</span></td>";
     }
     return strResult;
 }
Beispiel #4
0
 public SpringMvcMappings(string xmlFile) : this()
 {
     XmlFile     = xmlFile;
     springBeans = beans.Load(xmlFile);
 }
Beispiel #5
0
 public static List <beans.beanLocalType> urlBeans(this beans _beans)
 {
     return((from bean in _beans.bean
             where bean.name.notNull() && bean.name[0] == '/'
             select bean).toList());
 }
 public SpringMvcMappings(string xmlFile) : this()
 {
 	XmlFile = xmlFile;
 	springBeans = beans.Load(xmlFile); 
 }
		public static SpringMvcMappings map_ControllerBean(this SpringMvcMappings mvcMappings, string httpRequestUrl, beans.beanLocalType urlBean)
		{
			var controller = new SpringMvcController()
									{
										HttpRequestUrl = httpRequestUrl, 
										JavaClass = urlBean.@class							
									};
			foreach(var _property in urlBean.property)	
				controller.Properties.add(_property.name, _property.value + 
														 (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "" ));

//not used in the current case
//var beans_byId = mvcMappings.springBeans.beans_byId();			 				
/*				if (controller.JavaClass.inValid() && beans_byId.hasKey(urlBean.parent))
			{
				controller.JavaClass = beans_byId[urlBean.parent].@class;								
				foreach(var _property in beans_byId[urlBean.parent].property)	
					controller.Properties.add(_property.name, _property.value + 
														 (((_property.@ref).valid()) ? "ref:{0}".format(_property.@ref) : "" ));
			
			} 
*/				
			if (controller.JavaClass.valid())
				controller.FileName = "{0}.java".format(controller.JavaClass.replace(".","\\")); 
				
			controller.CommandName = controller.Properties["commandName"];
			controller.CommandClass= controller.Properties["commandClass"];  
			
			mvcMappings.Controllers.Add(controller); 
			
			return mvcMappings;
    	}
 public XRoot(beans root) {
     this.doc = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Beispiel #9
0
 public XRootNamespace(beans root)
 {
     this.doc        = new XDocument(root.Untyped);
     this.rootObject = root;
 }
Beispiel #10
0
    public static string GetResourceString(beans.ResourcesType type, int quantity)
    {
        if (quantity == 0)
            return "";

        switch (type)
        {
            case ResourcesType.Clay:
                return string.Format("<img src=\"images/resources/clay.png\" title=\"Clay\" /> {0}", quantity);
            case ResourcesType.Wood:
                return string.Format("<img src=\"images/resources/wood.png\" title=\"Wood\" /> {0}", quantity);
            case ResourcesType.Iron:
                return string.Format("<img src=\"images/resources/iron.png\" title=\"Iron\" /> {0}", quantity);
            default:
                return "";
        }

    }