def movefreighter(amount, regionfrom, regionto): fromname = display.region_display(regionfrom) toname = display.region_display(regionto) return 'Your %(amount)s %(pl)s will warp from %(from)s to %(to)s in' \ % {'amount':amount, 'pl':pl('freighter', amount), 'from':fromname, 'to':toname}
def movepersonalship(worldno, taskid, regionfrom, regionto): world = World.objects.get(worldid=worldno) try: task = Task.objects.get(pk=taskid) except: pass else: fromname = display.region_display(regionfrom) toname = display.region_display(regionto) check = (True if world.flagshiptype != 0 else False) if not check: htmldata = "Your personal ship was destroyed before it could warp from %s to %s!" % (fromname, toname) NewsItem.objects.create(target=world, content=htmldata) task.outcome = "Your personal ship was destroyed before it could warp from %s to %s!" % (fromname, toname) elif world.warpfuel < 5: htmldata = news.notenoughpersonal(amount, shiptext, fromname, toname, 'fuel') NewsItem.objects.create(target=world, content=htmldata) task.outcome = "You did not have enough fuel to warp your personal ship from %s to %s!" % (fromname, toname) else: attloss = '' world.warpfuel = F('warpfuel') - 5 world.flagshiplocation = regionto if world.wardefender.count() > 0 and regionfrom == world.region: utilities.contentmentchange(world, -10) utilities.stabilitychange(world, -5) attloss = 'You were in a defensive war, and you lost perception and stability by sending ships away from your home!' world.save(update_fields=['warpfuel','flagshiplocation']) task.outcome = "Your personal ship warped from %(from)s to %(to)s on %(time)s. %(att)s" \ % {'from':fromname, 'to':toname, 'time':now(), 'att':attloss} task.save()
def movepersonalship(regionfrom, regionto): fromname = display.region_display(regionfrom) toname = display.region_display(regionto) toreturn = 'Your personal ship will warp from %(from)s to %(to)s in' \ % {'from':fromname, 'to':toname} return toreturn
def moveship(shiptype, amount, regionfrom, regionto): shipname = utilities.resname(shiptype+10, amount, lower=True) fromname = display.region_display(regionfrom) toname = display.region_display(regionto) toreturn = 'Your %(amount)s %(ship)s will warp from %(from)s to %(to)s in' \ % {'amount':amount, 'ship':shipname, 'from':fromname, 'to':toname} return toreturn, shipname
def moveship(shiptype, amount, regionfrom, regionto): shipname = utilities.resname(shiptype + 10, amount, lower=True) fromname = display.region_display(regionfrom) toname = display.region_display(regionto) toreturn = 'Your %(amount)s %(ship)s will warp from %(from)s to %(to)s in' \ % {'amount':amount, 'ship':shipname, 'from':fromname, 'to':toname} return toreturn, shipname
def moveship(worldno, taskid, amount, shiptype, shiptext, regionfrom, regionto, fuelcost, trainingchange): world = World.objects.get(worldid=worldno) try: task = Task.objects.get(pk=taskid) except: pass # revoked else: fromname = display.region_display(regionfrom) toname = display.region_display(regionto) movecheck = utilities.movecheck(world, shiptype, amount, regionfrom) if not movecheck: htmldata = "Your attempt to warp %s %s from %s to %s failed as you did not have enough ships." \ % (amount, shiptext, regionfrom, regionto) NewsItem.objects.create(target=world, content=htmldata) task.outcome = "You did not have enough ships to warp %(amount)s %(ship)s from %(from)s to %(to)s!" \ % {'amount':amount, 'ship':shiptext, 'from':fromname, 'to':toname} elif world.warpfuel < fuelcost: htmldata = "Your attempt to warp %s %s from %s to %s failed as you did not have enough fuel." \ % (amount, shiptext, regionfrom, regionto) NewsItem.objects.create(target=world, content=htmldata) task.outcome = "You did not have enough fuel to warp %(amount)s %(ship)s from %(from)s to %(to)s!" \ % {'amount':amount, 'ship':shiptext, 'from':fromname, 'to':toname} else: attloss = '' world.warpfuel = F('warpfuel') - fuelcost if world.wardefender.count() > 0 and regionfrom == world.region: utilities.contentmentchange(world, -10) utilities.stabilitychange(world, -5) attloss = 'You were in a defensive war, and you lost perception and stability by sending ships away from your home!' world.save(update_fields=['warpfuel']) utilities.movecomplete(world, shiptype, -amount, regionfrom, -trainingchange) utilities.movecomplete(world, shiptype, amount, regionto, trainingchange) task.outcome = "Your %(amount)s %(ship)s warped from %(from)s to %(to)s on %(time)s. %(att)s" \ % {'amount':amount, 'ship':shiptext, 'from':fromname, 'to':toname, 'time':now(), 'att':attloss} task.save()
def movefreighter(worldno, taskid, amount, regionfrom, regionto): world = World.objects.get(worldid=worldno) try: task = Task.objects.get(pk=taskid) except: pass else: fromname = display.region_display(regionfrom) toname = display.region_display(regionto) movecheck = utilities.freightercheck(world, regionfrom, amount) if not movecheck: htmldata = news.notenough(amount, 'freighters', fromname, toname, 'of them') NewsItem.objects.create(target=world, content=htmldata) task.outcome = "You did not have enough freighters to warp %(amount)s of them from %(from)s to %(to)s!" \ % {'amount':amount, 'from':fromname, 'to':toname} else: utilities.freightermove(world, regionfrom, -amount) utilities.freightermove(world, regionto, amount) task.outcome = "Your %(amount)s freighters warped from %(from)s to %(to)s on %(time)s." \ % {'amount':amount, 'from':fromname, 'to':toname, 'time':now()} task.save()
def moveship(worldno, taskid, amount, shiptype, shiptext, regionfrom, regionto, fuelcost, trainingchange): world = World.objects.get(worldid=worldno) try: task = Task.objects.get(pk=taskid) except: pass # revoked else: fromname = display.region_display(regionfrom) toname = display.region_display(regionto) movecheck = utilities.movecheck(world, shiptype, amount, regionfrom) if not movecheck: htmldata = "Your attempt to warp %s %s from %s to %s failed as you did not have enough ships." \ % (amount, shiptext, regionfrom, regionto) NewsItem.objects.create(target=world, content=htmldata) task.outcome = "You did not have enough ships to warp %(amount)s %(ship)s from %(from)s to %(to)s!" \ % {'amount':amount, 'ship':shiptext, 'from':fromname, 'to':toname} elif world.warpfuel < fuelcost: htmldata = "Your attempt to warp %s %s from %s to %s failed as you did not have enough fuel." \ % (amount, shiptext, regionfrom, regionto) NewsItem.objects.create(target=world, content=htmldata) task.outcome = "You did not have enough fuel to warp %(amount)s %(ship)s from %(from)s to %(to)s!" \ % {'amount':amount, 'ship':shiptext, 'from':fromname, 'to':toname} else: attloss = '' world.warpfuel = F('warpfuel') - fuelcost if world.wardefender.count() > 0 and regionfrom == world.region: utilities.contentmentchange(world, -10) utilities.stabilitychange(world, -5) attloss = 'You were in a defensive war, and you lost perception and stability by sending ships away from your home!' world.save(update_fields=['warpfuel']) utilities.movecomplete(world,shiptype,-amount,regionfrom,-trainingchange) utilities.movecomplete(world,shiptype,amount,regionto,trainingchange) task.outcome = "Your %(amount)s %(ship)s warped from %(from)s to %(to)s on %(time)s. %(att)s" \ % {'amount':amount, 'ship':shiptext, 'from':fromname, 'to':toname, 'time':now(), 'att':attloss} task.save()
def movepersonalship(worldno, taskid, regionfrom, regionto): world = World.objects.get(worldid=worldno) try: task = Task.objects.get(pk=taskid) except: pass else: fromname = display.region_display(regionfrom) toname = display.region_display(regionto) check = (True if world.flagshiptype != 0 else False) if not check: htmldata = "Your personal ship was destroyed before it could warp from %s to %s!" % ( fromname, toname) NewsItem.objects.create(target=world, content=htmldata) task.outcome = "Your personal ship was destroyed before it could warp from %s to %s!" % ( fromname, toname) elif world.warpfuel < 5: htmldata = news.notenoughpersonal(amount, shiptext, fromname, toname, 'fuel') NewsItem.objects.create(target=world, content=htmldata) task.outcome = "You did not have enough fuel to warp your personal ship from %s to %s!" % ( fromname, toname) else: attloss = '' world.warpfuel = F('warpfuel') - 5 world.flagshiplocation = regionto if world.wardefender.count() > 0 and regionfrom == world.region: utilities.contentmentchange(world, -10) utilities.stabilitychange(world, -5) attloss = 'You were in a defensive war, and you lost perception and stability by sending ships away from your home!' world.save(update_fields=['warpfuel', 'flagshiplocation']) task.outcome = "Your personal ship warped from %(from)s to %(to)s on %(time)s. %(att)s" \ % {'from':fromname, 'to':toname, 'time':now(), 'att':attloss} task.save()