本文整理汇总了Python中Core.maps.Updates.midnight_tick方法的典型用法代码示例。如果您正苦于以下问题:Python Updates.midnight_tick方法的具体用法?Python Updates.midnight_tick怎么用?Python Updates.midnight_tick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core.maps.Updates
的用法示例。
在下文中一共展示了Updates.midnight_tick方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import midnight_tick [as 别名]
def execute(self, request, user, page="1", sort="score"):
page = int(page)
offset = (page - 1) * 50
order = {
"score": (asc(Galaxy.score_rank),),
"value": (asc(Galaxy.value_rank),),
"size": (asc(Galaxy.size_rank),),
"xp": (asc(Galaxy.xp_rank),),
}
if sort not in order.keys():
sort = "score"
order = order.get(sort)
tick = Updates.midnight_tick()
Q = session.query(Galaxy, GalaxyHistory)
Q = Q.outerjoin((GalaxyHistory, and_(Galaxy.id == GalaxyHistory.id, GalaxyHistory.tick == tick)))
Q = Q.filter(Galaxy.active == True)
count = Q.count()
pages = count / 50 + int(count % 50 > 0)
pages = range(1, 1 + pages)
for o in order:
Q = Q.order_by(o)
Q = Q.limit(50).offset(offset)
return render("galaxies.tpl", request, galaxies=Q.all(), offset=offset, pages=pages, page=page, sort=sort)
示例2: execute
# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import midnight_tick [as 别名]
def execute(self, request, user, page="1", sort="score", race="all"):
page = int(page)
offset = (page - 1)*50
order = {"score" : (asc(Planet.score_rank),),
"value" : (asc(Planet.value_rank),),
"size" : (asc(Planet.size_rank),),
"xp" : (asc(Planet.xp_rank),),
"race" : (asc(Planet.race), asc(Planet.size_rank),),
}
if sort not in order.keys():
sort = "score"
order = order.get(sort)
tick = Updates.midnight_tick()
Q = session.query(Planet, PlanetHistory, Intel.nick, Alliance.name)
Q = Q.outerjoin(Planet.intel)
Q = Q.outerjoin(Intel.alliance)
Q = Q.outerjoin((PlanetHistory, and_(Planet.id == PlanetHistory.id, PlanetHistory.tick == tick)))
Q = Q.filter(Planet.active == True)
if race.lower() in PA.options("races"):
Q = Q.filter(Planet.race.ilike(race))
else:
race = "all"
count = Q.count()
pages = count/50 + int(count%50 > 0)
pages = range(1, 1+pages)
for o in order:
Q = Q.order_by(o)
Q = Q.limit(50).offset(offset)
return render("planets.tpl", request, planets=Q.all(), offset=offset, pages=pages, page=page, sort=sort, race=race)
示例3: execute
# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import midnight_tick [as 别名]
def execute(self, request, user, x, y, z, fleets):
tick = Updates.midnight_tick()
week = Updates.week_tick()
planet = Planet.load(x, y, z)
if planet is None:
return HttpResponseRedirect(reverse("planet_ranks"))
ph = planet.history(tick)
Q = session.query(FleetScan, Planet, Alliance)
Q = Q.join(FleetScan.target)
Q = Q.outerjoin(Planet.intel).outerjoin(Intel.alliance)
Q = Q.filter(FleetScan.owner == planet)
Q = Q.order_by(desc(FleetScan.landing_tick))
if not fleets:
Q = Q.filter(FleetScan.landing_tick >= week)
outgoing = Q.all()
Q = session.query(FleetScan, Planet, Alliance)
Q = Q.join(FleetScan.owner)
Q = Q.outerjoin(Planet.intel).outerjoin(Intel.alliance)
Q = Q.filter(FleetScan.target == planet)
Q = Q.order_by(desc(FleetScan.landing_tick))
if not fleets:
Q = Q.filter(FleetScan.landing_tick >= week)
incoming = Q.all()
scan = planet.scan("A") or planet.scan("U")
return render("planet.tpl", request, planet=planet, ph=ph, scan=scan, outgoing=outgoing, incoming=incoming)
示例4: execute
# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import midnight_tick [as 别名]
def execute(self, request, user, page="1", sort="score"):
page = int(page)
offset = (page - 1)*50
order = {"score" : (asc(Alliance.score_rank),),
"size" : (asc(Alliance.size_rank),),
"avg_score" : (asc(Alliance.score_avg_rank),),
"avg_size" : (asc(Alliance.size_avg_rank),),
"members" : (asc(Alliance.members_rank),),
}
if sort not in order.keys():
sort = "score"
order = order.get(sort)
tick = Updates.midnight_tick()
Q = session.query(Alliance, AllianceHistory)
Q = Q.outerjoin((AllianceHistory, and_(Alliance.id == AllianceHistory.id, AllianceHistory.tick == tick)))
Q = Q.filter(Alliance.active == True)
count = Q.count()
pages = count/50 + int(count%50 > 0)
pages = range(1, 1+pages)
for o in order:
Q = Q.order_by(o)
Q = Q.limit(50).offset(offset)
return render("alliances.tpl", request, alliances=Q.all(), offset=offset, pages=pages, page=page, sort=sort)
示例5: execute
# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import midnight_tick [as 别名]
def execute(self, request, user):
if user.planet is not None:
tick = Updates.midnight_tick()
ph = user.planet.history(tick)
else:
ph = None
return render("index.tpl", request, planet=user.planet, ph=ph)
示例6: execute
# 需要导入模块: from Core.maps import Updates [as 别名]
# 或者: from Core.maps.Updates import midnight_tick [as 别名]
def execute(self, request, user, x, y):
tick = Updates.midnight_tick()
galaxy = Galaxy.load(x,y)
if galaxy is None:
return HttpResponseRedirect(reverse("galaxy_ranks"))
gh = galaxy.history(tick)
Q = session.query(Planet, PlanetHistory, Intel.nick, Alliance.name)
Q = Q.outerjoin(Planet.intel)
Q = Q.outerjoin(Intel.alliance)
Q = Q.outerjoin((PlanetHistory, and_(Planet.id == PlanetHistory.id, PlanetHistory.tick == tick)))
Q = Q.filter(Planet.active == True)
Q = Q.filter(Planet.galaxy == galaxy)
Q = Q.order_by(asc(Planet.z))
return render("galaxy.tpl", request, galaxy=galaxy, gh=gh, planets=Q.all())