def order(request, pp): mum = getCurrentMother(request) slot = int(request.GET['slot']) otype, olvl = pp.getPair(slot) if otype == 0: return HttpResponse('ZEROSLOT') # Cannot upgrade something that doesnt exist costs = getCosts(pp, getRace(request), olvl, otype) if pp.owner != getAccount(request): return HttpResponse('ACCOUNT') if costs[0] > getResourceIndex(request).stateUpdate(): return HttpResponse('COSTS') if pp.getPendingBuildingsCount() > 0: return HttpResponse('QUEUE') note(request, LP_BUILD_ORDERED, pid=pp.province.id, slot=slot, what=otype, levelfrom=olvl) orderBuild(pp, mum, otype, slot, costs) return HttpResponse('OK')
def erect(request, pp): mum = getCurrentMother(request) slot = None for i in xrange(0, pp.province.slots): if pp.getPair(i)[0] == 0: slot = i break if slot == None: return HttpResponse('NOFREESLOTS') what = int(request.GET['what']) otype, olvl = pp.getPair(slot) if otype != 0: return HttpResponse('NONZEROSLOT') # Can't build in occupied space costs = getCosts(pp, getRace(request), 0, what) if pp.owner != getAccount(request): return HttpResponse('ACCOUNT') if costs[0] > getResourceIndex(request).stateUpdate(): return HttpResponse('COSTS') if pp.getPendingBuildingsCount() > 0: return HttpResponse('QUEUE') if (otype == 1) and (pp.province.titan_coef == 0): return HttpResponse('RSFAIL_TITAN') if (otype == 2) and (pp.province.pluton_coef == 0): return HttpResponse('RSFAIL_TITAN') if (otype == 3) and (pp.province.town_coef == 0): return HttpResponse('RSFAIL_TITAN') note(request, LP_BUILD_ORDERED, pid=pp.province.id, slot=slot, what=what, levelfrom=olvl) orderBuild(pp, mum, what, slot, costs) return HttpResponse('OK')