Esempio n. 1
0
def get_relations_text(player):
    str_relations = "Cash:  %s\n\nKill breakdown:\n" % (int(
        player.getCredits()))

    # length of faction_kills = VS.GetNumFactions() + 1
    # could the last entry be the total?  or maybe the number of times the user has died?
    faction_kills = []
    for i in range(Director.getSaveDataLength(VS.getCurrentPlayer(), 'kills')):
        faction_kills.append(
            Director.getSaveData(VS.getCurrentPlayer(), 'kills', i))

    displayed_factions = [
        'confed', 'kilrathi', 'merchant', 'retro', 'pirates', 'hunter',
        'militia'
    ]

    for i in range(VS.GetNumFactions()):
        # VS.GetFactionIndex(s) expects a string
        # VS.GetFactionIndex(s) expects a name
        faction = VS.GetFactionName(i)
        if faction in displayed_factions:
            # note: the following calls do not always return equal values:
            #   VS.GetRelation(a, b)
            #   VS.GetRelation(b, a)
            relation = int(
                VS.GetRelation(faction, player.getFactionName()) * 100)
            if relation > 100:
                relation = 100
            elif relation < -100:
                relation = -100

            # not sure if the AI or Friend/Foe radar agree with these figures, but this ought to work, mostly
            if relation > 20:
                str_relation = "friendly"
            elif relation < -20:
                str_relation = "hostile"
            else:
                str_relation = "neutral"

            try:
                kills = int(faction_kills[i])
            except:
                kills = 0

            # try to pad the columns
            # (this doesn't work perfectly, since we're using a variable-width font)
            str_pad = "    "
            int_pad_len = len(str_pad) - len(str(kills))
            if int_pad_len < 1:
                str_pad = ""
            else:
                str_pad = str_pad[:int_pad_len]

            # add current faction to the output string
            str_relations = str_relations + "%s%s  %s\t(%s: %s)\n" % (
                str_pad, kills, faction.capitalize(), str_relation, relation)

    return str_relations
Esempio n. 2
0
def UpdateCombatTurn():
    generate_dyn_universe.KeepUniverseGenerated()
    if not generate_dyn_universe.hasUniverse:
        return
    stardateinc=0.05/24.0
    Director.putSaveData(0,"stardate",0,Director.getSaveData(0,"stardate",0)+stardateinc)
    global lastfac
    global lookorsiege
    nfac=VS.GetNumFactions()
    if lastfac>=nfac:
        if (not SimulateBattles()):
            lastfac=0
    else:
        for i in xrange(10):
            if (lastfac<nfac):
                fac = VS.GetFactionName(lastfac)
                if (lookorsiege):
                    lookorsiege=LookForTrouble (fac)
                else:
                    if (not Siege(fac)):
                        #fg_util.CheckAllShips(fac)
                        lastfac+=1
                        lookorsiege=1
#Changing the order of factions or removing any without starting a new game is not recommended. Adding to the end of this list should be fine.
factions = [
    "confed", "kilrathi", "nephilim", "merchant", "retro", "pirates", "hunter",
    "militia", "unknown", "landreich", "border_worlds", "firekkan", "AWACS",
    "confed_", "confed__", "kilrathi_", "kilrathi__", "merchant_",
    "merchant__", "retro_", "retro__", "pirates_", "pirates__", "hunter_",
    "hunter__", "militia_", "militia__", "civilian"
]
notfactions = [
]  #Factions in factions.xml but not in the above for whatever reason.
import VS
for i in range(VS.GetNumFactions()):
    fac = VS.GetFactionName(i)
    if fac not in factions:
        notfactions += [fac]
#notfactions += ["neutral","privateer","steltek","upgrades","planets","seelig","kroiz","miggs","toth","garrovick","reismann"]

missionfactions = []  #List of factions used only in missions
factiondict = {}  #Dictionary to find the faction number from its name
for i in range(len(factions)):
    factiondict[factions[i]] = i
    #Generate variables named as the faction names with the index values.
    exec(factions[i] + "=" + str(i))
    if factions[i].endswith("_"):  #Those that end with _ are mission factions
        missionfactions.append(factions[i])

generateRandomShips = {
}  # Should we randomly generate ships of this faction anywhere?
for f in factions:
    generateRandomShips[f] = False  #Put default false value.
for f in notfactions:
Esempio n. 4
0
def AllFactions ():
    facs =[]
    for i in xrange (VS.GetNumFactions()):
        facs.append(VS.GetFactionName(i))
    return facs
Esempio n. 5
0
def AllFactions():
    facs = []
    for i in range(VS.GetNumFactions()):
        facs += [VS.GetFactionName(i)]
    return facs