public bool CanSetStructureTarget(PlanetStructure ps) { if (Faction == null) { return(false); } if (ps.OwnerAccountID == AccountID || ps.Planet.OwnerAccountID == AccountID) { return(true); // owner of planet or owner of structure } if (ps.Planet.OwnerFactionID == FactionID && HasFactionRight(x => x.RightDropshipQuota > 0)) { return(true); } return(false); }
public bool CanSetPriority(PlanetStructure ps) { if (Faction == null) { return(false); } if (ps.Planet.OwnerFactionID == FactionID && HasFactionRight(x => x.RightSetEnergyPriority)) { return(true); } if (ClanID != null && ps.Account != null && ps.Account.ClanID == ClanID && HasClanRight(x => x.RightSetEnergyPriority)) { return(true); } return(false); }
public bool CanSetStructureTarget(PlanetStructure ps) { if (Faction == null) return false; if (ps.OwnerAccountID == AccountID || ps.Planet.OwnerAccountID == AccountID) return true; // owner of planet or owner of structure if (ps.Planet.OwnerFactionID == FactionID && HasFactionRight(x => x.RightDropshipQuota > 0)) return true; return false; }
public bool CanSetPriority(PlanetStructure ps) { if (Faction == null) return false; if (ps.Planet.OwnerFactionID == FactionID && HasFactionRight(x => x.RightSetEnergyPriority)) return true; if (ClanID != null && ps.Account != null && ps.Account.ClanID == ClanID && HasClanRight(x => x.RightSetEnergyPriority)) return true; return false; }
public ActionResult BuildStructure(int planetID, int structureTypeID) { using (var db = new ZkDataContext()) { Planet planet = db.Planets.Single(p => p.PlanetID == planetID); if (Global.Server.GetPlanetBattles(planet).Any(x => x.IsInGame)) return Content("Battle in progress on the planet, cannot build structures"); Account acc = db.Accounts.Single(x => x.AccountID == Global.AccountID); if (acc.FactionID != planet.OwnerFactionID) return Content("Planet is not under your control."); StructureType structureType = db.StructureTypes.SingleOrDefault(s => s.StructureTypeID == structureTypeID); if (structureType == null) return Content("Structure type does not exist."); if (!structureType.IsBuildable) return Content("Structure is not buildable."); if (acc.GetMetalAvailable() < structureType.Cost) return Content("Insufficient metal"); acc.SpendMetal(structureType.Cost); var newBuilding = new PlanetStructure { StructureTypeID = structureTypeID, PlanetID = planetID, OwnerAccountID = acc.AccountID, IsActive = false, ActivatedOnTurn = planet.Galaxy.Turn }; db.PlanetStructures.InsertOnSubmit(newBuilding); db.SubmitChanges(); db.Events.InsertOnSubmit(Global.CreateEvent("{0} has built a {1} on {2} planet {3}.", Global.Account, newBuilding.StructureType, planet.Faction, planet)); SetPlanetOwners(db); } return RedirectToAction("Planet", new { id = planetID }); }
public static MvcHtmlString PrintStructureState(this HtmlHelper helper, PlanetStructure s) { var url = Global.UrlHelper(); var state = ""; if (!s.IsActive) { if (s.ActivatedOnTurn == null) state = "<span style='color:red'>DISABLED</span>"; if (s.ActivatedOnTurn != null) { state = string.Format(" <span style='color:orange'>POWERING {0} turns left</span>", s.StructureType.TurnsToActivate - s.Planet.Galaxy.Turn + s.ActivatedOnTurn); } } else state = "<span style='color:green'>ACTIVE</span>"; return new MvcHtmlString(state); }