Exemplo n.º 1
0
def spoils(spoilsdict):
    loot = []
    gdp = (spoilsdict['gdp']['amount'] if spoilsdict.has_key('gdp') else 0)
    growth = (spoilsdict['growth']['amount'] if spoilsdict.has_key('growth') else 0)
    budget = (spoilsdict['budget']['amount'] if spoilsdict.has_key('budget') else 0)
    fuel = (spoilsdict['warpfuel']['amount'] if spoilsdict.has_key('warpfuel') else 0)
    dur = (spoilsdict['duranium']['amount'] if spoilsdict.has_key('duranium') else 0)
    trit = (spoilsdict['tritanium']['amount'] if spoilsdict.has_key('tritanium') else 0)
    adam = (spoilsdict['adamantium']['amount'] if spoilsdict.has_key('adamantium') else 0)
    fre = (spoilsdict['freighters']['amount'] if spoilsdict.has_key('freighters') else 0)
    if gdp > 0:
        loot.append([ 'million GEU\'s worth of GDP',  gdp])
    if growth > 0:
        loot.append([ 'million GEU\'s worth of growth',  growth])
    if budget > 0:
        loot.append([ '%s in cash' % pl('GEU', budget),  budget])
    if fuel > 0:
        loot.append([ 'of warpfuel',  fuel])
    if dur > 0:
        loot.append([ 'of duranium',  dur])
    if trit > 0:
        loot.append([ 'of tritanium',  trit])
    if adam > 0:
        loot.append([ 'of adamantium',  adam])
    if fre > 0:
        loot.append([ '%s' % pl('freighter', fre),  fre])
    return utilities.resource_text(loot)
Exemplo n.º 2
0
def losses(shiplist):
    sh1, sh2, sh3, sh4, sh5, sh6, sh7, sh8, sh9 = shiplist
    fighters = ' %s %s,' % (sh1, pl('fighter', sh1))
    corvettes = ' %s %s,' % (sh2, pl('corvette', sh2))
    lcruisers = ' %s %s,' % (sh3, pl('light cruiser', sh3))
    destroyers = ' %s %s,' % (sh4, pl('destroyer', sh4))
    frigates = ' %s %s,' % (sh5, pl('frigate', sh5))
    hcruisers = ' %s %s,' % (sh6, pl('heavy cruiser', sh6))
    bcruisers = ' %s %s,' % (sh7, pl('battlecruiser', sh7))
    battleships = ' %s %s,' % (sh8, pl('battleship', sh8))
    dreadnoughts = ' %s %s,' % (sh9, pl('dreadnought', sh9))

    if sh9 == 0:
        loss = fighters + corvettes + lcruisers + destroyers + frigates + hcruisers + bcruisers + ' and' + battleships[:-1]
        if sh8 == 0:
            loss = fighters + corvettes + lcruisers + destroyers + frigates + hcruisers + ' and' + bcruisers[:-1]
            if sh7 == 0:
                loss = fighters + corvettes + lcruisers + destroyers + frigates + ' and' + hcruisers[:-1]
                if sh6 == 0:
                    loss = fighters + corvettes + lcruisers + destroyers + ' and' + frigates[:-1]
                    if sh5 == 0:
                        loss = fighters + corvettes + lcruisers + ' and' + destroyers[:-1]
                        if sh4 == 0:
                            loss = fighters + corvettes + ' and' + lcruisers[:-1]
                            if sh3 == 0:
                                loss = fighters + ' and' + corvettes[:-1]
                                if sh2 == 0:
                                    loss = fighters[:-1]
                                    if sh1 == 0:
                                        loss = ' no ships at all'
    else:
        loss = fighters + corvettes + lcruisers + destroyers + frigates + hcruisers + bcruisers + battleships + \
            ' and' + dreadnoughts[:-1]

    return loss
Exemplo n.º 3
0
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}
Exemplo n.º 4
0
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}
Exemplo n.º 5
0
def spoils(growth, budget, fuel, dur, trit, adam, fre):

    growth = ('' if growth == 0 else ' %s million GEU\'s worth of growth,' % growth)
    budget = ('' if budget == 0 else ' %s %s in cash,' % (budget, pl('GEU', budget)))
    fuel = ('' if fuel == 0 else ' %s %s of warpfuel,' % (fuel, pl('canister', fuel)))
    dur = ('' if dur == 0 else ' %s %s of duranium,' % (dur, pl('ton', dur)))
    trit = ('' if trit == 0 else ' %s %s of tritanium,' % (trit, pl('ton', trit)))
    adam = ('' if adam == 0 else ' %s %s of adamantium,' % (adam, pl('ton', adam)))
    fre = ('' if fre == 0 else ' %s %s,' % (fre, pl('freighter', fre)))

    if fre == '':
        spoils = growth + budget + fuel + dur + trit + ' and' + adam[:-1]
        if adam == '':
            spoils = growth + budget + fuel + dur + ' and' + trit[:-1]
            if trit == '':
                spoils = growth + budget + fuel + ' and' + dur[:-1]
                if dur == '':
                    spoils = growth + budget + ' and' + fuel[:-1]
                    if fuel == '':
                        spoils = growth + ' and' + budget[:-1]
                        if budget == '':
                            spoils = growth[:-1]
                            if growth == '':
                                spoils = ""
    else:
        spoils = growth + budget + fuel + dur + trit + adam + ' and' + fre[:-1]

    return spoils
Exemplo n.º 6
0
def finalbattleresult(region, world, target, deflosses, attlosses, gdp, growth, budget, fuel, dur, trit, adam, hanglosses, flost, freighters,
  flagworld, flagtarget, flagmeet, flagworldlose, flagtargetlose):

    worldfleet, targetfleet = fleetnames(region, world, target)
    worldflag = (', headed by the flagship <i>%s</i>,<br>' % world.flagshipname if flagworld else '')
    targetflag = (', headed by the flagship <i>%s</i>,' % target.flagshipname if flagtarget else '')
    worldreport, targetreport = flagshipoutcome(flagmeet, flagworldlose, flagtargetlose)
    hangarlosses = losses(hanglosses)
    loot = spoils(growth, budget, fuel, dur, trit, adam, freighters)

    table = tablelosses(deflosses, attlosses)
    toaddhangar = ('' if hangarlosses == ' no ships at all' else ' %s from their orbital hangars,' % hangarlosses)
    freighter = ('' if flost == 0 else '%s You also managed to destroy %s %s in the heat of battle.' % (hl, flost, pl('freighter', flost)))

    dataatt = "Your fleet <i>%(worldfleet)s</i>%(worldflag)s engaged fleet <i>%(targetfleet)s</i>%(targetflag)s of world %(targetname)s! %(hl)s \
        Battle Report: %(hl)s </b> %(table)s %(flagreport)s %(freighter)s %(hl)s After the battle, their puny fleet cowers before yours and you \
        exact %(gdp)s million GEUs worth of GDP,%(hangar)s%(loot)s in reparations lest you utterly destroy their world." \
          % {'worldfleet':worldfleet, 'targetfleet':targetfleet, 'targetname':target.world_name, 'table':table, 'gdp':gdp, 'loot':loot,
          'hangar':toaddhangar, 'freighter':freighter, 'hl':hl, 'worldflag':worldflag, 'targetflag':targetflag, 'flagreport':worldreport}

    defenselosses = losses(deflosses)
    enemylosses = losses(attlosses)
    toaddhangar = ('' if hangarlosses == ' no ships at all' else ' %s from our orbital hangars,' % hangarlosses)
    pluralise = ('was' if flost == 1 else 'were')
    freighter = ('' if flost == 0 else '%s %s of your freighters %s also destroyed in the heat of battle.' % (hl, flost, pluralise))
    linkenemy = reverse('stats_ind', args=(world.worldid,))
    fullenemy = '<a href="%s">%s</a>' % (linkenemy, world.world_name)

    datadef = "Your fleet <i>%(targetfleet)s</i>%(targetflag)s was attacked by fleet <i>%(worldfleet)s</i>%(worldflag)s of world %(enemy)s! %(hl)s \
        We <span class=\"red\">lost</span> %(defenselosses)s in the resulting conflict and managed to <span class=\"green\">destroy</span> \
        %(enemylosses)s in retaliation. %(flagreport)s %(freighter)s %(hl)s We had to give them %(gdp)s million GEUs worth of GDP,%(hangar)s%(loot)s \
        in reparations in order to stop them from utterly destroying us after the battle! %(hl)s The war ends in a loss for us." \
          % {'worldfleet':worldfleet, 'targetfleet':targetfleet, 'enemy':fullenemy, 'defenselosses':defenselosses, 'enemylosses':enemylosses,
          'gdp':gdp, 'loot':loot, 'hangar':toaddhangar, 'freighter':freighter, 'hl':hl, 'worldflag':worldflag, 'targetflag':targetflag,
          'flagreport':targetreport}

    return dataatt, datadef
Exemplo n.º 7
0
def battleresult(region, world, target, deflosses, attlosses, flost, flagworld, flagtarget, flagmeet, flagworldlose, flagtargetlose):

    worldfleet, targetfleet = fleetnames(region, world, target)
    worldflag = (', headed by the flagship <i>%s</i>,<br>' % world.flagshipname if flagworld else '')
    targetflag = (', headed by the flagship <i>%s</i>,' % target.flagshipname if flagtarget else '')
    worldreport, targetreport = flagshipoutcome(flagmeet, flagworldlose, flagtargetlose)

    table = tablelosses(deflosses, attlosses)
    freighter = ('' if flost == 0 else '%s You also managed to destroy %s %s in the heat of battle.' % (hl, flost, pl('freighter', flost)))

    dataatt = "<b>Your fleet <i>%(worldfleet)s</i>%(worldflag)s engaged fleet <i>%(targetfleet)s</i>%(targetflag)s of world %(targetname)s! \
        %(hl)s Battle Report: %(hl)s </b> %(table)s %(flagreport)s %(freighter)s" \
          % {'worldfleet':worldfleet, 'targetfleet':targetfleet, 'targetname':target.world_name, 'table':table, 'freighter':freighter, 'hl':hl,
          'worldflag':worldflag, 'targetflag':targetflag, 'flagreport':worldreport}

    defenselosses = losses(deflosses)
    enemylosses = losses(attlosses)
    linkenemy = reverse('stats_ind', args=(world.worldid,))
    fullenemy = '<a href="%s">%s</a>' % (linkenemy, world.world_name)
    pluralise = ('was' if flost == 1 else 'were')
    freighterdef = ('' if flost == 0 else '%s %s of your freighters %s also destroyed in the heat of battle.' % (hl, flost, pluralise))

    conj = 'and <span class="green">destroyed</span>'
    if enemylosses == ' no ships at all' and defenselosses == ' no ships at all':
        mod = desc = ''
    elif enemylosses == ' no ships at all':
        mod = ''
        desc = 'crushingly '
    elif defenselosses == ' no ships at all':
        mod = 'mighty'
        desc = 'pathetically '
    else:
        mod = desc = ''
        conj = 'but we managed to <span class="green">destroy</span>'

    datadef = "Your %(mod)s fleet <i>%(targetfleet)s</i>%(targetflag)s was %(desc)sattacked by fleet <i>%(worldfleet)s</i>%(worldflag)s \
        of world %(enemy)s! %(hl)s We <span class=\"red\">lost</span> %(defenselosses)s in the resulting conflict, %(conj)s %(enemylosses)s \
        in retaliation! %(flagreport)s %(freighter)s" \
          % {'worldfleet':worldfleet, 'targetfleet':targetfleet, 'targetname':target.world_name, 'hl':hl, 'mod':mod, 'desc':desc, \
          'enemy':fullenemy, 'defenselosses':defenselosses, 'enemylosses':enemylosses, 'conj':conj, 'freighter':freighterdef, \
          'worldflag':worldflag, 'targetflag':targetflag, 'flagreport':targetreport}

    return dataatt, datadef
Exemplo n.º 8
0
def buildfreighter(amount):
    pluralise = ('%s ' % amount if amount > 1 else '')
    return 'Your %s%s will be ready in' % (pluralise, pl('freighter', amount))
Exemplo n.º 9
0
def buildfreighter(amount):
    pluralise = ('%s ' % amount if amount > 1 else '')
    return 'Your %s%s will be ready in' % (pluralise, pl('freighter', amount))