protected void Page_Load(object sender, EventArgs e) { inPage p = (inPage)this.Master; village = p.CurrentVillage; if (this.village[BuildingType.Rally] > 0) this.pConstructed.Visible = true; else { this.pNotConstruct.Visible = true; return; } switch (Request["page"]) { case "unit": TroopStat pTroopStat = (TroopStat)Page.LoadControl(@"TroopStat.ascx"); pTroopStat.Village = this.village; this.tblMenu.Rows[1].Cells[0].Attributes.Add("class", "selected"); this.troopPanel.Controls.Add(pTroopStat); break; default: TroopCommand pTroopCommand = (TroopCommand)Page.LoadControl(@"TroopCommand.ascx"); pTroopCommand.Village = this.village; this.tblMenu.Rows[0].Cells[0].Attributes.Add("class", "selected"); this.troopPanel.Controls.Add(pTroopCommand); break; } }
protected void Page_Load(object sender, EventArgs e) { current = ((inPage)(this.Master)).CurrentVillage; if (this.current[BuildingType.TimberCamp] > 0) this.pConstructed.Visible = true; else { this.pNotConstruct.Visible = true; return; } }
protected void Page_Load(object sender, EventArgs e) { this.NHibernateSession = (ISession)Context.Items[Constant.NHibernateSessionSign]; village = ((inPage)this.Master).CurrentVillage; if (this.village[BuildingType.Barracks] > 0) this.pConstructed.Visible = true; else { this.pNotConstruct.Visible = true; return; } this.AxePrice = Recruit.GetPrice(TroopType.Axe, this.village[BuildingType.Barracks]); this.SpearPrice = Recruit.GetPrice(TroopType.Spear, this.village[BuildingType.Barracks]); this.SwordPrice = Recruit.GetPrice(TroopType.Sword, this.village[BuildingType.Barracks]); if (Request["mode"] != null && Request["mode"] == "cancel_recruit") { int id = 0; int.TryParse(Request["recruit_id"], out id); if (id != 0) { this.village.VillageRecruitMethods.CancelRecruit(id, this.NHibernateSession); ((inPage)this.Master).WoodLabel.Text = this.village.VillageResourceData.Wood.ToString(); ((inPage)this.Master).ClayLabel.Text = this.village.VillageResourceData.Clay.ToString(); ((inPage)this.Master).IronLabel.Text = this.village.VillageResourceData.Iron.ToString(); } } if (IsPostBack) return; IList<Recruit> recruits = village.VillageRecruitMethods.InfantryRecruits; if (recruits.Count > 0) { this.rInfantryRecruits.DataSource = recruits; this.rInfantryRecruits.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { village = ((inPage)this.Master).CurrentVillage; this.NHibernateSession = ((inPage)this.Master).NHibernateSession; if (this.village[BuildingType.Workshop] > 0) this.pConstructed.Visible = true; else { this.pNotConstruct.Visible = true; return; } IList<Recruit> recruits = village.VillageRecruitMethods.CarRecruits; if (recruits.Count > 0) { this.rCarRecruits.DataSource = recruits; this.rCarRecruits.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { village = ((inPage)this.Master).CurrentVillage; if (this.village[BuildingType.Stable] > 0) this.pConstructed.Visible = true; else { this.pNotConstruct.Visible = true; return; } this.scoutPrice = Recruit.GetPrice(TroopType.Scout, this.village[BuildingType.Stable]); this.lightCavalryPrice = Recruit.GetPrice(TroopType.Light, this.village[BuildingType.Stable]); this.heavyCavalryPrice = Recruit.GetPrice(TroopType.Heavy, this.village[BuildingType.Stable]); this.NHibernateSession = ((inPage)this.Master).NHibernateSession; if (Request["mode"] != null && Request["mode"] == "cancel_recruit") { int id = 0; int.TryParse(Request["recruit_id"], out id); if (id != 0) { this.village.VillageRecruitMethods.CancelRecruit(id, this.NHibernateSession); ((inPage)this.Master).WoodLabel.Text = this.village.VillageResourceData.Wood.ToString(); ((inPage)this.Master).ClayLabel.Text = this.village.VillageResourceData.Clay.ToString(); ((inPage)this.Master).IronLabel.Text = this.village.VillageResourceData.Iron.ToString(); } } IList<Recruit> recruits = this.village.VillageRecruitMethods.CavalryRecruits; if (recruits.Count > 0) { this.rCavalryRecruits.DataSource = recruits; this.rCavalryRecruits.DataBind(); } }
public static DateTime LandingTime(int speed, Village from, Village to, DateTime start) { return start.AddMilliseconds(RangeCalculator(from.X, from.Y, to.X, to.Y) * speed); }
public static DateTime LandingTime(int speed, Village from, Village to, DateTime start, double speedIncrease) { return start.AddMilliseconds(RangeCalculator(from.X, from.Y, to.X, to.Y) * (speed + speed * speedIncrease)); }
public static DateTime LandingTime(TroopType troop, Village from, Village to, DateTime start, double speedIncrease) { return Map.LandingTime(troop, from.X, from.Y, to.X, to.Y, start, speedIncrease); }
public static DateTime LandingTime(TroopType troop, Village from, Village to, DateTime start) { return Map.LandingTime(troop, from.X, from.Y, to.X, to.Y, start, 0); }
public static double MovingTime(Village fromVillage, Village toVillage, TroopType troop) { return MovingTime(fromVillage.X, fromVillage.Y, toVillage.X, toVillage.Y, troop); }
void inPage_Init(object sender, EventArgs e) { this.Stopwatch.Start(); if (object.Equals(Session["user"], null)) { Response.Redirect("session_expired.aspx", true); return; //Session["user"] = 1; } int id; this.NHibernateSession = (ISession)Context.Items["NHibernateSession"]; this.player = this.NHibernateSession.Get<beans.Player>(Session[Constant.NormalUserSessionSign]); if (this.player == null) { Response.Redirect("index.aspx", false); return; } this.player.Update(DateTime.Now, this.NHibernateSession); if (object.Equals(Request["id"], null) || (!int.TryParse(Request["id"], out id))) this.village = this.player.Villages[0]; else this.village = this.player.GetVillage(id); if (this.village == null) this.village = this.player.Villages[0]; //this.village.VillageResourceData.ResourceChanged+=new ResourceChangeHandler(); int incomingAttackCount = this.Player.GetIncomingAttackCount(this.NHibernateSession); int incomingSupportCount = this.Player.GetIncomingSupportCount(this.NHibernateSession); this.lblClay.Text = this.CurrentVillage.VillageResourceData.Clay.ToString(); this.lblWood.Text = this.CurrentVillage.VillageResourceData.Wood.ToString(); this.lblIron.Text = this.CurrentVillage.VillageResourceData.Iron.ToString(); if (this.CurrentVillage.VillageResourceData.Wood == this.CurrentVillage.MaxResources) this.lblWood.ForeColor = System.Drawing.Color.Red; if (this.CurrentVillage.VillageResourceData.Clay == this.CurrentVillage.MaxResources) this.lblClay.ForeColor = System.Drawing.Color.Red; if (this.CurrentVillage.VillageResourceData.Iron == this.CurrentVillage.MaxResources) this.lblIron.ForeColor = System.Drawing.Color.Red; this.RadToolBar1.DataBind(); foreach (RadToolBarButton menuItem in this.menu.Items) menuItem.NavigateUrl += string.Format("?id={0}", this.village.ID); foreach (RadMenuItem item in this.RadToolBar1.Items) { if (item.NavigateUrl.Contains("?")) item.NavigateUrl += string.Format("&id={0}", this.village.ID); else item.NavigateUrl += string.Format("?id={0}", this.village.ID); foreach (RadMenuItem subItem in item.Items) if (subItem.NavigateUrl.Contains("?")) subItem.NavigateUrl += string.Format("&id={0}", this.village.ID); else subItem.NavigateUrl += string.Format("?id={0}", this.village.ID); } }
protected void Page_Load(object sender, EventArgs e) { village = ((inPage)(this.Master)).CurrentVillage; int command_id = 0; int.TryParse(Request["command"], out command_id); if (command_id == 0) { this.pCommandNotFound.Visible = true; this.pCommandFound.Visible = false; return; } ISession session = (ISession)Context.Items["NHibernateSession"]; Player player = session.Load<Player>(Session["user"]); current = player.GetCommand(command_id, session); if (current == null) { this.pCommandFound.Visible = false; this.pCommandNotFound.Visible = true; return; } this.pCommandFound.Visible = true; this.pCommandNotFound.Visible = false; switch (current.Type) { case MoveType.Attack: AttackCommand attackCommand = (AttackCommand)Page.LoadControl("AttackCommand.ascx"); attackCommand.Command = current; attackCommand.CurrentVillage = village; this.pCommand.Controls.Add(attackCommand); break; case MoveType.Support: SupportCommand supportCommand = (SupportCommand)Page.LoadControl("SupportCommand.ascx"); supportCommand.Command = current; supportCommand.CurrentVillage = village; this.pCommand.Controls.Add(supportCommand); break; case MoveType.Return: ReturnCommand returnCommand = (ReturnCommand)Page.LoadControl("ReturnCommand.ascx"); returnCommand.Command = current; returnCommand.CurrentVillage = village; this.pCommand.Controls.Add(returnCommand); break; default: throw new Exception("Hack hả ku :))"); } //SqlCommand cmdGetCommandInfo = conn.CreateCommand(); //cmdGetCommandInfo.CommandText = "select m.*, v1.id as id1, v1.x as x1, v1.y as y1, v1.name as name1, v1.userid as userid1, v2.id as id2, v2.x as x2, v2.y as y2, v2.name as name2, v2.userid as userid2 from movement m inner join villages v1 on (v1.id=m.[from]) inner join villages v2 on (v2.id=m.[to]) where m.landing_time>getdate() and (m.[from]=@village_id1 or m.[to]=@village_id2) and m.id=@id"; //cmdGetCommandInfo.Parameters.Add("@village_id1", SqlDbType.Int).Value = id; //cmdGetCommandInfo.Parameters.Add("@village_id2", SqlDbType.Int).Value = id; //cmdGetCommandInfo.Parameters.Add("@id", SqlDbType.Int).Value = current; //SqlDataAdapter daCommand = new SqlDataAdapter(cmdGetCommandInfo); //DataTable tb = new DataTable(); //daCommand.Fill(tb); //if (tb.Rows.Count == 0) //{ // Response.Write("Lệnh không tồn tại"); // return; //} //string sTroop = ""; //if (((string)row["userid1"] == (string)Session["username"]) || ((int)row["type"] == 4)) //{ // sTroop = "<table><tbody><tr><th width='50'><img src='images/unit_spear.png' title='Spear fighter' alt=''></th><th width='50'><img src='images/unit_sword.png' title='Swordsman' alt=''></th><th width='50'><img src='images/unit_axe.png' title='Axeman' alt=''></th><th width='50'><img src='images/unit_spy.png' title='Scout' alt=''></th><th width='50'><img src='images/unit_light.png' title='Light cavalry' alt=''></th><th width='50'><img src='images/unit_heavy.png' title='Heavy cavalry' alt=''></th><th width='50'><img src='images/unit_ram.png' title='Ram' alt=''></th><th width='50'><img src='images/unit_catapult.png' title='Catapult' alt=''></th><th width='50'><img src='images/unit_snob.png' title='Nobleman' alt=''></th></tr>"; // sTroop += "<tr><td>" + row["spear"] + "</td><td>" + row["sword"] + "</td><td>" + row["axe"] + "</td><td>" + row["scout"] + "</td><td>" + row["light"] + "</td><td>" + row["heavy"] + "</td><td>" + row["ram"] + "</td><td>" + row["catapult"] + "</td><td>" + row["noble"] + "</td></tr></tbody></table>"; //} //string sResources = ""; //if ((int)row["type"] == 4) //{ // sResources = "<table><tbody><tr><th width='50'><img src='images/lehm.png' title='Đá' alt=''></th><th width='50'><img src='images/holz.png' title='Gỗ' alt=''></th><th width='50'><img src='images/eisen.png' title='Kim loại' alt=''></th>"; // sResources += "<tr><td>" + row["clay"] + "</td><td>" + row["wood"] + "</td><td>" + row["iron"] + "</td></tr></table>"; //} //this.lblResources.Text = sResources; //this.lblTroop.Text = sTroop; }
protected void Page_Load(object sender, EventArgs e) { village = ((inPage)this.Master).CurrentVillage; int report_id; ISession session = (ISession)Context.Items[Constant.NHibernateSessionSign]; int.TryParse(Request["report"], out report_id); beans.Player user = session.Load<beans.Player>(Session["user"]); report = user.GetReport(report_id, session); if (report != null) { pHasReport.Visible = true; switch (report.Type) { case beans.ReportType.Attack: AttackReport pAttackReport = (AttackReport)Page.LoadControl(@"AttackReport.ascx"); pAttackReport.Village = this.village; pAttackReport.Report = report; this.panelReport.Controls.Add(pAttackReport); navigator.Rows[1].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.Defense: DefenseReport pDefenseReport = (DefenseReport)Page.LoadControl(@"DefenseReport.ascx"); pDefenseReport.Village = this.village; pDefenseReport.Report = report; this.panelReport.Controls.Add(pDefenseReport); navigator.Rows[2].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.InviteToTribe: InviteReport pInviteReport = (InviteReport)Page.LoadControl(@"InviteReport.ascx"); pInviteReport.Village = this.village; pInviteReport.Report = report; this.panelReport.Controls.Add(pInviteReport); navigator.Rows[5].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.DefenseOther: DefenseOtherReport pDefenseOther = (DefenseOtherReport)Page.LoadControl(@"DefenseOtherReport.ascx"); pDefenseOther.Village = this.village; pDefenseOther.Report = report; this.panelReport.Controls.Add(pDefenseOther); navigator.Rows[2].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.OfferAccepted: OfferAcceptedReport pOfferAcceptedReport = (OfferAcceptedReport)Page.LoadControl(@"OfferAcceptedReport.ascx"); pOfferAcceptedReport.Village = this.village; pOfferAcceptedReport.Report = report; this.panelReport.Controls.Add(pOfferAcceptedReport); navigator.Rows[3].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.ResourceReceive: ResourceReceive pResourceReceive = (ResourceReceive)Page.LoadControl(@"ResourceReceive.ascx"); pResourceReceive.Village = this.village; pResourceReceive.Report = report; this.panelReport.Controls.Add(pResourceReceive); navigator.Rows[3].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.Support: SupportOtherReport pSupport = (SupportOtherReport)Page.LoadControl(@"SupportOtherReport.ascx"); pSupport.Village = this.village; pSupport.Report = report; this.panelReport.Controls.Add(pSupport); navigator.Rows[2].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.SupportSendBack: SupportSendBackReport pSupportSendBack = (SupportSendBackReport)Page.LoadControl(@"SupportSendBackReport.ascx"); pSupportSendBack.Village = this.village; pSupportSendBack.Report = report; this.panelReport.Controls.Add(pSupportSendBack); navigator.Rows[2].Cells[0].Attributes["class"] = "selected"; break; case beans.ReportType.SupportWithdawal: TroopWithdrawal pTroopWithdrawal = (TroopWithdrawal)Page.LoadControl(@"TroopWithdrawal.ascx"); pTroopWithdrawal.Village = this.village; pTroopWithdrawal.Report = report; this.panelReport.Controls.Add(pTroopWithdrawal); navigator.Rows[3].Cells[0].Attributes["class"] = "selected"; break; default: pNoReport.Visible = true; pHasReport.Visible = false; break; } } else pNoReport.Visible = true; }
public static Attack CreateAttack( ISession session, Village from, int x, int y, int spear, int sword, int axe, int scout, int light, int heavy, int ram, int catapult, int noble, BuildingType building) { int intTo = Village.CheckVillage(x, y, session); if (intTo < 0) throw new Exception("Toạ độ không tồn tại"); if ((spear + sword + axe + scout + light + heavy + ram + catapult + noble) == 0) throw new Exception("Nhập một loại quân"); from.Update(DateTime.Now, session); if ((spear > from.Spear) || (sword > from.Sword) || (axe > from.Axe) || (scout > from.Scout) || (light > from.Light) || (heavy > from.Heavy) || (ram > from.Ram) || (catapult > from.Catapult) || (noble > from.Noble)) throw new Exception("Không đủ quân"); Attack attack = new Attack(); TroopType type = TroopType.Spear; if (scout > 0) type = TroopType.Scout; if (light > 0) type = TroopType.Light; if (heavy > 0) type = TroopType.Heavy; if (spear > 0) type = TroopType.Spear; if (axe > 0) type = TroopType.Axe; if (sword > 0) type = TroopType.Sword; if (ram > 0) type = TroopType.Ram; if (catapult > 0) type = TroopType.Catapult; if (noble > 0) type = TroopType.Nobleman; attack.From = from; attack.StartTime = DateTime.Now; attack.To = session.Load<Village>(intTo); attack.Spear = spear; attack.Sword = sword; attack.Axe = axe; attack.Scout = scout; attack.Light = light; attack.Heavy = heavy; attack.Ram = ram; attack.Catapult = catapult; attack.Noble = noble; attack.LandingTime = Map.LandingTime(type, attack.From.X, attack.From.Y, attack.To.X, attack.To.Y, attack.StartTime); attack.Type = MoveType.Attack; attack.Building = building; from.Spear -= spear; from.Sword -= sword; from.Axe -= axe; from.Scout -= scout; from.Light -= light; from.Heavy -= heavy; from.Ram -= ram; from.Catapult -= catapult; from.Noble -= noble; session.Save(attack); session.Update(from); return attack; }
public static IList<Village> GetMap(Village center, ISession session) { Configuration config = Configuration.TribalWarsConfiguration; NumericConfiguration mapSizeConfiguration = config.GetNumericConfigurationItem("Map.map_size"); int mapSize = (int)mapSizeConfiguration.Value; return (from village in session.Linq<Village>() where village.X >= center.X - mapSize && village.X <= center.X + mapSize && village.Y >= center.Y - mapSize && village.Y <= center.Y + mapSize orderby village.X descending orderby village.Y descending select village).ToList<Village>(); }
public static bool CanBuild(BuildingType building, int level, Village village) { switch (building) { case BuildingType.Headquarter: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.Barracks: if (village.VillageBuildingData.Headquarter < 3) return false; break; case BuildingType.Stable: if (village.VillageBuildingData.Barracks < 5 || village.VillageBuildingData.Smithy < 5 || village.VillageBuildingData.Headquarter < 10) return false; break; case BuildingType.Workshop: if (village.VillageBuildingData.Headquarter < 10 || village.VillageBuildingData.Smithy < 10) return false; break; case BuildingType.Academy: if (village.VillageBuildingData.Headquarter < 20 || village.VillageBuildingData.Smithy < 20 || village.VillageBuildingData.Market < 10) return false; break; case BuildingType.Smithy: if (village.VillageBuildingData.Headquarter < 5 || village.VillageBuildingData.Barracks < 1) return false; break; case BuildingType.Rally: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.Market: if (village.VillageBuildingData.Headquarter < 3 || village.VillageBuildingData.Warehouse < 2) return false; break; case BuildingType.TimberCamp: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.ClayPit: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.IronMine: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.Farm: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.Warehouse: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.HidingPlace: if (village.VillageBuildingData.Headquarter < 1) return false; break; case BuildingType.Wall: if (village.VillageBuildingData.Headquarter < 1 || village.VillageBuildingData.Barracks < 1) return false; break; default: return false; } BuildPrice price = Build.GetPrice(building, level, village.VillageBuildingData.Headquarter); return (price.Wood < village.VillageResourceData.Wood && price.Clay < village.VillageResourceData.Clay && price.Iron < village.VillageResourceData.Iron); }
public static bool CanRecruit(TroopType troop, int quantity, Village village) { switch (troop) { case TroopType.Spear: if (village.VillageBuildingData.Barracks == 0) return false; break; case TroopType.Sword: if (village.VillageBuildingData.Barracks == 0 || village.VillageBuildingData.Smithy < 1) return false; break; case TroopType.Axe: if (village.VillageBuildingData.Barracks == 0 || village.VillageBuildingData.Smithy < 2) return false; break; case TroopType.Scout: if (village.VillageBuildingData.Stable == 0) return false; break; case TroopType.Light: if (village.VillageBuildingData.Stable < 3 || village.VillageBuildingData.Stable < 3) return false; break; case TroopType.Heavy: if (village.VillageBuildingData.Stable < 10 || village.VillageBuildingData.Smithy < 15) return false; break; case TroopType.Ram: if (village.VillageBuildingData.Workshop == 0) return false; break; case TroopType.Catapult: if (village.VillageBuildingData.Workshop < 2 || village.VillageBuildingData.Smithy < 12) return false; break; case TroopType.Nobleman: if (village.VillageBuildingData.Academy == 0 || village.VillageBuildingData.Smithy < 20) return false; break; default: return false; } return Recruit.CanRecruit(troop, quantity, village.VillageResourceData.Wood, village.VillageResourceData.Clay, village.VillageResourceData.Iron); }
public static Support CreateSupport(ISession session, Village from, int x, int y, int spear, int sword, int axe, int scout, int light, int heavy, int ram, int catapult, int noble) { int intTo = Village.CheckVillage(x, y, session); if (intTo < 0) throw new Exception("Toạ độ không tồn tại"); if ((spear + sword + axe + scout + light + heavy + ram + catapult + noble) == 0) throw new Exception("Nhập một loại quân"); from.Update(DateTime.Now, session); if ((spear > from.Spear) || (sword > from.Sword) || (axe > from.Axe) || (scout > from.Scout) || (light > from.Light) || (heavy > from.Heavy) || (ram > from.Ram) || (catapult > from.Catapult) || (noble > from.Noble)) throw new Exception("Không đủ quân"); Support support = new Support(); support.From = from; support.StartTime = DateTime.Now; support.To = session.Load<Village>(intTo); support.Spear = spear; support.Sword = sword; support.Axe = axe; support.Scout = scout; support.Light = light; support.Heavy = heavy; support.Ram = ram; support.Catapult = catapult; support.Noble = noble; TroopType type = TroopType.Spear; if (scout > 0) type = TroopType.Scout; if (light > 0) type = TroopType.Light; if (heavy > 0) type = TroopType.Heavy; if (spear > 0) type = TroopType.Spear; if (axe > 0) type = TroopType.Axe; if (sword > 0) type = TroopType.Sword; if (ram > 0) type = TroopType.Ram; if (catapult > 0) type = TroopType.Catapult; if (noble > 0) type = TroopType.Nobleman; support.LandingTime = Map.LandingTime(type, support.From.X, support.From.Y, support.To.X, support.To.Y, support.StartTime); from.Spear -= spear; from.Sword -= sword; from.Axe -= axe; from.Scout -= scout; from.Light -= light; from.Heavy -= heavy; from.Ram -= ram; from.Catapult -= catapult; from.Noble -= noble; session.Save(support); session.Update(from); return support; }
public virtual void Update(DateTime time, ISession session) { if (this.MainVillage==null) { Village village = Village.CreateVillage(session); village.Player = this; this.Villages.Add(village); this.MainVillage = village; village.LastUpdate = time; village.Name = "Thành phố " + this.Username; //session.Save(village); village.Save(session); session.Update(this); return; } foreach (Village village in this.Villages) village.VillageCommonMethods.UpdateVillage(time, session); foreach (RecruitHero recruit in this.RecruitHeroes) recruit.Expire(time, session); }
public static Village CreateVillage(ISession session) { Configuration config = Configuration.TribalWarsConfiguration; NumericConfiguration expandTo = config.GetNumericConfigurationItem("Village.expand_to"); NumericConfiguration expandCount = config.GetNumericConfigurationItem("Village.expand_count"); NumericConfiguration centerX = config.GetNumericConfigurationItem("Map.center_x"); NumericConfiguration centerY = config.GetNumericConfigurationItem("Map.center_y"); if (expandCount.Value >= (expandTo.Value * 2 + 1)) { expandTo.Value++; expandCount.Value = 0; } expandCount.Value++; IList<Village> lst; Random r = new Random(); int X, Y; do { X = (int)(centerX.Value + expandTo.Value * (r.Next(3) - 1)); Y = (int)(centerY.Value + expandTo.Value * (r.Next(3) - 1)); ICriteria criteria = session.CreateCriteria(typeof(Village)); criteria.Add(Expression.Eq("X", X)); criteria.Add(Expression.Eq("Y", Y)); lst = criteria.List<Village>(); } while (lst.Count > 0); Village village = new Village(); village.VillageBuildingData = new VillageBuildingData(); village.VillageTroopData = new VillageTroopData(); village.VillageResourceData = new VillageResourcesData(); village.VillageResearchData = new VillageResearchData(); village.VillageBuildingData.Village = village; village.VillageTroopData.Village = village; village.VillageResourceData.Village = village; village.VillageResearchData.Village = village; village.X = X; village.Y = Y; village.Loyal = 100; village.LastUpdate = DateTime.Now; village.UpgradeBuilding(BuildingType.Headquarter, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitHeadquarterLevel").Value); village.UpgradeBuilding(BuildingType.Rally, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitRallyLevel").Value); village.UpgradeBuilding(BuildingType.Farm, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitFarmLevel").Value); village.UpgradeBuilding(BuildingType.ClayPit, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitClayPitLevel").Value); village.UpgradeBuilding(BuildingType.IronMine, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitIronMineLevel").Value); village.UpgradeBuilding(BuildingType.TimberCamp, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitTimberCampLevel").Value); village.UpgradeBuilding(BuildingType.Warehouse, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitWarehouseLevel").Value); village.UpgradeBuilding(BuildingType.Barracks, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitBarracksLevel").Value); village.UpgradeBuilding(BuildingType.Market, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitMarketLevel").Value); village.UpgradeBuilding(BuildingType.Smithy, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitSmithyLevel").Value); village.UpgradeBuilding(BuildingType.Stable, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitStableLevel").Value); village.UpgradeBuilding(BuildingType.Workshop, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitWorkshopLevel").Value); village.UpgradeBuilding(BuildingType.Wall, (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitWallLevel").Value); village.VillageResourceData.Iron = (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitIronCount").Value; village.VillageResourceData.Clay = (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitClayCount").Value; village.VillageResourceData.Wood = (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitWoodCount").Value; village.VillageResearchData.Attack = (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitAttackLevel").Value; ; village.VillageResearchData.Defense = (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitDefenseLevel").Value; ; village.VillageResearchData.TroopSpeed = (int)Configuration.TribalWarsConfiguration.GetNumericConfigurationItem("Village.InitSpeedLevel").Value; ; config.InsertOrUpdateConfiguration(expandCount, session); config.InsertOrUpdateConfiguration(expandTo, session); return village; }